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

Commit a76dae6e authored by Kevin Jeon's avatar Kevin Jeon Committed by Android (Google) Code Review
Browse files

Merge "Add a global setting for forcing PSS collection" into main

parents 1697b42f 800a3c47
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -15020,6 +15020,16 @@ public final class Settings {
        public static final String FOREGROUND_SERVICE_STARTS_LOGGING_ENABLED =
                "foreground_service_starts_logging_enabled";
        /**
         * Describes whether AM's AppProfiler should collect PSS even if RSS is the default. This
         * can be set by a user in developer settings.
         * Default: 0
         * @hide
         */
        @Readable
        public static final String FORCE_ENABLE_PSS_PROFILING =
                "force_enable_pss_profiling";
        /**
         * @hide
         * @see com.android.server.appbinding.AppBindingConstants
+1 −0
Original line number Diff line number Diff line
@@ -112,5 +112,6 @@ public class GlobalSettings {
        Settings.Global.Wearable.SCREENSHOT_ENABLED,
        Settings.Global.Wearable.SCREEN_UNLOCK_SOUND_ENABLED,
        Settings.Global.Wearable.CHARGING_SOUNDS_ENABLED,
        Settings.Global.FORCE_ENABLE_PSS_PROFILING,
    };
}
+1 −0
Original line number Diff line number Diff line
@@ -447,5 +447,6 @@ public class GlobalSettingsValidators {
        VALIDATORS.put(Global.Wearable.WEAR_LAUNCHER_UI_MODE, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Global.Wearable.WEAR_POWER_ANOMALY_SERVICE_ENABLED, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.Wearable.CONNECTIVITY_KEEP_DATA_ON, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Global.FORCE_ENABLE_PSS_PROFILING, BOOLEAN_VALIDATOR);
    }
}
+16 −0
Original line number Diff line number Diff line
@@ -650,6 +650,10 @@ final class ActivityManagerConstants extends ContentObserver {
    // foreground service background start restriction.
    volatile boolean mFgsStartRestrictionNotificationEnabled = false;

    // Indicates whether PSS profiling in AppProfiler is force-enabled, even if RSS is used by
    // default. Controlled by Settings.Global.FORCE_ENABLE_PSS_PROFILING
    volatile boolean mForceEnablePssProfiling = false;

    /**
     * Indicates whether the foreground service background start restriction is enabled for
     * caller app that is targeting S+.
@@ -979,6 +983,9 @@ final class ActivityManagerConstants extends ContentObserver {
    private static final Uri ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI =
            Settings.Global.getUriFor(Settings.Global.ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS);

    private static final Uri FORCE_ENABLE_PSS_PROFILING_URI =
            Settings.Global.getUriFor(Settings.Global.FORCE_ENABLE_PSS_PROFILING);

    /**
     * The threshold to decide if a given association should be dumped into metrics.
     */
@@ -1389,6 +1396,7 @@ final class ActivityManagerConstants extends ContentObserver {
            mResolver.registerContentObserver(ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI,
                    false, this);
        }
        mResolver.registerContentObserver(FORCE_ENABLE_PSS_PROFILING_URI, false, this);
        updateConstants();
        if (mSystemServerAutomaticHeapDumpEnabled) {
            updateEnableAutomaticSystemServerHeapDumps();
@@ -1404,6 +1412,7 @@ final class ActivityManagerConstants extends ContentObserver {
        // The following read from Settings.
        updateActivityStartsLoggingEnabled();
        updateForegroundServiceStartsLoggingEnabled();
        updateForceEnablePssProfiling();
        // Read DropboxRateLimiter params from flags.
        mService.initDropboxRateLimiter();
    }
@@ -1445,6 +1454,8 @@ final class ActivityManagerConstants extends ContentObserver {
            updateForegroundServiceStartsLoggingEnabled();
        } else if (ENABLE_AUTOMATIC_SYSTEM_SERVER_HEAP_DUMPS_URI.equals(uri)) {
            updateEnableAutomaticSystemServerHeapDumps();
        } else if (FORCE_ENABLE_PSS_PROFILING_URI.equals(uri)) {
            updateForceEnablePssProfiling();
        }
    }

@@ -1559,6 +1570,11 @@ final class ActivityManagerConstants extends ContentObserver {
                Settings.Global.ACTIVITY_STARTS_LOGGING_ENABLED, 1) == 1;
    }

    private void updateForceEnablePssProfiling() {
        mForceEnablePssProfiling = Settings.Global.getInt(mResolver,
                Settings.Global.FORCE_ENABLE_PSS_PROFILING, 0) == 1;
    }

    private void updateBackgroundActivityStarts() {
        mFlagBackgroundActivityStartsEnabled = DeviceConfig.getBoolean(
                DeviceConfig.NAMESPACE_ACTIVITY_MANAGER,
+4 −5
Original line number Diff line number Diff line
@@ -327,7 +327,6 @@ import android.os.Debug;
import android.os.DropBoxManager;
import android.os.FactoryTest;
import android.os.FileUtils;
import android.os.Flags;
import android.os.Handler;
import android.os.IBinder;
import android.os.IDeviceIdentifiersPolicyService;
@@ -8608,7 +8607,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                        final long initialIdlePssOrRss, lastPssOrRss, lastSwapPss;
                        synchronized (mAppProfiler.mProfilerLock) {
                            initialIdlePssOrRss = pr.getInitialIdlePssOrRss();
                            lastPssOrRss = !Flags.removeAppProfilerPssCollection()
                            lastPssOrRss = mAppProfiler.isProfilingPss()
                                    ? pr.getLastPss() : pr.getLastRss();
                            lastSwapPss = pr.getLastSwapPss();
                        }
@@ -8618,14 +8617,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                            final StringBuilder sb2 = new StringBuilder(128);
                            sb2.append("Kill");
                            sb2.append(proc.processName);
                            if (!Flags.removeAppProfilerPssCollection()) {
                            if (mAppProfiler.isProfilingPss()) {
                                sb2.append(" in idle maint: pss=");
                            } else {
                                sb2.append(" in idle maint: rss=");
                            }
                            sb2.append(lastPssOrRss);
                            if (!Flags.removeAppProfilerPssCollection()) {
                            if (mAppProfiler.isProfilingPss()) {
                                sb2.append(", swapPss=");
                                sb2.append(lastSwapPss);
                                sb2.append(", initialPss=");
@@ -8640,7 +8639,7 @@ public class ActivityManagerService extends IActivityManager.Stub
                            Slog.wtfQuiet(TAG, sb2.toString());
                            mHandler.post(() -> {
                                synchronized (ActivityManagerService.this) {
                                    proc.killLocked(!Flags.removeAppProfilerPssCollection()
                                    proc.killLocked(mAppProfiler.isProfilingPss()
                                            ? "idle maint (pss " : "idle maint (rss " + lastPssOrRss
                                            + " from " + initialIdlePssOrRss + ")",
                                            ApplicationExitInfo.REASON_OTHER,
Loading