Loading packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java +14 −2 Original line number Diff line number Diff line Loading @@ -157,9 +157,10 @@ public class QuickAccessWalletController { * Query the wallet cards from {@link QuickAccessWalletClient}. * * @param cardsRetriever a callback to retrieve wallet cards. * @param maxCards the maximum number of cards requested from the QuickAccessWallet */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever, int maxCards) { if (mClock.elapsedRealtime() - mQawClientCreatedTimeMillis > RECREATION_TIME_WINDOW) { Log.i(TAG, "Re-creating the QAW client to avoid stale."); Loading @@ -175,10 +176,21 @@ public class QuickAccessWalletController { mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height); int iconSizePx = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_icon_size); GetWalletCardsRequest request = new GetWalletCardsRequest(cardWidth, cardHeight, iconSizePx, /* maxCards= */ 1); new GetWalletCardsRequest(cardWidth, cardHeight, iconSizePx, maxCards); mQuickAccessWalletClient.getWalletCards(mBgExecutor, request, cardsRetriever); } /** * Query the wallet cards from {@link QuickAccessWalletClient}. * * @param cardsRetriever a callback to retrieve wallet cards. */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { queryWalletCards(cardsRetriever, /* maxCards= */ 1); } /** * Re-create the {@link QuickAccessWalletClient} of the controller. */ Loading packages/SystemUI/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsController.kt +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn Loading Loading @@ -88,7 +87,7 @@ constructor( QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE ) walletController.updateWalletPreference() walletController.queryWalletCards(callback) walletController.queryWalletCards(callback, MAX_CARDS) awaitClose { walletController.unregisterWalletChangeObservers( Loading Loading @@ -152,5 +151,6 @@ constructor( companion object { private const val TAG = "WalletSuggestions" private const val MAX_CARDS = 50 } } packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,25 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { request.getCardHeightPx()); } @Test public void queryWalletCards_walletEnabled_queryMultipleCards() { mController.queryWalletCards(mCardsRetriever, 5); verify(mQuickAccessWalletClient) .getWalletCards( eq(MoreExecutors.directExecutor()), mRequestCaptor.capture(), eq(mCardsRetriever)); GetWalletCardsRequest request = mRequestCaptor.getValue(); assertEquals(5, mRequestCaptor.getValue().getMaxCards()); assertEquals( mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width), request.getCardWidthPx()); assertEquals( mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height), request.getCardHeightPx()); } @Test public void queryWalletCards_walletFeatureNotAvailable_noQuery() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); Loading packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ class WalletContextualSuggestionsControllerTest : SysuiTestCase() { cards: List<WalletCard> = emptyList(), shouldFail: Boolean = false ) { whenever(walletController.queryWalletCards(any())).thenAnswer { invocation -> whenever(walletController.queryWalletCards(any(), anyInt())).thenAnswer { invocation -> with( invocation.arguments[0] as QuickAccessWalletClient.OnWalletCardsRetrievedCallback ) { Loading Loading
packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java +14 −2 Original line number Diff line number Diff line Loading @@ -157,9 +157,10 @@ public class QuickAccessWalletController { * Query the wallet cards from {@link QuickAccessWalletClient}. * * @param cardsRetriever a callback to retrieve wallet cards. * @param maxCards the maximum number of cards requested from the QuickAccessWallet */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever, int maxCards) { if (mClock.elapsedRealtime() - mQawClientCreatedTimeMillis > RECREATION_TIME_WINDOW) { Log.i(TAG, "Re-creating the QAW client to avoid stale."); Loading @@ -175,10 +176,21 @@ public class QuickAccessWalletController { mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height); int iconSizePx = mContext.getResources().getDimensionPixelSize(R.dimen.wallet_icon_size); GetWalletCardsRequest request = new GetWalletCardsRequest(cardWidth, cardHeight, iconSizePx, /* maxCards= */ 1); new GetWalletCardsRequest(cardWidth, cardHeight, iconSizePx, maxCards); mQuickAccessWalletClient.getWalletCards(mBgExecutor, request, cardsRetriever); } /** * Query the wallet cards from {@link QuickAccessWalletClient}. * * @param cardsRetriever a callback to retrieve wallet cards. */ public void queryWalletCards( QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) { queryWalletCards(cardsRetriever, /* maxCards= */ 1); } /** * Re-create the {@link QuickAccessWalletClient} of the controller. */ Loading
packages/SystemUI/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsController.kt +2 −2 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.asStateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.emptyFlow import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn Loading Loading @@ -88,7 +87,7 @@ constructor( QuickAccessWalletController.WalletChangeEvent.DEFAULT_PAYMENT_APP_CHANGE ) walletController.updateWalletPreference() walletController.queryWalletCards(callback) walletController.queryWalletCards(callback, MAX_CARDS) awaitClose { walletController.unregisterWalletChangeObservers( Loading Loading @@ -152,5 +151,6 @@ constructor( companion object { private const val TAG = "WalletSuggestions" private const val MAX_CARDS = 50 } }
packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java +19 −0 Original line number Diff line number Diff line Loading @@ -187,6 +187,25 @@ public class QuickAccessWalletControllerTest extends SysuiTestCase { request.getCardHeightPx()); } @Test public void queryWalletCards_walletEnabled_queryMultipleCards() { mController.queryWalletCards(mCardsRetriever, 5); verify(mQuickAccessWalletClient) .getWalletCards( eq(MoreExecutors.directExecutor()), mRequestCaptor.capture(), eq(mCardsRetriever)); GetWalletCardsRequest request = mRequestCaptor.getValue(); assertEquals(5, mRequestCaptor.getValue().getMaxCards()); assertEquals( mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width), request.getCardWidthPx()); assertEquals( mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_height), request.getCardHeightPx()); } @Test public void queryWalletCards_walletFeatureNotAvailable_noQuery() { when(mQuickAccessWalletClient.isWalletFeatureAvailable()).thenReturn(false); Loading
packages/SystemUI/tests/src/com/android/systemui/wallet/controller/WalletContextualSuggestionsControllerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -215,7 +215,7 @@ class WalletContextualSuggestionsControllerTest : SysuiTestCase() { cards: List<WalletCard> = emptyList(), shouldFail: Boolean = false ) { whenever(walletController.queryWalletCards(any())).thenAnswer { invocation -> whenever(walletController.queryWalletCards(any(), anyInt())).thenAnswer { invocation -> with( invocation.arguments[0] as QuickAccessWalletClient.OnWalletCardsRetrievedCallback ) { Loading