diff options
| author | Jackal Guo <jackalguo@google.com> | 2021-03-24 12:00:19 +0800 |
|---|---|---|
| committer | Jackal Guo <jackalguo@google.com> | 2021-03-26 08:31:02 +0800 |
| commit | 755cecda8d7bce95a99504fbb0136290f664b5c1 (patch) | |
| tree | e98c3ae7a8038f8d663c50e89bc181b400d93f53 /core/java | |
| parent | 5c02efbc1bea358c4024401979bb94b0f37239ff (diff) | |
Migrate the usage of sUseRoundIcon to PackageParserUtils
PackageParser is deprecated, but system still references its
sUseRoundIcon. We should move that to PackageParserUtils.
Bug: 180603085
Test: manually check if the icon has the white border
Change-Id: Idb2ccc2be9006237244aabfe9c45814e9c7c27b5
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/content/pm/parsing/ParsingPackageUtils.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/core/java/android/content/pm/parsing/ParsingPackageUtils.java b/core/java/android/content/pm/parsing/ParsingPackageUtils.java index 0e1574c8da92..459a362c88aa 100644 --- a/core/java/android/content/pm/parsing/ParsingPackageUtils.java +++ b/core/java/android/content/pm/parsing/ParsingPackageUtils.java @@ -34,6 +34,8 @@ import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.StyleableRes; +import android.app.ActivityThread; +import android.app.ResourcesManager; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.ApplicationInfo; @@ -85,7 +87,9 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.FileUtils; +import android.os.RemoteException; import android.os.Trace; +import android.os.UserHandle; import android.os.ext.SdkExtensions; import android.permission.PermissionManager; import android.text.TextUtils; @@ -3041,6 +3045,42 @@ public class ParsingPackageUtils { } } + /** + * @hide + */ + public static void readConfigUseRoundIcon(Resources r) { + if (r != null) { + sUseRoundIcon = r.getBoolean(com.android.internal.R.bool.config_useRoundIcon); + return; + } + + final ApplicationInfo androidAppInfo; + try { + androidAppInfo = ActivityThread.getPackageManager().getApplicationInfo( + "android", 0 /* flags */, + UserHandle.myUserId()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + final Resources systemResources = Resources.getSystem(); + + // Create in-flight as this overlayable resource is only used when config changes + final Resources overlayableRes = ResourcesManager.getInstance().getResources( + null /* activityToken */, + null /* resDir */, + null /* splitResDirs */, + androidAppInfo.resourceDirs, + androidAppInfo.overlayPaths, + androidAppInfo.sharedLibraryFiles, + null /* overrideDisplayId */, + null /* overrideConfig */, + systemResources.getCompatibilityInfo(), + systemResources.getClassLoader(), + null /* loaders */); + + sUseRoundIcon = overlayableRes.getBoolean(com.android.internal.R.bool.config_useRoundIcon); + } + /* The following set of methods makes code easier to read by re-ordering the TypedArray methods. |
