Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1dcfc423 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Do not report boot timings on first boot or runtime restart" into nyc-mr2-dev

parents fb764b70 83a218c4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -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>();
@@ -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.
     */
+13 −7
Original line number Diff line number Diff line
@@ -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
@@ -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
+5 −0
Original line number Diff line number Diff line
@@ -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);