summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Ressel <jereksel@gmail.com>2016-02-27 15:08:43 +0100
committerClark Scheff <clark@cyngn.com>2016-03-21 09:16:02 -0700
commit9d474093528d5eeec6beed1eb330fa6b0648221d (patch)
treeade679a963f0a403610065aeb27365b450654521
parent5716ba3d7a448c9a72c15b98b6125f6318485cab (diff)
downloadframeworks_base-9d474093528d5eeec6beed1eb330fa6b0648221d.zip
frameworks_base-9d474093528d5eeec6beed1eb330fa6b0648221d.tar.gz
frameworks_base-9d474093528d5eeec6beed1eb330fa6b0648221d.tar.bz2
Compile app theme in background
When a lot of themes are installed app installation takes a lot of time blocking UI. In some cases phone gets rebooted because of that (Watchdog kills PackageManager for blocking UI for too long). This commit changes that - only current app theme is compiled on UI thread, rest is compiled in background (like during theme installation). Change-Id: Ied2ded26172b1b140e538b3906b25db808e05828
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java56
1 files changed, 43 insertions, 13 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index d5c58df..86ac282 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -1491,6 +1491,17 @@ public class PackageManagerService extends IPackageManager.Stub {
// if this was a theme, send it off to the theme service for processing
if(res.pkg.mIsThemeApk || res.pkg.mIsLegacyIconPackApk) {
processThemeResourcesInThemeService(res.pkg.packageName);
+ } else if (mOverlays.containsKey(res.pkg.packageName)) {
+
+ // if this was an app and is themed send themes that theme it
+ // for processing
+ ArrayMap<String, PackageParser.Package> themes =
+ mOverlays.get(res.pkg.packageName);
+
+ for (PackageParser.Package themePkg : themes.values()) {
+ processThemeResourcesInThemeService(themePkg.packageName);
+ }
+
}
if (res.removedInfo.args != null) {
// Remove the replaced package's older resources safely now
@@ -7809,22 +7820,41 @@ public class PackageManagerService extends IPackageManager.Stub {
// Generate resources & idmaps if pkg is NOT a theme
// We must compile resources here because during the initial boot process we may get
// here before a default theme has had a chance to compile its resources
+ // During app installation we only compile applied theme here (rest will be compiled
+ // in background)
if (pkg.mOverlayTargets.isEmpty() && mOverlays.containsKey(pkg.packageName)) {
ArrayMap<String, PackageParser.Package> themes = mOverlays.get(pkg.packageName);
- for(PackageParser.Package themePkg : themes.values()) {
- if (!isBootScan || (mBootThemeConfig != null &&
- (themePkg.packageName.equals(mBootThemeConfig.getOverlayPkgName()) ||
+
+ final IActivityManager am = ActivityManagerNative.getDefault();
+ ThemeConfig themeConfig = null;
+ try {
+ if (am != null) {
+ themeConfig = am.getConfiguration().themeConfig;
+ } else {
+ Log.e(TAG, "ActivityManager getDefault() " +
+ "returned null, cannot compile app's theme");
+ }
+ } catch(RemoteException e) {
+ Log.e(TAG, "Failed to get the theme config ", e);
+ }
+
+ ThemeConfig config = isBootScan ? mBootThemeConfig : themeConfig;
+
+ if (config != null) {
+ for(PackageParser.Package themePkg : themes.values()) {
+ if (themePkg.packageName.equals(config.getOverlayPkgName()) ||
themePkg.packageName.equals(
- mBootThemeConfig.getOverlayPkgNameForApp(pkg.packageName))))) {
- try {
- compileResourcesAndIdmapIfNeeded(pkg, themePkg);
- } catch (Exception e) {
- // Do not stop a pkg installation just because of one bad theme
- // Also we don't break here because we should try to compile other
- // themes
- Slog.w(TAG, "Unable to compile " + themePkg.packageName
- + " for target " + pkg.packageName, e);
- themePkg.mOverlayTargets.remove(pkg.packageName);
+ config.getOverlayPkgNameForApp(pkg.packageName))) {
+ try {
+ compileResourcesAndIdmapIfNeeded(pkg, themePkg);
+ } catch (Exception e) {
+ // Do not stop a pkg installation just because of one bad theme
+ // Also we don't break here because we should try to compile other
+ // themes
+ Slog.w(TAG, "Unable to compile " + themePkg.packageName
+ + " for target " + pkg.packageName, e);
+ themePkg.mOverlayTargets.remove(pkg.packageName);
+ }
}
}
}