OSDN Git Service

Defer readSessionsLocked until system ready
authorTony Mak <tonymak@google.com>
Wed, 15 Feb 2017 18:40:03 +0000 (18:40 +0000)
committerTony Mak <tonymak@google.com>
Wed, 15 Feb 2017 19:44:08 +0000 (19:44 +0000)
readSessionsLocked depend on DPMS, so defer it until all system
service is started

Fix: 34663223

Test: Manual
      1. Try to install an app and reboot before it is installed
         (so the session is persisted in a file)
      2. Observe that PackageInstallerService
         read the persisted session in onSystemReady and
         able to get the DPM instance.
      3. Observe play can read the persisted session

Change-Id: Ia14ed09db08fcf59189fa29293f0ac5066650942

services/core/java/com/android/server/pm/PackageInstallerService.java

index efd3132..8b4ef56 100644 (file)
@@ -221,6 +221,10 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
                 new File(Environment.getDataSystemDirectory(), "install_sessions.xml"));
         mSessionsDir = new File(Environment.getDataSystemDirectory(), "install_sessions");
         mSessionsDir.mkdirs();
+    }
+
+    public void systemReady() {
+        mAppOps = mContext.getSystemService(AppOpsManager.class);
 
         synchronized (mSessions) {
             readSessionsLocked();
@@ -245,10 +249,6 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
         }
     }
 
-    public void systemReady() {
-        mAppOps = mContext.getSystemService(AppOpsManager.class);
-    }
-
     private void reconcileStagesLocked(String volumeUuid, boolean isEphemeral) {
         final File stagingDir = buildStagingDir(volumeUuid, isEphemeral);
         final ArraySet<File> unclaimedStages = newArraySet(