summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Silin Huang <silin@google.com> 2021-04-15 22:40:46 -0700
committer Silin Huang <silin@google.com> 2021-04-15 22:45:39 -0700
commit6d29225bf3f0c8c8e5d66eca45f21d33f1130a6d (patch)
tree674dc590d28cf0360480c95aa1f4d8074158068c
parent5600015ef095fdcdc1315b8243624423a615af54 (diff)
Bug fix for QuickAccessWallet.
1. Update the Wallet tile label. 2. Check the card width and height in the request, if they are not valid (is 0) do not query cards. Test: manual Test: atest Bug: 184905963 Change-Id: Ie1f02a27e2ac0c3077dd576a3ee2efcce0c6b8d4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java7
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java13
4 files changed, 22 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
index b728b4360db0..6f19276b8d00 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
@@ -184,8 +184,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
@Override
public CharSequence getTileLabel() {
- CharSequence qawLabel = mQuickAccessWalletClient.getServiceLabel();
- return qawLabel == null ? mLabel : qawLabel;
+ return mLabel;
}
private void queryWalletCards() {
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
index d19506212d91..d1a2c8a49a95 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
@@ -222,6 +222,11 @@ public class WalletScreenController implements
if (mIsDismissed) {
return;
}
+ int cardWidthPx = mCardCarousel.getCardWidthPx();
+ int cardHeightPx = mCardCarousel.getCardHeightPx();
+ if (cardWidthPx == 0 || cardHeightPx == 0) {
+ return;
+ }
if (!mHasRegisteredListener) {
// Listener is registered even when device is locked. Should only be registered once.
mWalletClient.addWalletServiceEventListener(this);
@@ -231,8 +236,6 @@ public class WalletScreenController implements
mWalletView.show();
mWalletView.hideErrorMessage();
int iconSizePx = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_icon_size);
- int cardWidthPx = mCardCarousel.getCardWidthPx();
- int cardHeightPx = mCardCarousel.getCardHeightPx();
GetWalletCardsRequest request =
new GetWalletCardsRequest(cardWidthPx, cardHeightPx, iconSizePx, MAX_CARDS);
mWalletClient.getWalletCards(mExecutor, request, this);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
index d236023499d2..4bba0d0d23e4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
@@ -233,6 +233,11 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
}
@Test
+ public void testGetTileLabel() {
+ assertEquals(mContext.getString(R.string.wallet_title), mTile.getTileLabel().toString());
+ }
+
+ @Test
public void testHandleUpdateState_hasCard_deviceLocked_tileInactive() {
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
QSTile.State state = new QSTile.State();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
index 653946ea5cc8..6f6ef7261020 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
@@ -71,15 +71,17 @@ import java.util.Collections;
public class WalletScreenControllerTest extends SysuiTestCase {
private static final int MAX_CARDS = 10;
+ private static final int CARD_CAROUSEL_WIDTH = 10;
private static final String CARD_ID = "card_id";
private static final CharSequence SHORTCUT_SHORT_LABEL = "View all";
private static final CharSequence SHORTCUT_LONG_LABEL = "Add a payment method";
private static final CharSequence SERVICE_LABEL = "Wallet app";
- private final WalletView mWalletView = new WalletView(mContext);
private final Drawable mWalletLogo = mContext.getDrawable(android.R.drawable.ic_lock_lock);
private final Intent mWalletIntent = new Intent(QuickAccessWalletService.ACTION_VIEW_WALLET)
.setComponent(new ComponentName(mContext.getPackageName(), "WalletActivity"));
+ private WalletView mWalletView;
+
@Mock
QuickAccessWalletClient mWalletClient;
@Mock
@@ -104,6 +106,8 @@ public class WalletScreenControllerTest extends SysuiTestCase {
MockitoAnnotations.initMocks(this);
mTestableLooper = TestableLooper.get(this);
when(mUserTracker.getUserContext()).thenReturn(mContext);
+ mWalletView = new WalletView(mContext);
+ mWalletView.getCardCarousel().setExpectedViewWidth(CARD_CAROUSEL_WIDTH);
when(mWalletClient.getLogo()).thenReturn(mWalletLogo);
when(mWalletClient.getShortcutLongLabel()).thenReturn(SHORTCUT_LONG_LABEL);
when(mWalletClient.getShortcutShortLabel()).thenReturn(SHORTCUT_SHORT_LABEL);
@@ -132,7 +136,12 @@ public class WalletScreenControllerTest extends SysuiTestCase {
verify(mWalletClient).getWalletCards(any(), any(), mCallbackCaptor.capture());
- mCallbackCaptor.getValue().onWalletCardsRetrieved(response);
+ QuickAccessWalletClient.OnWalletCardsRetrievedCallback callback =
+ mCallbackCaptor.getValue();
+
+ assertEquals(mController, callback);
+
+ callback.onWalletCardsRetrieved(response);
mTestableLooper.processAllMessages();
assertEquals(VISIBLE, mWalletView.getCardCarouselContainer().getVisibility());