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

Commit b93b7971 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Update to the ActivityManager proto"

parents 5694b0a6 db026a28
Loading
Loading
Loading
Loading
+4 −5
Original line number Original line Diff line number Diff line
@@ -21,7 +21,7 @@ package android.os.statsd;
option java_package = "com.android.os";
option java_package = "com.android.os";
option java_outer_classname = "AtomsProto";
option java_outer_classname = "AtomsProto";


import "frameworks/base/core/proto/android/app/activitymanager.proto";
import "frameworks/base/core/proto/android/app/enums.proto";


/**
/**
 * The master atom class. This message defines all of the available
 * The master atom class. This message defines all of the available
@@ -44,7 +44,7 @@ message Atom {
        BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
        BleUnoptimizedScanStateChanged ble_unoptimized_scan_state_changed = 3;
        BleScanResultReceived ble_scan_result_received = 4;
        BleScanResultReceived ble_scan_result_received = 4;
        SensorStateChanged sensor_state_changed = 5;
        SensorStateChanged sensor_state_changed = 5;
        GpsScanStateChanged gps_scan_state_changed = 6; // TODO: untested
        GpsScanStateChanged gps_scan_state_changed = 6;
        SyncStateChanged sync_state_changed = 7;
        SyncStateChanged sync_state_changed = 7;
        ScheduledJobStateChanged scheduled_job_state_changed = 8;
        ScheduledJobStateChanged scheduled_job_state_changed = 8;
        ScreenBrightnessChanged screen_brightness_changed = 9;
        ScreenBrightnessChanged screen_brightness_changed = 9;
@@ -185,9 +185,8 @@ message ScreenStateChanged {
message UidProcessStateChanged {
message UidProcessStateChanged {
    optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
    optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation


    // The state.
    // The state, from frameworks/base/core/proto/android/app/enums.proto.
    // TODO: Use the real (mapped) process states.
    optional android.app.ProcessStateEnum state = 2;
    optional android.app.ProcessState state = 2;
}
}


/**
/**
+55 −5
Original line number Original line Diff line number Diff line
@@ -575,18 +575,68 @@ public class ActivityManager {
    /** @hide Process does not exist. */
    /** @hide Process does not exist. */
    public static final int PROCESS_STATE_NONEXISTENT = 19;
    public static final int PROCESS_STATE_NONEXISTENT = 19;


    // NOTE: If PROCESS_STATEs are added or changed, then new fields must be added
    // NOTE: If PROCESS_STATEs are added, then new fields must be added
    // to frameworks/base/core/proto/android/app/activitymanager.proto and the following method must
    // to frameworks/base/core/proto/android/app/enums.proto and the following method must
    // be updated to correctly map between them.
    // 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 state.
    /**
    /**
     * Maps ActivityManager.PROCESS_STATE_ values to ProcessState enum.
     * Maps ActivityManager.PROCESS_STATE_ values to enums.proto ProcessStateEnum value.
     *
     *
     * @param amInt a process state of the form ActivityManager.PROCESS_STATE_
     * @param amInt a process state of the form ActivityManager.PROCESS_STATE_
     * @return the value of the corresponding ActivityManager's ProcessState enum.
     * @return the value of the corresponding enums.proto ProcessStateEnum value.
     * @hide
     * @hide
     */
     */
    public static final int processStateAmToProto(int amInt) {
    public static final int processStateAmToProto(int amInt) {
        return amInt * 100;
        switch (amInt) {
            case PROCESS_STATE_UNKNOWN:
                return AppProtoEnums.PROCESS_STATE_UNKNOWN;
            case PROCESS_STATE_PERSISTENT:
                return AppProtoEnums.PROCESS_STATE_PERSISTENT;
            case PROCESS_STATE_PERSISTENT_UI:
                return AppProtoEnums.PROCESS_STATE_PERSISTENT_UI;
            case PROCESS_STATE_TOP:
                return AppProtoEnums.PROCESS_STATE_TOP;
            case PROCESS_STATE_FOREGROUND_SERVICE:
                return AppProtoEnums.PROCESS_STATE_FOREGROUND_SERVICE;
            case PROCESS_STATE_BOUND_FOREGROUND_SERVICE:
                return AppProtoEnums.PROCESS_STATE_BOUND_FOREGROUND_SERVICE;
            case PROCESS_STATE_IMPORTANT_FOREGROUND:
                return AppProtoEnums.PROCESS_STATE_IMPORTANT_FOREGROUND;
            case PROCESS_STATE_IMPORTANT_BACKGROUND:
                return AppProtoEnums.PROCESS_STATE_IMPORTANT_BACKGROUND;
            case PROCESS_STATE_TRANSIENT_BACKGROUND:
                return AppProtoEnums.PROCESS_STATE_TRANSIENT_BACKGROUND;
            case PROCESS_STATE_BACKUP:
                return AppProtoEnums.PROCESS_STATE_BACKUP;
            case PROCESS_STATE_SERVICE:
                return AppProtoEnums.PROCESS_STATE_SERVICE;
            case PROCESS_STATE_RECEIVER:
                return AppProtoEnums.PROCESS_STATE_RECEIVER;
            case PROCESS_STATE_TOP_SLEEPING:
                return AppProtoEnums.PROCESS_STATE_TOP_SLEEPING;
            case PROCESS_STATE_HEAVY_WEIGHT:
                return AppProtoEnums.PROCESS_STATE_HEAVY_WEIGHT;
            case PROCESS_STATE_HOME:
                return AppProtoEnums.PROCESS_STATE_HOME;
            case PROCESS_STATE_LAST_ACTIVITY:
                return AppProtoEnums.PROCESS_STATE_LAST_ACTIVITY;
            case PROCESS_STATE_CACHED_ACTIVITY:
                return AppProtoEnums.PROCESS_STATE_CACHED_ACTIVITY;
            case PROCESS_STATE_CACHED_ACTIVITY_CLIENT:
                return AppProtoEnums.PROCESS_STATE_CACHED_ACTIVITY_CLIENT;
            case PROCESS_STATE_CACHED_RECENT:
                return AppProtoEnums.PROCESS_STATE_CACHED_RECENT;
            case PROCESS_STATE_CACHED_EMPTY:
                return AppProtoEnums.PROCESS_STATE_CACHED_EMPTY;
            case PROCESS_STATE_NONEXISTENT:
                return AppProtoEnums.PROCESS_STATE_NONEXISTENT;
            default:
                // ActivityManager process state (amInt)
                // could not be mapped to an AppProtoEnums ProcessState state.
                return AppProtoEnums.PROCESS_STATE_UNKNOWN_TO_PROTO;
        }
    }
    }


    /** @hide The lowest process state number */
    /** @hide The lowest process state number */
