| OLD | NEW |
| 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.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 8 import android.bluetooth.BluetoothAdapter; | 9 import android.bluetooth.BluetoothAdapter; |
| 9 import android.bluetooth.le.ScanSettings; | 10 import android.bluetooth.le.ScanSettings; |
| 10 import android.content.BroadcastReceiver; | 11 import android.content.BroadcastReceiver; |
| 11 import android.content.Context; | 12 import android.content.Context; |
| 12 import android.content.Intent; | 13 import android.content.Intent; |
| 13 import android.content.IntentFilter; | 14 import android.content.IntentFilter; |
| 14 import android.os.Build; | 15 import android.os.Build; |
| 15 import android.os.ParcelUuid; | 16 import android.os.ParcelUuid; |
| 16 | 17 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 183 } |
| 183 | 184 |
| 184 // -------------------------------------------------------------------------
-------------------- | 185 // -------------------------------------------------------------------------
-------------------- |
| 185 // Implementation details: | 186 // Implementation details: |
| 186 | 187 |
| 187 /** | 188 /** |
| 188 * @return true if Chromium has permission to scan for Bluetooth devices. | 189 * @return true if Chromium has permission to scan for Bluetooth devices. |
| 189 */ | 190 */ |
| 190 private boolean canScan() { | 191 private boolean canScan() { |
| 191 Wrappers.ContextWrapper context = mAdapter.getContext(); | 192 Wrappers.ContextWrapper context = mAdapter.getContext(); |
| 192 | 193 return context.checkPermission(Manifest.permission.ACCESS_COARSE_LOCATIO
N) |
| 193 return context.hasAndroidLocationPermission(); | 194 || context.checkPermission(Manifest.permission.ACCESS_FINE_LOCAT
ION); |
| 194 } | 195 } |
| 195 | 196 |
| 196 private void registerBroadcastReceiver() { | 197 private void registerBroadcastReceiver() { |
| 197 if (mAdapter != null) { | 198 if (mAdapter != null) { |
| 198 mAdapter.getContext().registerReceiver( | 199 mAdapter.getContext().registerReceiver( |
| 199 this, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED
)); | 200 this, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED
)); |
| 200 } | 201 } |
| 201 } | 202 } |
| 202 | 203 |
| 203 private void unregisterBroadcastReceiver() { | 204 private void unregisterBroadcastReceiver() { |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 // 'Object' type must be used for |bluetoothDeviceWrapper| because inner cla
ss | 344 // 'Object' type must be used for |bluetoothDeviceWrapper| because inner cla
ss |
| 344 // Wrappers.BluetoothDeviceWrapper reference is not handled by jni_generator
.py JavaToJni. | 345 // Wrappers.BluetoothDeviceWrapper reference is not handled by jni_generator
.py JavaToJni. |
| 345 // http://crbug.com/505554 | 346 // http://crbug.com/505554 |
| 346 private native void nativeCreateOrUpdateDeviceOnScan(long nativeBluetoothAda
pterAndroid, | 347 private native void nativeCreateOrUpdateDeviceOnScan(long nativeBluetoothAda
pterAndroid, |
| 347 String address, Object bluetoothDeviceWrapper, List<ParcelUuid> adve
rtisedUuids); | 348 String address, Object bluetoothDeviceWrapper, List<ParcelUuid> adve
rtisedUuids); |
| 348 | 349 |
| 349 // Binds to BluetoothAdapterAndroid::nativeOnAdapterStateChanged | 350 // Binds to BluetoothAdapterAndroid::nativeOnAdapterStateChanged |
| 350 private native void nativeOnAdapterStateChanged( | 351 private native void nativeOnAdapterStateChanged( |
| 351 long nativeBluetoothAdapterAndroid, boolean powered); | 352 long nativeBluetoothAdapterAndroid, boolean powered); |
| 352 } | 353 } |
| OLD | NEW |