Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68b0ca05 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Call the startQuickAccessUiIntent of QuickAccessWalletController for...

Merge "Call the startQuickAccessUiIntent of QuickAccessWalletController for QAWTile and Lockscreen wallet icon."
parents caba19f3 c61633ee
Loading
Loading
Loading
Loading
+3 −20
Original line number Diff line number Diff line
@@ -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<QSTile.State> {
                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
+2 −16
Original line number Diff line number Diff line
@@ -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) {
+11 −52
Original line number Diff line number Diff line
@@ -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<Intent> mIntentCaptor;
    @Captor
    ArgumentCaptor<QuickAccessWalletClient.OnWalletCardsRetrievedCallback> 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);
        setUpWalletCard(/* hasCard= */ false);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

        verify(mActivityStarter, times(1))
                .postStartActivityDismissingKeyguard(eq(intent), anyInt(),
                        eq(null) /* animationController */);
    }

    @Test
    public void testHandleClick_noCards_noIntent_doNothing() {
        when(mQuickAccessWalletClient.createWalletIntent()).thenReturn(null);
    public void testHandleClick_startQuickAccessUiIntent_noCard() {
        setUpWalletCard(/* hasCard= */ false);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

        verifyZeroInteractions(mActivityStarter);
    }

    @Test
    public void testHandleClick_hasCards_deviceLocked_startWalletActivity() {
        when(mKeyguardStateController.isUnlocked()).thenReturn(false);
        setUpWalletCard(/* hasCard= */ true);

        mTile.handleClick(null /* view */);
        mTile.handleClick(/* view= */ null);
        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(false));
    }

    @Test
    public void testHandleClick_hasCards_deviceUnlocked_startWalletActivity() {
        when(mKeyguardStateController.isUnlocked()).thenReturn(true);
    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);
        verify(mController).startQuickAccessUiIntent(
                eq(mActivityStarter),
                eq(null),
                /* hasCard= */ eq(true));
    }

    @Test