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
This commit is contained in:
Jorim Jaggi
2018-08-21 17:41:13 +02:00
parent 2c9fd5fbbb
commit 2bd9a25007
3 changed files with 27 additions and 2 deletions

View File

@@ -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();
}

View File

@@ -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");
}
}
}
}
}
/**

View File

@@ -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 */