summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author James Willcox <jwillcox@google.com> 2025-02-12 20:24:46 +0000
committer James Willcox <jwillcox@google.com> 2025-02-13 03:36:17 +0000
commit1f258a2526d3abe416b66cf3f4a254a256f0b76f (patch)
tree0b24ad1d362b3d1fd68ef5e5b7ca2f29ddbbbdcc
parent22ca5467adb0bb4928f97a72a7c2bbb2b58e9be7 (diff)
Fix profile badging for system apps with Wallet role
Bug: 395937157 Flag: EXEMPT bug fix Test: manual Change-Id: I3206cc441e8a1ac343cb17a99de3f73000e6f57e
-rw-r--r--PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java25
1 files changed, 21 insertions, 4 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java b/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java
index f1754dde9..09aaa0532 100644
--- a/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java
+++ b/PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java
@@ -22,6 +22,8 @@ import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
+import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.nfc.cardemulation.ApduServiceInfo;
import android.nfc.cardemulation.CardEmulation;
@@ -39,6 +41,7 @@ import androidx.annotation.RequiresApi;
import androidx.core.util.Pair;
import androidx.preference.Preference;
+import com.android.launcher3.icons.IconFactory;
import com.android.permissioncontroller.role.ui.TwoTargetPreference;
import com.android.permissioncontroller.role.ui.behavior.RoleUiBehavior;
import com.android.role.controller.model.Role;
@@ -122,7 +125,7 @@ public class WalletRoleUiBehavior implements RoleUiBehavior {
PackageManager.Property iconProperty = packageManager.getProperty(
ApduServiceInfo.PROPERTY_WALLET_PREFERRED_BANNER_AND_LABEL, componentName);
if (iconProperty.isBoolean() && iconProperty.getBoolean()) {
- return loadBannerAndLabel(serviceInfo, packageManager);
+ return loadBannerAndLabel(serviceInfo, packageManager, context, user);
}
} catch (PackageManager.NameNotFoundException e) {
continue;
@@ -186,7 +189,8 @@ public class WalletRoleUiBehavior implements RoleUiBehavior {
for (int i = 0; i < apduServiceInfoSize; i++) {
ApduServiceInfo serviceInfo = apduServiceInfos.get(i);
if (serviceInfo.getAids().isEmpty()) {
- bannerAndLabel = loadBannerAndLabel(serviceInfo, userPackageManager);
+ bannerAndLabel = loadBannerAndLabel(serviceInfo, userPackageManager, context,
+ user);
if (bannerAndLabel != null) {
return bannerAndLabel;
}
@@ -197,7 +201,8 @@ public class WalletRoleUiBehavior implements RoleUiBehavior {
String aid = aids.get(j);
String category = serviceInfo.getCategoryForAid(aid);
if (!CardEmulation.CATEGORY_PAYMENT.equals(category)) {
- bannerAndLabel = loadBannerAndLabel(serviceInfo, userPackageManager);
+ bannerAndLabel = loadBannerAndLabel(serviceInfo, userPackageManager,
+ context, user);
if (bannerAndLabel != null) {
return bannerAndLabel;
}
@@ -210,8 +215,20 @@ public class WalletRoleUiBehavior implements RoleUiBehavior {
@Nullable
private Pair<Drawable, CharSequence> loadBannerAndLabel(@NonNull ApduServiceInfo info,
- @NonNull PackageManager userPackageManager) {
+ @NonNull PackageManager userPackageManager, @NonNull Context context,
+ @NonNull UserHandle user) {
Drawable drawable = info.loadBanner(userPackageManager);
+ if (drawable != null) {
+ try (IconFactory factory = IconFactory.obtain(context)) {
+ Bitmap badged =
+ factory.createBadgedIconBitmap(drawable, user,
+ false).icon;
+ if (badged != null) {
+ drawable = new BitmapDrawable(context.getResources(), badged);
+ }
+ }
+ }
+
CharSequence label = info.loadLabel(userPackageManager);
if (drawable != null && !TextUtils.isEmpty(label)) {
return new Pair<>(drawable, label);