[DO NOT MERGE] Do not log boot times for secondary users and upgrades
Do not log framework_boot_completed/framework_locked_boot_completed
for secondary users, runtime restarts or first boot/upgrade.
First boot/upgrade also applies to boot_system_server_ready/
boot_package_manager_init_ready
Cherry-picked from commit 4ba91b9a87
Test: Manual update with fingerprint change
Test: runtime restart - not logged
Bug: 34516002
Bug: 32807863
Change-Id: I64b960c96a0e45b4fefaf05547ea5ac5c701c765
This commit is contained in:
@@ -36,7 +36,6 @@ 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>();
|
||||
@@ -258,17 +257,6 @@ public class SystemServiceManager {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -46,6 +46,7 @@ import static com.android.server.am.UserState.STATE_RUNNING_UNLOCKING;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.UserIdInt;
|
||||
import android.app.ActivityManager;
|
||||
import android.app.AppGlobals;
|
||||
import android.app.AppOpsManager;
|
||||
import android.app.Dialog;
|
||||
import android.app.IStopUserCallback;
|
||||
@@ -54,6 +55,7 @@ import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.IIntentReceiver;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.IPackageManager;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.UserInfo;
|
||||
import android.os.BatteryStats;
|
||||
@@ -239,8 +241,10 @@ 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()) {
|
||||
// Do not report secondary users, runtime restarts or first boot/upgrade
|
||||
if (userId == UserHandle.USER_SYSTEM
|
||||
&& !mService.mSystemServiceManager.isRuntimeRestarted()
|
||||
&& !isFirstBootOrUpgrade()) {
|
||||
int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000);
|
||||
MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed",
|
||||
uptimeSeconds);
|
||||
@@ -416,9 +420,10 @@ final class UserController {
|
||||
}
|
||||
|
||||
Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId);
|
||||
if (!mService.mSystemServiceManager.isRuntimeRestarted()
|
||||
&& !mService.mSystemServiceManager.isFirstBoot()) {
|
||||
|
||||
// Do not report secondary users, runtime restarts or first boot/upgrade
|
||||
if (userId == UserHandle.USER_SYSTEM
|
||||
&& !mService.mSystemServiceManager.isRuntimeRestarted()
|
||||
&& !isFirstBootOrUpgrade()) {
|
||||
int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000);
|
||||
MetricsLogger
|
||||
.histogram(mService.mContext, "framework_boot_completed", uptimeSeconds);
|
||||
@@ -433,6 +438,15 @@ final class UserController {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isFirstBootOrUpgrade() {
|
||||
IPackageManager pm = AppGlobals.getPackageManager();
|
||||
try {
|
||||
return pm.isFirstBoot() || pm.isUpgrade();
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
int stopUser(final int userId, final boolean force, final IStopUserCallback callback) {
|
||||
if (mService.checkCallingPermission(INTERACT_ACROSS_USERS_FULL)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
|
||||
@@ -327,7 +327,6 @@ 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);
|
||||
|
||||
Reference in New Issue
Block a user