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 | 2a9131f76879cbb7cc572ba999428197aece7e18 (patch) | |
| tree | 1aea1d8586c9ece7f58a64db18761d9e8901747a /core/java/android/bluetooth/BluetoothAvrcpController.java | |
| parent | 0d541559af18191897104e0685f43a561b1e5ba5 (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 'core/java/android/bluetooth/BluetoothAvrcpController.java')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothAvrcpController.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothAvrcpController.java b/core/java/android/bluetooth/BluetoothAvrcpController.java index e7c8944788fd..c447868d6f0c 100644 --- a/core/java/android/bluetooth/BluetoothAvrcpController.java +++ b/core/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; } |
