Loading services/core/java/com/android/server/SystemServiceManager.java +26 −2 Original line number Diff line number Diff line Loading @@ -35,13 +35,15 @@ 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>(); private int mCurrentPhase = -1; public SystemServiceManager(Context context) { SystemServiceManager(Context context) { mContext = context; } Loading Loading @@ -235,7 +237,7 @@ public class SystemServiceManager { } /** Sets the safe mode flag for services to query. */ public void setSafeMode(boolean safeMode) { void setSafeMode(boolean safeMode) { mSafeMode = safeMode; } Loading @@ -247,6 +249,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 +18 −7 Original line number Diff line number Diff line Loading @@ -255,10 +255,11 @@ final class UserController { // storage is already unlocked. if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) { mInjector.getUserManagerInternal().setUserState(userId, uss.state); if (!mInjector.isRuntimeRestarted() && !mInjector.isFirstBoot()) { int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mInjector.getContext(), "framework_locked_boot_completed", uptimeSeconds); MetricsLogger.histogram(mInjector.getContext(), "framework_locked_boot_completed", uptimeSeconds); } mHandler.sendMessage(mHandler.obtainMessage(REPORT_LOCKED_BOOT_COMPLETE_MSG, userId, 0)); Loading Loading @@ -429,9 +430,11 @@ final class UserController { } Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId); if (!mInjector.isRuntimeRestarted() && !mInjector.isFirstBoot()) { int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mInjector.getContext(), "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 Loading @@ -1696,6 +1699,14 @@ final class UserController { mService.mSystemServiceManager.stopUser(userId); } boolean isRuntimeRestarted() { return mService.mSystemServiceManager.isRuntimeRestarted(); } boolean isFirstBoot() { return mService.mSystemServiceManager.isFirstBoot(); } void sendPreBootBroadcast(int userId, boolean quiet, final Runnable onFinish) { new PreBootBroadcaster(mService, userId, null, quiet) { @Override Loading services/java/com/android/server/SystemServer.java +5 −3 Original line number Diff line number Diff line Loading @@ -278,7 +278,7 @@ public final class SystemServer { Slog.i(TAG, "Entered the Android system server!"); int uptimeMillis = (int) SystemClock.elapsedRealtime(); EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, uptimeMillis); if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_system_server_init", uptimeMillis); // Also report when first stage of init has started long initStartNs = SystemProperties.getLong("ro.boottime.init", -1); Loading Loading @@ -352,6 +352,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); // Prepare the thread pool for init tasks that can be parallelized SystemServerInitThreadPool.get(); Loading @@ -378,7 +380,7 @@ public final class SystemServer { if (StrictMode.conditionallyEnableDebugLogging()) { Slog.i(TAG, "Enabled StrictMode for system server main thread."); } if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_system_server_ready", (int) SystemClock.elapsedRealtime()); } Loading Loading @@ -520,7 +522,7 @@ public final class SystemServer { mFirstBoot = mPackageManagerService.isFirstBoot(); mPackageManager = mSystemContext.getPackageManager(); traceEnd(); if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_package_manager_init_ready", (int) SystemClock.elapsedRealtime()); } Loading Loading
services/core/java/com/android/server/SystemServiceManager.java +26 −2 Original line number Diff line number Diff line Loading @@ -35,13 +35,15 @@ 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>(); private int mCurrentPhase = -1; public SystemServiceManager(Context context) { SystemServiceManager(Context context) { mContext = context; } Loading Loading @@ -235,7 +237,7 @@ public class SystemServiceManager { } /** Sets the safe mode flag for services to query. */ public void setSafeMode(boolean safeMode) { void setSafeMode(boolean safeMode) { mSafeMode = safeMode; } Loading @@ -247,6 +249,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 +18 −7 Original line number Diff line number Diff line Loading @@ -255,10 +255,11 @@ final class UserController { // storage is already unlocked. if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) { mInjector.getUserManagerInternal().setUserState(userId, uss.state); if (!mInjector.isRuntimeRestarted() && !mInjector.isFirstBoot()) { int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mInjector.getContext(), "framework_locked_boot_completed", uptimeSeconds); MetricsLogger.histogram(mInjector.getContext(), "framework_locked_boot_completed", uptimeSeconds); } mHandler.sendMessage(mHandler.obtainMessage(REPORT_LOCKED_BOOT_COMPLETE_MSG, userId, 0)); Loading Loading @@ -429,9 +430,11 @@ final class UserController { } Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId); if (!mInjector.isRuntimeRestarted() && !mInjector.isFirstBoot()) { int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000); MetricsLogger.histogram(mInjector.getContext(), "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 Loading @@ -1696,6 +1699,14 @@ final class UserController { mService.mSystemServiceManager.stopUser(userId); } boolean isRuntimeRestarted() { return mService.mSystemServiceManager.isRuntimeRestarted(); } boolean isFirstBoot() { return mService.mSystemServiceManager.isFirstBoot(); } void sendPreBootBroadcast(int userId, boolean quiet, final Runnable onFinish) { new PreBootBroadcaster(mService, userId, null, quiet) { @Override Loading
services/java/com/android/server/SystemServer.java +5 −3 Original line number Diff line number Diff line Loading @@ -278,7 +278,7 @@ public final class SystemServer { Slog.i(TAG, "Entered the Android system server!"); int uptimeMillis = (int) SystemClock.elapsedRealtime(); EventLog.writeEvent(EventLogTags.BOOT_PROGRESS_SYSTEM_RUN, uptimeMillis); if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_system_server_init", uptimeMillis); // Also report when first stage of init has started long initStartNs = SystemProperties.getLong("ro.boottime.init", -1); Loading Loading @@ -352,6 +352,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); // Prepare the thread pool for init tasks that can be parallelized SystemServerInitThreadPool.get(); Loading @@ -378,7 +380,7 @@ public final class SystemServer { if (StrictMode.conditionallyEnableDebugLogging()) { Slog.i(TAG, "Enabled StrictMode for system server main thread."); } if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_system_server_ready", (int) SystemClock.elapsedRealtime()); } Loading Loading @@ -520,7 +522,7 @@ public final class SystemServer { mFirstBoot = mPackageManagerService.isFirstBoot(); mPackageManager = mSystemContext.getPackageManager(); traceEnd(); if (!mRuntimeRestart) { if (!mRuntimeRestart && !mFirstBoot) { MetricsLogger.histogram(null, "boot_package_manager_init_ready", (int) SystemClock.elapsedRealtime()); } Loading