diff options
12 files changed, 34 insertions, 561 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java index 0d12483bad0a..53708fd417e1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/ScreenRecordTileTest.java @@ -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()); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt index 899122d4dd45..0b56d7b64aab 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractorTest.kt @@ -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)) } } diff --git a/packages/SystemUI/res/layout/screen_record_dialog.xml b/packages/SystemUI/res/layout/screen_record_dialog.xml deleted file mode 100644 index dc560bf2fab7..000000000000 --- a/packages/SystemUI/res/layout/screen_record_dialog.xml +++ /dev/null @@ -1,164 +0,0 @@ -<?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 diff --git a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt index 8dd9a55dd71b..c62593063020 100644 --- a/packages/SystemUI/src/com/android/systemui/flags/Flags.kt +++ b/packages/SystemUI/src/com/android/systemui/flags/Flags.kt @@ -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") diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java index 47dacae6e0a0..2fda2013d6f5 100644 --- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java +++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java @@ -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,11 +186,9 @@ public class MediaProjectionPermissionActivity extends Activity { return; } - if (mFeatureFlags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) { - if (showScreenCaptureDisabledDialogIfNeeded()) { - finishAsCancelled(); - return; - } + if (showScreenCaptureDisabledDialogIfNeeded()) { + finishAsCancelled(); + return; } final String appName = extractAppName(aInfo, packageManager); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java index 284239ab1a78..f3be340f4951 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ScreenRecordTile.java @@ -191,8 +191,7 @@ public class ScreenRecordTile extends QSTileImpl<QSTile.BooleanState> mPanelInteractor.collapsePanels(); }; - final Dialog dialog = mController.createScreenRecordDialog(mContext, mFlags, - mDialogTransitionAnimator, mActivityStarter, onStartRecordingClicked); + final Dialog dialog = mController.createScreenRecordDialog(onStartRecordingClicked); ActivityStarter.OnDismissAction dismissAction = () -> { if (shouldAnimateFromExpandable) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt index 48b39ed25750..85aa6745e438 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/impl/screenrecord/domain/interactor/ScreenRecordTileUserActionInteractor.kt @@ -16,16 +16,13 @@ package com.android.systemui.qs.tiles.impl.screenrecord.domain.interactor -import android.content.Context import android.util.Log import com.android.internal.jank.InteractionJankMonitor import com.android.systemui.animation.DialogCuj import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.animation.Expandable -import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main -import com.android.systemui.flags.FeatureFlagsClassic import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger import com.android.systemui.plugins.ActivityStarter @@ -45,7 +42,6 @@ import kotlinx.coroutines.withContext class ScreenRecordTileUserActionInteractor @Inject constructor( - @Application private val context: Context, @Main private val mainContext: CoroutineContext, @Background private val backgroundContext: CoroutineContext, private val screenRecordRepository: ScreenRecordRepository, @@ -55,8 +51,6 @@ constructor( private val dialogTransitionAnimator: DialogTransitionAnimator, private val panelInteractor: PanelInteractor, private val mediaProjectionMetricsLogger: MediaProjectionMetricsLogger, - private val featureFlags: FeatureFlagsClassic, - private val activityStarter: ActivityStarter, ) : QSTileUserActionInteractor<ScreenRecordModel> { override suspend fun handleInput(input: QSTileInput<ScreenRecordModel>): Unit = with(input) { @@ -89,14 +83,7 @@ constructor( panelInteractor.collapsePanels() } - val dialog = - recordingController.createScreenRecordDialog( - context, - featureFlags, - dialogTransitionAnimator, - activityStarter, - onStartRecordingClicked - ) + val dialog = recordingController.createScreenRecordDialog(onStartRecordingClicked) if (dialog == null) { Log.w(TAG, "showPrompt: dialog was null") @@ -115,7 +102,7 @@ constructor( expandable?.dialogTransitionController( DialogCuj( InteractionJankMonitor.CUJ_SHADE_DIALOG_OPEN, - INTERACTION_JANK_TAG + INTERACTION_JANK_TAG, ) ) controller?.let { @@ -135,7 +122,7 @@ constructor( keyguardDismissUtil.executeWhenUnlocked( dismissAction, false /* requiresShadeOpen */, - true /* afterKeyguardDone */ + true, /* afterKeyguardDone */ ) } diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt index 6758c3ba0767..02b2bb1585bd 100644 --- a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt +++ b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueDialogDelegate.kt @@ -35,7 +35,6 @@ import androidx.annotation.WorkerThread import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.flags.FeatureFlagsClassic -import com.android.systemui.flags.Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger import com.android.systemui.mediaprojection.SessionCreationSource import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver @@ -132,10 +131,9 @@ constructor( @WorkerThread private fun onScreenRecordSwitchClicked() { if ( - flags.isEnabled(WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES) && - devicePolicyResolver - .get() - .isScreenCaptureCompletelyDisabled(UserHandle.of(userTracker.userId)) + devicePolicyResolver + .get() + .isScreenCaptureCompletelyDisabled(UserHandle.of(userTracker.userId)) ) { mainExecutor.execute { screenCaptureDisabledDialogDelegate.createSysUIDialog().show() diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java index a8a78a91097c..d7463f8f0c36 100644 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java +++ b/packages/SystemUI/src/com/android/systemui/screenrecord/RecordingController.java @@ -32,17 +32,13 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.android.internal.annotations.VisibleForTesting; -import com.android.systemui.animation.DialogTransitionAnimator; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.flags.FeatureFlags; -import com.android.systemui.flags.Flags; import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger; import com.android.systemui.mediaprojection.SessionCreationSource; import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver; import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDisabledDialogDelegate; -import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.policy.CallbackController; @@ -66,12 +62,10 @@ public class RecordingController private CountDownTimer mCountDownTimer = null; private final Executor mMainExecutor; private final BroadcastDispatcher mBroadcastDispatcher; - private final FeatureFlags mFlags; private final UserTracker mUserTracker; private final RecordingControllerLogger mRecordingControllerLogger; private final MediaProjectionMetricsLogger mMediaProjectionMetricsLogger; private final ScreenCaptureDisabledDialogDelegate mScreenCaptureDisabledDialogDelegate; - private final ScreenRecordDialogDelegate.Factory mScreenRecordDialogFactory; private final ScreenRecordPermissionDialogDelegate.Factory mScreenRecordPermissionDialogDelegateFactory; @@ -116,24 +110,20 @@ public class RecordingController public RecordingController( @Main Executor mainExecutor, BroadcastDispatcher broadcastDispatcher, - FeatureFlags flags, Lazy<ScreenCaptureDevicePolicyResolver> devicePolicyResolver, UserTracker userTracker, RecordingControllerLogger recordingControllerLogger, MediaProjectionMetricsLogger mediaProjectionMetricsLogger, ScreenCaptureDisabledDialogDelegate screenCaptureDisabledDialogDelegate, - ScreenRecordDialogDelegate.Factory screenRecordDialogFactory, ScreenRecordPermissionDialogDelegate.Factory screenRecordPermissionDialogDelegateFactory) { mMainExecutor = mainExecutor; - mFlags = flags; mDevicePolicyResolver = devicePolicyResolver; mBroadcastDispatcher = broadcastDispatcher; mUserTracker = userTracker; mRecordingControllerLogger = recordingControllerLogger; mMediaProjectionMetricsLogger = mediaProjectionMetricsLogger; mScreenCaptureDisabledDialogDelegate = screenCaptureDisabledDialogDelegate; - mScreenRecordDialogFactory = screenRecordDialogFactory; mScreenRecordPermissionDialogDelegateFactory = screenRecordPermissionDialogDelegateFactory; BroadcastOptions options = BroadcastOptions.makeBasic(); @@ -158,12 +148,8 @@ public class RecordingController /** Create a dialog to show screen recording options to the user. * If screen capturing is currently not allowed it will return a dialog * that warns users about it. */ - public Dialog createScreenRecordDialog(Context context, FeatureFlags flags, - DialogTransitionAnimator dialogTransitionAnimator, - ActivityStarter activityStarter, - @Nullable Runnable onStartRecordingClicked) { - if (mFlags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES) - && mDevicePolicyResolver.get() + public Dialog createScreenRecordDialog(@Nullable Runnable onStartRecordingClicked) { + if (mDevicePolicyResolver.get() .isScreenCaptureCompletelyDisabled(getHostUserHandle())) { return mScreenCaptureDisabledDialogDelegate.createSysUIDialog(); } diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordDialogDelegate.java b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordDialogDelegate.java deleted file mode 100644 index 9f1447b1f509..000000000000 --- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordDialogDelegate.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (C) 2018 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.screenrecord; - -import static android.app.Activity.RESULT_OK; - -import static com.android.systemui.mediaprojection.appselector.MediaProjectionAppSelectorActivity.KEY_CAPTURE_TARGET; -import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.INTERNAL; -import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.MIC; -import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.MIC_AND_INTERNAL; -import static com.android.systemui.screenrecord.ScreenRecordingAudioSource.NONE; - -import android.app.Activity; -import android.app.PendingIntent; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.os.Looper; -import android.os.ResultReceiver; -import android.view.Gravity; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.view.accessibility.AccessibilityNodeInfo; -import android.widget.ArrayAdapter; -import android.widget.Spinner; -import android.widget.Switch; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.android.systemui.mediaprojection.MediaProjectionCaptureTarget; -import com.android.systemui.res.R; -import com.android.systemui.settings.UserContextProvider; -import com.android.systemui.statusbar.phone.SystemUIDialog; - -import dagger.assisted.Assisted; -import dagger.assisted.AssistedFactory; -import dagger.assisted.AssistedInject; - -import java.util.Arrays; -import java.util.List; - -/** - * Dialog to select screen recording options - */ -public class ScreenRecordDialogDelegate implements SystemUIDialog.Delegate { - private static final List<ScreenRecordingAudioSource> MODES = Arrays.asList(INTERNAL, MIC, - MIC_AND_INTERNAL); - private static final long DELAY_MS = 3000; - private static final long INTERVAL_MS = 1000; - - private final SystemUIDialog.Factory mSystemUIDialogFactory; - private final UserContextProvider mUserContextProvider; - private final RecordingController mController; - private final Runnable mOnStartRecordingClicked; - private Switch mTapsSwitch; - private Switch mAudioSwitch; - private Spinner mOptions; - - @AssistedFactory - public interface Factory { - ScreenRecordDialogDelegate create( - RecordingController recordingController, - @Nullable Runnable onStartRecordingClicked - ); - } - - @AssistedInject - public ScreenRecordDialogDelegate( - SystemUIDialog.Factory systemUIDialogFactory, - UserContextProvider userContextProvider, - @Assisted RecordingController controller, - @Assisted @Nullable Runnable onStartRecordingClicked) { - mSystemUIDialogFactory = systemUIDialogFactory; - mUserContextProvider = userContextProvider; - mController = controller; - mOnStartRecordingClicked = onStartRecordingClicked; - } - - @Override - public SystemUIDialog createDialog() { - return mSystemUIDialogFactory.create(this); - } - - @Override - public void onCreate(SystemUIDialog dialog, Bundle savedInstanceState) { - Window window = dialog.getWindow(); - - window.addPrivateFlags(WindowManager.LayoutParams.SYSTEM_FLAG_SHOW_FOR_ALL_USERS); - - window.setGravity(Gravity.CENTER); - dialog.setTitle(R.string.screenrecord_title); - - dialog.setContentView(R.layout.screen_record_dialog); - - TextView cancelBtn = dialog.findViewById(R.id.button_cancel); - cancelBtn.setOnClickListener(v -> dialog.dismiss()); - TextView startBtn = dialog.findViewById(R.id.button_start); - startBtn.setOnClickListener(v -> { - if (mOnStartRecordingClicked != null) { - // Note that it is important to run this callback before dismissing, so that the - // callback can disable the dialog exit animation if it wants to. - mOnStartRecordingClicked.run(); - } - - // Start full-screen recording - requestScreenCapture(/* captureTarget= */ null); - dialog.dismiss(); - }); - - mAudioSwitch = dialog.findViewById(R.id.screenrecord_audio_switch); - mTapsSwitch = dialog.findViewById(R.id.screenrecord_taps_switch); - mOptions = dialog.findViewById(R.id.screen_recording_options); - ArrayAdapter a = new ScreenRecordingAdapter(dialog.getContext().getApplicationContext(), - android.R.layout.simple_spinner_dropdown_item, - MODES); - a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mOptions.setAdapter(a); - mOptions.setOnItemClickListenerInt((parent, view, position, id) -> { - mAudioSwitch.setChecked(true); - }); - - // disable redundant Touch & Hold accessibility action for Switch Access - mOptions.setAccessibilityDelegate(new View.AccessibilityDelegate() { - @Override - public void onInitializeAccessibilityNodeInfo(@NonNull View host, - @NonNull AccessibilityNodeInfo info) { - info.removeAction(AccessibilityNodeInfo.AccessibilityAction.ACTION_LONG_CLICK); - super.onInitializeAccessibilityNodeInfo(host, info); - } - }); - mOptions.setLongClickable(false); - } - - /** - * Starts screen capture after some countdown - * @param captureTarget target to capture (could be e.g. a task) or - * null to record the whole screen - */ - private void requestScreenCapture(@Nullable MediaProjectionCaptureTarget captureTarget) { - Context userContext = mUserContextProvider.getUserContext(); - boolean showTaps = mTapsSwitch.isChecked(); - ScreenRecordingAudioSource audioMode = mAudioSwitch.isChecked() - ? (ScreenRecordingAudioSource) mOptions.getSelectedItem() - : NONE; - PendingIntent startIntent = PendingIntent.getForegroundService(userContext, - RecordingService.REQUEST_CODE, - RecordingService.getStartIntent( - userContext, Activity.RESULT_OK, - audioMode.ordinal(), showTaps, captureTarget), - PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); - PendingIntent stopIntent = PendingIntent.getService(userContext, - RecordingService.REQUEST_CODE, - RecordingService.getStopIntent(userContext), - PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); - mController.startCountdown(DELAY_MS, INTERVAL_MS, startIntent, stopIntent); - } - - private class CaptureTargetResultReceiver extends ResultReceiver { - - CaptureTargetResultReceiver() { - super(new Handler(Looper.getMainLooper())); - } - - @Override - protected void onReceiveResult(int resultCode, Bundle resultData) { - if (resultCode == RESULT_OK) { - MediaProjectionCaptureTarget captureTarget = resultData - .getParcelable(KEY_CAPTURE_TARGET, MediaProjectionCaptureTarget.class); - - // Start recording of the selected target - requestScreenCapture(captureTarget); - } - } - } -} diff --git a/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt b/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt index 963973588236..991f78a3147c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/recordissue/RecordIssueDialogDelegateTest.kt @@ -27,7 +27,6 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.animation.DialogTransitionAnimator import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.flags.FeatureFlagsClassic -import com.android.systemui.flags.Flags import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger import com.android.systemui.mediaprojection.SessionCreationSource import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver @@ -56,7 +55,6 @@ import org.mockito.ArgumentMatchers.anyLong import org.mockito.Mock import org.mockito.Mockito.never import org.mockito.Mockito.spy -import org.mockito.Mockito.times import org.mockito.Mockito.verify import org.mockito.MockitoAnnotations @@ -150,8 +148,6 @@ class RecordIssueDialogDelegateTest : SysuiTestCase() { @Test fun screenCaptureDisabledDialog_isShown_whenFunctionalityIsDisabled() { - whenever(flags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) - .thenReturn(true) whenever(devicePolicyResolver.isScreenCaptureCompletelyDisabled(any<UserHandle>())) .thenReturn(true) @@ -170,48 +166,6 @@ class RecordIssueDialogDelegateTest : SysuiTestCase() { } @Test - fun screenCapturePermissionDialog_isShown_correctly() { - whenever(flags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) - .thenReturn(false) - whenever(devicePolicyResolver.isScreenCaptureCompletelyDisabled(any<UserHandle>())) - .thenReturn(false) - whenever(state.hasUserApprovedScreenRecording).thenReturn(false) - - val screenRecordSwitch = dialog.requireViewById<Switch>(R.id.screenrecord_switch) - screenRecordSwitch.isChecked = true - - bgExecutor.runAllReady() - mainExecutor.runAllReady() - - verify(mediaProjectionMetricsLogger) - .notifyProjectionInitiated( - anyInt(), - eq(SessionCreationSource.SYSTEM_UI_SCREEN_RECORDER), - ) - verify(factory, times(2)).create(any(SystemUIDialog.Delegate::class.java)) - } - - @Test - fun noDialogsAreShown_forScreenRecord_whenApprovalIsAlreadyGiven() { - whenever(flags.isEnabled(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES)) - .thenReturn(false) - whenever(devicePolicyResolver.isScreenCaptureCompletelyDisabled(any<UserHandle>())) - .thenReturn(false) - - val screenRecordSwitch = dialog.requireViewById<Switch>(R.id.screenrecord_switch) - screenRecordSwitch.isChecked = true - - bgExecutor.runAllReady() - - verify(mediaProjectionMetricsLogger) - .notifyProjectionInitiated( - anyInt(), - eq(SessionCreationSource.SYSTEM_UI_SCREEN_RECORDER), - ) - verify(factory, never()).create() - } - - @Test fun startButton_isDisabled_beforeIssueTypeIsSelected() { assertThat(dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled).isFalse() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingControllerTest.java index 6b16e78436d4..afff4858499a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/screenrecord/RecordingControllerTest.java @@ -42,15 +42,11 @@ import android.testing.TestableLooper; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; -import com.android.systemui.animation.DialogTransitionAnimator; import com.android.systemui.broadcast.BroadcastDispatcher; -import com.android.systemui.flags.FakeFeatureFlags; -import com.android.systemui.flags.Flags; import com.android.systemui.mediaprojection.MediaProjectionMetricsLogger; import com.android.systemui.mediaprojection.SessionCreationSource; import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDevicePolicyResolver; import com.android.systemui.mediaprojection.devicepolicy.ScreenCaptureDisabledDialogDelegate; -import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.settings.UserTracker; import com.android.systemui.statusbar.phone.SystemUIDialog; import com.android.systemui.util.concurrency.FakeExecutor; @@ -79,10 +75,6 @@ public class RecordingControllerTest extends SysuiTestCase { @Mock private ScreenCaptureDevicePolicyResolver mDevicePolicyResolver; @Mock - private DialogTransitionAnimator mDialogTransitionAnimator; - @Mock - private ActivityStarter mActivityStarter; - @Mock private UserTracker mUserTracker; @Mock private MediaProjectionMetricsLogger mMediaProjectionMetricsLogger; @@ -92,10 +84,6 @@ public class RecordingControllerTest extends SysuiTestCase { @Mock private SystemUIDialog mScreenCaptureDisabledDialog; @Mock - private ScreenRecordDialogDelegate.Factory mScreenRecordDialogFactory; - @Mock - private ScreenRecordDialogDelegate mScreenRecordDialogDelegate; - @Mock private ScreenRecordPermissionDialogDelegate.Factory mScreenRecordPermissionDialogDelegateFactory; @Mock @@ -103,7 +91,6 @@ public class RecordingControllerTest extends SysuiTestCase { @Mock private SystemUIDialog mScreenRecordSystemUIDialog; - private FakeFeatureFlags mFeatureFlags; private RecordingController mController; private static final int USER_ID = 10; @@ -114,12 +101,8 @@ public class RecordingControllerTest extends SysuiTestCase { Context spiedContext = spy(mContext); when(spiedContext.getUserId()).thenReturn(TEST_USER_ID); - mFeatureFlags = new FakeFeatureFlags(); when(mScreenCaptureDisabledDialogDelegate.createSysUIDialog()) .thenReturn(mScreenCaptureDisabledDialog); - when(mScreenRecordDialogFactory.create(any(), any())) - .thenReturn(mScreenRecordDialogDelegate); - when(mScreenRecordDialogDelegate.createDialog()).thenReturn(mScreenRecordSystemUIDialog); when(mScreenRecordPermissionDialogDelegateFactory.create(any(), any(), anyInt(), any())) .thenReturn(mScreenRecordPermissionDialogDelegate); when(mScreenRecordPermissionDialogDelegate.createDialog()) @@ -127,13 +110,11 @@ public class RecordingControllerTest extends SysuiTestCase { mController = new RecordingController( mMainExecutor, mBroadcastDispatcher, - mFeatureFlags, () -> mDevicePolicyResolver, mUserTracker, new RecordingControllerLogger(logcatLogBuffer("RecordingControllerTest")), mMediaProjectionMetricsLogger, mScreenCaptureDisabledDialogDelegate, - mScreenRecordDialogFactory, mScreenRecordPermissionDialogDelegateFactory ); mController.addCallback(mCallback); @@ -236,46 +217,19 @@ public class RecordingControllerTest extends SysuiTestCase { } @Test - public void testPoliciesFlagDisabled_screenCapturingNotAllowed_returnsNullDevicePolicyDialog() { - mFeatureFlags.set(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES, false); - when(mDevicePolicyResolver.isScreenCaptureCompletelyDisabled((any()))).thenReturn(true); - - Dialog dialog = - mController.createScreenRecordDialog( - mContext, - mFeatureFlags, - mDialogTransitionAnimator, - mActivityStarter, - /* onStartRecordingClicked= */ null); - - assertThat(dialog).isSameInstanceAs(mScreenRecordSystemUIDialog); - assertThat(mScreenRecordPermissionDialogDelegate) - .isInstanceOf(ScreenRecordPermissionDialogDelegate.class); - } - - @Test - public void testPoliciesFlagEnabled_screenCapturingNotAllowed_returnsDevicePolicyDialog() { - mFeatureFlags.set(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES, true); + public void testScreenCapturingNotAllowed_returnsDevicePolicyDialog() { when(mDevicePolicyResolver.isScreenCaptureCompletelyDisabled((any()))).thenReturn(true); - Dialog dialog = mController.createScreenRecordDialog(mContext, mFeatureFlags, - mDialogTransitionAnimator, mActivityStarter, /* onStartRecordingClicked= */ null); + Dialog dialog = mController.createScreenRecordDialog(/* onStartRecordingClicked= */ null); assertThat(dialog).isEqualTo(mScreenCaptureDisabledDialog); } @Test - public void testPoliciesFlagEnabled_screenCapturingAllowed_returnsNullDevicePolicyDialog() { - mFeatureFlags.set(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES, true); + public void testScreenCapturingAllowed_returnsNullDevicePolicyDialog() { when(mDevicePolicyResolver.isScreenCaptureCompletelyDisabled((any()))).thenReturn(false); - Dialog dialog = - mController.createScreenRecordDialog( - mContext, - mFeatureFlags, - mDialogTransitionAnimator, - mActivityStarter, - /* onStartRecordingClicked= */ null); + Dialog dialog = mController.createScreenRecordDialog(/* onStartRecordingClicked= */ null); assertThat(dialog).isSameInstanceAs(mScreenRecordSystemUIDialog); assertThat(mScreenRecordPermissionDialogDelegate) @@ -283,12 +237,10 @@ public class RecordingControllerTest extends SysuiTestCase { } @Test - public void testPoliciesFlagEnabled_screenCapturingAllowed_logsProjectionInitiated() { - mFeatureFlags.set(Flags.WM_ENABLE_PARTIAL_SCREEN_SHARING_ENTERPRISE_POLICIES, true); + public void testScreenCapturingAllowed_logsProjectionInitiated() { when(mDevicePolicyResolver.isScreenCaptureCompletelyDisabled((any()))).thenReturn(false); - mController.createScreenRecordDialog(mContext, mFeatureFlags, - mDialogTransitionAnimator, mActivityStarter, /* onStartRecordingClicked= */ null); + mController.createScreenRecordDialog(/* onStartRecordingClicked= */ null); verify(mMediaProjectionMetricsLogger) .notifyProjectionInitiated( |