Loading services/core/java/com/android/server/SystemServiceManager.java +24 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public class SystemServiceManager { private final Context mContext; private boolean mSafeMode; private boolean mRuntimeRestarted; private boolean mFirstBoot; // Services that should receive lifecycle events. private final ArrayList<SystemService> mServices = new ArrayList<SystemService>(); Loading Loading @@ -245,6 +247,28 @@ public class SystemServiceManager { return mSafeMode; } /** * @return true if runtime was restarted, false if it's normal boot */ public boolean isRuntimeRestarted() { return mRuntimeRestarted; } void setRuntimeRestarted(boolean runtimeRestarted) { mRuntimeRestarted = runtimeRestarted; } /** * @return true if it's first boot after OTA */ public boolean isFirstBoot() { return mFirstBoot; } void setFirstBoot(boolean firstBoot) { mFirstBoot = firstBoot; } /** * Outputs the state of this manager to the System log. */ Loading services/core/java/com/android/server/am/UserController.java +13 −7 Original line number Diff line number Diff line Loading @@ -239,11 +239,12 @@ final class UserController { // storage is already unlocked. if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) { getUserManagerInternal().setUserState(userId, uss.state); if (!mService.mSystemServiceManager.isRuntimeRestarted() && !mService.mSystemServiceManager.isFirstBoot()) { int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed", uptimeSeconds); } Intent intent = new Intent(Intent.ACTION_LOCKED_BOOT_COMPLETED, null); intent.putExtra(Intent.EXTRA_USER_HANDLE, userId); intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT Loading Loading @@ -415,8 +416,13 @@ final class UserController { } Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId); if (!mService.mSystemServiceManager.isRuntimeRestarted() && !mService.mSystemServiceManager.isFirstBoot()) { int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mService.mContext, "framework_boot_completed", uptimeSeconds); MetricsLogger .histogram(mService.mContext, "framework_boot_completed", uptimeSeconds); } final Intent bootIntent = new Intent(Intent.ACTION_BOOT_COMPLETED, null); bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT Loading services/java/com/android/server/SystemServer.java +5 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,7 @@ public final class SystemServer { private boolean mOnlyCore; private boolean mFirstBoot; private final boolean mRuntimeRestart; /** * Start the sensor service. Loading @@ -224,6 +225,8 @@ public final class SystemServer { public SystemServer() { // Check for factory test mode. mFactoryTestMode = FactoryTest.getMode(); // Remember if it's runtime restart(when sys.boot_completed is already set) or reboot mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed")); } private void run() { Loading Loading @@ -323,6 +326,8 @@ public final class SystemServer { // Create the system service manager. mSystemServiceManager = new SystemServiceManager(mSystemContext); mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart); mSystemServiceManager.setFirstBoot(mFirstBoot); LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); } finally { Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); Loading Loading
services/core/java/com/android/server/SystemServiceManager.java +24 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,8 @@ public class SystemServiceManager { private final Context mContext; private boolean mSafeMode; private boolean mRuntimeRestarted; private boolean mFirstBoot; // Services that should receive lifecycle events. private final ArrayList<SystemService> mServices = new ArrayList<SystemService>(); Loading Loading @@ -245,6 +247,28 @@ public class SystemServiceManager { return mSafeMode; } /** * @return true if runtime was restarted, false if it's normal boot */ public boolean isRuntimeRestarted() { return mRuntimeRestarted; } void setRuntimeRestarted(boolean runtimeRestarted) { mRuntimeRestarted = runtimeRestarted; } /** * @return true if it's first boot after OTA */ public boolean isFirstBoot() { return mFirstBoot; } void setFirstBoot(boolean firstBoot) { mFirstBoot = firstBoot; } /** * Outputs the state of this manager to the System log. */ Loading
services/core/java/com/android/server/am/UserController.java +13 −7 Original line number Diff line number Diff line Loading @@ -239,11 +239,12 @@ final class UserController { // storage is already unlocked. if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) { getUserManagerInternal().setUserState(userId, uss.state); if (!mService.mSystemServiceManager.isRuntimeRestarted() && !mService.mSystemServiceManager.isFirstBoot()) { int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed", uptimeSeconds); } Intent intent = new Intent(Intent.ACTION_LOCKED_BOOT_COMPLETED, null); intent.putExtra(Intent.EXTRA_USER_HANDLE, userId); intent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT Loading Loading @@ -415,8 +416,13 @@ final class UserController { } Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId); if (!mService.mSystemServiceManager.isRuntimeRestarted() && !mService.mSystemServiceManager.isFirstBoot()) { int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mService.mContext, "framework_boot_completed", uptimeSeconds); MetricsLogger .histogram(mService.mContext, "framework_boot_completed", uptimeSeconds); } final Intent bootIntent = new Intent(Intent.ACTION_BOOT_COMPLETED, null); bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId); bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT Loading
services/java/com/android/server/SystemServer.java +5 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,7 @@ public final class SystemServer { private boolean mOnlyCore; private boolean mFirstBoot; private final boolean mRuntimeRestart; /** * Start the sensor service. Loading @@ -224,6 +225,8 @@ public final class SystemServer { public SystemServer() { // Check for factory test mode. mFactoryTestMode = FactoryTest.getMode(); // Remember if it's runtime restart(when sys.boot_completed is already set) or reboot mRuntimeRestart = "1".equals(SystemProperties.get("sys.boot_completed")); } private void run() { Loading Loading @@ -323,6 +326,8 @@ public final class SystemServer { // Create the system service manager. mSystemServiceManager = new SystemServiceManager(mSystemContext); mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart); mSystemServiceManager.setFirstBoot(mFirstBoot); LocalServices.addService(SystemServiceManager.class, mSystemServiceManager); } finally { Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER); Loading