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; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 static class BluetoothGattCharacteristicWrapper { | 510 static class BluetoothGattCharacteristicWrapper { |
511 final BluetoothGattCharacteristic mCharacteristic; | 511 final BluetoothGattCharacteristic mCharacteristic; |
512 final BluetoothDeviceWrapper mDeviceWrapper; | 512 final BluetoothDeviceWrapper mDeviceWrapper; |
513 | 513 |
514 public BluetoothGattCharacteristicWrapper( | 514 public BluetoothGattCharacteristicWrapper( |
515 BluetoothGattCharacteristic characteristic, BluetoothDeviceWrapp
er deviceWrapper) { | 515 BluetoothGattCharacteristic characteristic, BluetoothDeviceWrapp
er deviceWrapper) { |
516 mCharacteristic = characteristic; | 516 mCharacteristic = characteristic; |
517 mDeviceWrapper = deviceWrapper; | 517 mDeviceWrapper = deviceWrapper; |
518 } | 518 } |
519 | 519 |
520 public BluetoothGattDescriptorWrapper getDescriptor(UUID uuid) { | |
521 BluetoothGattDescriptor descriptor = mCharacteristic.getDescriptor(u
uid); | |
522 if (descriptor == null) { | |
523 return null; | |
524 } | |
525 | |
526 BluetoothGattDescriptorWrapper descriptorWrapper = | |
527 mDeviceWrapper.mDescriptorsToWrappers.get(descriptor); | |
528 | |
529 if (descriptorWrapper == null) { | |
530 descriptorWrapper = new BluetoothGattDescriptorWrapper(descripto
r, mDeviceWrapper); | |
531 mDeviceWrapper.mDescriptorsToWrappers.put(descriptor, descriptor
Wrapper); | |
532 } | |
533 return descriptorWrapper; | |
534 } | |
535 | |
536 public List<BluetoothGattDescriptorWrapper> getDescriptors() { | 520 public List<BluetoothGattDescriptorWrapper> getDescriptors() { |
537 List<BluetoothGattDescriptor> descriptors = mCharacteristic.getDescr
iptors(); | 521 List<BluetoothGattDescriptor> descriptors = mCharacteristic.getDescr
iptors(); |
538 | 522 |
539 ArrayList<BluetoothGattDescriptorWrapper> descriptorsWrapped = | 523 ArrayList<BluetoothGattDescriptorWrapper> descriptorsWrapped = |
540 new ArrayList<BluetoothGattDescriptorWrapper>(descriptors.si
ze()); | 524 new ArrayList<BluetoothGattDescriptorWrapper>(descriptors.si
ze()); |
541 | 525 |
542 for (BluetoothGattDescriptor descriptor : descriptors) { | 526 for (BluetoothGattDescriptor descriptor : descriptors) { |
543 BluetoothGattDescriptorWrapper descriptorWrapper = | 527 BluetoothGattDescriptorWrapper descriptorWrapper = |
544 mDeviceWrapper.mDescriptorsToWrappers.get(descriptor); | 528 mDeviceWrapper.mDescriptorsToWrappers.get(descriptor); |
545 if (descriptorWrapper == null) { | 529 if (descriptorWrapper == null) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 | 580 |
597 public byte[] getValue() { | 581 public byte[] getValue() { |
598 return mDescriptor.getValue(); | 582 return mDescriptor.getValue(); |
599 } | 583 } |
600 | 584 |
601 public boolean setValue(byte[] value) { | 585 public boolean setValue(byte[] value) { |
602 return mDescriptor.setValue(value); | 586 return mDescriptor.setValue(value); |
603 } | 587 } |
604 } | 588 } |
605 } | 589 } |
OLD | NEW |