diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java | 20 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java | 22 |
2 files changed, 36 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 ff830bc952c1..be40423df3fa 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java @@ -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(); } 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 2f28b13ec280..5cdad05e43f5 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 @@ -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); |