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

Commit 271463ed authored by Lee Shombert's avatar Lee Shombert
Browse files

Update getHomeActivitiesAsUser()

Bug: 187080582

Call findPreferredActivityInternalLPr() from
getHomeActivitiesAsUser().

Test: atest
 * CtsContentTestCases:IntentFilterTest
 * CtsDynamicMimeHostTestCases
 * CtsRoleTestCases
 * FrameworksServicesTests:UserSystemPackageInstallerTest
 * FrameworksServicesTests:PackageManagerSettingsTests
 * FrameworksServicesTests:PackageManagerServiceTest
 * FrameworksServicesTests:AppsFilterTest
 * FrameworksServicesTests:PackageInstallerSessionTest
 * FrameworksServicesTests:ScanTests
 * UserLifecycleTests#startUser
 * UserLifecycleTests#stopUser
 * UserLifecycleTests#switchUser
 * FrameworksServicesTests:WatcherTest
 * android.appsecurity.cts.EphemeralTest
 * android.appsecurity.cts.InstantAppUserTest
Change-Id: I64ce898e36d5164b4891d8376da603e7b849aada
parent 881452bf
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -2921,7 +2921,24 @@ public class PackageManagerService extends IPackageManager.Stub
            }
            allHomeCandidates.addAll(resolveInfos);
            final String packageName = mDefaultAppProvider.getDefaultHome(userId);
            String packageName = mDefaultAppProvider.getDefaultHome(userId);
            if (packageName == null) {
                // Role changes are not and cannot be atomic because its implementation lives inside
                // a system app, so when the home role changes, there is a window when the previous
                // role holder is removed and the new role holder is granted the preferred activity,
                // but hasn't become the role holder yet. However, this case may be easily hit
                // because the preferred activity change triggers a broadcast and receivers may try
                // to get the default home activity there. So we need to fix it for this time
                // window, and an easy workaround is to fallback to the current preferred activity.
                final int appId = UserHandle.getAppId(Binder.getCallingUid());
                final boolean filtered = appId >= Process.FIRST_APPLICATION_UID;
                FindPreferredActivityBodyResult result = findPreferredActivityInternal(
                        intent, null, 0, resolveInfos, true, false, false, userId, filtered);
                ResolveInfo preferredResolveInfo =  result.mPreferredResolveInfo;
                if (preferredResolveInfo != null && preferredResolveInfo.activityInfo != null) {
                    packageName = preferredResolveInfo.activityInfo.packageName;
                }
            }
            if (packageName == null) {
                return null;
            }