|
45 | 45 | import android.app.LocaleConfig; |
46 | 46 | import android.app.ResourcesManager; |
47 | 47 | import android.compat.annotation.UnsupportedAppUsage; |
| 48 | +import android.content.ComponentName; |
48 | 49 | import android.content.Context; |
49 | 50 | import android.content.pm.ActivityInfo; |
50 | 51 | import android.content.pm.ActivityInfo.Config; |
@@ -251,6 +252,47 @@ public static Resources getSystem() { |
251 | 252 | } |
252 | 253 | } |
253 | 254 |
|
| 255 | + /** @hide */ |
| 256 | + @Nullable |
| 257 | + public Drawable getIconPackOverride( |
| 258 | + @NonNull String packageName, @NonNull String className, int density) { |
| 259 | + try { |
| 260 | + ThemeEngine themeEngine = ThemeEngine.getInstance(); |
| 261 | + if (themeEngine == null) return null; |
| 262 | + ComponentName cn = new ComponentName(packageName, className); |
| 263 | + return themeEngine.getIconPackDrawable(cn, density); |
| 264 | + } catch (Exception e) { |
| 265 | + return null; |
| 266 | + } |
| 267 | + } |
| 268 | + |
| 269 | + /** @hide */ |
| 270 | + @Nullable |
| 271 | + public Drawable getIconPackOverride( |
| 272 | + @NonNull String packageName, @NonNull String className) { |
| 273 | + return getIconPackOverride(packageName, className, 0); |
| 274 | + } |
| 275 | + |
| 276 | + /** @hide */ |
| 277 | + public boolean hasActiveIconPack() { |
| 278 | + try { |
| 279 | + ThemeEngine themeEngine = ThemeEngine.getInstance(); |
| 280 | + return themeEngine != null && themeEngine.hasActiveIconPack(); |
| 281 | + } catch (Exception e) { |
| 282 | + return false; |
| 283 | + } |
| 284 | + } |
| 285 | + |
| 286 | + /** @hide */ |
| 287 | + public String getIconPackPackage() { |
| 288 | + try { |
| 289 | + ThemeEngine themeEngine = ThemeEngine.getInstance(); |
| 290 | + return themeEngine != null ? themeEngine.getIconPackPackage() : null; |
| 291 | + } catch (Exception e) { |
| 292 | + return null; |
| 293 | + } |
| 294 | + } |
| 295 | + |
254 | 296 | /** |
255 | 297 | * This exception is thrown by the resource APIs when a requested resource |
256 | 298 | * can not be found. |
@@ -1026,9 +1068,31 @@ public Drawable getDrawableForDensity(@DrawableRes int id, int density, @Nullabl |
1026 | 1068 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
1027 | 1069 | Drawable loadDrawable(@NonNull TypedValue value, int id, int density, @Nullable Theme theme) |
1028 | 1070 | throws NotFoundException { |
| 1071 | + return loadDrawableInternal(value, id, density, theme); |
| 1072 | + } |
| 1073 | + |
| 1074 | + /** @hide */ |
| 1075 | + @NonNull |
| 1076 | + public Drawable loadDrawableInternal(@NonNull TypedValue value, int id, int density, |
| 1077 | + @Nullable Theme theme) throws NotFoundException { |
1029 | 1078 | return mResourcesImpl.loadDrawable(this, value, id, density, theme); |
1030 | 1079 | } |
1031 | 1080 |
|
| 1081 | + /** @hide */ |
| 1082 | + @Nullable |
| 1083 | + public Drawable getDrawableInternal(@DrawableRes int id) { |
| 1084 | + final TypedValue value = obtainTempTypedValue(); |
| 1085 | + try { |
| 1086 | + final ResourcesImpl impl = mResourcesImpl; |
| 1087 | + impl.getValueForDensity(id, 0, value, true); |
| 1088 | + return loadDrawableInternal(value, id, 0, null); |
| 1089 | + } catch (Exception e) { |
| 1090 | + return null; |
| 1091 | + } finally { |
| 1092 | + releaseTempTypedValue(value); |
| 1093 | + } |
| 1094 | + } |
| 1095 | + |
1032 | 1096 | /** |
1033 | 1097 | * Return a movie object associated with the particular resource ID. |
1034 | 1098 | * @param id The desired resource identifier, as generated by the aapt |
|
0 commit comments