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

Commit 12917c6b authored by Tony Mak's avatar Tony Mak
Browse files

Workaround a bug that causes multiple activity instances are created

If Intent A contains both package and component, while Intent B
contains the exact component but without the package, AMS thinks that
they are different and not reusing the existing activity.

Launcher starts app in current user by using startActivity(intent without
package), while CrossProfileAppsService does not.

This bug is tracked in b/64108432. And let's workaround it for now.
There is no harm to not setting package anyway given that the component
is set explicitly.

Fix: 71983351

Test: Manual
1. Start app that integrates with CrossProfileApps API in user 0
2. Start the work profile instance by consuming CrossProfileApps APIs
3. Switch back to user 0 by consuming CrossProfileApps APIs
4. Observe that the same activity instance in #1 is brought up.

Change-Id: I4da6737ed3df589a0acd86ace1a7add3783d4449
parent 1f31d9a8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -652,6 +652,7 @@ public class LauncherAppsService extends SystemService {
                            activityInfo.name.equals(component.getClassName())) {
                        // Found an activity with category launcher that matches
                        // this component so ok to launch.
                        launchIntent.setPackage(null);
                        launchIntent.setComponent(component);
                        mContext.startActivityAsUser(launchIntent, opts, user);
                        return;
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ public class CrossProfileAppsServiceImpl extends ICrossProfileApps.Stub {

        final long ident = mInjector.clearCallingIdentity();
        try {
            launchIntent.setPackage(null);
            launchIntent.setComponent(component);
            mContext.startActivityAsUser(launchIntent,
                    ActivityOptions.makeOpenCrossProfileAppsAnimation().toBundle(), user);