diff options
Diffstat (limited to 'packages')
4 files changed, 32 insertions, 27 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbAccessoryUriActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbAccessoryUriActivity.java index 5007cf4..ff06630 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbAccessoryUriActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbAccessoryUriActivity.java @@ -26,6 +26,7 @@ import android.net.Uri; import android.hardware.usb.UsbAccessory; import android.hardware.usb.UsbManager; import android.os.Bundle; +import android.os.UserHandle; import android.util.Log; import com.android.internal.app.AlertActivity; @@ -90,7 +91,7 @@ public class UsbAccessoryUriActivity extends AlertActivity intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { - startActivity(intent); + startActivityAsUser(intent, UserHandle.CURRENT); } catch (ActivityNotFoundException e) { Log.e(TAG, "startActivity failed for " + mUri); } diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java index 030a261..3eccccd 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbConfirmActivity.java @@ -16,23 +16,21 @@ package com.android.systemui.usb; -import android.app.Activity; import android.app.AlertDialog; import android.content.ComponentName; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; -import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.hardware.usb.IUsbManager; -import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbAccessory; +import android.hardware.usb.UsbDevice; import android.hardware.usb.UsbManager; import android.os.Bundle; import android.os.IBinder; -import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -42,7 +40,6 @@ import android.widget.TextView; import com.android.internal.app.AlertActivity; import com.android.internal.app.AlertController; - import com.android.systemui.R; public class UsbConfirmActivity extends AlertActivity @@ -62,10 +59,10 @@ public class UsbConfirmActivity extends AlertActivity public void onCreate(Bundle icicle) { super.onCreate(icicle); - Intent intent = getIntent(); - mDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); + Intent intent = getIntent(); + mDevice = (UsbDevice) intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); mAccessory = (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY); - mResolveInfo = (ResolveInfo)intent.getParcelableExtra("rinfo"); + mResolveInfo = (ResolveInfo) intent.getParcelableExtra("rinfo"); PackageManager packageManager = getPackageManager(); String appName = mResolveInfo.loadLabel(packageManager).toString(); @@ -117,7 +114,8 @@ public class UsbConfirmActivity extends AlertActivity try { IBinder b = ServiceManager.getService(USB_SERVICE); IUsbManager service = IUsbManager.Stub.asInterface(b); - int uid = mResolveInfo.activityInfo.applicationInfo.uid; + final int uid = mResolveInfo.activityInfo.applicationInfo.uid; + final int userId = UserHandle.myUserId(); boolean alwaysUse = mAlwaysUse.isChecked(); Intent intent = null; @@ -129,9 +127,10 @@ public class UsbConfirmActivity extends AlertActivity service.grantDevicePermission(mDevice, uid); // set or clear default setting if (alwaysUse) { - service.setDevicePackage(mDevice, mResolveInfo.activityInfo.packageName); + service.setDevicePackage( + mDevice, mResolveInfo.activityInfo.packageName, userId); } else { - service.setDevicePackage(mDevice, null); + service.setDevicePackage(mDevice, null, userId); } } else if (mAccessory != null) { intent = new Intent(UsbManager.ACTION_USB_ACCESSORY_ATTACHED); @@ -141,10 +140,10 @@ public class UsbConfirmActivity extends AlertActivity service.grantAccessoryPermission(mAccessory, uid); // set or clear default setting if (alwaysUse) { - service.setAccessoryPackage(mAccessory, - mResolveInfo.activityInfo.packageName); + service.setAccessoryPackage( + mAccessory, mResolveInfo.activityInfo.packageName, userId); } else { - service.setAccessoryPackage(mAccessory, null); + service.setAccessoryPackage(mAccessory, null, userId); } } @@ -152,7 +151,7 @@ public class UsbConfirmActivity extends AlertActivity intent.setComponent( new ComponentName(mResolveInfo.activityInfo.packageName, mResolveInfo.activityInfo.name)); - startActivity(intent); + startActivityAsUser(intent, new UserHandle(userId)); } catch (Exception e) { Log.e(TAG, "Unable to start activity", e); } diff --git a/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java index c384f50..6e88d0d 100644 --- a/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java +++ b/packages/SystemUI/src/com/android/systemui/usb/UsbPermissionActivity.java @@ -32,6 +32,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -67,7 +68,7 @@ public class UsbPermissionActivity extends AlertActivity mDevice = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE); mAccessory = (UsbAccessory)intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY); mPendingIntent = (PendingIntent)intent.getParcelableExtra(Intent.EXTRA_INTENT); - mUid = intent.getIntExtra("uid", 0); + mUid = intent.getIntExtra(Intent.EXTRA_UID, -1); mPackageName = intent.getStringExtra("package"); PackageManager packageManager = getPackageManager(); @@ -128,7 +129,8 @@ public class UsbPermissionActivity extends AlertActivity if (mPermissionGranted) { service.grantDevicePermission(mDevice, mUid); if (mAlwaysUse.isChecked()) { - service.setDevicePackage(mDevice, mPackageName); + final int userId = UserHandle.getUserId(mUid); + service.setDevicePackage(mDevice, mPackageName, userId); } } } @@ -137,7 +139,8 @@ public class UsbPermissionActivity extends AlertActivity if (mPermissionGranted) { service.grantAccessoryPermission(mAccessory, mUid); if (mAlwaysUse.isChecked()) { - service.setAccessoryPackage(mAccessory, mPackageName); + final int userId = UserHandle.getUserId(mUid); + service.setAccessoryPackage(mAccessory, mPackageName, userId); } } } 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); } |