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

Commit 6fe1e946 authored by Lucas Silva's avatar Lucas Silva
Browse files

Fix live timer activity launches

We add a new method to ActivityStarter to bypass the normal
showWhenLocked checks we do when starting an activity. This is due to
the fact that timers use a trampoline activity which is not
showWhenLocked, which then triggers a showWhenLocked activity. We
therefore do not want to trigger auth for these activities.

As this change is no longer a breaking change, the flag guarding this is
also removed.

Fixes: 345741071
Test: atest WidgetInteractionHandlerTest
Test: atest SmartspaceInteractionHandlerTest
Flag: com.android.systemui.communal_hub
Change-Id: I28dc5169642df8672578d28f9e3c47840277a32c
parent 7d12addd
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -1048,15 +1048,6 @@ flag {
  bug: "343505271"
}

flag {
  name: "glanceable_hub_animate_timer_activity_starts"
  namespace: "systemui"
  description: "Properly animates activity starts from live timers on the glanceable hub"
  bug: "345741071"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "new_touchpad_gestures_tutorial"
+2 −2
Original line number Diff line number Diff line
@@ -25,9 +25,9 @@ import androidx.compose.ui.layout.Layout
import androidx.compose.ui.unit.IntRect
import com.android.compose.animation.scene.SceneScope
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.systemui.communal.smartspace.SmartspaceInteractionHandler
import com.android.systemui.communal.ui.compose.section.AmbientStatusBarSection
import com.android.systemui.communal.ui.viewmodel.CommunalViewModel
import com.android.systemui.communal.widgets.WidgetInteractionHandler
import com.android.systemui.keyguard.ui.composable.blueprint.BlueprintAlignmentLines
import com.android.systemui.keyguard.ui.composable.section.LockSection
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
@@ -38,7 +38,7 @@ class CommunalContent
@Inject
constructor(
    private val viewModel: CommunalViewModel,
    private val interactionHandler: WidgetInteractionHandler,
    private val interactionHandler: SmartspaceInteractionHandler,
    private val dialogFactory: SystemUIDialogFactory,
    private val lockSection: LockSection,
    private val ambientStatusBarSection: AmbientStatusBarSection,
+1 −4
Original line number Diff line number Diff line
@@ -132,7 +132,6 @@ import com.android.compose.modifiers.thenIf
import com.android.compose.theme.LocalAndroidColorScheme
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import com.android.internal.R.dimen.system_app_widget_background_radius
import com.android.systemui.Flags.glanceableHubAnimateTimerActivityStarts
import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalContentSize
import com.android.systemui.communal.shared.model.CommunalScenes
@@ -1107,9 +1106,7 @@ private fun SmartspaceContent(
        modifier = modifier,
        factory = { context ->
            SmartspaceAppWidgetHostView(context).apply {
                if (glanceableHubAnimateTimerActivityStarts()) {
                interactionHandler?.let { setInteractionHandler(it) }
                }
                updateAppWidget(model.remoteViews)
            }
        },
+97 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.communal.smartspace

import android.app.PendingIntent
import android.content.Intent
import android.view.View
import android.widget.FrameLayout
import android.widget.RemoteViews.RemoteResponse
import androidx.core.util.component1
import androidx.core.util.component2
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView
import com.android.systemui.plugins.ActivityStarter
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.eq
import org.mockito.kotlin.isNull
import org.mockito.kotlin.mock
import org.mockito.kotlin.notNull
import org.mockito.kotlin.refEq
import org.mockito.kotlin.verify

@SmallTest
@RunWith(AndroidJUnit4::class)
class SmartspaceInteractionHandlerTest : SysuiTestCase() {
    private val activityStarter = mock<ActivityStarter>()

    private val testIntent =
        PendingIntent.getActivity(
            context,
            /* requestCode = */ 0,
            Intent("action"),
            PendingIntent.FLAG_IMMUTABLE
        )
    private val testResponse = RemoteResponse.fromPendingIntent(testIntent)

    private val underTest: SmartspaceInteractionHandler by lazy {
        SmartspaceInteractionHandler(activityStarter)
    }

    @Test
    fun launchAnimatorIsUsedForSmartspaceView() {
        val parent = FrameLayout(context)
        val view = SmartspaceAppWidgetHostView(context)
        parent.addView(view)
        val (fillInIntent, activityOptions) = testResponse.getLaunchOptions(view)

        underTest.onInteraction(view, testIntent, testResponse)

        verify(activityStarter)
            .startPendingIntentWithoutDismissing(
                eq(testIntent),
                eq(false),
                isNull(),
                notNull(),
                refEq(fillInIntent),
                refEq(activityOptions.toBundle()),
            )
    }

    @Test
    fun launchAnimatorIsNotUsedForRegularView() {
        val parent = FrameLayout(context)
        val view = View(context)
        parent.addView(view)
        val (fillInIntent, activityOptions) = testResponse.getLaunchOptions(view)

        underTest.onInteraction(view, testIntent, testResponse)

        verify(activityStarter)
            .startPendingIntentWithoutDismissing(
                eq(testIntent),
                eq(false),
                isNull(),
                isNull(),
                refEq(fillInIntent),
                refEq(activityOptions.toBundle()),
            )
    }
}
+0 −20
Original line number Diff line number Diff line
@@ -74,26 +74,6 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
            )
    }

    @Test
    fun launchAnimatorIsUsedForSmartspaceView() {
        val parent = FrameLayout(context)
        val view = SmartspaceAppWidgetHostView(context)
        parent.addView(view)
        val (fillInIntent, activityOptions) = testResponse.getLaunchOptions(view)

        underTest.onInteraction(view, testIntent, testResponse)

        verify(activityStarter)
            .startPendingIntentMaybeDismissingKeyguard(
                eq(testIntent),
                eq(false),
                isNull(),
                notNull(),
                refEq(fillInIntent),
                refEq(activityOptions.toBundle()),
            )
    }

    @Test
    fun launchAnimatorIsNotUsedForRegularView() {
        val parent = FrameLayout(context)
Loading