Add shutdown assurance
If something kills system_server before it completes its shutdown action, the runtime will just restart giving the illusion that a reboot for an OTA or something else has happened. To prevent this, write a system property containing the reboot reason before initiating the shutdown with all the services. If the system_server is killed before it completes, the next time the main thread of system_server starts up, it will immediately execute the shutdown action. Bug: 3022556 Change-Id: I81723bac333430f04205e7a7b799914d96f170eb
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package com.android.server;
|
||||
|
||||
import com.android.server.am.ActivityManagerService;
|
||||
import com.android.internal.app.ShutdownThread;
|
||||
import com.android.internal.os.BinderInternal;
|
||||
import com.android.internal.os.SamplingProfilerIntegration;
|
||||
import com.trustedlogic.trustednfc.android.server.NfcService;
|
||||
@@ -89,6 +90,24 @@ class ServerThread extends Thread {
|
||||
BinderInternal.disableBackgroundScheduling(true);
|
||||
android.os.Process.setCanSelfBackground(false);
|
||||
|
||||
// Check whether we failed to shut down last time we tried.
|
||||
{
|
||||
final String shutdownAction = SystemProperties.get(
|
||||
ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
|
||||
if (shutdownAction != null && shutdownAction.length() > 0) {
|
||||
boolean reboot = (shutdownAction.charAt(0) == '1');
|
||||
|
||||
final String reason;
|
||||
if (shutdownAction.length() > 1) {
|
||||
reason = shutdownAction.substring(1, shutdownAction.length());
|
||||
} else {
|
||||
reason = null;
|
||||
}
|
||||
|
||||
ShutdownThread.rebootOrShutdown(reboot, reason);
|
||||
}
|
||||
}
|
||||
|
||||
String factoryTestStr = SystemProperties.get("ro.factorytest");
|
||||
int factoryTest = "".equals(factoryTestStr) ? SystemServer.FACTORY_TEST_OFF
|
||||
: Integer.parseInt(factoryTestStr);
|
||||
|
||||
Reference in New Issue
Block a user