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

Commit 62bcd514 authored by Fyodor Kupolov's avatar Fyodor Kupolov Committed by android-build-merger
Browse files

Merge "Additional log instrumentation for multi-user" into oc-dev am: dadc0563

am: f2ffdb28

Change-Id: Iaaacd4a7044ae57f57b9ed0f5179e341f9ed354b
parents 48c00160 f2ffdb28
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -5094,24 +5094,26 @@ public final class ActivityThread {
        // caused by other sources, such as overlays. That means we want to be as conservative
        // about code changes as possible. Take the diff of the old ApplicationInfo and the new
        // to see if anything needs to change.
        synchronized (mResourcesManager) {
        LoadedApk apk;
        LoadedApk resApk;
        // Update all affected loaded packages with new package information
        synchronized (mResourcesManager) {
            WeakReference<LoadedApk> ref = mPackages.get(ai.packageName);
            LoadedApk apk = ref != null ? ref.get() : null;
            apk = ref != null ? ref.get() : null;
            ref = mResourcePackages.get(ai.packageName);
            resApk = ref != null ? ref.get() : null;
        }
        if (apk != null) {
            final ArrayList<String> oldPaths = new ArrayList<>();
            LoadedApk.makePaths(this, apk.getApplicationInfo(), oldPaths);
            apk.updateApplicationInfo(ai, oldPaths);
        }

            ref = mResourcePackages.get(ai.packageName);
            apk = ref != null ? ref.get() : null;
            if (apk != null) {
        if (resApk != null) {
            final ArrayList<String> oldPaths = new ArrayList<>();
                LoadedApk.makePaths(this, apk.getApplicationInfo(), oldPaths);
                apk.updateApplicationInfo(ai, oldPaths);
            LoadedApk.makePaths(this, resApk.getApplicationInfo(), oldPaths);
            resApk.updateApplicationInfo(ai, oldPaths);
        }

        synchronized (mResourcesManager) {
            // Update all affected Resources objects to use new ResourcesImpl
            mResourcesManager.applyNewResourceDirsLocked(ai.sourceDir, ai.resourceDirs);
        }
+29 −6
Original line number Diff line number Diff line
@@ -183,8 +183,10 @@ public abstract class BatteryStats implements Parcelable {
     *   - Wakelock data (wl) gets current and max times.
     * New in version 20:
     *   - Background timers and counters for: Sensor, BluetoothScan, WifiScan, Jobs, Syncs.
     * New in version 21:
     *   - Actual (not just apportioned) Wakelock time is also recorded.
     */
    static final String CHECKIN_VERSION = "20";
    static final String CHECKIN_VERSION = "21";

    /**
     * Old version, we hit 9 and ran out of room, need to remove.
@@ -205,6 +207,12 @@ public abstract class BatteryStats implements Parcelable {
    private static final String VIBRATOR_DATA = "vib";
    private static final String FOREGROUND_DATA = "fg";
    private static final String STATE_TIME_DATA = "st";
    // wl line is:
    // BATTERY_STATS_CHECKIN_VERSION, uid, which, "wl", name,
    // full totalTime,    'f', count, current duration, max duration, total duration,
    // partial totalTime, 'p', count, current duration, max duration, total duration,
    // window totalTime,  'w', count, current duration, max duration, total duration
    // [Currently, full and window wakelocks have durations current = max = total = -1]
    private static final String WAKELOCK_DATA = "wl";
    private static final String SYNC_DATA = "sy";
    private static final String JOB_DATA = "jb";
@@ -2659,6 +2667,12 @@ public abstract class BatteryStats implements Parcelable {
                    sb.append(" max=");
                    sb.append(maxDurationMs);
                }
                // Put actual time if it is available and different from totalTimeMillis.
                final long totalDurMs = timer.getTotalDurationMsLocked(elapsedRealtimeUs/1000);
                if (totalDurMs > totalTimeMillis) {
                    sb.append(" actual=");
                    sb.append(totalDurMs);
                }
                if (timer.isRunningLocked()) {
                    final long currentMs = timer.getCurrentDurationMsLocked(elapsedRealtimeUs/1000);
                    if (currentMs >= 0) {
@@ -2742,13 +2756,15 @@ public abstract class BatteryStats implements Parcelable {
            long elapsedRealtimeUs, String name, int which, String linePrefix) {
        long totalTimeMicros = 0;
        int count = 0;
        long max = -1;
        long current = -1;
        long max = 0;
        long current = 0;
        long totalDuration = 0;
        if (timer != null) {
            totalTimeMicros = timer.getTotalTimeLocked(elapsedRealtimeUs, which);
            count = timer.getCountLocked(which);
            current = timer.getCurrentDurationMsLocked(elapsedRealtimeUs/1000);
            max = timer.getMaxDurationMsLocked(elapsedRealtimeUs/1000);
            totalDuration = timer.getTotalDurationMsLocked(elapsedRealtimeUs/1000);
        }
        sb.append(linePrefix);
        sb.append((totalTimeMicros + 500) / 1000); // microseconds to milliseconds with rounding
@@ -2759,6 +2775,13 @@ public abstract class BatteryStats implements Parcelable {
        sb.append(current);
        sb.append(',');
        sb.append(max);
        // Partial, full, and window wakelocks are pooled, so totalDuration is meaningful (albeit
        // not always tracked). Kernel wakelocks (which have name == null) have no notion of
        // totalDuration independent of totalTimeMicros (since they are not pooled).
        if (name != null) {
            sb.append(',');
            sb.append(totalDuration);
        }
        return ",";
    }

+2 −0
Original line number Diff line number Diff line
@@ -740,6 +740,8 @@ class AppErrors {
        }
        // If we've created a crash dialog, show it without the lock held
        if(data.proc.crashDialog != null) {
            Slog.i(TAG, "Showing crash dialog for package " + data.proc.info.packageName
                    + " u" + data.proc.userId);
            data.proc.crashDialog.show();
        }
    }
+9 −2
Original line number Diff line number Diff line
@@ -439,7 +439,7 @@ final class UserController {
                }
            }

            Slog.d(TAG, "Sending BOOT_COMPLETE user #" + userId);
            Slog.i(TAG, "Sending BOOT_COMPLETE user #" + userId);
            // Do not report secondary users, runtime restarts or first boot/upgrade
            if (userId == UserHandle.USER_SYSTEM
                    && !mInjector.isRuntimeRestarted() && !mInjector.isFirstBootOrUpgrade()) {
@@ -451,7 +451,14 @@ final class UserController {
            bootIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
            bootIntent.addFlags(Intent.FLAG_RECEIVER_NO_ABORT
                    | Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
            mInjector.broadcastIntentLocked(bootIntent, null, null, 0, null, null,
            mInjector.broadcastIntentLocked(bootIntent, null, new IIntentReceiver.Stub() {
                @Override
                public void performReceive(Intent intent, int resultCode, String data,
                        Bundle extras, boolean ordered, boolean sticky, int sendingUser)
                        throws RemoteException {
                    Slog.i(UserController.TAG, "Finished processing BOOT_COMPLETED for u" + userId);
                }
            }, 0, null, null,
                    new String[] { android.Manifest.permission.RECEIVE_BOOT_COMPLETED },
                    AppOpsManager.OP_NONE, null, true, false, MY_PID, SYSTEM_UID, userId);
        }
+11 −11
Original line number Diff line number Diff line
@@ -567,22 +567,27 @@ public final class NightDisplayService extends SystemService

        private final TwilightManager mTwilightManager;

        private Calendar mLastActivatedTime;

        TwilightAutoMode() {
            mTwilightManager = getLocalService(TwilightManager.class);
        }

        private void updateActivated(TwilightState state) {
            boolean activate = state != null && state.isNight();
            if (state != null && mLastActivatedTime != null) {
            if (state == null) {
                // If there isn't a valid TwilightState then just keep the current activated
                // state.
                return;
            }

            boolean activate = state.isNight();
            final Calendar lastActivatedTime = getLastActivatedTime();
            if (lastActivatedTime != null) {
                final Calendar now = Calendar.getInstance();
                final Calendar sunrise = state.sunrise();
                final Calendar sunset = state.sunset();

                // Maintain the existing activated state if within the current period.
                if (mLastActivatedTime.before(now)
                        && (mLastActivatedTime.after(sunrise) ^ mLastActivatedTime.after(sunset))) {
                if (lastActivatedTime.before(now)
                        && (lastActivatedTime.after(sunrise) ^ lastActivatedTime.after(sunset))) {
                    activate = mController.isActivated();
                }
            }
@@ -595,7 +600,6 @@ public final class NightDisplayService extends SystemService
        @Override
        public void onStart() {
            mTwilightManager.registerListener(this, mHandler);
            mLastActivatedTime = getLastActivatedTime();

            // Force an update to initialize state.
            updateActivated(mTwilightManager.getLastTwilightState());
@@ -604,14 +608,10 @@ public final class NightDisplayService extends SystemService
        @Override
        public void onStop() {
            mTwilightManager.unregisterListener(this);
            mLastActivatedTime = null;
        }

        @Override
        public void onActivated(boolean activated) {
            if (mIsActivated != null) {
                mLastActivatedTime = getLastActivatedTime();
            }
        }

        @Override
Loading