WalletTile should display the default card of wallet.

Also a few polish:
1. update the tile icon.
2. do not use ActivityStarter to launch wallet activty when cards exist.

Fix: 185579396
Test: manual
Test: atest
Change-Id: I1ddc938f600708fc88fd9217d2286d3c273e6f72
This commit is contained in:
Silin Huang
2021-04-27 00:40:24 -07:00
parent de939e6572
commit 3984cd40a6
2 changed files with 36 additions and 6 deletions

View File

@@ -129,8 +129,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
Intent intent = new Intent(mContext, WalletActivity.class)
.setAction(Intent.ACTION_VIEW)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
mActivityStarter.startActivity(intent, true /* dismissShade */,
animationController);
if (mKeyguardStateController.isUnlocked()) {
mActivityStarter.startActivity(intent, true /* dismissShade */,
animationController);
} else {
mHost.collapsePanels();
// Do not use ActivityStarter here because the WalletActivity is required to be
// started without prompting keyguard when the device is locked.
mContext.startActivity(intent);
}
} else {
if (mQuickAccessWalletClient.createWalletIntent() == null) {
Log.w(TAG, "Could not get intent of the wallet app.");
@@ -147,7 +154,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
protected void handleUpdateState(State state, Object arg) {
state.label = mLabel;
state.contentDescription = state.label;
state.icon = ResourceIcon.get(R.drawable.ic_qs_wallet);
state.icon = ResourceIcon.get(R.drawable.ic_wallet_lockscreen);
boolean isDeviceLocked = !mKeyguardStateController.isUnlocked();
if (mQuickAccessWalletClient.isWalletServiceAvailable()) {
if (mHasCard) {
@@ -219,7 +226,12 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
refreshState();
return;
}
mCardViewDrawable = cards.get(0).getCardImage().loadDrawable(mContext);
int selectedIndex = response.getSelectedIndex();
if (selectedIndex >= cards.size()) {
Log.d(TAG, "Selected card index out of bounds.");
return;
}
mCardViewDrawable = cards.get(selectedIndex).getCardImage().loadDrawable(mContext);
mHasCard = true;
refreshState();
}

View File

@@ -207,7 +207,25 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
}
@Test
public void testHandleClick_hasCards_startWalletActivity() {
public void testHandleClick_hasCards_deviceLocked_startWalletActivity() {
when(mKeyguardStateController.isUnlocked()).thenReturn(false);
setUpWalletCard(/* hasCard= */ true);
mTile.handleClick(null /* view */);
mTestableLooper.processAllMessages();
verify(mSpiedContext).startActivity(mIntentCaptor.capture());
Intent nextStartedIntent = mIntentCaptor.getValue();
String walletClassName = "com.android.systemui.wallet.ui.WalletActivity";
assertNotNull(nextStartedIntent);
assertThat(nextStartedIntent.getComponent().getClassName()).isEqualTo(walletClassName);
}
@Test
public void testHandleClick_hasCards_deviceUnlocked_startWalletActivity() {
when(mKeyguardStateController.isUnlocked()).thenReturn(true);
setUpWalletCard(/* hasCard= */ true);
mTile.handleClick(null /* view */);
@@ -226,7 +244,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
@Test
public void testHandleUpdateState_updateLabelAndIcon() {
QSTile.State state = new QSTile.State();
QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_wallet);
QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_wallet_lockscreen);
mTile.handleUpdateState(state, null);