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

Commit 673d0dd1 authored by Riddle Hsu's avatar Riddle Hsu Committed by Automerger Merge Worker
Browse files

Merge "Pass real calling uid to metrics logger if available" into sc-dev am:...

Merge "Pass real calling uid to metrics logger if available" into sc-dev am: 87a5a818 am: 84924257

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

Change-Id: I38b6565367315d43509cbb14cd3dc3da4b0ddcc7
parents eb657cab 84924257
Loading
Loading
Loading
Loading
+3 −13
Original line number Original line Diff line number Diff line
@@ -80,7 +80,6 @@ import android.content.pm.IncrementalStatesInfo;
import android.content.pm.dex.ArtManagerInternal;
import android.content.pm.dex.ArtManagerInternal;
import android.content.pm.dex.PackageOptimizationInfo;
import android.content.pm.dex.PackageOptimizationInfo;
import android.metrics.LogMaker;
import android.metrics.LogMaker;
import android.os.Binder;
import android.os.Handler;
import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.SystemClock;
import android.os.SystemClock;
@@ -507,22 +506,13 @@ class ActivityMetricsLogger {
        return notifyActivityLaunching(intent, null /* caller */, IGNORE_CALLER);
        return notifyActivityLaunching(intent, null /* caller */, IGNORE_CALLER);
    }
    }


    /**
     * If the caller is found in an active transition, it will be considered as consecutive launch
     * and coalesced into the active transition.
     *
     * @see #notifyActivityLaunching(Intent, ActivityRecord, int)
     */
    LaunchingState notifyActivityLaunching(Intent intent, @Nullable ActivityRecord caller) {
        return notifyActivityLaunching(intent, caller, Binder.getCallingUid());
    }

    /**
    /**
     * Notifies the tracker at the earliest possible point when we are starting to launch an
     * Notifies the tracker at the earliest possible point when we are starting to launch an
     * activity. The caller must ensure that {@link #notifyActivityLaunched} will be called later
     * activity. The caller must ensure that {@link #notifyActivityLaunched} will be called later
     * with the returned {@link LaunchingState}.
     * with the returned {@link LaunchingState}. If the caller is found in an active transition,
     * it will be considered as consecutive launch and coalesced into the active transition.
     */
     */
    private LaunchingState notifyActivityLaunching(Intent intent, @Nullable ActivityRecord caller,
    LaunchingState notifyActivityLaunching(Intent intent, @Nullable ActivityRecord caller,
            int callingUid) {
            int callingUid) {
        final long transitionStartTimeNs = SystemClock.elapsedRealtimeNanos();
        final long transitionStartTimeNs = SystemClock.elapsedRealtimeNanos();
        TransitionInfo existingInfo = null;
        TransitionInfo existingInfo = null;
+3 −1
Original line number Original line Diff line number Diff line
@@ -618,8 +618,10 @@ class ActivityStarter {
            final LaunchingState launchingState;
            final LaunchingState launchingState;
            synchronized (mService.mGlobalLock) {
            synchronized (mService.mGlobalLock) {
                final ActivityRecord caller = ActivityRecord.forTokenLocked(mRequest.resultTo);
                final ActivityRecord caller = ActivityRecord.forTokenLocked(mRequest.resultTo);
                final int callingUid = mRequest.realCallingUid == Request.DEFAULT_REAL_CALLING_UID
                        ?  Binder.getCallingUid() : mRequest.realCallingUid;
                launchingState = mSupervisor.getActivityMetricsLogger().notifyActivityLaunching(
                launchingState = mSupervisor.getActivityMetricsLogger().notifyActivityLaunching(
                        mRequest.intent, caller);
                        mRequest.intent, caller, callingUid);
            }
            }


            // If the caller hasn't already resolved the activity, we're willing
            // If the caller hasn't already resolved the activity, we're willing
+4 −3
Original line number Original line Diff line number Diff line
@@ -306,7 +306,8 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
    private void notifyActivityLaunching(Intent intent) {
    private void notifyActivityLaunching(Intent intent) {
        final ActivityMetricsLogger.LaunchingState previousState = mLaunchingState;
        final ActivityMetricsLogger.LaunchingState previousState = mLaunchingState;
        mLaunchingState = mActivityMetricsLogger.notifyActivityLaunching(intent,
        mLaunchingState = mActivityMetricsLogger.notifyActivityLaunching(intent,
                mLaunchTopByTrampoline ? mTrampolineActivity : null /* caller */);
                mLaunchTopByTrampoline ? mTrampolineActivity : null /* caller */,
                mLaunchTopByTrampoline ? mTrampolineActivity.getUid() : 0);
        if (mLaunchTopByTrampoline) {
        if (mLaunchTopByTrampoline) {
            // The transition of TrampolineActivity has not been completed, so when the next
            // The transition of TrampolineActivity has not been completed, so when the next
            // activity is starting from it, the same launching state should be returned.
            // activity is starting from it, the same launching state should be returned.
@@ -429,7 +430,7 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {
                .setCreateTask(true)
                .setCreateTask(true)
                .build();
                .build();
        mActivityMetricsLogger.notifyActivityLaunching(activityOnNewTask.intent,
        mActivityMetricsLogger.notifyActivityLaunching(activityOnNewTask.intent,
                mTrampolineActivity /* caller */);
                mTrampolineActivity /* caller */, mTrampolineActivity.getUid());
        notifyActivityLaunched(START_SUCCESS, activityOnNewTask);
        notifyActivityLaunched(START_SUCCESS, activityOnNewTask);


        transitToDrawnAndVerifyOnLaunchFinished(activityOnNewTask);
        transitToDrawnAndVerifyOnLaunchFinished(activityOnNewTask);
@@ -453,7 +454,7 @@ public class ActivityMetricsLaunchObserverTests extends WindowTestsBase {


        // Before TopActivity is drawn, it launches another activity on a different display.
        // Before TopActivity is drawn, it launches another activity on a different display.
        mActivityMetricsLogger.notifyActivityLaunching(activityOnNewDisplay.intent,
        mActivityMetricsLogger.notifyActivityLaunching(activityOnNewDisplay.intent,
                mTopActivity /* caller */);
                mTopActivity /* caller */, mTopActivity.getUid());
        notifyActivityLaunched(START_SUCCESS, activityOnNewDisplay);
        notifyActivityLaunched(START_SUCCESS, activityOnNewDisplay);


        // There should be 2 events instead of coalescing as one event.
        // There should be 2 events instead of coalescing as one event.