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.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.bluetooth.BluetoothDevice; | 8 import android.bluetooth.BluetoothDevice; |
9 import android.bluetooth.le.ScanFilter; | 9 import android.bluetooth.le.ScanFilter; |
10 import android.bluetooth.le.ScanSettings; | 10 import android.bluetooth.le.ScanSettings; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 mNativeBluetoothTestAndroid = nativeBluetoothTestAndroid; | 61 mNativeBluetoothTestAndroid = nativeBluetoothTestAndroid; |
62 mFakeContext = (FakeContext) mContext; | 62 mFakeContext = (FakeContext) mContext; |
63 mFakeScanner = new FakeBluetoothLeScanner(); | 63 mFakeScanner = new FakeBluetoothLeScanner(); |
64 } | 64 } |
65 | 65 |
66 @CalledByNative("FakeBluetoothAdapter") | 66 @CalledByNative("FakeBluetoothAdapter") |
67 public void denyPermission() { | 67 public void denyPermission() { |
68 mFakeContext.mHasLocation = false; | 68 mFakeContext.mHasLocation = false; |
69 } | 69 } |
70 | 70 |
| 71 @CalledByNative("FakeBluetoothAdapter") |
| 72 public void simulateLocationServicesOff() { |
| 73 mFakeContext.mIsSystemLocationSettingEnabled = false; |
| 74 } |
| 75 |
71 /** | 76 /** |
72 * Creates and discovers a new device. | 77 * Creates and discovers a new device. |
73 */ | 78 */ |
74 @CalledByNative("FakeBluetoothAdapter") | 79 @CalledByNative("FakeBluetoothAdapter") |
75 public void simulateLowEnergyDevice(int deviceOrdinal) { | 80 public void simulateLowEnergyDevice(int deviceOrdinal) { |
76 if (mFakeScanner == null) { | 81 if (mFakeScanner == null) { |
77 return; | 82 return; |
78 } | 83 } |
79 | 84 |
80 switch (deviceOrdinal) { | 85 switch (deviceOrdinal) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 public boolean isDiscovering() { | 190 public boolean isDiscovering() { |
186 return false; | 191 return false; |
187 } | 192 } |
188 } | 193 } |
189 | 194 |
190 /** | 195 /** |
191 * Fakes android.content.Context. | 196 * Fakes android.content.Context. |
192 */ | 197 */ |
193 static class FakeContext extends Wrappers.ContextWrapper { | 198 static class FakeContext extends Wrappers.ContextWrapper { |
194 public boolean mHasLocation = true; | 199 public boolean mHasLocation = true; |
| 200 public boolean mIsSystemLocationSettingEnabled = true; |
195 | 201 |
196 public FakeContext() { | 202 public FakeContext() { |
197 super(null); | 203 super(null); |
198 } | 204 } |
199 | 205 |
200 @Override | 206 @Override |
201 public boolean hasAndroidLocationPermission() { | 207 public boolean hasAndroidLocationPermission() { |
202 return mHasLocation; | 208 return mHasLocation; |
203 } | 209 } |
204 | 210 |
205 @Override | 211 @Override |
| 212 public boolean isSystemLocationSettingEnabled() { |
| 213 return mIsSystemLocationSettingEnabled; |
| 214 } |
| 215 |
| 216 @Override |
206 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter
filter) { | 217 public Intent registerReceiver(BroadcastReceiver receiver, IntentFilter
filter) { |
207 return null; | 218 return null; |
208 } | 219 } |
209 | 220 |
210 @Override | 221 @Override |
211 public void unregisterReceiver(BroadcastReceiver receiver) {} | 222 public void unregisterReceiver(BroadcastReceiver receiver) {} |
212 } | 223 } |
213 | 224 |
214 /** | 225 /** |
215 * Fakes android.bluetooth.le.BluetoothLeScanner. | 226 * Fakes android.bluetooth.le.BluetoothLeScanner. |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 long nativeBluetoothTestAndroid, byte[] value); | 822 long nativeBluetoothTestAndroid, byte[] value); |
812 | 823 |
813 // Binds to BluetoothTestAndroid::OnFakeBluetoothGattReadDescriptor. | 824 // Binds to BluetoothTestAndroid::OnFakeBluetoothGattReadDescriptor. |
814 private static native void nativeOnFakeBluetoothGattReadDescriptor( | 825 private static native void nativeOnFakeBluetoothGattReadDescriptor( |
815 long nativeBluetoothTestAndroid); | 826 long nativeBluetoothTestAndroid); |
816 | 827 |
817 // Binds to BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor. | 828 // Binds to BluetoothTestAndroid::OnFakeBluetoothGattWriteDescriptor. |
818 private static native void nativeOnFakeBluetoothGattWriteDescriptor( | 829 private static native void nativeOnFakeBluetoothGattWriteDescriptor( |
819 long nativeBluetoothTestAndroid, byte[] value); | 830 long nativeBluetoothTestAndroid, byte[] value); |
820 } | 831 } |
OLD | NEW |