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

Commit c89425b4 authored by Yisroel Forta's avatar Yisroel Forta
Browse files

Fix AppStartInfo ProcessRecord lookup

AppStartInfo is using package name for process record lookup, rather
than process name, for Activity component starts only. This results
in being unable to obtain the process record for activity based
starts for apps which set a process name, which subsequently causes
the start record to be discarded.

Bug: 443136429
Test: trigger activity starts for an app which overrides process name
  confirm using shell command that records are now added as expected.
Test: atest WmTests:ActivityMetricsLaunchObserverTests
Flag: com.android.server.am.app_start_info_process_name_fix
Change-Id: I6aa5c0962f3f64c5d28348ad0646f2a91f7f84f8
parent 66e539d5
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1074,12 +1074,15 @@ public class ActivityManagerService extends IActivityManager.Stub
        }
        @Override
        public void onActivityLaunched(long id, ComponentName name, int temperature, int userId) {
        public void onActivityLaunched(long id, ComponentName name, int temperature, int userId,
                    String processName) {
            mAppProfiler.onActivityLaunched();
            synchronized (ActivityManagerService.this) {
                ProcessRecord record = null;
                try {
                    record = getProcessRecordLocked(name.getPackageName(), mContext
                    String processRecordName = Flags.appStartInfoProcessNameFix()
                            ? processName : name.getPackageName();
                    record = getProcessRecordLocked(processRecordName, mContext
                            .getPackageManager().getPackageUidAsUser(name.getPackageName(), 0,
                            userId));
                } catch (NameNotFoundException nnfe) {
+10 −0
Original line number Diff line number Diff line
@@ -272,3 +272,13 @@ flag {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "app_start_info_process_name_fix"
    namespace: "system_performance"
    description: "Use process name to lookup ProcessRecord."
    bug: "443136429"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -144,9 +144,10 @@ public class ActivityMetricsLaunchObserver {
     * @param name The launching activity name.
     * @param temperature The temperature at which a launch sequence had started.
     * @param userId The id of the user the activity is being launched for.
     * @param processName The name of the process that the launching activity belongs to.
     */
    public void onActivityLaunched(long id, ComponentName name, @Temperature int temperature,
            int userId) {
            int userId, String processName) {
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -1814,7 +1814,7 @@ class ActivityMetricsLogger {
        // Beginning a launch is timing sensitive and so should be observed as soon as possible.
        mLaunchObserver.onActivityLaunched(info.mLaunchingState.mStartUptimeNs,
                info.mLastLaunchedActivity.mActivityComponent, temperature,
                info.mLastLaunchedActivity.mUserId);
                info.mLastLaunchedActivity.mUserId, info.mLastLaunchedActivity.processName);

        Trace.traceEnd(Trace.TRACE_TAG_ACTIVITY_MANAGER);
    }
+5 −4
Original line number Diff line number Diff line
@@ -84,10 +84,11 @@ class LaunchObserverRegistryImpl extends ActivityMetricsLaunchObserver implement
    }

    @Override
    public void onActivityLaunched(long id, ComponentName name, int temperature, int userId) {
    public void onActivityLaunched(long id, ComponentName name, int temperature, int userId,
            String processName) {
        mHandler.sendMessage(PooledLambda.obtainMessage(
                LaunchObserverRegistryImpl::handleOnActivityLaunched,
                this, id, name, temperature, userId));
                this, id, name, temperature, userId, processName));
    }

    @Override
@@ -138,10 +139,10 @@ class LaunchObserverRegistryImpl extends ActivityMetricsLaunchObserver implement
    }

    private void handleOnActivityLaunched(long id, ComponentName name,
            @Temperature int temperature, int userId) {
            @Temperature int temperature, int userId, String processName) {
        // Traverse start-to-end to meet the registerLaunchObserver multi-cast order guarantee.
        for (int i = 0; i < mList.size(); i++) {
            mList.get(i).onActivityLaunched(id, name, temperature, userId);
            mList.get(i).onActivityLaunched(id, name, temperature, userId, processName);
        }
    }

Loading