From c61633ee7e3a98b3c2b6045a253de371fc28bcf7 Mon Sep 17 00:00:00 2001 From: Silin Huang Date: Fri, 21 Jan 2022 13:13:18 -0800 Subject: [PATCH] Call the startQuickAccessUiIntent of QuickAccessWalletController for QAWTile and Lockscreen wallet icon. Bug: 215737967 Test: atest QuickAccessWalletTileTest, manual Change-Id: I10d3773ccf1655c19b18b6e280cde91947fa301c --- .../qs/tiles/QuickAccessWalletTile.java | 23 +------ .../phone/KeyguardBottomAreaView.java | 18 +----- .../qs/tiles/QuickAccessWalletTileTest.java | 63 ++++--------------- 3 files changed, 16 insertions(+), 88 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 247f02b120db8..5ed9ab9c4f651 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java @@ -53,7 +53,6 @@ import com.android.systemui.qs.tileimpl.QSTileImpl; import com.android.systemui.statusbar.policy.KeyguardStateController; import com.android.systemui.util.settings.SecureSettings; import com.android.systemui.wallet.controller.QuickAccessWalletController; -import com.android.systemui.wallet.ui.WalletActivity; import java.util.List; @@ -128,25 +127,9 @@ public class QuickAccessWalletTile extends QSTileImpl { view == null ? null : ActivityLaunchAnimator.Controller.fromView(view, InteractionJankMonitor.CUJ_SHADE_APP_LAUNCH_FROM_QS_TILE); - mUiHandler.post(() -> { - if (mSelectedCard != null) { - 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, true /* showOverLockscreenWhenLocked */); - } else { - Intent intent = mController.getWalletClient().createWalletIntent(); - if (intent == null) { - Log.w(TAG, "Could not get intent of the wallet app."); - return; - } - mActivityStarter.postStartActivityDismissingKeyguard( - intent, - /* delay= */ 0, - animationController); - } - }); + mUiHandler.post( + () -> mController.startQuickAccessUiIntent( + mActivityStarter, animationController, mSelectedCard != null)); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java index 88fe1cae2d765..94ee0cc765486 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java @@ -107,7 +107,6 @@ import com.android.systemui.statusbar.policy.PreviewInflater; import com.android.systemui.tuner.LockscreenFragment.LockButtonFactory; import com.android.systemui.tuner.TunerService; import com.android.systemui.wallet.controller.QuickAccessWalletController; -import com.android.systemui.wallet.ui.WalletActivity; import java.util.List; @@ -1149,21 +1148,8 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL } ActivityLaunchAnimator.Controller animationController = createLaunchAnimationController(v); - if (mHasCard) { - 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, - true /* showOverLockscreenWhenLocked */); - } else { - if (mQuickAccessWalletController.getWalletClient().createWalletIntent() == null) { - Log.w(TAG, "Could not get intent of the wallet app."); - return; - } - mActivityStarter.postStartActivityDismissingKeyguard( - mQuickAccessWalletController.getWalletClient().createWalletIntent(), - /* delay= */ 0, animationController); - } + mQuickAccessWalletController.startQuickAccessUiIntent( + mActivityStarter, animationController, mHasCard); } protected ActivityLaunchAnimator.Controller createLaunchAnimationController(View view) { 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 8922b43b74470..1e5acde8bef53 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 @@ -28,7 +28,6 @@ import static junit.framework.TestCase.assertNull; import static junit.framework.TestCase.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.spy; @@ -62,7 +61,6 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.testing.UiEventLoggerFake; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; -import com.android.systemui.animation.ActivityLaunchAnimator; import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.qs.QSTile; @@ -120,8 +118,6 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { @Mock private QuickAccessWalletController mController; @Captor - ArgumentCaptor mIntentCaptor; - @Captor ArgumentCaptor mCallbackCaptor; private Context mSpiedContext; @@ -196,66 +192,29 @@ public class QuickAccessWalletTileTest extends SysuiTestCase { } @Test - public void testHandleClick_noCards_hasIntent_openWalletApp() { - Intent intent = new Intent("WalletIntent"); - when(mQuickAccessWalletClient.createWalletIntent()).thenReturn(intent); + public void testHandleClick_startQuickAccessUiIntent_noCard() { setUpWalletCard(/* hasCard= */ false); - mTile.handleClick(null /* view */); + mTile.handleClick(/* view= */ null); mTestableLooper.processAllMessages(); - verify(mActivityStarter, times(1)) - .postStartActivityDismissingKeyguard(eq(intent), anyInt(), - eq(null) /* animationController */); + verify(mController).startQuickAccessUiIntent( + eq(mActivityStarter), + eq(null), + /* hasCard= */ eq(false)); } @Test - public void testHandleClick_noCards_noIntent_doNothing() { - when(mQuickAccessWalletClient.createWalletIntent()).thenReturn(null); - setUpWalletCard(/* hasCard= */ false); - - mTile.handleClick(null /* view */); - mTestableLooper.processAllMessages(); - - verifyZeroInteractions(mActivityStarter); - } - - @Test - public void testHandleClick_hasCards_deviceLocked_startWalletActivity() { - when(mKeyguardStateController.isUnlocked()).thenReturn(false); + public void testHandleClick_startQuickAccessUiIntent_hasCard() { setUpWalletCard(/* hasCard= */ true); mTile.handleClick(null /* view */); mTestableLooper.processAllMessages(); - verify(mActivityStarter).startActivity(mIntentCaptor.capture(), eq(true) /* dismissShade */, - (ActivityLaunchAnimator.Controller) eq(null), - eq(true) /* showOverLockscreenWhenLocked */); - - 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 */); - mTestableLooper.processAllMessages(); - - verify(mActivityStarter).startActivity(mIntentCaptor.capture(), eq(true) /* dismissShade */, - (ActivityLaunchAnimator.Controller) eq(null), - eq(true) /* showOverLockscreenWhenLocked */); - - Intent nextStartedIntent = mIntentCaptor.getValue(); - String walletClassName = "com.android.systemui.wallet.ui.WalletActivity"; - - assertNotNull(nextStartedIntent); - assertThat(nextStartedIntent.getComponent().getClassName()).isEqualTo(walletClassName); + verify(mController).startQuickAccessUiIntent( + eq(mActivityStarter), + eq(null), + /* hasCard= */ eq(true)); } @Test