+0 −59
Original line number Original line Diff line number Diff line
@@ -21,65 +21,6 @@ package android.app;
option java_multiple_files = true;
option java_multiple_files = true;
option java_outer_classname = "ActivityManagerProto";
option java_outer_classname = "ActivityManagerProto";


// ActivityManager.java PROCESS_STATEs
enum ProcessState {
  // Order matters for process states, so values have been spaced to provide
  // room for future additions.

  // Not a real process state.
  PROCESS_STATE_UNKNOWN = -100;
  // Process is a persistent system process.
  PROCESS_STATE_PERSISTENT = 0;
  // Process is a persistent system process and is doing UI.
  PROCESS_STATE_PERSISTENT_UI = 100;
  // Process is hosting the current top activities. Note that this covers
  // all activities that are visible to the user.
  PROCESS_STATE_TOP = 200;
  // Process is hosting a foreground service due to a system binding.
  PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 300;
  // Process is hosting a foreground service.
  PROCESS_STATE_FOREGROUND_SERVICE = 400;
  // Process is important to the user, and something they are aware of.
  PROCESS_STATE_IMPORTANT_FOREGROUND = 500;
  // Process is important to the user, but not something they are aware of.
  PROCESS_STATE_IMPORTANT_BACKGROUND = 600;
  // Process is in the background transient so we will try to keep running.
  PROCESS_STATE_TRANSIENT_BACKGROUND = 700;
  // Process is in the background running a backup/restore operation.
  PROCESS_STATE_BACKUP = 800;
  // Process is in the background running a service. Unlike oom_adj, this
  // level is used for both the normal running in background state and the
  // executing operations state.
  PROCESS_STATE_SERVICE = 900;
  // Process is in the background running a receiver. Note that from the
  // perspective of oom_adj, receivers run at a higher foreground level, but
  // for our prioritization here that is not necessary and putting them
  // below services means many fewer changes in some process states as they
  // receive broadcasts.
  PROCESS_STATE_RECEIVER = 1000;
  // Same as PROCESS_STATE_TOP but while device is sleeping.
  PROCESS_STATE_TOP_SLEEPING = 1100;
  // Process is in the background, but it can't restore its state so we want
  // to try to avoid killing it.
  PROCESS_STATE_HEAVY_WEIGHT = 1200;
  // Process is in the background but hosts the home activity.
  PROCESS_STATE_HOME = 1300;
  // Process is in the background but hosts the last shown activity.
  PROCESS_STATE_LAST_ACTIVITY = 1400;
  // Process is being cached for later use and contains activities.
  PROCESS_STATE_CACHED_ACTIVITY = 1500;
  // Process is being cached for later use and is a client of another cached
  // process that contains activities.
  PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 1600;
  // Process is being cached for later use and has an activity that corresponds
  // to an existing recent task.
  PROCESS_STATE_CACHED_RECENT = 1700;
  // Process is being cached for later use and is empty.
  PROCESS_STATE_CACHED_EMPTY = 1800;
  // Process does not exist.
  PROCESS_STATE_NONEXISTENT = 1900;
}

