Merge "[DO NOT MERGE] Do not log boot times for secondary users and upgrades" into nyc-mr2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fcb06b3735
@@ -36,7 +36,6 @@ public class SystemServiceManager {
|
|||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private boolean mSafeMode;
|
private boolean mSafeMode;
|
||||||
private boolean mRuntimeRestarted;
|
private boolean mRuntimeRestarted;
|
||||||
private boolean mFirstBoot;
|
|
||||||
|
|
||||||
// Services that should receive lifecycle events.
|
// Services that should receive lifecycle events.
|
||||||
private final ArrayList<SystemService> mServices = new ArrayList<SystemService>();
|
private final ArrayList<SystemService> mServices = new ArrayList<SystemService>();
|
||||||
@@ -258,17 +257,6 @@ public class SystemServiceManager {
|
|||||||
mRuntimeRestarted = 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.
|
* 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.NonNull;
|
||||||
import android.annotation.UserIdInt;
|
import android.annotation.UserIdInt;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
|
import android.app.AppGlobals;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.IStopUserCallback;
|
import android.app.IStopUserCallback;
|
||||||
@@ -54,6 +55,7 @@ import android.app.KeyguardManager;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.IIntentReceiver;
|
import android.content.IIntentReceiver;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.IPackageManager;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.UserInfo;
|
import android.content.pm.UserInfo;
|
||||||
import android.os.BatteryStats;
|
import android.os.BatteryStats;
|
||||||
@@ -239,8 +241,10 @@ final class UserController {
|
|||||||
// storage is already unlocked.
|
// storage is already unlocked.
|
||||||
if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) {
|
if (uss.setState(STATE_BOOTING, STATE_RUNNING_LOCKED)) {
|
||||||
getUserManagerInternal().setUserState(userId, uss.state);
|
getUserManagerInternal().setUserState(userId, uss.state);
|
||||||
if (!mService.mSystemServiceManager.isRuntimeRestarted()
|
// Do not report secondary users, runtime restarts or first boot/upgrade
|
||||||
&& !mService.mSystemServiceManager.isFirstBoot()) {
|
if (userId == UserHandle.USER_SYSTEM
|
||||||
|
&& !mService.mSystemServiceManager.isRuntimeRestarted()
|
||||||
|
&& !isFirstBootOrUpgrade()) {
|
||||||
int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000);
|
int uptimeSeconds = (int)(SystemClock.elapsedRealtime() / 1000);
|
||||||
MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed",
|
MetricsLogger.histogram(mService.mContext, "framework_locked_boot_completed",
|
||||||
uptimeSeconds);
|
uptimeSeconds);
|
||||||
@@ -416,9 +420,10 @@ final class UserController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId);
|
Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId);
|
||||||
if (!mService.mSystemServiceManager.isRuntimeRestarted()
|
// Do not report secondary users, runtime restarts or first boot/upgrade
|
||||||
&& !mService.mSystemServiceManager.isFirstBoot()) {
|
if (userId == UserHandle.USER_SYSTEM
|
||||||
|
&& !mService.mSystemServiceManager.isRuntimeRestarted()
|
||||||
|
&& !isFirstBootOrUpgrade()) {
|
||||||
int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000);
|
int uptimeSeconds = (int) (SystemClock.elapsedRealtime() / 1000);
|
||||||
MetricsLogger
|
MetricsLogger
|
||||||
.histogram(mService.mContext, "framework_boot_completed", uptimeSeconds);
|
.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) {
|
int stopUser(final int userId, final boolean force, final IStopUserCallback callback) {
|
||||||
if (mService.checkCallingPermission(INTERACT_ACROSS_USERS_FULL)
|
if (mService.checkCallingPermission(INTERACT_ACROSS_USERS_FULL)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|||||||
@@ -327,7 +327,6 @@ public final class SystemServer {
|
|||||||
// Create the system service manager.
|
// Create the system service manager.
|
||||||
mSystemServiceManager = new SystemServiceManager(mSystemContext);
|
mSystemServiceManager = new SystemServiceManager(mSystemContext);
|
||||||
mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart);
|
mSystemServiceManager.setRuntimeRestarted(mRuntimeRestart);
|
||||||
mSystemServiceManager.setFirstBoot(mFirstBoot);
|
|
||||||
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
|
LocalServices.addService(SystemServiceManager.class, mSystemServiceManager);
|
||||||
} finally {
|
} finally {
|
||||||
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
Trace.traceEnd(Trace.TRACE_TAG_SYSTEM_SERVER);
|
||||||
|
|||||||
Reference in New Issue
Block a user