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

Commit 4cc4b538 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Fix potential overflow of launch event uptime" into sc-dev am: 90b85f3e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15044708

Change-Id: Ief1486e110250804a41706da4c7afe93d45ea684
parents a3f882fe 90b85f3e
Loading
Loading
Loading
Loading
+7 −8
Original line number Original line Diff line number Diff line
@@ -206,8 +206,8 @@ class ActivityMetricsLogger {
         * observer to identify which callbacks belong to a launch event.
         * observer to identify which callbacks belong to a launch event.
         */
         */
        final long mTransitionStartTimeNs;
        final long mTransitionStartTimeNs;
        /** The device uptime in seconds when this transition info is created. */
        /** The device uptime in millis when this transition info is created. */
        final int mCurrentTransitionDeviceUptime;
        final long mTransitionDeviceUptimeMs;
        /** The type can be cold (new process), warm (new activity), or hot (bring to front). */
        /** The type can be cold (new process), warm (new activity), or hot (bring to front). */
        final int mTransitionType;
        final int mTransitionType;
        /** Whether the process was already running when the transition started. */
        /** Whether the process was already running when the transition started. */
@@ -277,8 +277,7 @@ class ActivityMetricsLogger {
            mTransitionType = transitionType;
            mTransitionType = transitionType;
            mProcessRunning = processRunning;
            mProcessRunning = processRunning;
            mProcessSwitch = processSwitch;
            mProcessSwitch = processSwitch;
            mCurrentTransitionDeviceUptime =
            mTransitionDeviceUptimeMs = launchingState.mCurrentUpTimeMs;
                    (int) TimeUnit.MILLISECONDS.toSeconds(launchingState.mCurrentUpTimeMs);
            setLatestLaunchedActivity(r);
            setLatestLaunchedActivity(r);
            launchingState.mAssociatedTransitionInfo = this;
            launchingState.mAssociatedTransitionInfo = this;
            if (options != null) {
            if (options != null) {
@@ -908,7 +907,7 @@ class ActivityMetricsLogger {
        final TransitionInfoSnapshot infoSnapshot = new TransitionInfoSnapshot(info);
        final TransitionInfoSnapshot infoSnapshot = new TransitionInfoSnapshot(info);
        if (info.isInterestingToLoggerAndObserver()) {
        if (info.isInterestingToLoggerAndObserver()) {
            mLoggerHandler.post(() -> logAppTransition(
            mLoggerHandler.post(() -> logAppTransition(
                    info.mCurrentTransitionDeviceUptime, info.mCurrentTransitionDelayMs,
                    info.mTransitionDeviceUptimeMs, info.mCurrentTransitionDelayMs,
                    infoSnapshot, isHibernating));
                    infoSnapshot, isHibernating));
        }
        }
        mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
        mLoggerHandler.post(() -> logAppDisplayed(infoSnapshot));
@@ -920,7 +919,7 @@ class ActivityMetricsLogger {
    }
    }


    // This gets called on another thread without holding the activity manager lock.
    // This gets called on another thread without holding the activity manager lock.
    private void logAppTransition(int currentTransitionDeviceUptime, int currentTransitionDelayMs,
    private void logAppTransition(long transitionDeviceUptimeMs, int currentTransitionDelayMs,
            TransitionInfoSnapshot info, boolean isHibernating) {
            TransitionInfoSnapshot info, boolean isHibernating) {
        final LogMaker builder = new LogMaker(APP_TRANSITION);
        final LogMaker builder = new LogMaker(APP_TRANSITION);
        builder.setPackageName(info.packageName);
        builder.setPackageName(info.packageName);
@@ -937,7 +936,7 @@ class ActivityMetricsLogger {
        }
        }
        builder.addTaggedData(APP_TRANSITION_IS_EPHEMERAL, isInstantApp ? 1 : 0);
        builder.addTaggedData(APP_TRANSITION_IS_EPHEMERAL, isInstantApp ? 1 : 0);
        builder.addTaggedData(APP_TRANSITION_DEVICE_UPTIME_SECONDS,
        builder.addTaggedData(APP_TRANSITION_DEVICE_UPTIME_SECONDS,
                currentTransitionDeviceUptime);
                TimeUnit.MILLISECONDS.toSeconds(transitionDeviceUptimeMs));
        builder.addTaggedData(APP_TRANSITION_DELAY_MS, currentTransitionDelayMs);
        builder.addTaggedData(APP_TRANSITION_DELAY_MS, currentTransitionDelayMs);
        builder.setSubtype(info.reason);
        builder.setSubtype(info.reason);
        if (info.startingWindowDelayMs != INVALID_DELAY) {
        if (info.startingWindowDelayMs != INVALID_DELAY) {
@@ -972,7 +971,7 @@ class ActivityMetricsLogger {
                info.launchedActivityName,
                info.launchedActivityName,
                info.launchedActivityLaunchedFromPackage,
                info.launchedActivityLaunchedFromPackage,
                isInstantApp,
                isInstantApp,
                currentTransitionDeviceUptime * 1000,
                transitionDeviceUptimeMs,
                info.reason,
                info.reason,
                currentTransitionDelayMs,
                currentTransitionDelayMs,
                info.startingWindowDelayMs,
                info.startingWindowDelayMs,