diff options
author | Rahul Sabnis <rahulsabnis@google.com> | 2021-12-09 20:00:08 +0000 |
---|---|---|
committer | Rahul Sabnis <rahulsabnis@google.com> | 2021-12-09 20:01:20 +0000 |
commit | c8c069f93655035ddb169391e42ae13d94ebb47f (patch) | |
tree | cf96897ec9ae12ce27dcc025427e1b3ad5ab0866 /framework/java/android/bluetooth/BluetoothHeadset.java | |
parent | 7d8bba4d531c96586f0ef3fb1f325d4fc663ccd8 (diff) |
Revert "Complete hard removal of BluetoothHeadset#setPriority system API that"
This reverts commit 7d8bba4d531c96586f0ef3fb1f325d4fc663ccd8.
Bug: 209335798
Test: Manual
Reason for revert: Failing signature test that will be updated by paulduffin@
Change-Id: I9de1b07f2d0f4d01d9e3b57a6ddf8a4232db29b6
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothHeadset.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 8212eaa4e4..c0463243f4 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -601,6 +601,49 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** + * Set priority of the profile + * + * <p> The device should already be paired. + * Priority can be one of {@link BluetoothProfile#PRIORITY_ON} or + * {@link BluetoothProfile#PRIORITY_OFF} + * + * @param device Paired bluetooth device + * @param priority + * @return true if priority is set, false on error + * @hide + * @deprecated Replaced with {@link #setConnectionPolicy(BluetoothDevice, int)} + * @removed + */ + @Deprecated + @SystemApi + @RequiresLegacyBluetoothAdminPermission + @RequiresBluetoothConnectPermission + @RequiresPermission(allOf = { + android.Manifest.permission.BLUETOOTH_CONNECT, + android.Manifest.permission.MODIFY_PHONE_STATE, + }) + public boolean setPriority(BluetoothDevice device, int priority) { + if (DBG) log("setPriority(" + device + ", " + priority + ")"); + final IBluetoothHeadset service = mService; + if (service != null && isEnabled() && isValidDevice(device)) { + if (priority != BluetoothProfile.PRIORITY_OFF + && priority != BluetoothProfile.PRIORITY_ON) { + return false; + } + try { + return service.setPriority( + device, BluetoothAdapter.priorityToConnectionPolicy(priority), + mAttributionSource); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + return false; + } + } + if (service == null) Log.w(TAG, "Proxy not attached to service"); + return false; + } + + /** * Set connection policy of the profile * * <p> The device should already be paired. |