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:
 - boot_system_server_init - check added for consistency with other
   metrics in SystemServer. The metric is actually unaffected by first boot,
   because dexopt will start later
 - boot_package_manager_init_ready
 - boot_system_server_init
 - framework_locked_boot_completed
 - framework_boot_completed

Test: manual + UserControllerTest pass
Bug: 32807863
Change-Id: Iff13697b7d4f9ff8439e1e932d7e276f48cd5c37
diff --git a/services/core/java/com/android/server/SystemServiceManager.java b/services/core/java/com/android/server/SystemServiceManager.java
index fb8a815..d879919 100644
--- a/services/core/java/com/android/server/SystemServiceManager.java
+++ b/services/core/java/com/android/server/SystemServiceManager.java
@@ -35,13 +35,15 @@
 
     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;
     }
 
@@ -235,7 +237,7 @@
     }
 
     /** Sets the safe mode flag for services to query. */
-    public void setSafeMode(boolean safeMode) {
+    void setSafeMode(boolean safeMode) {
         mSafeMode = safeMode;
     }
 
@@ -248,6 +250,28 @@
     }
 
     /**
+     * @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() {