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

Commit b4be9771 authored by Yisroel Forta's avatar Yisroel Forta Committed by Android (Google) Code Review
Browse files

Merge "Pass profiling triggers" into main

parents 41104b7c cde4d019
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -240,6 +240,7 @@ java_library_static {
        "aconfig_new_storage_flags_lib",
        "powerstats_flags_lib",
        "locksettings_flags_lib",
        "profiling_flags_lib",
    ],
    javac_shard_size: 50,
    javacflags: [
@@ -255,6 +256,13 @@ java_library_static {
            "FlaggedApi",
        ],
    },
    jarjar_rules: ":services-jarjar-rules",
    apex_available: ["//apex_available:platform"],
}

filegroup {
    name: "services-jarjar-rules",
    srcs: ["services-jarjar-rules.txt"],
}

java_genrule {
+14 −1
Original line number Diff line number Diff line
@@ -337,6 +337,8 @@ import android.os.PowerManager;
import android.os.PowerManager.ServiceType;
import android.os.PowerManagerInternal;
import android.os.Process;
import android.os.ProfilingServiceHelper;
import android.os.ProfilingTrigger;
import android.os.RemoteCallback;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -1089,7 +1091,18 @@ public class ActivityManagerService extends IActivityManager.Stub
        @Override
        public void onReportFullyDrawn(long id, long timestampNanos) {
            mProcessList.getAppStartInfoTracker().onActivityReportFullyDrawn(id, timestampNanos);
            ApplicationStartInfo startInfo = mProcessList.getAppStartInfoTracker()
                    .onActivityReportFullyDrawn(id, timestampNanos);
            if (android.os.profiling.Flags.systemTriggeredProfilingNew()
                    && startInfo != null
                    && startInfo.getStartType() == ApplicationStartInfo.START_TYPE_COLD
                    && startInfo.getPackageName() != null) {
                ProfilingServiceHelper.getInstance().onProfilingTriggerOccurred(
                        startInfo.getRealUid(),
                        startInfo.getPackageName(),
                        ProfilingTrigger.TRIGGER_TYPE_APP_COLD_START_ACTIVITY);
            }
        }
    };
+11 −1
Original line number Diff line number Diff line
@@ -20,7 +20,8 @@ import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;

import android.content.pm.ApplicationInfo;
import android.os.Process;
import android.os.ProfilingServiceHelper;
import android.os.ProfilingTrigger;
import android.os.SystemClock;
import android.os.Trace;
import android.util.ArraySet;
@@ -240,6 +241,15 @@ class AnrHelper {
                        || startTime < SELF_ONLY_AFTER_BOOT_MS;
                r.appNotResponding(onlyDumpSelf);
                final long endTime = SystemClock.uptimeMillis();

                if (android.os.profiling.Flags.systemTriggeredProfilingNew() && r.mAppInfo != null
                        && r.mAppInfo.packageName != null) {
                    ProfilingServiceHelper.getInstance().onProfilingTriggerOccurred(
                            r.mUid,
                            r.mAppInfo.packageName,
                            ProfilingTrigger.TRIGGER_TYPE_ANR);
                }

                Slog.d(TAG, "Completed ANR of " + r.mApp.processName + " in "
                        + (endTime - startTime) + "ms, latency " + reportLatency
                        + (onlyDumpSelf ? "ms (expired, only dump ANR app)" : "ms"));
+7 −4
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ApplicationStartInfo;
import android.app.Flags;
import android.app.IApplicationStartInfoCompleteListener;
@@ -419,23 +420,25 @@ public final class AppStartInfoTracker {
     * Should only be called for Activity launch sequences from an instance of
     * {@link ActivityMetricsLaunchObserver}.
     */
    void onActivityReportFullyDrawn(long id, long timestampNanos) {
    @Nullable
    ApplicationStartInfo onActivityReportFullyDrawn(long id, long timestampNanos) {
        synchronized (mLock) {
            if (!mEnabled) {
                return;
                return null;
            }
            int index = mInProgressRecords.indexOfKey(id);
            if (index < 0) {
                return;
                return null;
            }
            ApplicationStartInfo info = mInProgressRecords.valueAt(index);
            if (info == null) {
                mInProgressRecords.removeAt(index);
                return;
                return null;
            }
            info.addStartupTimestamp(ApplicationStartInfo.START_TIMESTAMP_FULLY_DRAWN,
                    timestampNanos);
            mInProgressRecords.removeAt(index);
            return info;
        }
    }

+2 −0
Original line number Diff line number Diff line
# For profiling flags
rule android.os.profiling.** android.internal.os.profiling.@1