diff options
author | Jeff Sharkey <jsharkey@android.com> | 2012-10-01 21:45:52 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2012-10-02 18:09:10 -0700 |
commit | fc3f24b4b60c10e0d3f41f70df37e11ea311cc2c (patch) | |
tree | be61172447392620b42c88517ad58a5210adf5cb /packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java | |
parent | c6e570dbadc3689bc80c0516492a3209d5f6742b (diff) | |
download | frameworks_base-fc3f24b4b60c10e0d3f41f70df37e11ea311cc2c.zip frameworks_base-fc3f24b4b60c10e0d3f41f70df37e11ea311cc2c.tar.gz frameworks_base-fc3f24b4b60c10e0d3f41f70df37e11ea311cc2c.tar.bz2 |
Make USB services multi-user aware.
USB settings are now isolated per-user, since they revolve around
installed packages. User-specific settings are returned based on
calling user, or referenced by UserHandle passed to SystemUI. Each
settings Context is wrapped as a specific user, so all broadcasts are
sent correctly. Upgrades any existing USB settings to OWNER.
Physical events, like new devices, are routed to the currently active
user. Switch to using AtomicFile when persisting settings.
Bug: 7244888
Change-Id: I8a723ad3d55ac1bff99276c5f3a3f5e8f013432f
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java index f61ecb1..9928f7f 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbResolverActivity.java @@ -16,8 +16,6 @@ package com.android.systemui.usb; -import com.android.internal.app.ResolverActivity; - import android.content.ActivityNotFoundException; import android.content.Intent; import android.content.pm.ResolveInfo; @@ -30,9 +28,11 @@ import android.os.IBinder; import android.os.Parcelable; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.util.Log; import android.widget.CheckBox; +import com.android.internal.app.ResolverActivity; import com.android.systemui.R; import java.util.ArrayList; @@ -92,34 +92,36 @@ public class UsbResolverActivity extends ResolverActivity { super.onDestroy(); } + @Override protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) { try { IBinder b = ServiceManager.getService(USB_SERVICE); IUsbManager service = IUsbManager.Stub.asInterface(b); - int uid = ri.activityInfo.applicationInfo.uid; + final int uid = ri.activityInfo.applicationInfo.uid; + final int userId = UserHandle.myUserId(); if (mDevice != null) { // grant permission for the device service.grantDevicePermission(mDevice, uid); // set or clear default setting if (alwaysCheck) { - service.setDevicePackage(mDevice, ri.activityInfo.packageName); + service.setDevicePackage(mDevice, ri.activityInfo.packageName, userId); } else { - service.setDevicePackage(mDevice, null); + service.setDevicePackage(mDevice, null, userId); } } else if (mAccessory != null) { // grant permission for the accessory service.grantAccessoryPermission(mAccessory, uid); // set or clear default setting if (alwaysCheck) { - service.setAccessoryPackage(mAccessory, ri.activityInfo.packageName); + service.setAccessoryPackage(mAccessory, ri.activityInfo.packageName, userId); } else { - service.setAccessoryPackage(mAccessory, null); + service.setAccessoryPackage(mAccessory, null, userId); } } try { - startActivity(intent); + startActivityAsUser(intent, new UserHandle(userId)); } catch (ActivityNotFoundException e) { Log.e(TAG, "startActivity failed", e); } |