diff options
author | jovanak <jovanak@google.com> | 2018-10-15 17:50:19 -0700 |
---|---|---|
committer | jovanak <jovanak@google.com> | 2018-10-15 17:50:19 -0700 |
commit | 86999c2001953beead860b15a898adad0092ebf9 (patch) | |
tree | 4f5a36fade61e50eac70288044d246c6cec8b2bb /framework/java/android/bluetooth/BluetoothAvrcpController.java | |
parent | cb3d16a59b4b566104741110e49611efcc07cb50 (diff) |
Makes bluetooth profile services bind to current (foreground) user.
If profile services are created from a singleton process
(like SystemUI), they need to be re-bind to a new foreground user
when we switch to a secondary user.
This is achieved by binding to UserHandle.CURRENT_OR_SELF.
If the process doesn't have adequate permissions to bind to current,
it will bind to self (which is the same as the previous behavior).
Change-Id: Ib1134a1a62887d6f5b2c97301dccd3223ade9ed2
Fixes: 117517812
Test: ran the existing core bluetooth tests; manual testing on a mojave, verifying that the service correctly rebinds from sys ui after user switch.
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAvrcpController.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothAvrcpController.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAvrcpController.java b/framework/java/android/bluetooth/BluetoothAvrcpController.java index e7c8944788..c447868d6f 100644 --- a/framework/java/android/bluetooth/BluetoothAvrcpController.java +++ b/framework/java/android/bluetooth/BluetoothAvrcpController.java @@ -23,6 +23,7 @@ import android.content.ServiceConnection; import android.os.Binder; import android.os.IBinder; import android.os.RemoteException; +import android.os.UserHandle; import android.util.Log; import java.util.ArrayList; @@ -138,7 +139,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile { ComponentName comp = intent.resolveSystemService(mContext.getPackageManager(), 0); intent.setComponent(comp); if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0, - mContext.getUser())) { + UserHandle.CURRENT_OR_SELF)) { Log.e(TAG, "Could not bind to Bluetooth AVRCP Controller Service with " + intent); return false; } |