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

Commit ce7fbc39 authored by William Xiao's avatar William Xiao
Browse files

Add unlock reason to alternate bouncer when starting activity

Pass a custom message parameter to the APIs used by the glanceable hub
to start an activity that dismisses the keyguard. This message will
serve as the unlock reason in the alternate bouncer.
On the communal side, support the two use cases for displaying the
unlock reason: 1) when starting the EditWidgetsActivity;
2) tapping on a widget that requires authentication.

Bug: b/325110448
Flag: com.android.systemui.communal_hub
Test: atest LegacyActivityStarterInternalImplTest
Test: atest WidgetInteractionHandlerTest
Test: manually with device_entry_udfps_refactor flag off
Change-Id: Ib89c0b1a6b0cfef0e7f7b5f0b7770f58f4ea689e
parent c7c4057c
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
                /* animationController = */ notNull(),
                /* fillInIntent = */ refEq(fillInIntent),
                /* extraOptions = */ refEq(activityOptions.toBundle()),
                /* customMessage */ isNull(),
            )
    }

@@ -93,6 +94,7 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
                /* animationController = */ isNull(),
                /* fillInIntent = */ refEq(fillInIntent),
                /* extraOptions = */ refEq(activityOptions.toBundle()),
                /* customMessage */ isNull(),
            )
    }
}
+21 −0
Original line number Diff line number Diff line
@@ -153,6 +153,25 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
            .dismissWithAction(any(), eq(null), anyBoolean(), eq(null))
    }

    @Test
    fun startPendingIntentDismissingKeyguard_withCustomMessage_dismissWithAction() {
        val pendingIntent = mock(PendingIntent::class.java)
        `when`(pendingIntent.isActivity).thenReturn(true)
        `when`(keyguardStateController.isShowing).thenReturn(true)
        `when`(deviceProvisionedController.isDeviceProvisioned).thenReturn(true)
        val customMessage = "Custom unlock reason"

        underTest.startPendingIntentDismissingKeyguard(
            intent = pendingIntent,
            dismissShade = true,
            customMessage = customMessage
        )
        mainExecutor.runAllReady()

        verify(statusBarKeyguardViewManager)
            .dismissWithAction(any(), eq(null), anyBoolean(), eq(customMessage))
    }

    @Test
    fun startPendingIntentMaybeDismissingKeyguard_keyguardShowing_showOverLs_launchAnimator() {
        val pendingIntent = mock(PendingIntent::class.java)
@@ -466,6 +485,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
        animationController: ActivityTransitionAnimator.Controller?,
        fillInIntent: Intent? = null,
        extraOptions: Bundle? = null,
        customMessage: String? = null,
    ) {
        underTest.startPendingIntentDismissingKeyguard(
            intent = intent,
@@ -475,6 +495,7 @@ class LegacyActivityStarterInternalImplTest : SysuiTestCase() {
            showOverLockscreen = true,
            fillInIntent = fillInIntent,
            extraOptions = extraOptions,
            customMessage = customMessage,
        )
    }

+13 −4
Original line number Diff line number Diff line
@@ -84,14 +84,17 @@ public interface ActivityStarter {
     * Similar to {@link #startPendingIntentMaybeDismissingKeyguard(PendingIntent, Runnable,
     * ActivityTransitionAnimator.Controller)}, but also specifies a fill-in intent and extra
     * option that could be used to populate the pending intent and launch the activity. This also
     * allows the caller to avoid dismissing the shade.
     * allows the caller to avoid dismissing the shade. An optional custom message can be set as
     * the unlock reason in the alternate bouncer.
     */
    void startPendingIntentMaybeDismissingKeyguard(PendingIntent intent,
            boolean dismissShade,
            @Nullable Runnable intentSentUiThreadCallback,
            @Nullable ActivityTransitionAnimator.Controller animationController,
            @Nullable Intent fillInIntent,
            @Nullable Bundle extraOptions);
            @Nullable Bundle extraOptions,
            @Nullable String customMessage
        );

    /**
     * The intent flag can be specified in startActivity().
@@ -134,14 +137,20 @@ public interface ActivityStarter {
    void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
            boolean afterKeyguardGone);

    /** Authenticates if needed and dismisses keyguard to execute an action. */
    /**
     * Authenticates if needed and dismisses keyguard to execute an action.
     *
     * TODO(b/348431835) Display the custom message in the new alternate bouncer, when the
     * device_entry_udfps_refactor flag is enabled.
     */
    void dismissKeyguardThenExecute(OnDismissAction action, @Nullable Runnable cancel,
            boolean afterKeyguardGone, @Nullable String customMessage);

    /** Starts an activity and dismisses keyguard. */
    void startActivityDismissingKeyguard(Intent intent,
            boolean onlyProvisioned,
            boolean dismissShade);
            boolean dismissShade,
            @Nullable String customMessage);

    /** Starts an activity and dismisses keyguard. */
    void startActivityDismissingKeyguard(Intent intent,
+2 −0
Original line number Diff line number Diff line
@@ -1188,6 +1188,8 @@
    <string name="popup_on_dismiss_cta_tile_text">Long press to customize widgets</string>
    <!-- Text for the button to configure widgets after long press. [CHAR LIMIT=50] -->
    <string name="button_to_configure_widgets_text">Customize widgets</string>
    <!-- Text for unlock reason on the bouncer before customizing widgets. [CHAR LIMIT=NONE] -->
    <string name="unlock_reason_to_customize_widgets">Unlock to customize widgets</string>
    <!-- Description for the App icon of disabled widget. [CHAR LIMIT=NONE] -->
    <string name="icon_description_for_disabled_widget">App icon for disabled widget</string>
    <!-- Description for the App icon of a package that is currently being installed. [CHAR LIMIT=NONE] -->
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import com.android.systemui.communal.widgets.EditWidgetsActivity.Companion.EXTRA
import com.android.systemui.communal.widgets.EditWidgetsActivity.Companion.EXTRA_PRESELECTED_KEY
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import javax.inject.Inject

interface EditWidgetsActivityStarter {
@@ -48,6 +49,7 @@ constructor(
                },
            /* onlyProvisioned = */ true,
            /* dismissShade = */ true,
            applicationContext.resources.getString(R.string.unlock_reason_to_customize_widgets),
        )
    }
}
Loading