Loading packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1661,6 +1661,8 @@ <string name="wallet_action_button_label_unlock">Unlock to pay</string> <!-- Secondary label of the quick access wallet tile if no card. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_no_card">Not set up</string> <!-- Secondary label of the quick access wallet tile if wallet is still updating. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_updating">Updating</string> <!-- Secondary label of the quick access wallet tile if device locked. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_device_locked">Unlock to use</string> <!-- Message shown when an unknown failure occurred when fetching cards. [CHAR LIMIT=NONE] --> Loading packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +12 −4 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { private final QuickAccessWalletController mController; private WalletCard mSelectedCard; private boolean mIsWalletUpdating = true; @VisibleForTesting Drawable mCardViewDrawable; @Inject Loading Loading @@ -110,7 +111,8 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { super.handleSetListening(listening); if (listening) { mController.setupWalletChangeObservers(mCardRetriever, DEFAULT_PAYMENT_APP_CHANGE); if (!mController.getWalletClient().isWalletServiceAvailable()) { if (!mController.getWalletClient().isWalletServiceAvailable() || !mController.getWalletClient().isWalletFeatureAvailable()) { Log.i(TAG, "QAW service is unavailable, recreating the wallet client."); mController.reCreateWalletClient(); } Loading Loading @@ -158,7 +160,8 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { state.contentDescription = state.label; state.icon = ResourceIcon.get(R.drawable.ic_wallet_lockscreen); boolean isDeviceLocked = !mKeyguardStateController.isUnlocked(); if (mController.getWalletClient().isWalletServiceAvailable()) { if (mController.getWalletClient().isWalletServiceAvailable() && mController.getWalletClient().isWalletFeatureAvailable()) { if (mSelectedCard != null) { if (isDeviceLocked) { state.state = Tile.STATE_INACTIVE; Loading @@ -172,7 +175,11 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { } } else { state.state = Tile.STATE_INACTIVE; state.secondaryLabel = mContext.getString(R.string.wallet_secondary_label_no_card); state.secondaryLabel = mContext.getString( mIsWalletUpdating ? R.string.wallet_secondary_label_updating : R.string.wallet_secondary_label_no_card); state.sideViewCustomDrawable = null; } state.stateDescription = state.secondaryLabel; Loading Loading @@ -218,6 +225,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { @Override public void onWalletCardsRetrieved(@NonNull GetWalletCardsResponse response) { Log.i(TAG, "Successfully retrieved wallet cards."); mIsWalletUpdating = false; List<WalletCard> cards = response.getWalletCards(); if (cards.isEmpty()) { Log.d(TAG, "No wallet cards exist."); Loading @@ -240,7 +248,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { @Override public void onWalletCardRetrievalError(@NonNull GetWalletCardsError error) { Log.w(TAG, "Error retrieve wallet cards"); mIsWalletUpdating = false; mCardViewDrawable = null; mSelectedCard = null; refreshState(); Loading packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java +7 −2 Original line number Diff line number Diff line Loading @@ -25,10 +25,11 @@ import android.provider.Settings; import android.service.quickaccesswallet.GetWalletCardsRequest; import android.service.quickaccesswallet.QuickAccessWalletClient; import android.service.quickaccesswallet.QuickAccessWalletClientImpl; import android.util.Log; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.util.settings.SecureSettings; import java.util.concurrent.Executor; Loading Loading @@ -65,7 +66,7 @@ public class QuickAccessWalletController { @Inject public QuickAccessWalletController( Context context, @Main Executor executor, @Background Executor executor, SecureSettings secureSettings, QuickAccessWalletClient quickAccessWalletClient) { mContext = context; Loading Loading @@ -142,6 +143,10 @@ public class QuickAccessWalletController { */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { if (!mQuickAccessWalletClient.isWalletFeatureAvailable()) { Log.d(TAG, "QuickAccessWallet feature is not available."); return; } int cardWidth = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width); int cardHeight = Loading packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +57 −1 Original line number Diff line number Diff line Loading @@ -174,6 +174,15 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { verify(mController, times(1)).reCreateWalletClient(); } @Test public void testWalletFeatureUnavailable_recreateWalletClient() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); mTile.handleSetListening(true); verify(mController, times(1)).reCreateWalletClient(); } @Test public void testIsAvailable_qawFeatureAvailable() { when(mPackageManager.hasSystemFeature(FEATURE_NFC_HOST_CARD_EMULATION)).thenReturn(true); Loading Loading @@ -266,6 +275,41 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertEquals(mContext.getString(R.string.wallet_title), mTile.getTileLabel().toString()); } @Test public void testHandleUpdateState_walletIsUpdating() { when(mKeyguardStateController.isUnlocked()).thenReturn(true); QSTile.State state = new QSTile.State(); GetWalletCardsResponse response = new GetWalletCardsResponse( Collections.singletonList(createWalletCard(mContext)), 0); mTile.handleSetListening(true); verify(mController).queryWalletCards(mCallbackCaptor.capture()); // Wallet cards fetching on its way; wallet updating. mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_INACTIVE, state.state); assertEquals( mContext.getString(R.string.wallet_secondary_label_updating), state.secondaryLabel); assertNotNull(state.stateDescription); assertNull(state.sideViewCustomDrawable); // Wallet cards fetching completed. mCallbackCaptor.getValue().onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_ACTIVE, state.state); assertEquals( "•••• 1234", state.secondaryLabel); assertNotNull(state.stateDescription); assertNotNull(state.sideViewCustomDrawable); } @Test public void testHandleUpdateState_hasCard_deviceLocked_tileInactive() { when(mKeyguardStateController.isUnlocked()).thenReturn(false); Loading Loading @@ -315,7 +359,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { } @Test public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() { public void testHandleUpdateState_qawServiceUnavailable_tileUnavailable() { when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false); QSTile.State state = new QSTile.State(); Loading @@ -326,6 +370,18 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertNull(state.sideViewCustomDrawable); } @Test public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); QSTile.State state = new QSTile.State(); mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_UNAVAILABLE, state.state); assertNull(state.stateDescription); assertNull(state.sideViewCustomDrawable); } @Test public void testHandleSetListening_queryCards() { mTile.handleSetListening(true); Loading packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java +11 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -61,12 +63,10 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { private ArgumentCaptor<GetWalletCardsRequest> mRequestCaptor; private QuickAccessWalletController mController; private TestableLooper mTestableLooper; @Before public void setUp() { MockitoAnnotations.initMocks(this); mTestableLooper = TestableLooper.get(this); when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(true); when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(true); when(mQuickAccessWalletClient.isWalletFeatureAvailableWhenDeviceLocked()).thenReturn(true); Loading Loading @@ -143,4 +143,13 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height), request.getCardHeightPx()); } @Test public void queryWalletCards_walletFeatureNotAvailable_noQuery() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); mController.queryWalletCards(mCardsRetriever); verify(mQuickAccessWalletClient, never()).getWalletCards(any(), any(), any()); } } Loading
packages/SystemUI/res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -1661,6 +1661,8 @@ <string name="wallet_action_button_label_unlock">Unlock to pay</string> <!-- Secondary label of the quick access wallet tile if no card. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_no_card">Not set up</string> <!-- Secondary label of the quick access wallet tile if wallet is still updating. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_updating">Updating</string> <!-- Secondary label of the quick access wallet tile if device locked. [CHAR LIMIT=NONE] --> <string name="wallet_secondary_label_device_locked">Unlock to use</string> <!-- Message shown when an unknown failure occurred when fetching cards. [CHAR LIMIT=NONE] --> Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +12 −4 Original line number Diff line number Diff line Loading @@ -73,6 +73,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { private final QuickAccessWalletController mController; private WalletCard mSelectedCard; private boolean mIsWalletUpdating = true; @VisibleForTesting Drawable mCardViewDrawable; @Inject Loading Loading @@ -110,7 +111,8 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { super.handleSetListening(listening); if (listening) { mController.setupWalletChangeObservers(mCardRetriever, DEFAULT_PAYMENT_APP_CHANGE); if (!mController.getWalletClient().isWalletServiceAvailable()) { if (!mController.getWalletClient().isWalletServiceAvailable() || !mController.getWalletClient().isWalletFeatureAvailable()) { Log.i(TAG, "QAW service is unavailable, recreating the wallet client."); mController.reCreateWalletClient(); } Loading Loading @@ -158,7 +160,8 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { state.contentDescription = state.label; state.icon = ResourceIcon.get(R.drawable.ic_wallet_lockscreen); boolean isDeviceLocked = !mKeyguardStateController.isUnlocked(); if (mController.getWalletClient().isWalletServiceAvailable()) { if (mController.getWalletClient().isWalletServiceAvailable() && mController.getWalletClient().isWalletFeatureAvailable()) { if (mSelectedCard != null) { if (isDeviceLocked) { state.state = Tile.STATE_INACTIVE; Loading @@ -172,7 +175,11 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { } } else { state.state = Tile.STATE_INACTIVE; state.secondaryLabel = mContext.getString(R.string.wallet_secondary_label_no_card); state.secondaryLabel = mContext.getString( mIsWalletUpdating ? R.string.wallet_secondary_label_updating : R.string.wallet_secondary_label_no_card); state.sideViewCustomDrawable = null; } state.stateDescription = state.secondaryLabel; Loading Loading @@ -218,6 +225,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { @Override public void onWalletCardsRetrieved(@NonNull GetWalletCardsResponse response) { Log.i(TAG, "Successfully retrieved wallet cards."); mIsWalletUpdating = false; List<WalletCard> cards = response.getWalletCards(); if (cards.isEmpty()) { Log.d(TAG, "No wallet cards exist."); Loading @@ -240,7 +248,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> { @Override public void onWalletCardRetrievalError(@NonNull GetWalletCardsError error) { Log.w(TAG, "Error retrieve wallet cards"); mIsWalletUpdating = false; mCardViewDrawable = null; mSelectedCard = null; refreshState(); Loading
packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java +7 −2 Original line number Diff line number Diff line Loading @@ -25,10 +25,11 @@ import android.provider.Settings; import android.service.quickaccesswallet.GetWalletCardsRequest; import android.service.quickaccesswallet.QuickAccessWalletClient; import android.service.quickaccesswallet.QuickAccessWalletClientImpl; import android.util.Log; import com.android.systemui.R; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.util.settings.SecureSettings; import java.util.concurrent.Executor; Loading Loading @@ -65,7 +66,7 @@ public class QuickAccessWalletController { @Inject public QuickAccessWalletController( Context context, @Main Executor executor, @Background Executor executor, SecureSettings secureSettings, QuickAccessWalletClient quickAccessWalletClient) { mContext = context; Loading Loading @@ -142,6 +143,10 @@ public class QuickAccessWalletController { */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { if (!mQuickAccessWalletClient.isWalletFeatureAvailable()) { Log.d(TAG, "QuickAccessWallet feature is not available."); return; } int cardWidth = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width); int cardHeight = Loading
packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java +57 −1 Original line number Diff line number Diff line Loading @@ -174,6 +174,15 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { verify(mController, times(1)).reCreateWalletClient(); } @Test public void testWalletFeatureUnavailable_recreateWalletClient() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); mTile.handleSetListening(true); verify(mController, times(1)).reCreateWalletClient(); } @Test public void testIsAvailable_qawFeatureAvailable() { when(mPackageManager.hasSystemFeature(FEATURE_NFC_HOST_CARD_EMULATION)).thenReturn(true); Loading Loading @@ -266,6 +275,41 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertEquals(mContext.getString(R.string.wallet_title), mTile.getTileLabel().toString()); } @Test public void testHandleUpdateState_walletIsUpdating() { when(mKeyguardStateController.isUnlocked()).thenReturn(true); QSTile.State state = new QSTile.State(); GetWalletCardsResponse response = new GetWalletCardsResponse( Collections.singletonList(createWalletCard(mContext)), 0); mTile.handleSetListening(true); verify(mController).queryWalletCards(mCallbackCaptor.capture()); // Wallet cards fetching on its way; wallet updating. mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_INACTIVE, state.state); assertEquals( mContext.getString(R.string.wallet_secondary_label_updating), state.secondaryLabel); assertNotNull(state.stateDescription); assertNull(state.sideViewCustomDrawable); // Wallet cards fetching completed. mCallbackCaptor.getValue().onWalletCardsRetrieved(response); mTestableLooper.processAllMessages(); mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_ACTIVE, state.state); assertEquals( "•••• 1234", state.secondaryLabel); assertNotNull(state.stateDescription); assertNotNull(state.sideViewCustomDrawable); } @Test public void testHandleUpdateState_hasCard_deviceLocked_tileInactive() { when(mKeyguardStateController.isUnlocked()).thenReturn(false); Loading Loading @@ -315,7 +359,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { } @Test public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() { public void testHandleUpdateState_qawServiceUnavailable_tileUnavailable() { when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false); QSTile.State state = new QSTile.State(); Loading @@ -326,6 +370,18 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { assertNull(state.sideViewCustomDrawable); } @Test public void testHandleUpdateState_qawFeatureUnavailable_tileUnavailable() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); QSTile.State state = new QSTile.State(); mTile.handleUpdateState(state, null); assertEquals(Tile.STATE_UNAVAILABLE, state.state); assertNull(state.stateDescription); assertNull(state.sideViewCustomDrawable); } @Test public void testHandleSetListening_queryCards() { mTile.handleSetListening(true); Loading
packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java +11 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,9 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; Loading Loading @@ -61,12 +63,10 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { private ArgumentCaptor<GetWalletCardsRequest> mRequestCaptor; private QuickAccessWalletController mController; private TestableLooper mTestableLooper; @Before public void setUp() { MockitoAnnotations.initMocks(this); mTestableLooper = TestableLooper.get(this); when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(true); when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(true); when(mQuickAccessWalletClient.isWalletFeatureAvailableWhenDeviceLocked()).thenReturn(true); Loading Loading @@ -143,4 +143,13 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height), request.getCardHeightPx()); } @Test public void queryWalletCards_walletFeatureNotAvailable_noQuery() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); mController.queryWalletCards(mCardsRetriever); verify(mQuickAccessWalletClient, never()).getWalletCards(any(), any(), any()); } }