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

Commit 7f704b52 authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix unexpected process restart of size compat mode

Since hierarchy merged, the difference between full configuration
and resolved override configuration is no longer the same as the
changes of override configuration. It should be more reliable to
explicitly get the change of the requested override configuration
in display.

Also ensure the popup hint window uses the same window type as
its anchor window, so it won't be occluded by activity.

Bug: 139656157
Test: SizeCompatTests#testResetNonVisibleActivity
Change-Id: I146ca1f55227012da58f5e4d6d85e42a41d1f7cb
parent b49e6f44
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -452,6 +452,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        if ((diff & ActivityInfo.CONFIG_SMALLEST_SCREEN_SIZE) != 0) {
            list.add("CONFIG_SMALLEST_SCREEN_SIZE");
        }
        if ((diff & ActivityInfo.CONFIG_DENSITY) != 0) {
            list.add("CONFIG_DENSITY");
        }
        if ((diff & ActivityInfo.CONFIG_LAYOUT_DIRECTION) != 0) {
            list.add("CONFIG_LAYOUT_DIRECTION");
        }
@@ -461,6 +464,9 @@ public final class Configuration implements Parcelable, Comparable<Configuration
        if ((diff & ActivityInfo.CONFIG_ASSETS_PATHS) != 0) {
            list.add("CONFIG_ASSETS_PATHS");
        }
        if ((diff & ActivityInfo.CONFIG_WINDOW_CONFIGURATION) != 0) {
            list.add("CONFIG_WINDOW_CONFIGURATION");
        }
        StringBuilder builder = new StringBuilder("{");
        for (int i = 0, n = list.size(); i < n; i++) {
            builder.append(list.get(i));
+1 −0
Original line number Diff line number Diff line
@@ -280,6 +280,7 @@ public class SizeCompatModeActivityController extends SystemUI implements Comman
                    R.layout.size_compat_mode_hint, null /* root */);
            PopupWindow popupWindow = new PopupWindow(popupView,
                    LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
            popupWindow.setWindowLayoutType(mWinParams.type);
            popupWindow.setElevation(getResources().getDimension(R.dimen.bubble_elevation));
            popupWindow.setAnimationStyle(android.R.style.Animation_InputMethod);
            popupWindow.setClippingEnabled(false);
+1 −1
Original line number Diff line number Diff line
@@ -6533,7 +6533,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        } else if (mCompatDisplayInsets != null) {
            // The override changes can only be obtained from display, because we don't have the
            // difference of full configuration in each hierarchy.
            final int displayChanges = display.getLastOverrideConfigurationChanges();
            final int displayChanges = display.getCurrentOverrideConfigurationChanges();
            final int orientationChanges = CONFIG_WINDOW_CONFIGURATION
                    | CONFIG_SCREEN_SIZE | CONFIG_ORIENTATION;
            final boolean hasNonOrienSizeChanged = hasResizeChange(displayChanges)
+1 −10
Original line number Diff line number Diff line
@@ -81,9 +81,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
     */
    private Configuration mFullConfiguration = new Configuration();

    /** The bit mask of the last override fields of full configuration. */
    private int mLastOverrideConfigurationChanges;

    /**
     * Contains merged override configuration settings from the top of the hierarchy down to this
     * particular instance. It is different from {@link #mFullConfiguration} because it starts from
@@ -121,11 +118,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
        return mFullConfiguration;
    }

    /** Returns the last changes from applying override configuration. */
    int getLastOverrideConfigurationChanges() {
        return mLastOverrideConfigurationChanges;
    }

    /**
     * Notify that parent config changed and we need to update full configuration.
     * @see #mFullConfiguration
@@ -141,7 +133,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
        mResolvedTmpConfig.setTo(mResolvedOverrideConfiguration);
        resolveOverrideConfiguration(newParentConfig);
        mFullConfiguration.setTo(newParentConfig);
        mLastOverrideConfigurationChanges =
        mFullConfiguration.updateFrom(mResolvedOverrideConfiguration);
        if (!mResolvedTmpConfig.equals(mResolvedOverrideConfiguration)) {
            onMergedOverrideConfigurationChanged();
+22 −0
Original line number Diff line number Diff line
@@ -346,6 +346,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    /** The desired scaling factor for compatible apps. */
    float mCompatibleScreenScale;

    /** @see #getCurrentOverrideConfigurationChanges */
    private int mCurrentOverrideConfigurationChanges;

    /**
     * Orientation forced by some window. If there is no visible window that specifies orientation
     * it is set to {@link android.content.pm.ActivityInfo#SCREEN_ORIENTATION_UNSPECIFIED}.
@@ -1867,6 +1870,25 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        mTaskStackContainers.onStackWindowingModeChanged(stack);
    }

    /**
     * The value is only valid in the scope {@link #onRequestedOverrideConfigurationChanged} of the
     * changing hierarchy and the {@link #onConfigurationChanged} of its children.
     *
     * @return The current changes ({@link android.content.pm.ActivityInfo.Config}) of requested
     *         override configuration.
     */
    int getCurrentOverrideConfigurationChanges() {
        return mCurrentOverrideConfigurationChanges;
    }

    @Override
    public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) {
        mCurrentOverrideConfigurationChanges =
                getRequestedOverrideConfiguration().diff(overrideConfiguration);
        super.onRequestedOverrideConfigurationChanged(overrideConfiguration);
        mCurrentOverrideConfigurationChanges = 0;
    }

    @Override
    public void onConfigurationChanged(Configuration newParentConfig) {
        final int lastOrientation = getConfiguration().orientation;
Loading