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

Commit 38d3e785 authored by Alex Light's avatar Alex Light Committed by android-build-merger
Browse files

Merge \\"cp preopted files from B partition during PM init.\\" into nyc-mr1-dev am: 7281cf27

am: 53f5e870

Change-Id: I3bc16096bb5703c3cadc05f1488e9b52fb1b5c82
parents 7f38c642 53f5e870
Loading
Loading
Loading
Loading
+36 −4
Original line number Diff line number Diff line
@@ -629,7 +629,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    final ProtectedPackages mProtectedPackages;
    boolean mRestoredSettings;
    boolean mFirstBoot;
    // System configuration read by SystemConfig.
    final int[] mGlobalGids;
@@ -2222,6 +2222,34 @@ public class PackageManagerService extends IPackageManager.Stub {
        displayManager.getDisplay(Display.DEFAULT_DISPLAY).getMetrics(metrics);
    }
    /**
     * Requests that files preopted on a secondary system partition be copied to the data partition
     * if possible.  Note that the actual copying of the files is accomplished by init for security
     * reasons. This simply requests that the copy takes place and awaits confirmation of its
     * completion. See platform/system/extras/cppreopt/ for the implementation of the actual copy.
     */
    private static void requestCopyPreoptedFiles() {
        final int WAIT_TIME_MS = 100;
        final String CP_PREOPT_PROPERTY = "sys.cppreopt";
        if (SystemProperties.getInt("ro.cp_system_other_odex", 0) == 1) {
            SystemProperties.set(CP_PREOPT_PROPERTY, "requested");
            // We will wait for up to 100 seconds.
            final long timeEnd = SystemClock.uptimeMillis() + 100 * 1000;
            while (!SystemProperties.get(CP_PREOPT_PROPERTY).equals("finished")) {
                try {
                    Thread.sleep(WAIT_TIME_MS);
                } catch (InterruptedException e) {
                    // Do nothing
                }
                if (SystemClock.uptimeMillis() > timeEnd) {
                    SystemProperties.set(CP_PREOPT_PROPERTY, "timed-out");
                    Slog.wtf(TAG, "cppreopt did not finish!");
                    break;
                }
            }
        }
    }
    public PackageManagerService(Context context, Installer installer,
            boolean factoryTest, boolean onlyCore) {
        EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_PMS_START,
@@ -2325,7 +2353,11 @@ public class PackageManagerService extends IPackageManager.Stub {
            mFoundPolicyFile = SELinuxMMAC.readInstallPolicy();
            mRestoredSettings = mSettings.readLPw(sUserManager.getUsers(false));
            mFirstBoot = !mSettings.readLPw(sUserManager.getUsers(false));
            if (mFirstBoot) {
                requestCopyPreoptedFiles();
            }
            String customResolverActivity = Resources.getSystem().getString(
                    R.string.config_customResolverActivity);
@@ -2702,7 +2734,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            // If this is the first boot or an update from pre-M, and it is a normal
            // boot, then we need to initialize the default preferred apps across
            // all defined users.
            if (!onlyCore && (mPromoteSystemApps || !mRestoredSettings)) {
            if (!onlyCore && (mPromoteSystemApps || mFirstBoot)) {
                for (UserInfo user : sUserManager.getUsers(true)) {
                    mSettings.applyDefaultPreferredAppsLPw(this, user.id);
                    applyFactoryDefaultBrowserLPw(user.id);
@@ -2860,7 +2892,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    @Override
    public boolean isFirstBoot() {
        return !mRestoredSettings;
        return mFirstBoot;
    }
    @Override