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