Loading services/contextualsearch/java/com/android/server/contextualsearch/ContextualSearchManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.contextualsearch; import static android.Manifest.permission.ACCESS_CONTEXTUAL_SEARCH; import static android.app.AppOpsManager.OP_ASSIST_SCREENSHOT; import static android.app.AppOpsManager.OP_ASSIST_STRUCTURE; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.Context.CONTEXTUAL_SEARCH_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -75,6 +76,7 @@ import android.util.Log; import android.util.Slog; import android.view.Display; import android.view.IWindowManager; import android.window.DesktopExperienceFlags; import android.window.ScreenCapture.ScreenshotHardwareBuffer; import com.android.internal.R; Loading Loading @@ -425,6 +427,9 @@ public class ContextualSearchManagerService extends SystemService { final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext, /* enterResId= */ 0, /* exitResId= */ 0, null, null, null); opts.setDisableStartingWindow(true); if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { opts.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); } return mAtmInternal.startActivityWithScreenshot(launchIntent, mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null, opts.toBundle(), userId); Loading services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java +29 −11 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE_PER_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.window.DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS; import static android.window.DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; Loading @@ -38,7 +39,6 @@ import android.app.WindowConfiguration; import android.content.Context; import android.content.pm.ActivityInfo; import android.util.Slog; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -104,7 +104,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { boolean hasLaunchWindowingMode = false; final boolean inDesktopMode = suggestedDisplayArea.inFreeformWindowingMode() || suggestedDisplayArea.getTopMostVisibleFreeformActivity() != null; if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && task == null if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && task == null && (isRequestingFreeformWindowMode(null, options, currentParams) || inDesktopMode)) { if (options != null) { Loading @@ -131,11 +131,15 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { } final Task organizerTask = task.getCreatedByOrganizerTask(); // If task is already launched, check if organizer task matches the target display. final boolean inDesktopFirstContainer = ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && ( suggestedDisplayArea.inFreeformWindowingMode() || ( ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue() && organizerTask != null && organizerTask.inFreeformWindowingMode() && organizerTask.getDisplayId() == display.getDisplayId())); // In multiple desks, freeform tasks are always children of a root task controlled // by DesksOrganizer, so don't skip resolving freeform bounds. if (organizerTask != null && !(ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue() && organizerTask.inFreeformWindowingMode())) { if (organizerTask != null && !inDesktopFirstContainer) { appendLog("has created-by-organizer-task, skipping"); return RESULT_SKIP; } Loading @@ -148,12 +152,20 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { // Copy over any values outParams.set(currentParams); boolean requestFullscreen = options != null && options.getLaunchWindowingMode() == WINDOWING_MODE_FULLSCREEN; boolean isFullscreenInDeskTask = inDesktopFirstContainer && requestFullscreen; if (source != null && source.getTask() != null) { final Task sourceTask = source.getTask(); // Don't explicitly set to freeform if task is launching in full-screen in desktop-first // container, as it should already inherit freeform by default if undefined. requestFullscreen |= sourceTask.getWindowingMode() == WINDOWING_MODE_FULLSCREEN; isFullscreenInDeskTask = inDesktopFirstContainer && requestFullscreen; if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue() && isEnteringDesktopMode(sourceTask, options, currentParams)) { && isEnteringDesktopMode(sourceTask, options, currentParams) && !isFullscreenInDeskTask) { // If trampoline source is not freeform but we are entering or in desktop mode, // ignore the source windowing mode and set the windowing mode to freeform // ignore the source windowing mode and set the windowing mode to freeform. outParams.mWindowingMode = WINDOWING_MODE_FREEFORM; appendLog("freeform window mode applied to task trampoline"); } else { Loading @@ -168,8 +180,15 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { hasLaunchWindowingMode = true; } if (isFullscreenInDeskTask) { // Return early to prevent freeform bounds always being set in multi-desk mode for // fullscreen tasks. Tasks should inherit from parent bounds. appendLog("launch-in-fullscreen"); return RESULT_DONE; } if (phase == PHASE_WINDOWING_MODE) { if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { return RESULT_DONE; } return RESULT_CONTINUE; Loading @@ -184,7 +203,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue()) { // We are in desktop, return result done to prevent other modifiers from modifying // exiting task bounds or resolved windowing mode. if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { outParams.mBounds.set(task.getRequestedOverrideBounds()); } appendLog("task-has-override-bounds=%s", task.getRequestedOverrideBounds()); Loading Loading @@ -218,8 +237,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { appendLog("inherit-options=" + options.getLaunchWindowingMode()); return RESULT_DONE; } if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && hasLaunchWindowingMode) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && hasLaunchWindowingMode) { return RESULT_DONE; } return RESULT_CONTINUE; Loading services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -1596,6 +1596,32 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS}) public void testInMultiDesk_requestFullscreen_returnDone() { setupDesktopModeLaunchParamsModifier(); final Task task = new TaskBuilder(mSupervisor).setActivityType( ACTIVITY_TYPE_STANDARD).setCreatedByOrganizer(true).build(); final Task sourceTask = new TaskBuilder(mSupervisor).setActivityType( ACTIVITY_TYPE_STANDARD).setWindowingMode(WINDOWING_MODE_FULLSCREEN).build(); assertNotNull(task.getCreatedByOrganizerTask()); task.getCreatedByOrganizerTask().setWindowingMode(WINDOWING_MODE_FREEFORM); final ActivityRecord sourceActivity = new ActivityBuilder(task.mAtmService) .setTask(sourceTask).build(); assertEquals(RESULT_DONE, new CalculateRequestBuilder().setTask(task) .setSource(sourceActivity).calculate()); assertEquals(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode); final Rect emptyRect = new Rect(); assertEquals(emptyRect, mResult.mBounds); assertEquals(emptyRect, mResult.mAppBounds); } private Task createTask(DisplayContent display, boolean isResizeable) { final int resizeMode = isResizeable ? RESIZE_MODE_RESIZEABLE : RESIZE_MODE_UNRESIZEABLE; Loading services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.voiceinteraction; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION; Loading Loading @@ -81,7 +82,6 @@ import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback import android.service.voice.IVisualQueryDetectionVoiceInteractionCallback; import android.service.voice.IVoiceInteractionSession; import android.service.voice.VoiceInteractionManagerInternal; import android.service.voice.VoiceInteractionManagerInternal.WearableHotwordDetectionCallback; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionServiceInfo; import android.service.voice.VoiceInteractionSession; Loading @@ -90,6 +90,7 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; import android.util.Slog; import android.window.DesktopExperienceFlags; import android.window.ScreenCapture; import com.android.internal.R; Loading Loading @@ -2794,6 +2795,9 @@ public class VoiceInteractionManagerService extends SystemService { final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext, /* enterResId= */ 0, /* exitResId= */ 0, null, null, null); opts.setDisableStartingWindow(true); if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { opts.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); } int resultCode = mAtmInternal.startActivityWithScreenshot(launchIntent, mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null, opts.toBundle(), userId); Loading Loading
services/contextualsearch/java/com/android/server/contextualsearch/ContextualSearchManagerService.java +5 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ package com.android.server.contextualsearch; import static android.Manifest.permission.ACCESS_CONTEXTUAL_SEARCH; import static android.app.AppOpsManager.OP_ASSIST_SCREENSHOT; import static android.app.AppOpsManager.OP_ASSIST_STRUCTURE; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.Context.CONTEXTUAL_SEARCH_SERVICE; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; Loading Loading @@ -75,6 +76,7 @@ import android.util.Log; import android.util.Slog; import android.view.Display; import android.view.IWindowManager; import android.window.DesktopExperienceFlags; import android.window.ScreenCapture.ScreenshotHardwareBuffer; import com.android.internal.R; Loading Loading @@ -425,6 +427,9 @@ public class ContextualSearchManagerService extends SystemService { final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext, /* enterResId= */ 0, /* exitResId= */ 0, null, null, null); opts.setDisableStartingWindow(true); if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { opts.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); } return mAtmInternal.startActivityWithScreenshot(launchIntent, mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null, opts.toBundle(), userId); Loading
services/core/java/com/android/server/wm/DesktopModeLaunchParamsModifier.java +29 −11 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE_PER_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.window.DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS; import static android.window.DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND; import static com.android.server.wm.ActivityTaskManagerDebugConfig.TAG_ATM; Loading @@ -38,7 +39,6 @@ import android.app.WindowConfiguration; import android.content.Context; import android.content.pm.ActivityInfo; import android.util.Slog; import android.window.DesktopExperienceFlags; import android.window.DesktopModeFlags; import com.android.internal.annotations.VisibleForTesting; Loading Loading @@ -104,7 +104,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { boolean hasLaunchWindowingMode = false; final boolean inDesktopMode = suggestedDisplayArea.inFreeformWindowingMode() || suggestedDisplayArea.getTopMostVisibleFreeformActivity() != null; if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && task == null if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && task == null && (isRequestingFreeformWindowMode(null, options, currentParams) || inDesktopMode)) { if (options != null) { Loading @@ -131,11 +131,15 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { } final Task organizerTask = task.getCreatedByOrganizerTask(); // If task is already launched, check if organizer task matches the target display. final boolean inDesktopFirstContainer = ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && ( suggestedDisplayArea.inFreeformWindowingMode() || ( ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue() && organizerTask != null && organizerTask.inFreeformWindowingMode() && organizerTask.getDisplayId() == display.getDisplayId())); // In multiple desks, freeform tasks are always children of a root task controlled // by DesksOrganizer, so don't skip resolving freeform bounds. if (organizerTask != null && !(ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue() && organizerTask.inFreeformWindowingMode())) { if (organizerTask != null && !inDesktopFirstContainer) { appendLog("has created-by-organizer-task, skipping"); return RESULT_SKIP; } Loading @@ -148,12 +152,20 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { // Copy over any values outParams.set(currentParams); boolean requestFullscreen = options != null && options.getLaunchWindowingMode() == WINDOWING_MODE_FULLSCREEN; boolean isFullscreenInDeskTask = inDesktopFirstContainer && requestFullscreen; if (source != null && source.getTask() != null) { final Task sourceTask = source.getTask(); // Don't explicitly set to freeform if task is launching in full-screen in desktop-first // container, as it should already inherit freeform by default if undefined. requestFullscreen |= sourceTask.getWindowingMode() == WINDOWING_MODE_FULLSCREEN; isFullscreenInDeskTask = inDesktopFirstContainer && requestFullscreen; if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue() && isEnteringDesktopMode(sourceTask, options, currentParams)) { && isEnteringDesktopMode(sourceTask, options, currentParams) && !isFullscreenInDeskTask) { // If trampoline source is not freeform but we are entering or in desktop mode, // ignore the source windowing mode and set the windowing mode to freeform // ignore the source windowing mode and set the windowing mode to freeform. outParams.mWindowingMode = WINDOWING_MODE_FREEFORM; appendLog("freeform window mode applied to task trampoline"); } else { Loading @@ -168,8 +180,15 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { hasLaunchWindowingMode = true; } if (isFullscreenInDeskTask) { // Return early to prevent freeform bounds always being set in multi-desk mode for // fullscreen tasks. Tasks should inherit from parent bounds. appendLog("launch-in-fullscreen"); return RESULT_DONE; } if (phase == PHASE_WINDOWING_MODE) { if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { return RESULT_DONE; } return RESULT_CONTINUE; Loading @@ -184,7 +203,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { if (DesktopModeFlags.DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX.isTrue()) { // We are in desktop, return result done to prevent other modifiers from modifying // exiting task bounds or resolved windowing mode. if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { outParams.mBounds.set(task.getRequestedOverrideBounds()); } appendLog("task-has-override-bounds=%s", task.getRequestedOverrideBounds()); Loading Loading @@ -218,8 +237,7 @@ class DesktopModeLaunchParamsModifier implements LaunchParamsModifier { appendLog("inherit-options=" + options.getLaunchWindowingMode()); return RESULT_DONE; } if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && hasLaunchWindowingMode) { if (ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue() && hasLaunchWindowingMode) { return RESULT_DONE; } return RESULT_CONTINUE; Loading
services/tests/wmtests/src/com/android/server/wm/DesktopModeLaunchParamsModifierTests.java +26 −0 Original line number Diff line number Diff line Loading @@ -1596,6 +1596,32 @@ public class DesktopModeLaunchParamsModifierTests extends assertEquals(WINDOWING_MODE_FREEFORM, mResult.mWindowingMode); } @Test @EnableFlags({Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE, Flags.FLAG_DISABLE_DESKTOP_LAUNCH_PARAMS_OUTSIDE_DESKTOP_BUG_FIX, Flags.FLAG_ENABLE_MULTIPLE_DESKTOPS_BACKEND, Flags.FLAG_ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS}) public void testInMultiDesk_requestFullscreen_returnDone() { setupDesktopModeLaunchParamsModifier(); final Task task = new TaskBuilder(mSupervisor).setActivityType( ACTIVITY_TYPE_STANDARD).setCreatedByOrganizer(true).build(); final Task sourceTask = new TaskBuilder(mSupervisor).setActivityType( ACTIVITY_TYPE_STANDARD).setWindowingMode(WINDOWING_MODE_FULLSCREEN).build(); assertNotNull(task.getCreatedByOrganizerTask()); task.getCreatedByOrganizerTask().setWindowingMode(WINDOWING_MODE_FREEFORM); final ActivityRecord sourceActivity = new ActivityBuilder(task.mAtmService) .setTask(sourceTask).build(); assertEquals(RESULT_DONE, new CalculateRequestBuilder().setTask(task) .setSource(sourceActivity).calculate()); assertEquals(WINDOWING_MODE_FULLSCREEN, mResult.mWindowingMode); final Rect emptyRect = new Rect(); assertEquals(emptyRect, mResult.mBounds); assertEquals(emptyRect, mResult.mAppBounds); } private Task createTask(DisplayContent display, boolean isResizeable) { final int resizeMode = isResizeable ? RESIZE_MODE_RESIZEABLE : RESIZE_MODE_UNRESIZEABLE; Loading
services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.server.voiceinteraction; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NO_ANIMATION; Loading Loading @@ -81,7 +82,6 @@ import android.service.voice.IMicrophoneHotwordDetectionVoiceInteractionCallback import android.service.voice.IVisualQueryDetectionVoiceInteractionCallback; import android.service.voice.IVoiceInteractionSession; import android.service.voice.VoiceInteractionManagerInternal; import android.service.voice.VoiceInteractionManagerInternal.WearableHotwordDetectionCallback; import android.service.voice.VoiceInteractionService; import android.service.voice.VoiceInteractionServiceInfo; import android.service.voice.VoiceInteractionSession; Loading @@ -90,6 +90,7 @@ import android.util.ArrayMap; import android.util.ArraySet; import android.util.Log; import android.util.Slog; import android.window.DesktopExperienceFlags; import android.window.ScreenCapture; import com.android.internal.R; Loading Loading @@ -2794,6 +2795,9 @@ public class VoiceInteractionManagerService extends SystemService { final ActivityOptions opts = ActivityOptions.makeCustomTaskAnimation(mContext, /* enterResId= */ 0, /* exitResId= */ 0, null, null, null); opts.setDisableStartingWindow(true); if (DesktopExperienceFlags.ENABLE_FREEFORM_DISPLAY_LAUNCH_PARAMS.isTrue()) { opts.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); } int resultCode = mAtmInternal.startActivityWithScreenshot(launchIntent, mContext.getPackageName(), Binder.getCallingUid(), Binder.getCallingPid(), null, opts.toBundle(), userId); Loading