Loading packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +16 −4 Original line number Diff line number Diff line Loading @@ -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); 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."); Loading @@ -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) { Loading Loading @@ -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(); } Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +20 −2 Original line number Diff line number Diff line Loading @@ -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 */); Loading @@ -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); Loading Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +16 −4 Original line number Diff line number Diff line Loading @@ -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); 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."); Loading @@ -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) { Loading Loading @@ -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(); } Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +20 −2 Original line number Diff line number Diff line Loading @@ -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 */); Loading @@ -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); Loading