Loading android/app/src/com/android/bluetooth/tbs/TbsGatt.java +1 −1 Original line number Diff line number Diff line Loading @@ -1025,7 +1025,7 @@ public class TbsGatt { operations.add(op); // Send authorization request for each device only for it's first GATT request if (operations.size() == 1) { mTbsService.getDeviceAuthorization(device); mTbsService.onDeviceUnauthorized(device); } } } Loading android/app/src/com/android/bluetooth/tbs/TbsService.java +10 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,16 @@ public class TbsService extends ProfileService { sTbsService = instance; } public void onDeviceUnauthorized(BluetoothDevice device) { if (Utils.isPtsTestMode()) { Log.d(TAG, "PTS test: setDeviceAuthorized"); setDeviceAuthorized(device, true); return; } Log.w(TAG, "onDeviceUnauthorized - authorization notification not implemented yet "); setDeviceAuthorized(device, false); } /** * Sets device authorization for TBS. * Loading android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java +78 −4 Original line number Diff line number Diff line Loading @@ -818,7 +818,7 @@ public class TbsGattTest { } @Test public void testCharacteristicReadUnauthorized() { public void testCharacteristicReadAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = Loading @@ -837,7 +837,24 @@ public class TbsGattTest { } @Test public void testCharacteristicWriteUnauthorized() { public void testCharacteristicReadAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = getCharacteristic(TbsGatt.UUID_BEARER_TECHNOLOGY); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); mTbsGatt.mGattServerCallback.onCharacteristicReadRequest( mFirstDevice, 1, 0, characteristic); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testCharacteristicWriteAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = Loading @@ -858,7 +875,26 @@ public class TbsGattTest { } @Test public void testDescriptorReadUnauthorized() { public void testCharacteristicWriteAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = getCharacteristic(TbsGatt.UUID_CALL_CONTROL_POINT); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); byte[] value = new byte[] {0x00, /* opcode */ 0x0A, /* argument */ }; mTbsGatt.mGattServerCallback.onCharacteristicWriteRequest( mFirstDevice, 1, characteristic, false, true, 0, value); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testDescriptorReadAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = Loading @@ -878,7 +914,25 @@ public class TbsGattTest { } @Test public void testDescriptorWriteUnauthorized() { public void testDescriptorReadAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = getCharacteristic(TbsGatt.UUID_BEARER_TECHNOLOGY) .getDescriptor(TbsGatt.UUID_CLIENT_CHARACTERISTIC_CONFIGURATION); Assert.assertNotNull(descriptor); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); mTbsGatt.mGattServerCallback.onDescriptorReadRequest(mFirstDevice, 1, 0, descriptor); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testDescriptorWriteAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = Loading @@ -900,4 +954,24 @@ public class TbsGattTest { eq(BluetoothGatt.GATT_INSUFFICIENT_AUTHORIZATION), eq(0), any()); } @Test public void testDescriptorWriteAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = getCharacteristic(TbsGatt.UUID_CALL_CONTROL_POINT) .getDescriptor(TbsGatt.UUID_CLIENT_CHARACTERISTIC_CONFIGURATION); Assert.assertNotNull(descriptor); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); byte[] value = new byte[] {0x00, /* opcode */ 0x0A, /* argument */ }; mTbsGatt.mGattServerCallback.onDescriptorWriteRequest( mFirstDevice, 1, descriptor, false, true, 0, value); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } } Loading
android/app/src/com/android/bluetooth/tbs/TbsGatt.java +1 −1 Original line number Diff line number Diff line Loading @@ -1025,7 +1025,7 @@ public class TbsGatt { operations.add(op); // Send authorization request for each device only for it's first GATT request if (operations.size() == 1) { mTbsService.getDeviceAuthorization(device); mTbsService.onDeviceUnauthorized(device); } } } Loading
android/app/src/com/android/bluetooth/tbs/TbsService.java +10 −0 Original line number Diff line number Diff line Loading @@ -139,6 +139,16 @@ public class TbsService extends ProfileService { sTbsService = instance; } public void onDeviceUnauthorized(BluetoothDevice device) { if (Utils.isPtsTestMode()) { Log.d(TAG, "PTS test: setDeviceAuthorized"); setDeviceAuthorized(device, true); return; } Log.w(TAG, "onDeviceUnauthorized - authorization notification not implemented yet "); setDeviceAuthorized(device, false); } /** * Sets device authorization for TBS. * Loading
android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java +78 −4 Original line number Diff line number Diff line Loading @@ -818,7 +818,7 @@ public class TbsGattTest { } @Test public void testCharacteristicReadUnauthorized() { public void testCharacteristicReadAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = Loading @@ -837,7 +837,24 @@ public class TbsGattTest { } @Test public void testCharacteristicWriteUnauthorized() { public void testCharacteristicReadAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = getCharacteristic(TbsGatt.UUID_BEARER_TECHNOLOGY); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); mTbsGatt.mGattServerCallback.onCharacteristicReadRequest( mFirstDevice, 1, 0, characteristic); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testCharacteristicWriteAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = Loading @@ -858,7 +875,26 @@ public class TbsGattTest { } @Test public void testDescriptorReadUnauthorized() { public void testCharacteristicWriteAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattCharacteristic characteristic = getCharacteristic(TbsGatt.UUID_CALL_CONTROL_POINT); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); byte[] value = new byte[] {0x00, /* opcode */ 0x0A, /* argument */ }; mTbsGatt.mGattServerCallback.onCharacteristicWriteRequest( mFirstDevice, 1, characteristic, false, true, 0, value); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testDescriptorReadAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = Loading @@ -878,7 +914,25 @@ public class TbsGattTest { } @Test public void testDescriptorWriteUnauthorized() { public void testDescriptorReadAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = getCharacteristic(TbsGatt.UUID_BEARER_TECHNOLOGY) .getDescriptor(TbsGatt.UUID_CLIENT_CHARACTERISTIC_CONFIGURATION); Assert.assertNotNull(descriptor); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); mTbsGatt.mGattServerCallback.onDescriptorReadRequest(mFirstDevice, 1, 0, descriptor); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } @Test public void testDescriptorWriteAccessRejectedUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = Loading @@ -900,4 +954,24 @@ public class TbsGattTest { eq(BluetoothGatt.GATT_INSUFFICIENT_AUTHORIZATION), eq(0), any()); } @Test public void testDescriptorWriteAccessUnknownUnauthorized() { prepareDefaultService(); BluetoothGattDescriptor descriptor = getCharacteristic(TbsGatt.UUID_CALL_CONTROL_POINT) .getDescriptor(TbsGatt.UUID_CLIENT_CHARACTERISTIC_CONFIGURATION); Assert.assertNotNull(descriptor); doReturn(BluetoothDevice.ACCESS_UNKNOWN) .when(mMockTbsService) .getDeviceAuthorization(any(BluetoothDevice.class)); byte[] value = new byte[] {0x00, /* opcode */ 0x0A, /* argument */ }; mTbsGatt.mGattServerCallback.onDescriptorWriteRequest( mFirstDevice, 1, descriptor, false, true, 0, value); verify(mMockTbsService).onDeviceUnauthorized(eq(mFirstDevice)); } }