@@ -174,9 +174,8 @@ public boolean applyCompatConfiguration(int displayDensity,
174174 public Resources getTopLevelResources (String resDir , String [] splitResDirs ,
175175 String [] overlayDirs , String [] libDirs , int displayId , String packageName ,
176176 Configuration overrideConfiguration , CompatibilityInfo compatInfo , IBinder token ,
177- Context context ) {
177+ Context context , boolean isThemeable ) {
178178 final float scale = compatInfo .applicationScale ;
179- final boolean isThemeable = compatInfo .isThemeable ;
180179 final ThemeConfig themeConfig = getThemeConfig ();
181180 ResourcesKey key = new ResourcesKey (resDir , displayId , overrideConfiguration , scale ,
182181 isThemeable , themeConfig , token );
@@ -205,7 +204,7 @@ public Resources getTopLevelResources(String resDir, String[] splitResDirs,
205204
206205 AssetManager assets = new AssetManager ();
207206 assets .setAppName (packageName );
208- assets .setThemeSupport (compatInfo . isThemeable );
207+ assets .setThemeSupport (isThemeable );
209208 // resDir can be null if the 'android' package is creating a new Resources object.
210209 // This is fine, since each AssetManager automatically loads the 'android' package
211210 // already.
@@ -260,7 +259,7 @@ public Resources getTopLevelResources(String resDir, String[] splitResDirs,
260259
261260 boolean iconsAttached = false ;
262261 /* Attach theme information to the resulting AssetManager when appropriate. */
263- if (compatInfo . isThemeable && config != null && !context .getPackageManager ().isSafeMode ()) {
262+ if (isThemeable && config != null && !context .getPackageManager ().isSafeMode ()) {
264263 if (config .themeConfig == null ) {
265264 try {
266265 config .themeConfig = ThemeConfig .getBootTheme (context .getContentResolver ());
@@ -311,15 +310,14 @@ public Resources getTopLevelResources(String resDir, String[] splitResDirs,
311310 *
312311 * @hide
313312 */
314- public Resources getTopLevelThemedResources (String resDir , int displayId ,
315- String packageName ,
316- String themePackageName ,
317- CompatibilityInfo compatInfo , IBinder token ) {
313+ public Resources getTopLevelThemedResources (String resDir , int displayId , String packageName ,
314+ String themePackageName , CompatibilityInfo compatInfo , IBinder token ,
315+ boolean isThemeable ) {
318316 Resources r ;
319317
320318 AssetManager assets = new AssetManager ();
321319 assets .setAppName (packageName );
322- assets .setThemeSupport (true );
320+ assets .setThemeSupport (isThemeable );
323321 if (assets .addAssetPath (resDir ) == 0 ) {
324322 return null ;
325323 }
@@ -335,19 +333,21 @@ public Resources getTopLevelThemedResources(String resDir, int displayId,
335333 config = getConfiguration ();
336334 }
337335
338- /* Attach theme information to the resulting AssetManager when appropriate. */
339- ThemeConfig .Builder builder = new ThemeConfig .Builder ();
340- builder .defaultOverlay (themePackageName );
341- builder .defaultIcon (themePackageName );
342- builder .defaultFont (themePackageName );
343-
344- ThemeConfig themeConfig = builder .build ();
345- attachThemeAssets (assets , themeConfig );
346- attachCommonAssets (assets , themeConfig );
347- attachIconAssets (assets , themeConfig );
348-
336+ boolean iconsAttached = false ;
337+ if (isThemeable ) {
338+ /* Attach theme information to the resulting AssetManager when appropriate. */
339+ ThemeConfig .Builder builder = new ThemeConfig .Builder ();
340+ builder .defaultOverlay (themePackageName );
341+ builder .defaultIcon (themePackageName );
342+ builder .defaultFont (themePackageName );
343+
344+ ThemeConfig themeConfig = builder .build ();
345+ attachThemeAssets (assets , themeConfig );
346+ attachCommonAssets (assets , themeConfig );
347+ iconsAttached = attachIconAssets (assets , themeConfig );
348+ }
349349 r = new Resources (assets , dm , config , compatInfo , token );
350- setActivityIcons (r );
350+ if ( iconsAttached ) setActivityIcons (r );
351351
352352 return r ;
353353 }
0 commit comments