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

Commit ab37f0f8 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Start unaware persistent apps after user unlocked." into nyc-dev

parents 791d078d f7d47f91
Loading
Loading
Loading
Loading
+24 −22
Original line number Diff line number Diff line
@@ -1896,6 +1896,9 @@ public final class ActivityManagerService extends ActivityManagerNative
                final int userId = msg.arg1;
                mSystemServiceManager.unlockUser(userId);
                mRecentTasks.loadUserRecentsLocked(userId);
                if (userId == UserHandle.USER_SYSTEM) {
                    startPersistentApps(PackageManager.MATCH_ENCRYPTION_UNAWARE);
                }
                installEncryptionUnawareProviders(userId);
                break;
            }
@@ -10779,6 +10782,23 @@ public final class ActivityManagerService extends ActivityManagerNative
        //mUsageStatsService.monitorPackages();
    }
    private void startPersistentApps(int matchFlags) {
        if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL) return;
        synchronized (this) {
            try {
                final List<ApplicationInfo> apps = AppGlobals.getPackageManager()
                        .getPersistentApplications(STOCK_PM_FLAGS | matchFlags);
                for (ApplicationInfo app : apps) {
                    if (!"android".equals(app.packageName)) {
                        addAppLocked(app, false, null /* ABI override */);
                    }
                }
            } catch (RemoteException ex) {
            }
        }
    }
    /**
     * When a user is unlocked, we need to install encryption-unaware providers
     * belonging to any running apps.
@@ -10795,8 +10815,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        // We're only interested in providers that are encryption unaware, and
        // we don't care about uninstalled apps, since there's no way they're
        // running at this point.
        final int matchFlags = GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE
                | MATCH_DEBUG_TRIAGED_MISSING;
        final int matchFlags = GET_PROVIDERS | MATCH_ENCRYPTION_UNAWARE;
        synchronized (this) {
            final int NP = mProcessNames.getMap().size();
@@ -12682,26 +12701,9 @@ public final class ActivityManagerService extends ActivityManagerNative
        mSystemServiceManager.startUser(currentUserId);
        synchronized (this) {
            if (mFactoryTest != FactoryTest.FACTORY_TEST_LOW_LEVEL) {
                try {
                    List apps = AppGlobals.getPackageManager().
                        getPersistentApplications(STOCK_PM_FLAGS);
                    if (apps != null) {
                        int N = apps.size();
                        int i;
                        for (i=0; i<N; i++) {
                            ApplicationInfo info
                                = (ApplicationInfo)apps.get(i);
                            if (info != null &&
                                    !info.packageName.equals("android")) {
                                addAppLocked(info, false, null /* ABI override */);
                            }
                        }
                    }
                } catch (RemoteException ex) {
                    // pm is in same process, this will never happen.
                }
            }
            // Only start up encryption-aware persistent apps; once user is
            // unlocked we'll come back around and start unaware apps
            startPersistentApps(PackageManager.MATCH_ENCRYPTION_AWARE);
            // Start up initial activity.
            mBooting = true;
+12 −3
Original line number Diff line number Diff line
@@ -62,7 +62,9 @@ import static android.content.pm.PackageManager.INTENT_FILTER_DOMAIN_VERIFICATIO
import static android.content.pm.PackageManager.MATCH_ALL;
import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
import static android.content.pm.PackageManager.MATCH_ENCRYPTION_AWARE;
import static android.content.pm.PackageManager.MATCH_ENCRYPTION_AWARE_AND_UNAWARE;
import static android.content.pm.PackageManager.MATCH_ENCRYPTION_UNAWARE;
import static android.content.pm.PackageManager.MATCH_SYSTEM_ONLY;
import static android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES;
import static android.content.pm.PackageManager.MOVE_FAILED_DEVICE_ADMIN;
@@ -6072,9 +6074,16 @@ public class PackageManagerService extends IPackageManager.Stub {
            final int userId = UserHandle.getCallingUserId();
            while (i.hasNext()) {
                final PackageParser.Package p = i.next();
                if (p.applicationInfo != null
                        && (p.applicationInfo.flags&ApplicationInfo.FLAG_PERSISTENT) != 0
                        && (!mSafeMode || isSystemApp(p))) {
                if (p.applicationInfo == null) continue;
                final boolean matchesUnaware = ((flags & MATCH_ENCRYPTION_UNAWARE) != 0)
                        && !p.applicationInfo.isEncryptionAware();
                final boolean matchesAware = ((flags & MATCH_ENCRYPTION_AWARE) != 0)
                        && p.applicationInfo.isEncryptionAware();
                if ((p.applicationInfo.flags & ApplicationInfo.FLAG_PERSISTENT) != 0
                        && (!mSafeMode || isSystemApp(p))
                        && (matchesUnaware || matchesAware)) {
                    PackageSetting ps = mSettings.mPackages.get(p.packageName);
                    if (ps != null) {
                        ApplicationInfo ai = PackageParser.generateApplicationInfo(p, flags,