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

Commit 36a94ddd authored by Andre Melendez's avatar Andre Melendez
Browse files

Updated activity dumpsys to include process capability flags.

Bug: 432782474
Test: manual (adb shell dumpsys activity --proto > activity.bin; m
graph_ams; graph_ams activity.bin --format json > activity.json; look
for capabilityFlags property)
Flag: EXEMPTED proto update

Change-Id: If72552023136b24f34e848b77a700c93d32c132b
parent 6a9ecb79
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -1106,6 +1106,47 @@ public class ActivityManager {
        return sb.toString();
    }

    // NOTE: If a new PROCESS_CAPABILITY is added, then new fields must be added
    // to frameworks/base/core/proto/android/app/enums.proto and the following method must
    // be updated to correctly map between them.
    // However, if the current ActivityManager values are merely modified, no update should be made
    // to enums.proto, to which values can only be added but never modified. Note that the proto
    // versions do NOT have the ordering restrictions of the ActivityManager process capabilities.
    /**
     * Maps ActivityManager.PROCESS_CAPABILITY_ values to enums.proto ProcessCapabilityEnum value.
     *
     * @param amInt a process capability of the form ActivityManager.PROCESS_CAPABILITY_
     * @return the value of the corresponding enums.proto ProcessCapabilityEnum value.
     * @hide
     */
    @android.ravenwood.annotation.RavenwoodKeep
    public static final int processCapabilityAmToProto(int amInt) {
        switch (amInt) {
            case PROCESS_CAPABILITY_FOREGROUND_LOCATION:
                return AppProtoEnums.PROCESS_CAPABILITY_FOREGROUND_LOCATION;
            case PROCESS_CAPABILITY_FOREGROUND_CAMERA:
                return AppProtoEnums.PROCESS_CAPABILITY_FOREGROUND_CAMERA;
            case PROCESS_CAPABILITY_FOREGROUND_MICROPHONE:
                return AppProtoEnums.PROCESS_CAPABILITY_FOREGROUND_MICROPHONE;
            case PROCESS_CAPABILITY_POWER_RESTRICTED_NETWORK:
                return AppProtoEnums.PROCESS_CAPABILITY_POWER_RESTRICTED_NETWORK;
            case PROCESS_CAPABILITY_BFSL:
                return AppProtoEnums.PROCESS_CAPABILITY_BFSL;
            case PROCESS_CAPABILITY_USER_RESTRICTED_NETWORK:
                return AppProtoEnums.PROCESS_CAPABILITY_USER_RESTRICTED_NETWORK;
            case PROCESS_CAPABILITY_FOREGROUND_AUDIO_CONTROL:
                return AppProtoEnums.PROCESS_CAPABILITY_FOREGROUND_AUDIO_CONTROL;
            case PROCESS_CAPABILITY_CPU_TIME:
                return AppProtoEnums.PROCESS_CAPABILITY_CPU_TIME;
            case PROCESS_CAPABILITY_IMPLICIT_CPU_TIME:
                return AppProtoEnums.PROCESS_CAPABILITY_IMPLICIT_CPU_TIME;
            default:
                // ActivityManager capabilities
                // could not be mapped to an AppProtoEnums ProcessCapability capability.
                return AppProtoEnums.PROCESS_CAPABILITY_UNKNOWN;
        }
    }

    // NOTE: If PROCESS_STATEs are added, then new fields must be added
    // to frameworks/base/core/proto/android/app/enums.proto and the following method must
    // be updated to correctly map between them.
+1 −0
Original line number Diff line number Diff line
@@ -909,6 +909,7 @@ message ProcessOomProto {
            optional float ultilization = 3; // ratio of cpu time usage
        }
        optional CpuRunTime service_run_time = 15;
        repeated .android.app.ProcessCapabilityEnum capability_flags = 16;
    }
    optional Detail detail = 15;
}
+12 −0
Original line number Diff line number Diff line
@@ -1278,6 +1278,17 @@ public final class ProcessList implements ProcessStateController.ProcessLruUpdat
        }
    }

    // write a process capabilities to the proto
    private static void writeProcessCapabilitiesListToProto(ProtoOutputStream proto, int cap) {
        for (int i = 0; i < 32; i++) {
            final int capability = 1 << i;
            if ((cap & capability) != 0) {
                final int protoCapability = ActivityManager.processCapabilityAmToProto(capability);
                proto.write(ProcessOomProto.Detail.CAPABILITY_FLAGS, protoCapability);
            }
        }
    }

    public static void appendRamKb(StringBuilder sb, long ramKb) {
        for (int j = 0, fact = 10; j < 6; j++, fact *= 10) {
            if (ramKb < fact) {
@@ -4766,6 +4777,7 @@ public final class ProcessList implements ProcessStateController.ProcessLruUpdat
                        makeProcStateProtoEnum(state.getCurProcState()));
                proto.write(ProcessOomProto.Detail.SET_STATE,
                        makeProcStateProtoEnum(state.getSetProcState()));
                writeProcessCapabilitiesListToProto(proto, state.getCurCapability());
                proto.write(ProcessOomProto.Detail.LAST_PSS, DebugUtils.sizeValueToString(
                        r.mProfile.getLastPss() * 1024, new StringBuilder()));
                proto.write(ProcessOomProto.Detail.LAST_SWAP_PSS, DebugUtils.sizeValueToString(