// Create a characteristic and add it to this service. @CalledByNative("FakeBluetoothGattService") private static void addCharacteristic( ChromeBluetoothRemoteGattService chromeService, String uuidString, int properties) { FakeBluetoothGattService fakeService = (FakeBluetoothGattService) chromeService.mService; UUID uuid = UUID.fromString(uuidString); int countOfDuplicateUUID = 0; for (Wrappers.BluetoothGattCharacteristicWrapper characteristic : fakeService.mCharacteristics) { if (characteristic.getUuid().equals(uuid)) { countOfDuplicateUUID++; } } fakeService.mCharacteristics.add( new FakeBluetoothGattCharacteristic( fakeService, /* instanceId */ countOfDuplicateUUID, properties, uuid)); }
@Override boolean writeCharacteristic(Wrappers.BluetoothGattCharacteristicWrapper characteristic) { if (mWriteCharacteristicWillFailSynchronouslyOnce) { mWriteCharacteristicWillFailSynchronouslyOnce = false; return false; } nativeOnFakeBluetoothGattWriteCharacteristic( mDevice.mAdapter.mNativeBluetoothTestAndroid, characteristic.getValue()); return true; }