Loading core/java/android/app/ActivityThread.java +9 −0 Original line number Diff line number Diff line Loading @@ -1545,6 +1545,15 @@ public final class ActivityThread { overrideConfiguration, pkgInfo.getCompatibilityInfo(), null, context); } /** * Creates the top level resources for the given package. */ Resources getTopLevelThemedResources(String resDir, int displayId, LoadedApk pkgInfo, String pkgName, String themePkgName) { return mResourcesManager.getTopLevelThemedResources(resDir, displayId, pkgName, themePkgName, pkgInfo.getCompatibilityInfo(), null); } final Handler getHandler() { return mH; } Loading core/java/android/app/ApplicationPackageManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,29 @@ final class ApplicationPackageManager extends PackageManager { getApplicationInfo(appPackageName, 0)); } /** @hide */ @Override public Resources getThemedResourcesForApplication( ApplicationInfo app, String themePkgName) throws NameNotFoundException { if (app.packageName.equals("system")) { return mContext.mMainThread.getSystemContext().getResources(); } Resources r = mContext.mMainThread.getTopLevelThemedResources( app.uid == Process.myUid() ? app.sourceDir : app.publicSourceDir, Display.DEFAULT_DISPLAY, mContext.mPackageInfo, app.packageName, themePkgName); if (r != null) { return r; } throw new NameNotFoundException("Unable to open " + app.publicSourceDir); } /** @hide */ @Override public Resources getThemedResourcesForApplication( String appPackageName, String themePkgName) throws NameNotFoundException { return getThemedResourcesForApplication( getApplicationInfo(appPackageName, 0), themePkgName); } /** @hide */ @Override public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) Loading core/java/android/app/ResourcesManager.java +46 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,52 @@ public class ResourcesManager { } } /** * Creates the top level Resources for applications with the given compatibility info. * * @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, IBinder token) { Resources r; AssetManager assets = new AssetManager(); assets.setAppName(packageName); assets.setThemeSupport(true); if (assets.addAssetPath(resDir) == 0) { return null; } //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics); DisplayMetrics dm = getDisplayMetricsLocked(displayId); Configuration config; boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); if (!isDefaultDisplay) { config = new Configuration(getConfiguration()); applyNonDefaultDisplayMetricsToConfigurationLocked(dm, config); } else { config = getConfiguration(); } /* Attach theme information to the resulting AssetManager when appropriate. */ CustomTheme customTheme = new CustomTheme(themePackageName, themePackageName, themePackageName); attachThemeAssets(assets, customTheme); attachCommonAssets(assets, customTheme); attachIconAssets(assets, customTheme); r = new Resources(assets, dm, config, compatInfo, token); setActivityIcons(r); return r; } /** * Creates a map between an activity & app's icon ids to its component info. This map * is then stored in the resource object. Loading core/java/android/content/pm/PackageManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -2631,6 +2631,16 @@ public abstract class PackageManager { public abstract Resources getResourcesForApplication(String appPackageName) throws NameNotFoundException; /** @hide */ public abstract Resources getThemedResourcesForApplication(ApplicationInfo app, String themePkgName) throws NameNotFoundException; /** @hide */ public abstract Resources getThemedResourcesForApplication(String appPackageName, String themePkgName) throws NameNotFoundException; /** @hide */ public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) throws NameNotFoundException; Loading test-runner/src/android/test/mock/MockPackageManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,18 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } @Override public Resources getThemedResourcesForApplication(ApplicationInfo app, String themePkgName) throws NameNotFoundException { return null; } @Override public Resources getThemedResourcesForApplication(String appPackageName, String themePkgName) throws NameNotFoundException { return null; } /** @hide */ @Override public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) { Loading Loading
core/java/android/app/ActivityThread.java +9 −0 Original line number Diff line number Diff line Loading @@ -1545,6 +1545,15 @@ public final class ActivityThread { overrideConfiguration, pkgInfo.getCompatibilityInfo(), null, context); } /** * Creates the top level resources for the given package. */ Resources getTopLevelThemedResources(String resDir, int displayId, LoadedApk pkgInfo, String pkgName, String themePkgName) { return mResourcesManager.getTopLevelThemedResources(resDir, displayId, pkgName, themePkgName, pkgInfo.getCompatibilityInfo(), null); } final Handler getHandler() { return mH; } Loading
core/java/android/app/ApplicationPackageManager.java +23 −0 Original line number Diff line number Diff line Loading @@ -788,6 +788,29 @@ final class ApplicationPackageManager extends PackageManager { getApplicationInfo(appPackageName, 0)); } /** @hide */ @Override public Resources getThemedResourcesForApplication( ApplicationInfo app, String themePkgName) throws NameNotFoundException { if (app.packageName.equals("system")) { return mContext.mMainThread.getSystemContext().getResources(); } Resources r = mContext.mMainThread.getTopLevelThemedResources( app.uid == Process.myUid() ? app.sourceDir : app.publicSourceDir, Display.DEFAULT_DISPLAY, mContext.mPackageInfo, app.packageName, themePkgName); if (r != null) { return r; } throw new NameNotFoundException("Unable to open " + app.publicSourceDir); } /** @hide */ @Override public Resources getThemedResourcesForApplication( String appPackageName, String themePkgName) throws NameNotFoundException { return getThemedResourcesForApplication( getApplicationInfo(appPackageName, 0), themePkgName); } /** @hide */ @Override public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) Loading
core/java/android/app/ResourcesManager.java +46 −0 Original line number Diff line number Diff line Loading @@ -259,6 +259,52 @@ public class ResourcesManager { } } /** * Creates the top level Resources for applications with the given compatibility info. * * @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, IBinder token) { Resources r; AssetManager assets = new AssetManager(); assets.setAppName(packageName); assets.setThemeSupport(true); if (assets.addAssetPath(resDir) == 0) { return null; } //Slog.i(TAG, "Resource: key=" + key + ", display metrics=" + metrics); DisplayMetrics dm = getDisplayMetricsLocked(displayId); Configuration config; boolean isDefaultDisplay = (displayId == Display.DEFAULT_DISPLAY); if (!isDefaultDisplay) { config = new Configuration(getConfiguration()); applyNonDefaultDisplayMetricsToConfigurationLocked(dm, config); } else { config = getConfiguration(); } /* Attach theme information to the resulting AssetManager when appropriate. */ CustomTheme customTheme = new CustomTheme(themePackageName, themePackageName, themePackageName); attachThemeAssets(assets, customTheme); attachCommonAssets(assets, customTheme); attachIconAssets(assets, customTheme); r = new Resources(assets, dm, config, compatInfo, token); setActivityIcons(r); return r; } /** * Creates a map between an activity & app's icon ids to its component info. This map * is then stored in the resource object. Loading
core/java/android/content/pm/PackageManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -2631,6 +2631,16 @@ public abstract class PackageManager { public abstract Resources getResourcesForApplication(String appPackageName) throws NameNotFoundException; /** @hide */ public abstract Resources getThemedResourcesForApplication(ApplicationInfo app, String themePkgName) throws NameNotFoundException; /** @hide */ public abstract Resources getThemedResourcesForApplication(String appPackageName, String themePkgName) throws NameNotFoundException; /** @hide */ public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) throws NameNotFoundException; Loading
test-runner/src/android/test/mock/MockPackageManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -400,6 +400,18 @@ public class MockPackageManager extends PackageManager { throw new UnsupportedOperationException(); } @Override public Resources getThemedResourcesForApplication(ApplicationInfo app, String themePkgName) throws NameNotFoundException { return null; } @Override public Resources getThemedResourcesForApplication(String appPackageName, String themePkgName) throws NameNotFoundException { return null; } /** @hide */ @Override public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) { Loading