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

Commit df241e97 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Allow home activity to be resizeable if it explicitly wants to be.

We previously didn't allow home activities to be resizeable due to not fully
understanding how the UX would work. We now have a better idea of how the UX will
work. However, since this is a behavior change for home activities we require them
to explicitly say they want to be resizeable vs. the framework assuming they can
be resizeable based on their target sdk.

Bug: 30982291
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test android.server.cts
Change-Id: I41aefc8c3b3da4c2cf66be81835222196df3ef26
parent 72a73e34
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -164,7 +164,8 @@ public class ActivityInfo extends ComponentInfo
    public static final int RESIZE_MODE_UNRESIZEABLE = 0;
    /**
     * Activity didn't explicitly request to be resizeable, but we are making it resizeable because
     * of the SDK version it targets.
     * of the SDK version it targets. Only affects apps with target SDK >= N where the app is
     * implied to be resizeable if it doesn't explicitly set the attribute to any value.
     * @hide
     */
    public static final int RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION = 1;
@@ -179,7 +180,8 @@ public class ActivityInfo extends ComponentInfo
     */
    public static final int RESIZE_MODE_RESIZEABLE_AND_PIPABLE = 3;
    /**
     * Activity is does not support resizing, but we are forcing it to be resizeable.
     * Activity is does not support resizing, but we are forcing it to be resizeable. Only affects
     * certain pre-N apps where we force them to be resizeable.
     * @hide
     */
    public static final int RESIZE_MODE_FORCE_RESIZEABLE = 4;
+10 −2
Original line number Diff line number Diff line
@@ -26,9 +26,11 @@ import static android.content.pm.ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE;
import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER;
import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_AND_PIPABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONFIGURATION;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SAVED_STATE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SCREENSHOTS;
@@ -795,6 +797,12 @@ final class ActivityRecord {
                && isHomeIntent(intent) && !isResolverActivity()) {
            // This sure looks like a home activity!
            mActivityType = HOME_ACTIVITY_TYPE;

            if (info.resizeMode == RESIZE_MODE_FORCE_RESIZEABLE
                    || info.resizeMode == RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION) {
                // We only allow home activities to be resizeable if they explicitly requested it.
                info.resizeMode = RESIZE_MODE_UNRESIZEABLE;
            }
        } else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) {
            mActivityType = RECENTS_ACTIVITY_TYPE;
        } else {
@@ -887,7 +895,7 @@ final class ActivityRecord {
    }

    boolean isResizeable() {
        return !isHomeActivity() && ActivityInfo.isResizeableMode(info.resizeMode);
        return ActivityInfo.isResizeableMode(info.resizeMode);
    }

    boolean isResizeableOrForced() {
@@ -895,7 +903,7 @@ final class ActivityRecord {
    }

    boolean isNonResizableOrForced() {
        return !isHomeActivity() && info.resizeMode != RESIZE_MODE_RESIZEABLE
        return info.resizeMode != RESIZE_MODE_RESIZEABLE
                && info.resizeMode != RESIZE_MODE_RESIZEABLE_AND_PIPABLE
                && info.resizeMode != RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION;
    }
+2 −2
Original line number Diff line number Diff line
@@ -1067,8 +1067,8 @@ final class TaskRecord extends ConfigurationContainer {
    }

    boolean isResizeable() {
        return !isHomeTask() && (mService.mForceResizableActivities
                || ActivityInfo.isResizeableMode(mResizeMode)) && !mTemporarilyUnresizable;
        return (mService.mForceResizableActivities || ActivityInfo.isResizeableMode(mResizeMode))
                && !mTemporarilyUnresizable;
    }

    boolean isOnTopLauncher() {
+3 −4
Original line number Diff line number Diff line
@@ -277,8 +277,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
    }

    boolean isResizeable() {
        return !mHomeTask
                && (ActivityInfo.isResizeableMode(mResizeMode) || mService.mForceResizableTasks);
        return ActivityInfo.isResizeableMode(mResizeMode) || mService.mForceResizableTasks;
    }

    boolean isOnTopLauncher() {
@@ -286,7 +285,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU
    }

    boolean cropWindowsToStackBounds() {
        return !mHomeTask && isResizeable();
        return isResizeable();
    }

    boolean isHomeTask() {
@@ -560,7 +559,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU

    @Override
    public boolean dimFullscreen() {
        return isHomeTask() || isFullscreen();
        return isFullscreen();
    }

    boolean isFullscreen() {