From e6b00b8ff61ed42e0fc83cf0485880d4aa4dd9b3 Mon Sep 17 00:00:00 2001 From: William Escande Date: Tue, 15 Mar 2022 11:15:35 +0100 Subject: [PATCH] API Review: add `UNBOND` in `EXTRA_REASON` name > Can you make EXTRA_REASON an 'unsupported app usage' alias for > EXTRA_UNBOUND_REASON (which is in the public API)? > And add a max target SDK to the @UnsupportedAppUsage annotation. Bug: 221851154 Test: Build + TH Tag: #refactor Change-Id: I684e56572d1882d02f6f782fa10f3db793fe182d --- .../settingslib/bluetooth/BluetoothEventManager.java | 2 +- .../bluetooth/BluetoothEventManagerTest.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java index 389892ed15e4e..62c83cf04a4fa 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothEventManager.java @@ -371,7 +371,7 @@ public class BluetoothEventManager { || cachedDevice.getHiSyncId() != BluetoothHearingAid.HI_SYNC_ID_INVALID) { mDeviceManager.onDeviceUnpaired(cachedDevice); } - int reason = intent.getIntExtra(BluetoothDevice.EXTRA_REASON, + int reason = intent.getIntExtra(BluetoothDevice.EXTRA_UNBOND_REASON, BluetoothDevice.ERROR); showUnbondMessage(context, cachedDevice.getName(), reason); diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java index 852ac5ca6abe3..7b94492cef4f1 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/BluetoothEventManagerTest.java @@ -357,7 +357,8 @@ public class BluetoothEventManagerTest { mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice); mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE); - mIntent.putExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.UNBOND_REASON_AUTH_TIMEOUT); + mIntent.putExtra(BluetoothDevice.EXTRA_UNBOND_REASON, + BluetoothDevice.UNBOND_REASON_AUTH_TIMEOUT); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedDevice1); when(mCachedDevice1.getName()).thenReturn(DEVICE_NAME); @@ -372,7 +373,7 @@ public class BluetoothEventManagerTest { mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice); mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE); - mIntent.putExtra(BluetoothDevice.EXTRA_REASON, + mIntent.putExtra(BluetoothDevice.EXTRA_UNBOND_REASON, BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedDevice1); when(mCachedDevice1.getName()).thenReturn(DEVICE_NAME); @@ -388,7 +389,8 @@ public class BluetoothEventManagerTest { mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice); mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE); - mIntent.putExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.UNBOND_REASON_AUTH_REJECTED); + mIntent.putExtra(BluetoothDevice.EXTRA_UNBOND_REASON, + BluetoothDevice.UNBOND_REASON_AUTH_REJECTED); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedDevice1); when(mCachedDevice1.getName()).thenReturn(DEVICE_NAME); @@ -403,7 +405,8 @@ public class BluetoothEventManagerTest { mIntent = new Intent(BluetoothDevice.ACTION_BOND_STATE_CHANGED); mIntent.putExtra(BluetoothDevice.EXTRA_DEVICE, mBluetoothDevice); mIntent.putExtra(BluetoothDevice.EXTRA_BOND_STATE, BluetoothDevice.BOND_NONE); - mIntent.putExtra(BluetoothDevice.EXTRA_REASON, BluetoothDevice.UNBOND_REASON_AUTH_FAILED); + mIntent.putExtra(BluetoothDevice.EXTRA_UNBOND_REASON, + BluetoothDevice.UNBOND_REASON_AUTH_FAILED); when(mCachedDeviceManager.findDevice(mBluetoothDevice)).thenReturn(mCachedDevice1); when(mCachedDevice1.getName()).thenReturn(DEVICE_NAME);