summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Light <allight@google.com> 2016-06-22 17:56:37 -0700
committer Alex Light <allight@google.com> 2016-06-24 13:50:20 -0700
commit3dafee6c1820bf0946bab04b290c5a757112d3e7 (patch)
treef9e818101f6914cb9ee234436277d695103ff9d3
parenta65d8b660986520a8d7b6ec4c363ce13e4560667 (diff)
cp preopted files from B partition during PM init.
This allows us to save space on the system partition while still having access to the preopted files. We do this on first boot when the "ro.cp_system_other_odex" property is set to 1. We do this during package manager initialization before scanning the system to see which apks need to be optimized again. Note that a separate script, run by init, is actually responsible for finding and copying the files. We simply request that it runs. Bug: 29278988 Change-Id: I8d7c790ad35b32a0ce1d87939f043419bae4d88a
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java40
1 files changed, 36 insertions, 4 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index fe492c73519f..410ec38bce73 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -629,7 +629,7 @@ public class PackageManagerService extends IPackageManager.Stub {
final ProtectedPackages mProtectedPackages = new ProtectedPackages();
- boolean mRestoredSettings;
+ boolean mFirstBoot;
// System configuration read by SystemConfig.
final int[] mGlobalGids;
@@ -2220,6 +2220,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,
@@ -2321,7 +2349,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);
@@ -2698,7 +2730,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);
@@ -2856,7 +2888,7 @@ public class PackageManagerService extends IPackageManager.Stub {
@Override
public boolean isFirstBoot() {
- return !mRestoredSettings;
+ return mFirstBoot;
}
@Override