diff options
author | Jorim Jaggi <jjaggi@google.com> | 2018-08-21 17:41:13 +0200 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-08-22 16:19:53 +0000 |
commit | e39c79bfe77f27aa7243c1d1ce7f9f708e9750f6 (patch) | |
tree | 5e710d5a9515847b550a7721bb1f9a5763ee185e | |
parent | be46ea28ed19f3d742bd46514c81b7e4ce83f56d (diff) | |
download | base-e39c79bfe77f27aa7243c1d1ce7f9f708e9750f6.tar.gz |
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
(cherry picked from commit 2bd9a25007fcec5612944af7db0d1aa4d9849351)
3 files changed, 27 insertions, 2 deletions
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java index 9b6764d96fb2..14cae95508e7 100644 --- a/core/java/android/app/ActivityManagerInternal.java +++ b/core/java/android/app/ActivityManagerInternal.java @@ -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(); } diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 189506cb0f40..3faa1deb5c40 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -26849,6 +26849,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"); + } + } + } + } } /** diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 2887e5ef9061..2941e93d12dc 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -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 */ |