| 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.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.os.Build; | 26 import android.os.Build; |
| 27 import android.os.ParcelUuid; | 27 import android.os.ParcelUuid; |
| 28 import android.os.Process; |
| 28 | 29 |
| 29 import org.chromium.base.Log; | 30 import org.chromium.base.Log; |
| 30 import org.chromium.base.annotations.CalledByNative; | 31 import org.chromium.base.annotations.CalledByNative; |
| 31 import org.chromium.base.annotations.JNINamespace; | 32 import org.chromium.base.annotations.JNINamespace; |
| 32 import org.chromium.components.location.LocationUtils; | |
| 33 | 33 |
| 34 import java.util.ArrayList; | 34 import java.util.ArrayList; |
| 35 import java.util.HashMap; | 35 import java.util.HashMap; |
| 36 import java.util.List; | 36 import java.util.List; |
| 37 import java.util.UUID; | 37 import java.util.UUID; |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Wrapper classes around android.bluetooth.* classes that provide an | 40 * Wrapper classes around android.bluetooth.* classes that provide an |
| 41 * indirection layer enabling fake implementations when running tests. | 41 * indirection layer enabling fake implementations when running tests. |
| 42 * | 42 * |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 /** | 155 /** |
| 156 * Wraps android.content.Context. | 156 * Wraps android.content.Context. |
| 157 */ | 157 */ |
| 158 static class ContextWrapper { | 158 static class ContextWrapper { |
| 159 private final Context mContext; | 159 private final Context mContext; |
| 160 | 160 |
| 161 public ContextWrapper(Context context) { | 161 public ContextWrapper(Context context) { |
| 162 mContext = context; | 162 mContext = context; |
| 163 } | 163 } |
| 164 | 164 |
| 165 public boolean hasAndroidLocationPermission() { | 165 public boolean checkPermission(String permission) { |
| 166 return LocationUtils.getInstance().hasAndroidLocationPermission(mCon
text); | 166 return mContext.checkPermission(permission, Process.myPid(), Process
.myUid()) |
| 167 == PackageManager.PERMISSION_GRANTED; |
| 167 } | 168 } |
| 168 | 169 |
| 169 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter
filter) { | 170 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter
filter) { |
| 170 return mContext.registerReceiver(receiver, filter); | 171 return mContext.registerReceiver(receiver, filter); |
| 171 } | 172 } |
| 172 | 173 |
| 173 public void unregisterReceiver(BroadcastReceiver receiver) { | 174 public void unregisterReceiver(BroadcastReceiver receiver) { |
| 174 mContext.unregisterReceiver(receiver); | 175 mContext.unregisterReceiver(receiver); |
| 175 } | 176 } |
| 176 } | 177 } |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 | 580 |
| 580 public byte[] getValue() { | 581 public byte[] getValue() { |
| 581 return mDescriptor.getValue(); | 582 return mDescriptor.getValue(); |
| 582 } | 583 } |
| 583 | 584 |
| 584 public boolean setValue(byte[] value) { | 585 public boolean setValue(byte[] value) { |
| 585 return mDescriptor.setValue(value); | 586 return mDescriptor.setValue(value); |
| 586 } | 587 } |
| 587 } | 588 } |
| 588 } | 589 } |
| OLD | NEW |