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

Commit 6102dfaf authored by Hai Zhang's avatar Hai Zhang
Browse files

Fix Go to Web and App Info buttons in AIA notification.

This change fixes the PendingIntents for the buttons by obtaining them
with PendingIntent.getActivityAsUser() instead of getActivity() so
that they can be launched for the correct user.

Bug: 111415104
Bug: 111436542
Test: Install cl/209819423 and try the buttons as a secondary user.
Change-Id: I5f4caed7c0d97a6147dfb5d79df6548349553711
parent 02360205
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -596,9 +596,10 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
                mContext.getString(R.string.instant_apps));
        mCurrentNotifs.add(new Pair<>(pkg, userId));
        String message = mContext.getString(R.string.instant_apps_message);
        PendingIntent appInfoAction = PendingIntent.getActivity(mContext, 0,
        UserHandle user = UserHandle.of(userId);
        PendingIntent appInfoAction = PendingIntent.getActivityAsUser(mContext, 0,
                new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
                        .setData(Uri.fromParts("package", pkg, null)), 0);
                        .setData(Uri.fromParts("package", pkg, null)), 0, null, user);
        Action action = new Notification.Action.Builder(null, mContext.getString(R.string.app_info),
                appInfoAction).build();

@@ -611,8 +612,8 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
                    .addFlags(Intent.FLAG_IGNORE_EPHEMERAL)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            PendingIntent pendingIntent = PendingIntent.getActivity(mContext,
                    0 /* requestCode */, browserIntent, 0 /* flags */);
            PendingIntent pendingIntent = PendingIntent.getActivityAsUser(mContext,
                    0 /* requestCode */, browserIntent, 0 /* flags */, null, user);
            ComponentName aiaComponent = null;
            try {
                aiaComponent = AppGlobals.getPackageManager().getInstantAppInstallerComponent();
@@ -629,7 +630,8 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
                    .putExtra(Intent.EXTRA_LONG_VERSION_CODE, appInfo.versionCode)
                    .putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, pendingIntent);

            PendingIntent webPendingIntent = PendingIntent.getActivity(mContext, 0, goToWebIntent, 0);
            PendingIntent webPendingIntent = PendingIntent.getActivityAsUser(mContext, 0,
                    goToWebIntent, 0, null, user);
            Action webAction = new Notification.Action.Builder(null, mContext.getString(R.string.go_to_web),
                    webPendingIntent).build();
            builder.addAction(webAction);