diff options
author | Cheney Ni <cheneyni@google.com> | 2018-08-21 12:17:42 +0800 |
---|---|---|
committer | Cheney Ni <cheneyni@google.com> | 2018-08-21 14:08:00 +0800 |
commit | 167334ff4b73ddefdb9eb671758cca7a0f388f2a (patch) | |
tree | 369f5f64583ec66ab6afc00c25b7cad945b34af6 /framework/java/android/bluetooth/BluetoothA2dp.java | |
parent | 09547135579faf932b492341cd07b3a7a8b46b61 (diff) |
Be the current user to get A2DP proxy
After user switched, Bluetooth process will be restarted to run as
secondary user and some system process like AudioService keeps as
primary user. When BluetoothA2dp did rebind, it still used primary UID
for those system process and caused they could not invoke A2DP APIs.
This changes to use current user ID when rebinding to A2dpService and
system process can get correct A2DP proxy after user switched.
Bug: 112469503
Test: manual
Change-Id: If5ee945b0dcf2044ef2baedd762751fa6ef3d09a
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothA2dp.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothA2dp.java | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/framework/java/android/bluetooth/BluetoothA2dp.java b/framework/java/android/bluetooth/BluetoothA2dp.java index 966f9025e8..d21f76d435 100644 --- a/framework/java/android/bluetooth/BluetoothA2dp.java +++ b/framework/java/android/bluetooth/BluetoothA2dp.java @@ -30,6 +30,7 @@ import android.os.Binder; import android.os.IBinder; import android.os.ParcelUuid; import android.os.RemoteException; +import android.os.UserHandle; import android.util.Log; import com.android.internal.annotations.GuardedBy; @@ -270,7 +271,7 @@ public final class BluetoothA2dp 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 A2DP Service with " + intent); return false; } |