diff options
| author | 2017-01-19 12:11:32 -0800 | |
|---|---|---|
| committer | 2017-01-20 17:32:50 +0000 | |
| commit | 83a218c416ffc0096b99bc33eb007bbf218d9ced (patch) | |
| tree | 5be1ab5e10df9ce821fecab1cda68d70740dfe8b | |
| parent | 18f1a35d466a6afd08014daeb0e3021fb8172071 (diff) | |
[DO NOT MERGE] Do not report boot timings on first boot or runtime restart
During first boot after OTA, additional dexopting has to be done
during PM initialization. Timings for OTA are reported separately,
so we should ignore first boot to avoid skewing the metrics.
The following metrics were updated:
- framework_locked_boot_completed
- framework_boot_completed
Cherry-picked from commit 1d87e40d4214a7f6d20a58d6f27cca174f0d974e
Test: manual
Bug: 32807863
Change-Id: I9d545cf38118f45f3f13597df2949d0ae4abd26a
3 files changed, 42 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java index 90f507c146bf..40b0e2e431b8 100644 --- a/services/core/java/com/android/server/SystemServiceManager.java +++ b/services/core/java/com/android/server/SystemServiceManager.java @@ -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>(); @@ -246,6 +248,28 @@ public class SystemServiceManager { } /** + * @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. */ public void dump() { diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index 1ef3728c6444..19eeff0d440c 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -239,11 +239,12 @@ final class UserController { // storage is already unlocked. if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) { getUserManagerInternal().setUserState(userId, uss.state); - - int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); - MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed", - uptimeSeconds); - + 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 @@ -415,8 +416,13 @@ final class UserController { } Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId); - int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000); - MetricsLogger.histogram(mService.mContext, "framework_boot_completed", uptimeSeconds); + if (!mService.mSystemServiceManager.isRuntimeRestarted() + && !mService.mSystemServiceManager.isFirstBoot()) { + + int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000); + 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 diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 05071ad2eee7..865277e88ab5 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -208,6 +208,7 @@ public final class SystemServer { private boolean mOnlyCore; private boolean mFirstBoot; + private final boolean mRuntimeRestart; /** * Start the sensor service. @@ -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() { @@ -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); |