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

Commit 2bd9a250 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

DO NOT MERGE Kill most processes when display size changes

This isn't something apps generally can handle, so we kill all of
them for now.

Test: Change cutout overlay that changes display size
Test: Rotate screen
Bug: 112876936
Change-Id: Ic3b0f1b3ae1e9bd93ac8f2c6952aa093878602b8
parent 2c9fd5fb
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -413,4 +413,9 @@ public abstract class ActivityManagerInternal {
     * @return The intent used to launch the home activity.
     */
    public abstract Intent getHomeIntent();

    /**
     * WindowManager notifies AM when display size of the default display changes.
     */
    public abstract void notifyDefaultDisplaySizeChanged();
}
+15 −0
Original line number Diff line number Diff line
@@ -26870,6 +26870,21 @@ public class ActivityManagerService extends IActivityManager.Stub
                return ActivityManagerService.this.getHomeIntent();
            }
        }
        @Override
        public void notifyDefaultDisplaySizeChanged() {
            synchronized (this) {
                if (mSystemServiceManager.isBootCompleted()) {
                    Slog.i(TAG, "Killing processes because of display size change");
                    killAllBackgroundProcessesExcept(-1, ActivityManager.PROCESS_STATE_SERVICE);
                    // TODO: Ugly hack to unblock the release
                    if (mHomeProcess != null) {
                        removeProcessLocked(mHomeProcess, false, true, "kill home screen size");
                    }
                }
            }
        }
    }
    /**
+7 −2
Original line number Diff line number Diff line
@@ -1775,8 +1775,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
        final int newDensity = mDisplayInfo.logicalDensityDpi;
        final DisplayCutout newCutout = mDisplayInfo.displayCutout;

        final boolean displayMetricsChanged = mInitialDisplayWidth != newWidth
                || mInitialDisplayHeight != newHeight
        final boolean sizeChanged = mInitialDisplayWidth != newWidth
                || mInitialDisplayHeight != newHeight;
        final boolean displayMetricsChanged = sizeChanged
                || mInitialDisplayDensity != mDisplayInfo.logicalDensityDpi
                || !Objects.equals(mInitialDisplayCutout, newCutout);

@@ -1798,6 +1799,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            mInitialDisplayCutout = newCutout;
            mService.reconfigureDisplayLocked(this);
        }

        if (isDefaultDisplay && sizeChanged) {
            mService.mH.post(mService.mAmInternal::notifyDefaultDisplaySizeChanged);
        }
    }

    /** Sets the maximum width the screen resolution can be */