// ActivityManager.java UID_OBSERVERs flags
// ActivityManager.java UID_OBSERVERs flags
enum UidObserverFlag {
enum UidObserverFlag {
  // report changes in process state, original value is 1 << 0
  // report changes in process state, original value is 1 << 0
+87 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package android.app;

option java_outer_classname = "AppProtoEnums";
option java_multiple_files = true;

// ActivityManager.java PROCESS_STATEs
enum ProcessStateEnum {
    // Unlike the ActivityManager PROCESS_STATE values, the ordering and numerical values
    // here are completely fixed and arbitrary. Order is irrelevant.
    // No attempt need be made to keep them in sync.
    // The values here must not be modified. Any new process states can be appended to the end.

    // Process state that is unknown to this proto file (i.e. is not mapped
    // by ActivityManager.processStateAmToProto()). Can only happen if there's a bug in the mapping.
    PROCESS_STATE_UNKNOWN_TO_PROTO = 998;
    // Not a real process state.
    PROCESS_STATE_UNKNOWN = 999;
    // Process is a persistent system process.
    PROCESS_STATE_PERSISTENT = 1000;
    // Process is a persistent system process and is doing UI.
    PROCESS_STATE_PERSISTENT_UI = 1001;
    // Process is hosting the current top activities. Note that this covers
    // all activities that are visible to the user.
    PROCESS_STATE_TOP = 1002;
    // Process is hosting a foreground service.
    PROCESS_STATE_FOREGROUND_SERVICE = 1003;
    // Process is hosting a foreground service due to a system binding.
    PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 1004;
    // Process is important to the user, and something they are aware of.
    PROCESS_STATE_IMPORTANT_FOREGROUND = 1005;
    // Process is important to the user, but not something they are aware of.
    PROCESS_STATE_IMPORTANT_BACKGROUND = 1006;
    // Process is in the background transient so we will try to keep running.
    PROCESS_STATE_TRANSIENT_BACKGROUND = 1007;
    // Process is in the background running a backup/restore operation.
    PROCESS_STATE_BACKUP = 1008;
    // Process is in the background running a service. Unlike oom_adj, this
    // level is used for both the normal running in background state and the
    // executing operations state.
    PROCESS_STATE_SERVICE = 1009;
    // Process is in the background running a receiver. Note that from the
    // perspective of oom_adj, receivers run at a higher foreground level, but
    // for our prioritization here that is not necessary and putting them
    // below services means many fewer changes in some process states as they
    // receive broadcasts.
    PROCESS_STATE_RECEIVER = 1010;
    // Same as PROCESS_STATE_TOP but while device is sleeping.
    PROCESS_STATE_TOP_SLEEPING = 1011;
    // Process is in the background, but it can't restore its state so we want
    // to try to avoid killing it.
    PROCESS_STATE_HEAVY_WEIGHT = 1012;
    // Process is in the background but hosts the home activity.
    PROCESS_STATE_HOME = 1013;
    // Process is in the background but hosts the last shown activity.
    PROCESS_STATE_LAST_ACTIVITY = 1014;
    // Process is being cached for later use and contains activities.
    PROCESS_STATE_CACHED_ACTIVITY = 1015;
    // Process is being cached for later use and is a client of another cached
    // process that contains activities.
    PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 1016;
    // Process is being cached for later use and has an activity that corresponds
    // to an existing recent task.
    PROCESS_STATE_CACHED_RECENT = 1017;
    // Process is being cached for later use and is empty.
    PROCESS_STATE_CACHED_EMPTY = 1018;
    // Process does not exist.
    PROCESS_STATE_NONEXISTENT = 1019;
}
+5 −4
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@ syntax = "proto2";
package com.android.server.am.proto;
package com.android.server.am.proto;


import "frameworks/base/core/proto/android/app/activitymanager.proto";
import "frameworks/base/core/proto/android/app/activitymanager.proto";
import "frameworks/base/core/proto/android/app/enums.proto";
import "frameworks/base/core/proto/android/app/notification.proto";
import "frameworks/base/core/proto/android/app/notification.proto";
import "frameworks/base/core/proto/android/app/profilerinfo.proto";
import "frameworks/base/core/proto/android/app/profilerinfo.proto";
import "frameworks/base/core/proto/android/content/component_name.proto";
import "frameworks/base/core/proto/android/content/component_name.proto";
@@ -797,7 +798,7 @@ message UidRecordProto {


  optional string hex_hash = 1;
  optional string hex_hash = 1;
  optional int32 uid = 2;
  optional int32 uid = 2;
  optional .android.app.ProcessState current = 3;
  optional .android.app.ProcessStateEnum current = 3;
  optional bool ephemeral = 4;
  optional bool ephemeral = 4;
  optional bool fg_services = 5;
  optional bool fg_services = 5;
  optional bool whilelist = 6;
  optional bool whilelist = 6;
@@ -855,7 +856,7 @@ message ProcessOomProto {
    bool services = 6;
    bool services = 6;
  }
  }


  optional .android.app.ProcessState state = 7;
  optional .android.app.ProcessStateEnum state = 7;
  optional int32 trim_memory_level = 8;
  optional int32 trim_memory_level = 8;
  optional ProcessRecordProto proc = 9;
  optional ProcessRecordProto proc = 9;
  optional string adj_type = 10;
  optional string adj_type = 10;
@@ -878,8 +879,8 @@ message ProcessOomProto {
    optional int32 set_raw_adj = 3;
    optional int32 set_raw_adj = 3;
    optional int32 cur_adj = 4;
    optional int32 cur_adj = 4;
    optional int32 set_adj = 5;
    optional int32 set_adj = 5;
    optional .android.app.ProcessState current_state = 7;
    optional .android.app.ProcessStateEnum current_state = 7;
    optional .android.app.ProcessState set_state = 8;
    optional .android.app.ProcessStateEnum set_state = 8;
    optional string last_pss = 9;
    optional string last_pss = 9;
    optional string last_swap_pss = 10;
    optional string last_swap_pss = 10;
    optional string last_cached_pss = 11;
    optional string last_cached_pss = 11;
Loading