Toast timeout: Just strip FLAG_KEEP_SCREEN_ON
We added the toast timeout to fix b/21693547. Where the client leaks non visible toasts which end up keeping the screen on. Simply removing the toast windows as we were doing previously, isn't very good though. If the timeout fires when an app could still use the toast (e.g. due to long pause under debugger), the app could crash. It's not obvious how (if even possible without API semantic/guarantee change) to prevent this issue from the client side. Furthermore, #33 at b/21693457 implies that we need to respect FLAG_KEEP_SCREEN_ON even for windows that never submitted a buffer. With time constraints as they are, the only solution I can think of that solves both without chance of regression is just stripping FLAG_KEEP_SCREEN_ON when the timeout fires. Bug: 29105388 Change-Id: Ic2df897f86acf814ea3d4f911a0532d65af0c19f
This commit is contained in:
@@ -177,6 +177,7 @@ import static android.view.WindowManager.DOCKED_TOP;
|
||||
import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW;
|
||||
import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
|
||||
@@ -8614,12 +8615,18 @@ public class WindowManagerService extends IWindowManager.Stub
|
||||
case WINDOW_REMOVE_TIMEOUT: {
|
||||
final WindowState window = (WindowState) msg.obj;
|
||||
synchronized(mWindowMap) {
|
||||
// It's counterintuitive that we check that "mWindowRemovalAllowed"
|
||||
// is false. But in fact if it's true, it means a remove has already
|
||||
// been requested and we better just not do anything.
|
||||
if (!window.mRemoved && !window.mWindowRemovalAllowed) {
|
||||
removeWindowLocked(window);
|
||||
}
|
||||
// TODO: This is all about fixing b/21693547
|
||||
// where partially initialized Toasts get stuck
|
||||
// around and keep the screen on. We'd like
|
||||
// to just remove the toast...but this can cause clients
|
||||
// who miss the timeout due to normal circumstances (e.g.
|
||||
// running under debugger) to crash (b/29105388). The windows will
|
||||
// eventually be removed when the client process finishes.
|
||||
// The best we can do for now is remove the FLAG_KEEP_SCREEN_ON
|
||||
// and prevent the symptoms of b/21693547.
|
||||
window.mAttrs.flags &= ~FLAG_KEEP_SCREEN_ON;
|
||||
window.setDisplayLayoutNeeded();
|
||||
mWindowPlacerLocked.performSurfacePlacement();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user