Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: device/bluetooth/android/java/src/org/chromium/device/bluetooth/Wrappers.java

Issue 2032273002: If location services are turned off, have the BT chooser prompt the user to turn them on. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.device.bluetooth; 5 package org.chromium.device.bluetooth;
6 6
7 import android.Manifest; 7 import android.Manifest;
8 import android.annotation.TargetApi; 8 import android.annotation.TargetApi;
9 import android.bluetooth.BluetoothAdapter; 9 import android.bluetooth.BluetoothAdapter;
10 import android.bluetooth.BluetoothDevice; 10 import android.bluetooth.BluetoothDevice;
11 import android.bluetooth.BluetoothGatt; 11 import android.bluetooth.BluetoothGatt;
12 import android.bluetooth.BluetoothGattCallback; 12 import android.bluetooth.BluetoothGattCallback;
13 import android.bluetooth.BluetoothGattCharacteristic; 13 import android.bluetooth.BluetoothGattCharacteristic;
14 import android.bluetooth.BluetoothGattDescriptor; 14 import android.bluetooth.BluetoothGattDescriptor;
15 import android.bluetooth.BluetoothGattService; 15 import android.bluetooth.BluetoothGattService;
16 import android.bluetooth.le.BluetoothLeScanner; 16 import android.bluetooth.le.BluetoothLeScanner;
17 import android.bluetooth.le.ScanCallback; 17 import android.bluetooth.le.ScanCallback;
18 import android.bluetooth.le.ScanFilter; 18 import android.bluetooth.le.ScanFilter;
19 import android.bluetooth.le.ScanResult; 19 import android.bluetooth.le.ScanResult;
20 import android.bluetooth.le.ScanSettings; 20 import android.bluetooth.le.ScanSettings;
21 import android.content.BroadcastReceiver; 21 import android.content.BroadcastReceiver;
22 import android.content.Context; 22 import android.content.Context;
23 import android.content.Intent; 23 import android.content.Intent;
24 import android.content.IntentFilter; 24 import android.content.IntentFilter;
25 import android.content.pm.PackageManager; 25 import android.content.pm.PackageManager;
26 import android.location.LocationManager;
26 import android.os.Build; 27 import android.os.Build;
27 import android.os.ParcelUuid; 28 import android.os.ParcelUuid;
28 import android.os.Process; 29 import android.os.Process;
29 30
30 import org.chromium.base.Log; 31 import org.chromium.base.Log;
31 import org.chromium.base.annotations.CalledByNative; 32 import org.chromium.base.annotations.CalledByNative;
32 import org.chromium.base.annotations.JNINamespace; 33 import org.chromium.base.annotations.JNINamespace;
33 34
34 import java.util.ArrayList; 35 import java.util.ArrayList;
35 import java.util.HashMap; 36 import java.util.HashMap;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 161
161 public ContextWrapper(Context context) { 162 public ContextWrapper(Context context) {
162 mContext = context; 163 mContext = context;
163 } 164 }
164 165
165 public boolean checkPermission(String permission) { 166 public boolean checkPermission(String permission) {
166 return mContext.checkPermission(permission, Process.myPid(), Process .myUid()) 167 return mContext.checkPermission(permission, Process.myPid(), Process .myUid())
167 == PackageManager.PERMISSION_GRANTED; 168 == PackageManager.PERMISSION_GRANTED;
168 } 169 }
169 170
171 public LocationManagerWrapper getLocationManager() {
172 return new LocationManagerWrapper(
173 (LocationManager) mContext.getSystemService(Context.LOCATION _SERVICE));
174 }
175
170 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) { 176 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter filter) {
171 return mContext.registerReceiver(receiver, filter); 177 return mContext.registerReceiver(receiver, filter);
172 } 178 }
173 179
174 public void unregisterReceiver(BroadcastReceiver receiver) { 180 public void unregisterReceiver(BroadcastReceiver receiver) {
175 mContext.unregisterReceiver(receiver); 181 mContext.unregisterReceiver(receiver);
176 } 182 }
177 } 183 }
178 184
185 static class LocationManagerWrapper {
186 private final LocationManager mLocationManager;
187
188 public LocationManagerWrapper(LocationManager locationManager) {
189 mLocationManager = locationManager;
190 }
191
192 public boolean isProviderEnabled(String name) {
193 return mLocationManager.isProviderEnabled(name);
194 }
195 }
196
179 /** 197 /**
180 * Wraps android.bluetooth.BluetoothLeScanner. 198 * Wraps android.bluetooth.BluetoothLeScanner.
181 */ 199 */
182 static class BluetoothLeScannerWrapper { 200 static class BluetoothLeScannerWrapper {
183 protected final BluetoothLeScanner mScanner; 201 protected final BluetoothLeScanner mScanner;
184 private final HashMap<ScanCallbackWrapper, ForwardScanCallbackToWrapper> mCallbacks; 202 private final HashMap<ScanCallbackWrapper, ForwardScanCallbackToWrapper> mCallbacks;
185 203
186 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) { 204 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) {
187 mScanner = scanner; 205 mScanner = scanner;
188 mCallbacks = new HashMap<ScanCallbackWrapper, ForwardScanCallbackToW rapper>(); 206 mCallbacks = new HashMap<ScanCallbackWrapper, ForwardScanCallbackToW rapper>();
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 598
581 public byte[] getValue() { 599 public byte[] getValue() {
582 return mDescriptor.getValue(); 600 return mDescriptor.getValue();
583 } 601 }
584 602
585 public boolean setValue(byte[] value) { 603 public boolean setValue(byte[] value) {
586 return mDescriptor.setValue(value); 604 return mDescriptor.setValue(value);
587 } 605 }
588 } 606 }
589 } 607 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698