diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 6176c61d363ab..dc24dce76d789 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -967,6 +967,7 @@ android:enabled="false" android:exported="true" android:excludeFromRecents="true" + android:resizeableActivity="false" android:theme="@android:style/Theme.NoDisplay" android:label="@string/note_task_button_label" android:icon="@drawable/ic_note_task_shortcut_widget"> @@ -981,6 +982,7 @@ android:name=".notetask.shortcut.LaunchNoteTaskActivity" android:exported="true" android:excludeFromRecents="true" + android:resizeableActivity="false" android:theme="@android:style/Theme.NoDisplay" /> diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt index 6cd04c861155e..ac22b7ce8b6b7 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskController.kt @@ -89,22 +89,16 @@ constructor( /** * Shows a note task. How the task is shown will depend on when the method is invoked. * - * If in multi-window mode, notes will open as a full screen experience. That is particularly - * important for Large screen devices. These devices may support a taskbar that let users to - * drag and drop a shortcut into multi-window mode, and notes should comply with this behaviour. - * * If the keyguard is locked, notes will open as a full screen experience. A locked device has * no contextual information which let us use the whole screen space available. * - * If not in multi-window or the keyguard is unlocked, notes will open as a bubble OR it will be - * collapsed if the notes bubble is already opened. + * If the keyguard is unlocked, notes will open as a bubble OR it will be collapsed if the notes + * bubble is already opened. * * That will let users open other apps in full screen, and take contextual notes. */ - @JvmOverloads fun showNoteTask( entryPoint: NoteTaskEntryPoint, - isInMultiWindowMode: Boolean = false, ) { if (!isEnabled) return @@ -125,13 +119,7 @@ constructor( return } - val info = - resolver.resolveInfo( - entryPoint = entryPoint, - isInMultiWindowMode = isInMultiWindowMode, - isKeyguardLocked = isKeyguardLocked, - ) - ?: return + val info = resolver.resolveInfo(entryPoint, isKeyguardLocked) ?: return infoReference.set(info) diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfo.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfo.kt index 28d76474efba1..2b9f0af046ff8 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfo.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfo.kt @@ -20,12 +20,11 @@ data class NoteTaskInfo( val packageName: String, val uid: Int, val entryPoint: NoteTaskEntryPoint? = null, - val isInMultiWindowMode: Boolean = false, val isKeyguardLocked: Boolean = false, ) { val launchMode: NoteTaskLaunchMode = - if (isInMultiWindowMode || isKeyguardLocked) { + if (isKeyguardLocked) { NoteTaskLaunchMode.Activity } else { NoteTaskLaunchMode.AppBubble diff --git a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfoResolver.kt b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfoResolver.kt index b98a0fd75331c..8ecf08192e293 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfoResolver.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/NoteTaskInfoResolver.kt @@ -34,7 +34,6 @@ constructor( fun resolveInfo( entryPoint: NoteTaskEntryPoint? = null, - isInMultiWindowMode: Boolean = false, isKeyguardLocked: Boolean = false, ): NoteTaskInfo? { // TODO(b/267634412): Select UserHandle depending on where the user initiated note-taking. @@ -48,7 +47,6 @@ constructor( packageName = packageName, uid = packageManager.getUidOf(packageName, user), entryPoint = entryPoint, - isInMultiWindowMode = isInMultiWindowMode, isKeyguardLocked = isKeyguardLocked, ) } diff --git a/packages/SystemUI/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivity.kt b/packages/SystemUI/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivity.kt index 80fce6ae288b0..14b0779ab162c 100644 --- a/packages/SystemUI/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivity.kt +++ b/packages/SystemUI/src/com/android/systemui/notetask/shortcut/LaunchNoteTaskActivity.kt @@ -28,17 +28,12 @@ import javax.inject.Inject class LaunchNoteTaskActivity @Inject constructor( - private val noteTaskController: NoteTaskController, + private val controller: NoteTaskController, ) : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - - noteTaskController.showNoteTask( - entryPoint = NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT, - isInMultiWindowMode = isInMultiWindowMode, - ) - + controller.showNoteTask(entryPoint = NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT) finish() } diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt index 608d809e7e56f..3f940d64f236f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskControllerTest.kt @@ -72,7 +72,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { MockitoAnnotations.initMocks(this) whenever(context.packageManager).thenReturn(packageManager) - whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(noteTaskInfo) + whenever(resolver.resolveInfo(any(), any())).thenReturn(noteTaskInfo) whenever(userManager.isUserUnlocked).thenReturn(true) whenever( devicePolicyManager.getKeyguardDisabledFeatures( @@ -102,7 +102,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { // region onBubbleExpandChanged @Test fun onBubbleExpandChanged_expanding_logNoteTaskOpened() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false, isInMultiWindowMode = false) + val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false) createNoteTaskController() .apply { infoReference.set(expectedInfo) } @@ -117,7 +117,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun onBubbleExpandChanged_collapsing_logNoteTaskClosed() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false, isInMultiWindowMode = false) + val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false) createNoteTaskController() .apply { infoReference.set(expectedInfo) } @@ -132,7 +132,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun onBubbleExpandChanged_expandingAndKeyguardLocked_doNothing() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = true, isInMultiWindowMode = false) + val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = true) createNoteTaskController() .apply { infoReference.set(expectedInfo) } @@ -146,35 +146,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun onBubbleExpandChanged_notExpandingAndKeyguardLocked_doNothing() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = true, isInMultiWindowMode = false) - - createNoteTaskController() - .apply { infoReference.set(expectedInfo) } - .onBubbleExpandChanged( - isExpanding = false, - key = Bubble.KEY_APP_BUBBLE, - ) - - verifyZeroInteractions(context, bubbles, keyguardManager, userManager, eventLogger) - } - - @Test - fun onBubbleExpandChanged_expandingAndInMultiWindowMode_doNothing() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false, isInMultiWindowMode = true) - - createNoteTaskController() - .apply { infoReference.set(expectedInfo) } - .onBubbleExpandChanged( - isExpanding = true, - key = Bubble.KEY_APP_BUBBLE, - ) - - verifyZeroInteractions(context, bubbles, keyguardManager, userManager) - } - - @Test - fun onBubbleExpandChanged_notExpandingAndInMultiWindowMode_doNothing() { - val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = false, isInMultiWindowMode = true) + val expectedInfo = noteTaskInfo.copy(isKeyguardLocked = true) createNoteTaskController() .apply { infoReference.set(expectedInfo) } @@ -215,16 +187,14 @@ internal class NoteTaskControllerTest : SysuiTestCase() { val expectedInfo = noteTaskInfo.copy( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, isKeyguardLocked = true, ) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) - whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) + whenever(resolver.resolveInfo(any(), any())).thenReturn(expectedInfo) createNoteTaskController() .showNoteTask( entryPoint = expectedInfo.entryPoint!!, - isInMultiWindowMode = expectedInfo.isInMultiWindowMode, ) val intentCaptor = argumentCaptor() @@ -250,16 +220,14 @@ internal class NoteTaskControllerTest : SysuiTestCase() { val expectedInfo = noteTaskInfo.copy( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, isKeyguardLocked = false, ) - whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) + whenever(resolver.resolveInfo(any(), any())).thenReturn(expectedInfo) whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) createNoteTaskController() .showNoteTask( entryPoint = expectedInfo.entryPoint!!, - isInMultiWindowMode = expectedInfo.isInMultiWindowMode, ) verifyZeroInteractions(context) @@ -274,50 +242,11 @@ internal class NoteTaskControllerTest : SysuiTestCase() { verifyZeroInteractions(eventLogger) } - @Test - fun showNoteTask_isInMultiWindowMode_shouldStartActivityAndLogUiEvent() { - val expectedInfo = - noteTaskInfo.copy( - entryPoint = NoteTaskEntryPoint.WIDGET_PICKER_SHORTCUT, - isInMultiWindowMode = true, - isKeyguardLocked = false, - ) - whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(expectedInfo) - whenever(keyguardManager.isKeyguardLocked).thenReturn(expectedInfo.isKeyguardLocked) - - createNoteTaskController() - .showNoteTask( - entryPoint = expectedInfo.entryPoint!!, - isInMultiWindowMode = expectedInfo.isInMultiWindowMode, - ) - - val intentCaptor = argumentCaptor() - val userCaptor = argumentCaptor() - verify(context).startActivityAsUser(capture(intentCaptor), capture(userCaptor)) - - (intentCaptor.value.flags and FLAG_ACTIVITY_NEW_TASK) == FLAG_ACTIVITY_NEW_TASK - - intentCaptor.value.let { intent -> - assertThat(intent.action).isEqualTo(Intent.ACTION_CREATE_NOTE) - assertThat(intent.`package`).isEqualTo(NOTES_PACKAGE_NAME) - assertThat(intent.flags and FLAG_ACTIVITY_NEW_TASK).isEqualTo(FLAG_ACTIVITY_NEW_TASK) - assertThat(intent.flags and FLAG_ACTIVITY_MULTIPLE_TASK) - .isEqualTo(FLAG_ACTIVITY_MULTIPLE_TASK) - assertThat(intent.flags and FLAG_ACTIVITY_NEW_DOCUMENT) - .isEqualTo(FLAG_ACTIVITY_NEW_DOCUMENT) - assertThat(intent.getBooleanExtra(Intent.EXTRA_USE_STYLUS_MODE, false)).isTrue() - } - assertThat(userCaptor.value).isEqualTo(userTracker.userHandle) - verify(eventLogger).logNoteTaskOpened(expectedInfo) - verifyZeroInteractions(bubbles) - } - @Test fun showNoteTask_bubblesIsNull_shouldDoNothing() { createNoteTaskController(bubbles = null) .showNoteTask( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, ) verifyZeroInteractions(context, bubbles, eventLogger) @@ -325,12 +254,11 @@ internal class NoteTaskControllerTest : SysuiTestCase() { @Test fun showNoteTask_intentResolverReturnsNull_shouldDoNothing() { - whenever(resolver.resolveInfo(any(), any(), any())).thenReturn(null) + whenever(resolver.resolveInfo(any(), any())).thenReturn(null) createNoteTaskController() .showNoteTask( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, ) verifyZeroInteractions(context, bubbles, eventLogger) @@ -341,7 +269,6 @@ internal class NoteTaskControllerTest : SysuiTestCase() { createNoteTaskController(isEnabled = false) .showNoteTask( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, ) verifyZeroInteractions(context, bubbles, eventLogger) @@ -354,7 +281,6 @@ internal class NoteTaskControllerTest : SysuiTestCase() { createNoteTaskController() .showNoteTask( entryPoint = NoteTaskEntryPoint.TAIL_BUTTON, - isInMultiWindowMode = false, ) verifyZeroInteractions(context, bubbles, eventLogger) @@ -405,11 +331,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { ) .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL) - createNoteTaskController() - .showNoteTask( - isInMultiWindowMode = false, - entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE - ) + createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE) verifyZeroInteractions(context, bubbles, eventLogger) } @@ -425,11 +347,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { ) .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL) - createNoteTaskController() - .showNoteTask( - isInMultiWindowMode = false, - entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE - ) + createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE) verifyZeroInteractions(context, bubbles, eventLogger) } @@ -445,11 +363,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { ) .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_SHORTCUTS_ALL) - createNoteTaskController() - .showNoteTask( - isInMultiWindowMode = false, - entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE - ) + createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE) val intentCaptor = argumentCaptor() verify(bubbles).showOrHideAppBubble(capture(intentCaptor)) @@ -472,11 +386,7 @@ internal class NoteTaskControllerTest : SysuiTestCase() { ) .thenReturn(DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_ALL) - createNoteTaskController() - .showNoteTask( - isInMultiWindowMode = false, - entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE - ) + createNoteTaskController().showNoteTask(entryPoint = NoteTaskEntryPoint.QUICK_AFFORDANCE) val intentCaptor = argumentCaptor() verify(bubbles).showOrHideAppBubble(capture(intentCaptor)) diff --git a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt index 7e975b6732a5f..91cd6ae5d9887 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/notetask/NoteTaskInfoTest.kt @@ -31,41 +31,19 @@ internal class NoteTaskInfoTest : SysuiTestCase() { NoteTaskInfo(packageName = NOTES_PACKAGE_NAME, uid = NOTES_UID) @Test - fun launchMode_notInMultiWindowModeAndKeyguardUnlocked_launchModeAppBubble() { - val underTest = - createNoteTaskInfo() - .copy( - isKeyguardLocked = false, - isInMultiWindowMode = false, - ) + fun launchMode_keyguardLocked_launchModeActivity() { + val underTest = createNoteTaskInfo().copy(isKeyguardLocked = true) + + assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.Activity) + } + + @Test + fun launchMode_keyguardUnlocked_launchModeActivity() { + val underTest = createNoteTaskInfo().copy(isKeyguardLocked = false) assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.AppBubble) } - @Test - fun launchMode_inMultiWindowMode_launchModeActivity() { - val underTest = - createNoteTaskInfo() - .copy( - isKeyguardLocked = false, - isInMultiWindowMode = true, - ) - - assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.Activity) - } - - @Test - fun launchMode_keyguardLocked_launchModeActivity() { - val underTest = - createNoteTaskInfo() - .copy( - isKeyguardLocked = true, - isInMultiWindowMode = false, - ) - - assertThat(underTest.launchMode).isEqualTo(NoteTaskLaunchMode.Activity) - } - private companion object { const val NOTES_PACKAGE_NAME = "com.android.note.app" const val NOTES_UID = 123456