From 2ab184598dfe512899349a1948b049b7e1a940f4 Mon Sep 17 00:00:00 2001 From: Omer Ozer Date: Thu, 6 Feb 2025 20:23:08 +0000 Subject: Extend prepareRequestRoleItemViewAsUser on wallet role behavior. LOW_COVERAGE_REASON=b/396512164 Bug: 393217200 Test: manual Flag: EXEMPT bugfix Relnote: FIX override a new method to fix ui Change-Id: I10747b08317318674cce4440f5181d21797bec4b --- .../role/ui/behavior/v35/WalletRoleUiBehavior.java | 53 ++++++++++++++++------ 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'PermissionController/src') 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 09aaa0532..eb1dbb5ef 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 @@ -42,6 +42,7 @@ import androidx.core.util.Pair; import androidx.preference.Preference; import com.android.launcher3.icons.IconFactory; +import com.android.permissioncontroller.role.ui.RequestRoleItemView; import com.android.permissioncontroller.role.ui.TwoTargetPreference; import com.android.permissioncontroller.role.ui.behavior.RoleUiBehavior; import com.android.role.controller.model.Role; @@ -72,6 +73,21 @@ public class WalletRoleUiBehavior implements RoleUiBehavior { } } + @Override + public void prepareRequestRoleItemViewAsUser(@NonNull Role role, + @NonNull RequestRoleItemView itemView, @NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, @NonNull Context context) { + if (isSystemApplication(applicationInfo)) { + Pair bannerAndLabel = getLabelAndIconIfItExists( + applicationInfo, user, context); + + if (bannerAndLabel != null) { + itemView.getIconImageView().setImageDrawable(bannerAndLabel.first); + itemView.getTitleTextView().setText(bannerAndLabel.second); + } + } + } + @Override public void prepareApplicationPreferenceAsUser(@NonNull Role role, @NonNull Preference preference, @NonNull ApplicationInfo applicationInfo, @@ -84,21 +100,8 @@ public class WalletRoleUiBehavior implements RoleUiBehavior { @NonNull ApplicationInfo applicationInfo, boolean setTitle, @NonNull UserHandle user, @NonNull Context context) { if (isSystemApplication(applicationInfo)) { - List serviceInfos = getNfcServicesForPackage( - applicationInfo.packageName, user, context); - - Pair bannerAndLabel = null; - // If the flag is enabled , attempt to fetch it from property - if (Flags.walletRoleIconPropertyEnabled()) { - bannerAndLabel = - getBannerAndLabelFromPackageProperty(context, user, - applicationInfo.packageName); - } - // If it's null, indicating that the property is not set, perform a legacy icon lookup. - if (bannerAndLabel == null) { - bannerAndLabel = - getNonPaymentServiceBannerAndLabelIfExists(serviceInfos, user, context); - } + Pair bannerAndLabel = getLabelAndIconIfItExists( + applicationInfo, user, context); if (bannerAndLabel != null) { preference.setIcon(bannerAndLabel.first); if (setTitle) { @@ -110,6 +113,26 @@ public class WalletRoleUiBehavior implements RoleUiBehavior { } } + @Nullable + private Pair getLabelAndIconIfItExists( + @NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, + @NonNull Context context) { + Pair result = null; + // If the flag is enabled , attempt to fetch it from property + if (Flags.walletRoleIconPropertyEnabled()) { + result = getBannerAndLabelFromPackageProperty(context, user, + applicationInfo.packageName); + } + if (result != null) { + return result; + } + List serviceInfos = getNfcServicesForPackage( + applicationInfo.packageName, user, context); + // If it's null, indicating that the property is not set, perform a legacy icon lookup. + return getNonPaymentServiceBannerAndLabelIfExists(serviceInfos, user, context); + } + @Nullable private Pair getBannerAndLabelFromPackageProperty( -- cgit v1.2.3-59-g8ed1b