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

Commit d9f3fa0b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Clean up obsolete screen record code" into main

parents 441859af b30b43e3
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -160,9 +159,7 @@ public class ScreenRecordTileTest extends SysuiTestCase {
        mTestableLooper.processAllMessages();

        ArgumentCaptor<Runnable> onStartRecordingClicked = ArgumentCaptor.forClass(Runnable.class);
        verify(mController).createScreenRecordDialog(any(), eq(mFeatureFlags),
                eq(mDialogTransitionAnimator), eq(mActivityStarter),
                onStartRecordingClicked.capture());
        verify(mController).createScreenRecordDialog(onStartRecordingClicked.capture());

        // When starting the recording, we collapse the shade and disable the dialog animation.
        assertNotNull(onStartRecordingClicked.getValue());
@@ -298,14 +295,13 @@ public class ScreenRecordTileTest extends SysuiTestCase {
    public void showingDialogPrompt_logsMediaProjectionPermissionRequested() {
        when(mController.isStarting()).thenReturn(false);
        when(mController.isRecording()).thenReturn(false);
        when(mController.createScreenRecordDialog(any(), any(), any(), any(), any()))
        when(mController.createScreenRecordDialog(any()))
                .thenReturn(mPermissionDialogPrompt);

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

        verify(mController).createScreenRecordDialog(any(), eq(mFeatureFlags),
                eq(mDialogTransitionAnimator), eq(mActivityStarter), any());
        verify(mController).createScreenRecordDialog(any());
        var onDismissAction = ArgumentCaptor.forClass(ActivityStarter.OnDismissAction.class);
        verify(mKeyguardDismissUtil).executeWhenUnlocked(
                onDismissAction.capture(), anyBoolean(), anyBoolean());
+13 −43
Original line number Diff line number Diff line
@@ -23,29 +23,27 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.animation.DialogTransitionAnimator
import com.android.systemui.animation.Expandable
import com.android.systemui.flags.featureFlagsClassic
import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.keyguard.domain.interactor.keyguardInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger
import com.android.systemui.plugins.ActivityStarter.OnDismissAction
import com.android.systemui.plugins.activityStarter
import com.android.systemui.qs.pipeline.domain.interactor.PanelInteractor
import com.android.systemui.qs.tiles.base.interactor.QSTileInputTestKtx
import com.android.systemui.screenrecord.RecordingController
import com.android.systemui.screenrecord.data.model.ScreenRecordModel
import com.android.systemui.screenrecord.data.repository.ScreenRecordRepositoryImpl
import com.android.systemui.statusbar.phone.KeyguardDismissUtil
import com.android.systemui.util.mockito.any
import com.android.systemui.util.mockito.argumentCaptor
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import kotlinx.coroutines.test.runTest
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.verify
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.eq
import org.mockito.kotlin.mock

@SmallTest
@RunWith(AndroidJUnit4::class)
@@ -54,24 +52,11 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
    private val testScope = kosmos.testScope
    private val keyguardInteractor = kosmos.keyguardInteractor
    private val dialogTransitionAnimator = mock<DialogTransitionAnimator>()
    private val featureFlags = kosmos.featureFlagsClassic
    private val activityStarter = kosmos.activityStarter
    private val keyguardDismissUtil = mock<KeyguardDismissUtil>()
    private val panelInteractor = mock<PanelInteractor>()
    private val dialog = mock<Dialog>()
    private val recordingController =
        mock<RecordingController> {
            whenever(
                    createScreenRecordDialog(
                        eq(context),
                        eq(featureFlags),
                        eq(dialogTransitionAnimator),
                        eq(activityStarter),
                        any()
                    )
                )
                .thenReturn(dialog)
        }
        mock<RecordingController> { on { createScreenRecordDialog(any()) } doReturn dialog }

    private val screenRecordRepository =
        ScreenRecordRepositoryImpl(
@@ -81,7 +66,6 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {

    private val underTest =
        ScreenRecordTileUserActionInteractor(
            context,
            testScope.testScheduler,
            testScope.testScheduler,
            screenRecordRepository,
@@ -91,8 +75,6 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
            dialogTransitionAnimator,
            panelInteractor,
            mock<MediaProjectionMetricsLogger>(),
            featureFlags,
            activityStarter,
        )

    @Test
@@ -120,22 +102,16 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
        underTest.handleInput(QSTileInputTestKtx.click(recordingModel))
        val onStartRecordingClickedCaptor = argumentCaptor<Runnable>()
        verify(recordingController)
            .createScreenRecordDialog(
                eq(context),
                eq(featureFlags),
                eq(dialogTransitionAnimator),
                eq(activityStarter),
                onStartRecordingClickedCaptor.capture()
            )
            .createScreenRecordDialog(onStartRecordingClickedCaptor.capture())

        val onDismissActionCaptor = argumentCaptor<OnDismissAction>()
        verify(keyguardDismissUtil)
            .executeWhenUnlocked(onDismissActionCaptor.capture(), eq(false), eq(true))
        onDismissActionCaptor.value.onDismiss()
        onDismissActionCaptor.lastValue.onDismiss()
        verify(dialog).show() // because the view was null

        // When starting the recording, we collapse the shade and disable the dialog animation.
        onStartRecordingClickedCaptor.value.run()
        onStartRecordingClickedCaptor.lastValue.run()
        verify(dialogTransitionAnimator).disableAllCurrentDialogsExitAnimations()
        verify(panelInteractor).collapsePanels()
    }
@@ -145,9 +121,9 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
     */
    @Test
    fun handleClickFromView_whenDoingNothing_whenKeyguardNotShowing_showDialogFromView() = runTest {
        val expandable = mock<Expandable>()
        val controller = mock<DialogTransitionAnimator.Controller>()
        whenever(expandable.dialogTransitionController(any())).thenReturn(controller)
        val expandable =
            mock<Expandable> { on { dialogTransitionController(any()) } doReturn controller }

        kosmos.fakeKeyguardRepository.setKeyguardShowing(false)

@@ -158,18 +134,12 @@ class ScreenRecordTileUserActionInteractorTest : SysuiTestCase() {
        )
        val onStartRecordingClickedCaptor = argumentCaptor<Runnable>()
        verify(recordingController)
            .createScreenRecordDialog(
                eq(context),
                eq(featureFlags),
                eq(dialogTransitionAnimator),
                eq(activityStarter),
                onStartRecordingClickedCaptor.capture()
            )
            .createScreenRecordDialog(onStartRecordingClickedCaptor.capture())

        val onDismissActionCaptor = argumentCaptor<OnDismissAction>()
        verify(keyguardDismissUtil)
            .executeWhenUnlocked(onDismissActionCaptor.capture(), eq(false), eq(true))
        onDismissActionCaptor.value.onDismiss()
        onDismissActionCaptor.lastValue.onDismiss()
        verify(dialogTransitionAnimator).show(eq(dialog), eq(controller), eq(true))
    }
}
+0 −164
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2020 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.
  -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">

    <!-- Scrollview is necessary to fit everything in landscape layout -->
    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingStart="@dimen/dialog_side_padding"
            android:paddingEnd="@dimen/dialog_side_padding"
            android:paddingTop="@dimen/dialog_top_padding"
            android:paddingBottom="@dimen/dialog_bottom_padding"
            android:orientation="vertical">

            <!-- Header -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical"
                android:gravity="center">
                <ImageView
                    android:layout_width="@dimen/screenrecord_logo_size"
                    android:layout_height="@dimen/screenrecord_logo_size"
                    android:src="@drawable/ic_screenrecord"
                    android:tint="@color/screenrecord_icon_color"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textAppearance="@style/TextAppearance.Dialog.Title"
                    android:fontFamily="@*android:string/config_headlineFontFamily"
                    android:text="@string/screenrecord_permission_dialog_title"
                    android:layout_marginTop="22dp"
                    android:layout_marginBottom="15dp"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="@string/screenrecord_permission_dialog_warning_entire_screen"
                    android:textAppearance="@style/TextAppearance.Dialog.Body.Message"
                    android:gravity="center"
                    android:layout_marginBottom="20dp"/>

                <!-- Options -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal">
                    <ImageView
                        android:layout_width="@dimen/screenrecord_option_icon_size"
                        android:layout_height="@dimen/screenrecord_option_icon_size"
                        android:src="@drawable/ic_mic_26dp"
                        android:tint="?android:attr/textColorSecondary"
                        android:layout_gravity="center"
                        android:layout_weight="0"
                        android:layout_marginEnd="@dimen/screenrecord_option_padding"/>
                    <Spinner
                        android:id="@+id/screen_recording_options"
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:minHeight="48dp"
                        android:layout_weight="1"
                        android:popupBackground="@drawable/screenrecord_spinner_background"
                        android:textColor="?androidprv:attr/materialColorOnSurface"
                        android:dropDownWidth="274dp"
                        android:prompt="@string/screenrecord_audio_label"/>
                    <Switch
                        android:layout_width="wrap_content"
                        android:minWidth="48dp"
                        android:layout_height="48dp"
                        android:layout_weight="0"
                        android:layout_gravity="end"
                        android:contentDescription="@string/screenrecord_audio_label"
                        android:id="@+id/screenrecord_audio_switch"
                        style="@style/ScreenRecord.Switch"/>
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:orientation="horizontal"
                    android:layout_marginTop="@dimen/screenrecord_option_padding">
                    <ImageView
                        android:layout_width="@dimen/screenrecord_option_icon_size"
                        android:layout_height="@dimen/screenrecord_option_icon_size"
                        android:layout_weight="0"
                        android:src="@drawable/ic_touch"
                        android:tint="?android:attr/textColorSecondary"
                        android:layout_gravity="center"
                        android:layout_marginEnd="@dimen/screenrecord_option_padding"/>
                    <TextView
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:minHeight="48dp"
                        android:layout_weight="1"
                        android:layout_gravity="fill_vertical"
                        android:gravity="center_vertical"
                        android:text="@string/screenrecord_taps_label"
                        android:textAppearance="?android:attr/textAppearanceMedium"
                        android:fontFamily="@*android:string/config_headlineFontFamily"
                        android:textColor="?androidprv:attr/materialColorOnSurface"
                        android:importantForAccessibility="no"/>
                    <Switch
                        android:layout_width="wrap_content"
                        android:minWidth="48dp"
                        android:layout_height="48dp"
                        android:layout_weight="0"
                        android:id="@+id/screenrecord_taps_switch"
                        android:contentDescription="@string/screenrecord_taps_label"
                        style="@style/ScreenRecord.Switch"/>
                </LinearLayout>
            </LinearLayout>

            <!-- Buttons -->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:layout_marginTop="36dp">
                <TextView
                    android:id="@+id/button_cancel"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:layout_gravity="start"
                    android:text="@string/cancel"
                    style="@style/Widget.Dialog.Button.BorderButton" />
                <Space
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_weight="1"/>

                <TextView
                    android:id="@+id/button_start"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0"
                    android:layout_gravity="end"
                    android:text="@string/screenrecord_continue"
                    style="@style/Widget.Dialog.Button" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>
</LinearLayout>
 No newline at end of file
+0 −10
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
 */
package com.android.systemui.flags

import android.provider.DeviceConfig
import com.android.internal.annotations.Keep
import com.android.systemui.flags.FlagsFactory.releasedFlag
import com.android.systemui.flags.FlagsFactory.resourceBooleanFlag
@@ -251,15 +250,6 @@ object Flags {
    val WM_ENABLE_SHELL_TRANSITIONS =
        sysPropBooleanFlag("persist.wm.debug.shell_transit", default = true)

    // TODO(b/254513207): Tracking Bug to delete
    @Keep
    @JvmField
    val WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES =
        releasedFlag(
            name = "enable_screen_record_enterprise_policies",
            namespace = DeviceConfig.NAMESPACE_WINDOW_MANAGER,
        )

    // TODO(b/293252410) : Tracking Bug
    @JvmField val LOCKSCREEN_ENABLE_LANDSCAPE = unreleasedFlag("lockscreen.enable_landscape")

+3 −6
Original line number Diff line number Diff line
@@ -57,7 +57,6 @@ import android.view.Display;
import android.view.Window;

import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.flags.Flags;
import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger;
import com.android.systemui.mediaprojection.MediaProjectionServiceHelper;
import com.android.systemui.mediaprojection.MediaProjectionUtils;
@@ -187,12 +186,10 @@ public class MediaProjectionPermissionActivity extends Activity {
            return;
        }

        if (mFeatureFlags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) {
        if (showScreenCaptureDisabledDialogIfNeeded()) {
            finishAsCancelled();
            return;
        }
        }

        final String appName = extractAppName(aInfo, packageManager);
        final boolean hasCastingCapabilities =
Loading