From 1566233bfdb994cd41d21ffb2615af8d0e29166f Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Mon, 3 Apr 2017 16:41:29 -0600 Subject: [PATCH] Offer to "fixup" GIDs used for app data. We recently started tracking cached app data using a per-app GID for the "cache" and "code_cache" directories and their contents. For upgraded devices, we ideally want to "fixup" the GIDs of any existing data while the device is still showing the boot animation, instead of blocking the user when they unlock the device. This fixup operation has the nice side-effect of priming the dentry cache with all the directories that we'll be validating when unlocking a user, so by always running fixup we speed up onBeforeUnlockUser() from about ~540ms to ~220ms. Test: /data/nativetest/installd_service_test/installd_service_test Bug: 34201111, 35084485 Change-Id: If40244d0356beb11df25d3052097c3c5a90d010f --- .../core/java/com/android/server/pm/Installer.java | 10 ++++++++++ .../com/android/server/pm/PackageManagerService.java | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/services/core/java/com/android/server/pm/Installer.java b/services/core/java/com/android/server/pm/Installer.java index 7eef7adc7e12c..9f7c4a2793dba 100644 --- a/services/core/java/com/android/server/pm/Installer.java +++ b/services/core/java/com/android/server/pm/Installer.java @@ -66,6 +66,7 @@ public class Installer extends SystemService { public static final int FLAG_FREE_CACHE_V2 = 1 << 13; public static final int FLAG_FREE_CACHE_V2_DEFY_QUOTA = 1 << 14; public static final int FLAG_FREE_CACHE_NOOP = 1 << 15; + public static final int FLAG_FORCE = 1 << 16; private final boolean mIsolated; @@ -202,6 +203,15 @@ public class Installer extends SystemService { } } + public void fixupAppData(String uuid, int flags) throws InstallerException { + if (!checkBeforeRemote()) return; + try { + mInstalld.fixupAppData(uuid, flags); + } catch (Exception e) { + throw InstallerException.from(e); + } + } + public void moveCompleteApp(String fromUuid, String toUuid, String packageName, String dataAppName, int appId, String seInfo, int targetSdkVersion) throws InstallerException { diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 6b6adc36ac8bc..6eac5cb2d271f 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -2713,6 +2713,15 @@ public class PackageManagerService extends IPackageManager.Stub { UserHandle.USER_SYSTEM, storageFlags, true /* migrateAppData */, true /* onlyCoreApps */); mPrepareAppDataFuture = SystemServerInitThreadPool.get().submit(() -> { + Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "fixup"); + try { + mInstaller.fixupAppData(StorageManager.UUID_PRIVATE_INTERNAL, + StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE); + } catch (InstallerException e) { + Slog.w(TAG, "Trouble fixing GIDs", e); + } + Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER); + if (deferPackages == null || deferPackages.isEmpty()) { return; }