diff options
author | 2025-02-06 20:23:08 +0000 | |
---|---|---|
committer | 2025-02-19 10:09:16 -0800 | |
commit | 2ab184598dfe512899349a1948b049b7e1a940f4 (patch) | |
tree | a4183547d95925b2871e335c2817230976d364b1 /PermissionController/src | |
parent | 660efbcedb1a2f081bb8222de8d678f330a5799c (diff) |
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
Diffstat (limited to 'PermissionController/src')
-rw-r--r-- | PermissionController/src/com/android/permissioncontroller/role/ui/behavior/v35/WalletRoleUiBehavior.java | 53 |
1 files changed, 38 insertions, 15 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 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; @@ -73,6 +74,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<Drawable, CharSequence> 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, @NonNull UserHandle user, @NonNull Context context) { @@ -84,21 +100,8 @@ public class WalletRoleUiBehavior implements RoleUiBehavior { @NonNull ApplicationInfo applicationInfo, boolean setTitle, @NonNull UserHandle user, @NonNull Context context) { if (isSystemApplication(applicationInfo)) { - List<ApduServiceInfo> serviceInfos = getNfcServicesForPackage( - applicationInfo.packageName, user, context); - - Pair<Drawable, CharSequence> 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<Drawable, CharSequence> 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<Drawable, CharSequence> getLabelAndIconIfItExists( + @NonNull ApplicationInfo applicationInfo, + @NonNull UserHandle user, + @NonNull Context context) { + Pair<Drawable, CharSequence> 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<ApduServiceInfo> 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<Drawable, CharSequence> getBannerAndLabelFromPackageProperty( |