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
This commit is contained in:
Silin Huang
2021-04-15 22:40:46 -07:00
parent 5600015ef0
commit 6d29225bf3
4 changed files with 22 additions and 6 deletions

View File

@@ -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() {

View File

@@ -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);

View File

@@ -232,6 +232,11 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
assertEquals(icon, state.icon);
}
@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);

View File

@@ -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());