summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/app/ActivityThread.java6
-rw-r--r--core/java/android/app/ContextImpl.java6
-rw-r--r--core/java/android/app/ResourcesManager.java47
-rw-r--r--core/java/android/content/pm/PackageParser.java21
-rw-r--r--core/java/android/content/res/CompatibilityInfo.java17
-rw-r--r--core/res/res/values/cm_arrays.xml6
-rw-r--r--core/res/res/values/cm_symbols.xml3
7 files changed, 60 insertions, 46 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index b3005f9..1383c13 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -1702,7 +1702,8 @@ public final class ActivityThread {
String[] libDirs, int displayId, Configuration overrideConfiguration,
LoadedApk pkgInfo, Context context, String pkgName) {
return mResourcesManager.getTopLevelResources(resDir, splitResDirs, overlayDirs, libDirs,
- displayId, pkgName, overrideConfiguration, pkgInfo.getCompatibilityInfo(), context);
+ displayId, pkgName, overrideConfiguration, pkgInfo.getCompatibilityInfo(), context,
+ pkgInfo.getApplicationInfo().isThemeable);
}
/**
@@ -1711,7 +1712,8 @@ public final class ActivityThread {
Resources getTopLevelThemedResources(String resDir, int displayId, LoadedApk pkgInfo,
String pkgName, String themePkgName) {
return mResourcesManager.getTopLevelThemedResources(resDir, displayId, pkgName,
- themePkgName, pkgInfo.getCompatibilityInfo());
+ themePkgName, pkgInfo.getCompatibilityInfo(),
+ pkgInfo.getApplicationInfo().isThemeable);
}
final Handler getHandler() {
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 321437e..3667914 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -1870,9 +1870,11 @@ class ContextImpl extends Context {
packageInfo.getResDir(), packageInfo.getSplitResDirs(),
packageInfo.getOverlayDirs(),
packageInfo.getApplicationInfo().sharedLibraryFiles, displayId,
- packageInfo.getAppDir(), overrideConfiguration, compatInfo, mOuterContext) :
+ packageInfo.getAppDir(), overrideConfiguration, compatInfo, mOuterContext,
+ packageInfo.getApplicationInfo().isThemeable) :
mResourcesManager.getTopLevelThemedResources(packageInfo.getResDir(), displayId,
- packageInfo.getPackageName(), themePackageName, compatInfo);
+ packageInfo.getPackageName(), themePackageName, compatInfo,
+ packageInfo.getApplicationInfo().isThemeable);
}
}
mResources = resources;
diff --git a/core/java/android/app/ResourcesManager.java b/core/java/android/app/ResourcesManager.java
index 4e1c42c..0b17389 100644
--- a/core/java/android/app/ResourcesManager.java
+++ b/core/java/android/app/ResourcesManager.java
@@ -179,12 +179,12 @@ public class ResourcesManager {
*/
Resources getTopLevelResources(String resDir, String[] splitResDirs,
String[] overlayDirs, String[] libDirs, int displayId, String packageName,
- Configuration overrideConfiguration, CompatibilityInfo compatInfo, Context context) {
+ Configuration overrideConfiguration, CompatibilityInfo compatInfo, Context context,
+ boolean isThemeable) {
final float scale = compatInfo.applicationScale;
- final boolean isThemeable = compatInfo.isThemeable;
+ final ThemeConfig themeConfig = getThemeConfig();
Configuration overrideConfigCopy = (overrideConfiguration != null)
? new Configuration(overrideConfiguration) : null;
- final ThemeConfig themeConfig = getThemeConfig();
ResourcesKey key = new ResourcesKey(resDir, displayId, overrideConfiguration, scale,
isThemeable, themeConfig);
Resources r;
@@ -210,7 +210,7 @@ public class ResourcesManager {
AssetManager assets = new AssetManager();
assets.setAppName(packageName);
- assets.setThemeSupport(compatInfo.isThemeable);
+ assets.setThemeSupport(isThemeable);
// resDir can be null if the 'android' package is creating a new Resources object.
// This is fine, since each AssetManager automatically loads the 'android' package
// already.
@@ -267,7 +267,7 @@ public class ResourcesManager {
boolean iconsAttached = false;
/* Attach theme information to the resulting AssetManager when appropriate. */
- if (compatInfo.isThemeable && config != null && !context.getPackageManager().isSafeMode()) {
+ if (isThemeable && config != null && !context.getPackageManager().isSafeMode()) {
if (config.themeConfig == null) {
try {
config.themeConfig = ThemeConfig.getBootTheme(context.getContentResolver());
@@ -312,19 +312,16 @@ public class ResourcesManager {
*
* @param resDir the resource directory.
* @param compatInfo the compability info. Must not be null.
- * @param token the application token for determining stack bounds.
*
* @hide
*/
- public Resources getTopLevelThemedResources(String resDir, int displayId,
- String packageName,
- String themePackageName,
- CompatibilityInfo compatInfo) {
+ public Resources getTopLevelThemedResources(String resDir, int displayId, String packageName,
+ String themePackageName, CompatibilityInfo compatInfo, boolean isThemeable) {
Resources r;
AssetManager assets = new AssetManager();
assets.setAppName(packageName);
- assets.setThemeSupport(true);
+ assets.setThemeSupport(isThemeable);
if (assets.addAssetPath(resDir) == 0) {
return null;
}
@@ -340,19 +337,21 @@ public class ResourcesManager {
config = getConfiguration();
}
- /* Attach theme information to the resulting AssetManager when appropriate. */
- ThemeConfig.Builder builder = new ThemeConfig.Builder();
- builder.defaultOverlay(themePackageName);
- builder.defaultIcon(themePackageName);
- builder.defaultFont(themePackageName);
-
- ThemeConfig themeConfig = builder.build();
- attachThemeAssets(assets, themeConfig);
- attachCommonAssets(assets, themeConfig);
- attachIconAssets(assets, themeConfig);
-
+ boolean iconsAttached = false;
+ if (isThemeable) {
+ /* Attach theme information to the resulting AssetManager when appropriate. */
+ ThemeConfig.Builder builder = new ThemeConfig.Builder();
+ builder.defaultOverlay(themePackageName);
+ builder.defaultIcon(themePackageName);
+ builder.defaultFont(themePackageName);
+
+ ThemeConfig themeConfig = builder.build();
+ attachThemeAssets(assets, themeConfig);
+ attachCommonAssets(assets, themeConfig);
+ iconsAttached = attachIconAssets(assets, themeConfig);
+ }
r = new Resources(assets, dm, config, compatInfo);
- setActivityIcons(r);
+ if (iconsAttached) setActivityIcons(r);
return r;
}
@@ -362,8 +361,6 @@ public class ResourcesManager {
* is then stored in the resource object.
* When resource.getDrawable(id) is called it will check this mapping and replace
* the id with the themed resource id if one is available
- * @param context
- * @param pkgName
* @param r
*/
private void setActivityIcons(Resources r) {
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index 7653c39..b4af2c9 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -2582,8 +2582,9 @@ public class PackageParser {
final ApplicationInfo ai = owner.applicationInfo;
final String pkgName = owner.applicationInfo.packageName;
- // assume that this package is themeable unless explicitly set to false.
- ai.isThemeable = true;
+ String[] nonThemeablePackages =
+ res.getStringArray(com.android.internal.R.array.non_themeable_packages);
+ ai.isThemeable = isPackageThemeable(pkgName, nonThemeablePackages);
TypedArray sa = res.obtainAttributes(attrs,
com.android.internal.R.styleable.AndroidManifestApplication);
@@ -4443,6 +4444,22 @@ public class PackageParser {
return true;
}
+ /**1
+ * Returns whether the specified package is themeable
+ * @param packageName Name of package to check
+ * @param nonThemeablePackages Array of packages that are declared as non-themeable
+ * @return True if the package is themeable, false otherwise
+ */
+ private static boolean isPackageThemeable(String packageName, String[] nonThemeablePackages) {
+ for (String pkg : nonThemeablePackages) {
+ if (packageName.startsWith(pkg)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/**
* Representation of a full package parsed from APK files on disk. A package
* consists of a single base APK, and zero or more split APKs.
diff --git a/core/java/android/content/res/CompatibilityInfo.java b/core/java/android/content/res/CompatibilityInfo.java
index 47d5d05..2b8951e 100644
--- a/core/java/android/content/res/CompatibilityInfo.java
+++ b/core/java/android/content/res/CompatibilityInfo.java
@@ -92,15 +92,9 @@ public class CompatibilityInfo implements Parcelable {
*/
public final float applicationInvertedScale;
- /**
- * Whether the application supports third-party theming.
- */
- public final boolean isThemeable;
-
public CompatibilityInfo(ApplicationInfo appInfo, int screenLayout, int sw,
boolean forceCompat) {
int compatFlags = 0;
- isThemeable = appInfo.isThemeable;
if (appInfo.requiresSmallestWidthDp != 0 || appInfo.compatibleWidthLimitDp != 0
|| appInfo.largestWidthLimitDp != 0) {
@@ -247,20 +241,17 @@ public class CompatibilityInfo implements Parcelable {
mCompatibilityFlags = compatFlags;
}
- private CompatibilityInfo(int compFlags,
- int dens, float scale, float invertedScale, boolean isThemeable) {
+ private CompatibilityInfo(int compFlags, int dens, float scale, float invertedScale) {
mCompatibilityFlags = compFlags;
applicationDensity = dens;
applicationScale = scale;
applicationInvertedScale = invertedScale;
- this.isThemeable = isThemeable;
}
private CompatibilityInfo() {
this(NEVER_NEEDS_COMPAT, DisplayMetrics.DENSITY_DEVICE,
1.0f,
- 1.0f,
- true);
+ 1.0f);
}
/**
@@ -534,7 +525,6 @@ public class CompatibilityInfo implements Parcelable {
if (applicationDensity != oc.applicationDensity) return false;
if (applicationScale != oc.applicationScale) return false;
if (applicationInvertedScale != oc.applicationInvertedScale) return false;
- if (isThemeable != oc.isThemeable) return false;
return true;
} catch (ClassCastException e) {
return false;
@@ -572,7 +562,6 @@ public class CompatibilityInfo implements Parcelable {
result = 31 * result + applicationDensity;
result = 31 * result + Float.floatToIntBits(applicationScale);
result = 31 * result + Float.floatToIntBits(applicationInvertedScale);
- result = 31 * result + (isThemeable ? 1 : 0);
return result;
}
@@ -587,7 +576,6 @@ public class CompatibilityInfo implements Parcelable {
dest.writeInt(applicationDensity);
dest.writeFloat(applicationScale);
dest.writeFloat(applicationInvertedScale);
- dest.writeInt(isThemeable ? 1 : 0);
}
public static final Parcelable.Creator<CompatibilityInfo> CREATOR
@@ -608,6 +596,5 @@ public class CompatibilityInfo implements Parcelable {
applicationDensity = source.readInt();
applicationScale = source.readFloat();
applicationInvertedScale = source.readFloat();
- isThemeable = source.readInt() == 1 ? true : false;
}
}
diff --git a/core/res/res/values/cm_arrays.xml b/core/res/res/values/cm_arrays.xml
index b78fe37..c833f41 100644
--- a/core/res/res/values/cm_arrays.xml
+++ b/core/res/res/values/cm_arrays.xml
@@ -63,4 +63,10 @@
<item>recovery</item>
<item>bootloader</item>
</string-array>
+
+ <!-- List of packages that should not be themed.
+ Note: These strings are checked using String.startsWith() so include as much of the
+ package name as possible to avoid other packages being un-themed unintentionally -->
+ <string-array name="non_themeable_packages" translatable="false">
+ </string-array>
</resources>
diff --git a/core/res/res/values/cm_symbols.xml b/core/res/res/values/cm_symbols.xml
index 4261c5c..26bc0f3 100644
--- a/core/res/res/values/cm_symbols.xml
+++ b/core/res/res/values/cm_symbols.xml
@@ -84,4 +84,7 @@
<!-- LED pulse -->
<java-symbol type="bool" name="config_ledCanPulse" />
+
+ <!-- Non-themeable packages -->
+ <java-symbol type="array" name="non_themeable_packages" />
</resources>