Don't cause infinite loop if windows manager crashes in safe mode

We set ro.sys.safemode=1 on startup in windows manager in safe
mode so that safemode will be carried over to the second bounce for
fde (see b/28008032). However, if windows manager restarts for any
reason, it cannot set this value twice (read only) and throws.

Don't set if already set.

Bug: 79608610
Test: Kill Windows Manager in safe mode. Before this change, windows
      manager would reboot indefinitely. After this change, system
      comes back up quickly

Change-Id: I05f3adfa801eef0e5a1357a19fb7a3bf61ce02eb
This commit is contained in:
Paul Lawrence
2018-05-15 13:32:06 -07:00
parent 19c4ef269f
commit b1a13f8093

View File

@@ -4489,7 +4489,10 @@ public class WindowManagerService extends IWindowManager.Stub
if (mSafeMode) {
Log.i(TAG_WM, "SAFE MODE ENABLED (menu=" + menuState + " s=" + sState
+ " dpad=" + dpadState + " trackball=" + trackballState + ")");
SystemProperties.set(ShutdownThread.RO_SAFEMODE_PROPERTY, "1");
// May already be set if (for instance) this process has crashed
if (SystemProperties.getInt(ShutdownThread.RO_SAFEMODE_PROPERTY, 0) == 0) {
SystemProperties.set(ShutdownThread.RO_SAFEMODE_PROPERTY, "1");
}
} else {
Log.i(TAG_WM, "SAFE MODE not enabled");
}