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
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user