Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 33064dba authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I9d3b4f8f,I4854a310

* changes:
  shell pm: move context creation to where it's used
  adb shell pm: create context as the right user
parents 26a949ed 2cae9f62
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ class PackageManagerShellCommand extends ShellCommand {

    final IPackageManager mInterface;
    final IPermissionManager mPermissionManager;
    final Context mShellPackageContext;
    final Context mContext;
    final private WeakHashMap<String, Resources> mResourceCache =
            new WeakHashMap<String, Resources>();
    int mTargetUser;
@@ -158,12 +158,7 @@ class PackageManagerShellCommand extends ShellCommand {
            PackageManagerService service, IPermissionManager permissionManager, Context context) {
        mInterface = service;
        mPermissionManager = permissionManager;
        try {
            mShellPackageContext = context.createPackageContext("com.android.shell", 0);
        } catch (NameNotFoundException e) {
            // should not happen
            throw new RuntimeException(e);
        }
        mContext = context;
    }

    @Override
@@ -486,8 +481,17 @@ class PackageManagerShellCommand extends ShellCommand {
            return 1;
        }

        final Context shellPackageContext;
        try {
            shellPackageContext = mContext.createPackageContextAsUser(
                    "com.android.shell", 0, Binder.getCallingUserHandle());
        } catch (NameNotFoundException e) {
            // should not happen
            throw new RuntimeException(e);
        }

        final LocalIntentReceiver receiver = new LocalIntentReceiver();
        RollbackManager rm = mShellPackageContext.getSystemService(RollbackManager.class);
        RollbackManager rm = shellPackageContext.getSystemService(RollbackManager.class);
        RollbackInfo rollback = null;
        for (RollbackInfo r : rm.getAvailableRollbacks()) {
            for (PackageRollbackInfo info : r.getPackages()) {