From 1c6f72397320c8e4aeb34d55429ee62e2acd432a Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 19 Dec 2016 16:39:02 -0700 Subject: [PATCH] Remove ~1/3 of the installd calls at boot. When preparing CE storage for an app, we always perform a second call to extract any newly created CE directory inode. Let's simplify this and just return the inode number from the createAppData() call. Test: builds, boots, reads CE inodes after wipe Bug: 33463450 Change-Id: I9b73da576800b56d7d0961dd4deb0b6a546acbe7 --- .../java/com/android/server/pm/Installer.java | 16 +++--------- .../server/pm/PackageManagerService.java | 25 +++++++------------ 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java index 31939749ee66d..203f841bb3057 100644 --- a/services/core/java/com/android/server/pm/Installer.java +++ b/services/core/java/com/android/server/pm/Installer.java @@ -105,11 +105,11 @@ public class Installer extends SystemService { } } - public void createAppData(String uuid, String packageName, int userId, int flags, int appId, + public long createAppData(String uuid, String packageName, int userId, int flags, int appId, String seInfo, int targetSdkVersion) throws InstallerException { - if (!checkBeforeRemote()) return; + if (!checkBeforeRemote()) return -1; try { - mInstalld.createAppData(uuid, packageName, userId, flags, appId, seInfo, + return mInstalld.createAppData(uuid, packageName, userId, flags, appId, seInfo, targetSdkVersion); } catch (Exception e) { throw InstallerException.from(e); @@ -182,16 +182,6 @@ public class Installer extends SystemService { } } - public long getAppDataInode(String uuid, String packageName, int userId, int flags) - throws InstallerException { - if (!checkBeforeRemote()) return -1; - try { - return mInstalld.getAppDataInode(uuid, packageName, userId, flags); - } catch (Exception e) { - throw InstallerException.from(e); - } - } - public void dexopt(String apkPath, int uid, @Nullable String pkgName, String instructionSet, int dexoptNeeded, @Nullable String outputPath, int dexFlags, String compilerFilter, @Nullable String volumeUuid, @Nullable String sharedLibraries) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index fb06f0178dc47..1c78b1637ccda 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -19969,8 +19969,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); Preconditions.checkNotNull(app.seinfo); + long ceDataInode = -1; try { - mInstaller.createAppData(volumeUuid, packageName, userId, flags, + ceDataInode = mInstaller.createAppData(volumeUuid, packageName, userId, flags, appId, app.seinfo, app.targetSdkVersion); } catch (InstallerException e) { if (app.isSystemApp()) { @@ -19978,7 +19979,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); + ", but trying to recover: " + e); destroyAppDataLeafLIF(pkg, userId, flags); try { - mInstaller.createAppData(volumeUuid, packageName, userId, flags, + ceDataInode = mInstaller.createAppData(volumeUuid, packageName, userId, flags, appId, app.seinfo, app.targetSdkVersion); logCriticalInfo(Log.DEBUG, "Recovery succeeded!"); } catch (InstallerException e2) { @@ -19989,21 +19990,13 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); } } - if ((flags & StorageManager.FLAG_STORAGE_CE) != 0) { - try { - // CE storage is unlocked right now, so read out the inode and - // remember for use later when it's locked - // TODO: mark this structure as dirty so we persist it! - final long ceDataInode = mInstaller.getAppDataInode(volumeUuid, packageName, userId, - StorageManager.FLAG_STORAGE_CE); - synchronized (mPackages) { - final PackageSetting ps = mSettings.mPackages.get(packageName); - if (ps != null) { - ps.setCeDataInode(ceDataInode, userId); - } + if ((flags & StorageManager.FLAG_STORAGE_CE) != 0 && ceDataInode != -1) { + // TODO: mark this structure as dirty so we persist it! + synchronized (mPackages) { + final PackageSetting ps = mSettings.mPackages.get(packageName); + if (ps != null) { + ps.setCeDataInode(ceDataInode, userId); } - } catch (InstallerException e) { - Slog.e(TAG, "Failed to find inode for " + packageName + ": " + e); } }