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

Commit f12fce1a authored by Andrii Kulian's avatar Andrii Kulian
Browse files

Update override config to include some changes from global config

In override config for task we set Configuration#screenLayout field based on
initial global config + shrink to fit the area on screen given for this task.
However this field also contains information (like layout direction) that we
do not intend to override and it can be changed in global config separately.
In this case we need to update the override config with changes from global
config.

Bug: 28616488
Change-Id: I22673257621b3f9ae7933b37bd0fb9446c6042ea
parent 9801a926
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ public final class Configuration implements Parcelable, Comparable<Configuration
    public static final int SCREENLAYOUT_COMPAT_NEEDED = 0x10000000;

    /**
     * Bit mask of overall layout of the screen.  Currently there are two
     * Bit mask of overall layout of the screen.  Currently there are four
     * fields:
     * <p>The {@link #SCREENLAYOUT_SIZE_MASK} bits define the overall size
     * of the screen.  They may be one of
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE;
import static com.android.server.am.ActivityRecord.STARTING_WINDOW_REMOVED;
import static com.android.server.am.ActivityRecord.STARTING_WINDOW_SHOWN;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
import static com.android.server.am.ActivityStackSupervisor.MOVING;
import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_CLOSE;
@@ -4464,6 +4463,7 @@ final class ActivityStack {
        // Short circuit: if the two configurations are equal (the common case), then there is
        // nothing to do.
        final Configuration newConfig = mService.mConfiguration;
        r.task.sanitizeOverrideConfiguration(newConfig);
        final Configuration taskConfig = r.task.mOverrideConfig;
        if (r.configuration.equals(newConfig)
                && r.taskConfigOverride.equals(taskConfig)
+20 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ import static android.content.pm.ActivityInfo.LOCK_TASK_LAUNCH_MODE_NEVER;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
import static android.content.res.Configuration.SCREENLAYOUT_LONG_MASK;
import static android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
@@ -1574,6 +1576,24 @@ final class TaskRecord {
        return bounds;
    }

    /**
     * Update fields that are not overridden for task from global configuration.
     *
     * @param globalConfig global configuration to update from.
     */
    void sanitizeOverrideConfiguration(Configuration globalConfig) {
        // screenLayout field is set in #calculateOverrideConfig but only part of it is really
        // overridden - aspect ratio and size. Other flags (like layout direction) can be updated
        // separately in global config and they also must be updated in override config.
        int overrideScreenLayout = mOverrideConfig.screenLayout;
        int newScreenLayout = globalConfig.screenLayout;
        newScreenLayout = (newScreenLayout & ~SCREENLAYOUT_LONG_MASK)
                | (overrideScreenLayout & SCREENLAYOUT_LONG_MASK);
        newScreenLayout = (newScreenLayout & ~SCREENLAYOUT_SIZE_MASK)
                | (overrideScreenLayout & SCREENLAYOUT_SIZE_MASK);
        mOverrideConfig.screenLayout = newScreenLayout;
    }

    static Rect validateBounds(Rect bounds) {
        if (bounds != null && bounds.isEmpty()) {
            Slog.wtf(TAG, "Received strange task bounds: " + bounds, new Throwable());