| 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.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.Context; | 22 import android.content.Context; |
| 23 import android.content.Intent; |
| 24 import android.content.IntentFilter; |
| 22 import android.content.pm.PackageManager; | 25 import android.content.pm.PackageManager; |
| 23 import android.os.Build; | 26 import android.os.Build; |
| 24 import android.os.ParcelUuid; | 27 import android.os.ParcelUuid; |
| 25 import android.os.Process; | 28 import android.os.Process; |
| 26 | 29 |
| 27 import org.chromium.base.Log; | 30 import org.chromium.base.Log; |
| 28 import org.chromium.base.annotations.CalledByNative; | 31 import org.chromium.base.annotations.CalledByNative; |
| 29 import org.chromium.base.annotations.JNINamespace; | 32 import org.chromium.base.annotations.JNINamespace; |
| 30 | 33 |
| 31 import java.util.ArrayList; | 34 import java.util.ArrayList; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 private final Context mContext; | 159 private final Context mContext; |
| 157 | 160 |
| 158 public ContextWrapper(Context context) { | 161 public ContextWrapper(Context context) { |
| 159 mContext = context; | 162 mContext = context; |
| 160 } | 163 } |
| 161 | 164 |
| 162 public boolean checkPermission(String permission) { | 165 public boolean checkPermission(String permission) { |
| 163 return mContext.checkPermission(permission, Process.myPid(), Process
.myUid()) | 166 return mContext.checkPermission(permission, Process.myPid(), Process
.myUid()) |
| 164 == PackageManager.PERMISSION_GRANTED; | 167 == PackageManager.PERMISSION_GRANTED; |
| 165 } | 168 } |
| 169 |
| 170 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter
filter) { |
| 171 return mContext.registerReceiver(receiver, filter); |
| 172 } |
| 173 |
| 174 public void unregisterReceiver(BroadcastReceiver receiver) { |
| 175 mContext.unregisterReceiver(receiver); |
| 176 } |
| 166 } | 177 } |
| 167 | 178 |
| 168 /** | 179 /** |
| 169 * Wraps android.bluetooth.BluetoothLeScanner. | 180 * Wraps android.bluetooth.BluetoothLeScanner. |
| 170 */ | 181 */ |
| 171 static class BluetoothLeScannerWrapper { | 182 static class BluetoothLeScannerWrapper { |
| 172 protected final BluetoothLeScanner mScanner; | 183 protected final BluetoothLeScanner mScanner; |
| 173 private final HashMap<ScanCallbackWrapper, ForwardScanCallbackToWrapper>
mCallbacks; | 184 private final HashMap<ScanCallbackWrapper, ForwardScanCallbackToWrapper>
mCallbacks; |
| 174 | 185 |
| 175 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) { | 186 public BluetoothLeScannerWrapper(BluetoothLeScanner scanner) { |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 566 |
| 556 public byte[] getValue() { | 567 public byte[] getValue() { |
| 557 return mDescriptor.getValue(); | 568 return mDescriptor.getValue(); |
| 558 } | 569 } |
| 559 | 570 |
| 560 public boolean setValue(byte[] value) { | 571 public boolean setValue(byte[] value) { |
| 561 return mDescriptor.setValue(value); | 572 return mDescriptor.setValue(value); |
| 562 } | 573 } |
| 563 } | 574 } |
| 564 } | 575 } |
| OLD | NEW |