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

Commit 33aa3bc4 authored by Eghosa Ewansiha-Vlachavas's avatar Eghosa Ewansiha-Vlachavas
Browse files

Don't set freeform bounds for fullscreen task on desktop enabled devices

The legacy freeform mode applied freeform bounds to fullscreen task so
that the defualt freeform bounds can easily be restored later. However,
for devices which support and have desktop mode enabled, storing these
freeform bounds for fullscreen tasks is not needed and thus can be
omitted.

Flag: NONE Exempt
Test: atest WmTests:TaskLaunchParamsModifierTests
Bug: 421055142
Change-Id: I22f07ca8462a2cc28c2f29fe199c04afe1b8acaf
parent 61a25925
Loading
Loading
Loading
Loading
+5 −3
Original line number Original line Diff line number Diff line
@@ -30,6 +30,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
import android.app.WindowConfiguration.WindowingMode;
import android.app.WindowConfiguration.WindowingMode;
import android.content.Context;
import android.content.pm.ActivityInfo.WindowLayout;
import android.content.pm.ActivityInfo.WindowLayout;
import android.graphics.Rect;
import android.graphics.Rect;


@@ -68,9 +69,10 @@ class LaunchParamsController {
     */
     */
    void registerDefaultModifiers(ActivityTaskSupervisor supervisor) {
    void registerDefaultModifiers(ActivityTaskSupervisor supervisor) {
        // {@link TaskLaunchParamsModifier} handles window layout preferences.
        // {@link TaskLaunchParamsModifier} handles window layout preferences.
        registerModifier(new TaskLaunchParamsModifier(supervisor));
        final Context context = mService.mContext;
        registerModifier(new DesktopModeLaunchParamsModifier(mService.mContext, supervisor,
        registerModifier(new TaskLaunchParamsModifier(supervisor, context));
                new DesktopModeCompatPolicy(mService.mContext)));
        registerModifier(new DesktopModeLaunchParamsModifier(context, supervisor,
                new DesktopModeCompatPolicy(context)));
    }
    }


    /**
    /**
+9 −3
Original line number Original line Diff line number Diff line
@@ -36,12 +36,14 @@ import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;


import static com.android.server.wm.ActivityStarter.Request;
import static com.android.server.wm.ActivityStarter.Request;
import static com.android.server.wm.DesktopModeHelper.canEnterDesktopMode;
import static com.android.server.wm.LaunchParamsUtil.getPreferredLaunchTaskDisplayArea;
import static com.android.server.wm.LaunchParamsUtil.getPreferredLaunchTaskDisplayArea;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.app.ActivityOptions;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
import android.app.WindowConfiguration;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.graphics.Rect;
@@ -77,6 +79,7 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
    private static final int MINIMAL_STEP = 1;
    private static final int MINIMAL_STEP = 1;


    private final ActivityTaskSupervisor mSupervisor;
    private final ActivityTaskSupervisor mSupervisor;
    private final Context mContext;
    private final Rect mTmpBounds = new Rect();
    private final Rect mTmpBounds = new Rect();
    private final Rect mTmpStableBounds = new Rect();
    private final Rect mTmpStableBounds = new Rect();
    private final int[] mTmpDirections = new int[2];
    private final int[] mTmpDirections = new int[2];
@@ -85,8 +88,9 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {


    private StringBuilder mLogBuilder;
    private StringBuilder mLogBuilder;


    TaskLaunchParamsModifier(ActivityTaskSupervisor supervisor) {
    TaskLaunchParamsModifier(ActivityTaskSupervisor supervisor, Context context) {
        mSupervisor = supervisor;
        mSupervisor = supervisor;
        mContext = context;
    }
    }


    @Override
    @Override
@@ -557,9 +561,11 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
            @NonNull ActivityInfo.WindowLayout layout, int resolvedMode, boolean hasInitialBounds,
            @NonNull ActivityInfo.WindowLayout layout, int resolvedMode, boolean hasInitialBounds,
            @NonNull Rect inOutBounds) {
            @NonNull Rect inOutBounds) {
        if (resolvedMode != WINDOWING_MODE_FREEFORM
        if (resolvedMode != WINDOWING_MODE_FREEFORM
                && resolvedMode != WINDOWING_MODE_FULLSCREEN) {
                && (resolvedMode != WINDOWING_MODE_FULLSCREEN || canEnterDesktopMode(mContext))) {
            // This function should be used only for freeform bounds adjustment. Freeform bounds
            // This function should be used only for freeform bounds adjustment. Freeform bounds
            // needs to be set to fullscreen tasks too as restore bounds.
            // needs to be set to fullscreen tasks too as restore bounds for legacy use case only.
            // If desktop mode is available on the device do not set freeform bounds for fullscreen
            // task.
            appendLog("skip-bounds-" + WindowConfiguration.windowingModeToString(resolvedMode));
            appendLog("skip-bounds-" + WindowConfiguration.windowingModeToString(resolvedMode));
            return;
            return;
        }
        }
+1 −1
Original line number Original line Diff line number Diff line
@@ -83,7 +83,7 @@ public class TaskLaunchParamsModifierTests extends
        mActivity.info.applicationInfo.targetSdkVersion = Build.VERSION_CODES.N_MR1;
        mActivity.info.applicationInfo.targetSdkVersion = Build.VERSION_CODES.N_MR1;
        mActivity.info.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;
        mActivity.info.applicationInfo.flags |= ApplicationInfo.FLAG_SUPPORTS_SCREEN_DENSITIES;


        mTarget = new TaskLaunchParamsModifier(mSupervisor);
        mTarget = new TaskLaunchParamsModifier(mSupervisor, mContext);


        mCurrent = new LaunchParams();
        mCurrent = new LaunchParams();
        mCurrent.reset();
        mCurrent.reset();