Loading services/core/java/com/android/server/UserspaceRebootLogger.java +29 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPOR import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__LOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__LOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__UNLOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__UNLOCKED; import android.os.PowerManager; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -53,8 +54,15 @@ public final class UserspaceRebootLogger { /** /** * Modifies internal state to note that {@code UserspaceRebootReported} atom needs to be * Modifies internal state to note that {@code UserspaceRebootReported} atom needs to be * logged on the next successful boot. * logged on the next successful boot. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void noteUserspaceRebootWasRequested() { public static void noteUserspaceRebootWasRequested() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } SystemProperties.set(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, "1"); SystemProperties.set(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, "1"); SystemProperties.set(USERSPACE_REBOOT_LAST_STARTED_PROPERTY, SystemProperties.set(USERSPACE_REBOOT_LAST_STARTED_PROPERTY, String.valueOf(SystemClock.elapsedRealtime())); String.valueOf(SystemClock.elapsedRealtime())); Loading @@ -64,16 +72,30 @@ public final class UserspaceRebootLogger { * Updates internal state on boot after successful userspace reboot. * Updates internal state on boot after successful userspace reboot. * * * <p>Should be called right before framework sets {@code sys.boot_completed} property. * <p>Should be called right before framework sets {@code sys.boot_completed} property. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void noteUserspaceRebootSuccess() { public static void noteUserspaceRebootSuccess() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } SystemProperties.set(USERSPACE_REBOOT_LAST_FINISHED_PROPERTY, SystemProperties.set(USERSPACE_REBOOT_LAST_FINISHED_PROPERTY, String.valueOf(SystemClock.elapsedRealtime())); String.valueOf(SystemClock.elapsedRealtime())); } } /** /** * Returns {@code true} if {@code UserspaceRebootReported} atom should be logged. * Returns {@code true} if {@code UserspaceRebootReported} atom should be logged. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static boolean shouldLogUserspaceRebootEvent() { public static boolean shouldLogUserspaceRebootEvent() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return false; } return SystemProperties.getBoolean(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, false); return SystemProperties.getBoolean(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, false); } } Loading @@ -83,8 +105,15 @@ public final class UserspaceRebootLogger { * <p>Should be called in the end of {@link * <p>Should be called in the end of {@link * com.android.server.am.ActivityManagerService#finishBooting()} method, after framework have * com.android.server.am.ActivityManagerService#finishBooting()} method, after framework have * tried to proactivelly unlock storage of the primary user. * tried to proactivelly unlock storage of the primary user. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void logEventAsync(boolean userUnlocked, Executor executor) { public static void logEventAsync(boolean userUnlocked, Executor executor) { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } final int outcome = computeOutcome(); final int outcome = computeOutcome(); final long durationMillis; final long durationMillis; if (outcome == USERSPACE_REBOOT_REPORTED__OUTCOME__SUCCESS) { if (outcome == USERSPACE_REBOOT_REPORTED__OUTCOME__SUCCESS) { Loading Loading
services/core/java/com/android/server/UserspaceRebootLogger.java +29 −0 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPOR import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__LOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__LOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__UNLOCKED; import static com.android.internal.util.FrameworkStatsLog.USERSPACE_REBOOT_REPORTED__USER_ENCRYPTION_STATE__UNLOCKED; import android.os.PowerManager; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.text.TextUtils; import android.text.TextUtils; Loading Loading @@ -53,8 +54,15 @@ public final class UserspaceRebootLogger { /** /** * Modifies internal state to note that {@code UserspaceRebootReported} atom needs to be * Modifies internal state to note that {@code UserspaceRebootReported} atom needs to be * logged on the next successful boot. * logged on the next successful boot. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void noteUserspaceRebootWasRequested() { public static void noteUserspaceRebootWasRequested() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } SystemProperties.set(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, "1"); SystemProperties.set(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, "1"); SystemProperties.set(USERSPACE_REBOOT_LAST_STARTED_PROPERTY, SystemProperties.set(USERSPACE_REBOOT_LAST_STARTED_PROPERTY, String.valueOf(SystemClock.elapsedRealtime())); String.valueOf(SystemClock.elapsedRealtime())); Loading @@ -64,16 +72,30 @@ public final class UserspaceRebootLogger { * Updates internal state on boot after successful userspace reboot. * Updates internal state on boot after successful userspace reboot. * * * <p>Should be called right before framework sets {@code sys.boot_completed} property. * <p>Should be called right before framework sets {@code sys.boot_completed} property. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void noteUserspaceRebootSuccess() { public static void noteUserspaceRebootSuccess() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } SystemProperties.set(USERSPACE_REBOOT_LAST_FINISHED_PROPERTY, SystemProperties.set(USERSPACE_REBOOT_LAST_FINISHED_PROPERTY, String.valueOf(SystemClock.elapsedRealtime())); String.valueOf(SystemClock.elapsedRealtime())); } } /** /** * Returns {@code true} if {@code UserspaceRebootReported} atom should be logged. * Returns {@code true} if {@code UserspaceRebootReported} atom should be logged. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static boolean shouldLogUserspaceRebootEvent() { public static boolean shouldLogUserspaceRebootEvent() { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return false; } return SystemProperties.getBoolean(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, false); return SystemProperties.getBoolean(USERSPACE_REBOOT_SHOULD_LOG_PROPERTY, false); } } Loading @@ -83,8 +105,15 @@ public final class UserspaceRebootLogger { * <p>Should be called in the end of {@link * <p>Should be called in the end of {@link * com.android.server.am.ActivityManagerService#finishBooting()} method, after framework have * com.android.server.am.ActivityManagerService#finishBooting()} method, after framework have * tried to proactivelly unlock storage of the primary user. * tried to proactivelly unlock storage of the primary user. * * <p>This call should only be made on devices supporting userspace reboot. */ */ public static void logEventAsync(boolean userUnlocked, Executor executor) { public static void logEventAsync(boolean userUnlocked, Executor executor) { if (!PowerManager.isRebootingUserspaceSupportedImpl()) { Slog.wtf(TAG, "Userspace reboot is not supported."); return; } final int outcome = computeOutcome(); final int outcome = computeOutcome(); final long durationMillis; final long durationMillis; if (outcome == USERSPACE_REBOOT_REPORTED__OUTCOME__SUCCESS) { if (outcome == USERSPACE_REBOOT_REPORTED__OUTCOME__SUCCESS) { Loading