Statsd and frameworks reference proto enums
For frameworks constants that don't have intrinsic meaning (i.e. their actual
value and order don't matter), so that it is unlikely that their values
will be changed:
This cl introduces proto enums representing some constants found in
the Android codebase, and connects the two.
By using the Proto enum as the source-of-truth, it means that Java and
proto can be kept in sync. Otherwise, when the Java frameworks code
changes, it silently breaks the protos from working properly, since the enums
are wrong. By having the Java code reference the proto enums, it ensures
that everything is in sync. The values of the constants are unchanged.
But future changes to these constants will need to be done in the proto
file, which the Java file merely references.
The protos are necessary for incidentd and statsd and, in the future,
possibly dumpsys. In this way, the logging mechanism is much less likely
to get broken when new constants are added, and we can be ensured that
the logging accurately reflects the underlying codebase.
Bug: 69478930
Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases
Test: cts-tradefed run cts-dev -m CtsIncidentHostTestCases
Change-Id: If79032c34b2799db1e3e70cb47b1312fd72092b9
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index c990296..8f0a44a 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -22,6 +22,9 @@
option java_outer_classname = "AtomsProto";
import "frameworks/base/core/proto/android/app/enums.proto";
+import "frameworks/base/core/proto/android/os/enums.proto";
+import "frameworks/base/core/proto/android/telephony/enums.proto";
+import "frameworks/base/core/proto/android/view/enums.proto";
/**
* The master atom class. This message defines all of the available
@@ -162,18 +165,8 @@
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message ScreenStateChanged {
- // TODO: Use the real screen state.
- enum State {
- STATE_UNKNOWN = 0;
- STATE_OFF = 1;
- STATE_ON = 2;
- STATE_DOZE = 3;
- STATE_DOZE_SUSPEND = 4;
- STATE_VR = 5;
- STATE_ON_SUSPEND = 6;
- }
- // New screen state.
- optional State display_state = 1;
+ // New screen state, from frameworks/base/core/proto/android/view/enums.proto.
+ optional android.view.DisplayStateEnum state = 1;
}
/**
@@ -196,7 +189,6 @@
* frameworks/base/services/core/java/com/android/server/am/BatteryStatsService.java
*/
message ProcessLifeCycleStateChanged {
- // TODO: Use the real (mapped) process states.
optional int32 uid = 1; // TODO: should be a string tagged w/ uid annotation
// TODO: What is this?
@@ -412,13 +404,9 @@
message WakelockStateChanged {
repeated AttributionNode attribution_node = 1;
- // Type of wakelock.
- enum Type {
- PARTIAL = 0;
- FULL = 1;
- WINDOW = 2;
- }
- optional Type type = 2;
+ // The type (level) of the wakelock; e.g. a partial wakelock or a full wakelock.
+ // From frameworks/base/core/proto/android/os/enums.proto.
+ optional android.os.WakeLockLevelEnum level = 2;
// The wakelock tag (Called tag in the Java API, sometimes name elsewhere).
optional string tag = 3;
@@ -530,15 +518,8 @@
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message ChargingStateChanged {
- // TODO: Link directly to BatteryManager.java's constants (via a proto).
- enum State {
- BATTERY_STATUS_UNKNOWN = 1;
- BATTERY_STATUS_CHARGING = 2;
- BATTERY_STATUS_DISCHARGING = 3;
- BATTERY_STATUS_NOT_CHARGING = 4;
- BATTERY_STATUS_FULL = 5;
- }
- optional State charging_state = 1;
+ // State of the battery, from frameworks/base/core/proto/android/os/enums.proto.
+ optional android.os.BatteryStatusEnum state = 1;
}
/**
@@ -548,18 +529,8 @@
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message PluggedStateChanged {
- // TODO: Link directly to BatteryManager.java's constants (via a proto).
- enum State {
- // Note that NONE is not in BatteryManager.java's constants.
- BATTERY_PLUGGED_NONE = 0;
- // Power source is an AC charger.
- BATTERY_PLUGGED_AC = 1;
- // Power source is a USB port.
- BATTERY_PLUGGED_USB = 2;
- // Power source is wireless.
- BATTERY_PLUGGED_WIRELESS = 4;
- }
- optional State plugged_state = 1;
+ // Whether the device is plugged in, from frameworks/base/core/proto/android/os/enums.proto.
+ optional android.os.BatteryPluggedStateEnum state = 1;
}
/**
@@ -613,13 +584,8 @@
// TODO: Add attribution instead of uid?
optional int32 uid = 1;
- // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
- enum PowerState {
- DC_POWER_STATE_LOW = 1;
- DC_POWER_STATE_MEDIUM = 2;
- DC_POWER_STATE_HIGH = 3;
- }
- optional PowerState power_state = 2;
+ // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
+ optional android.telephony.DataConnectionPowerStateEnum state = 2;
}
/**
@@ -633,13 +599,8 @@
// TODO: Add attribution instead of uid?
optional int32 uid = 1;
- // TODO: Reference telephony/java/android/telephony/DataConnectionRealTimeInfo.java states.
- enum PowerState {
- DC_POWER_STATE_LOW = 1;
- DC_POWER_STATE_MEDIUM = 2;
- DC_POWER_STATE_HIGH = 3;
- }
- optional PowerState power_state = 2;
+ // Power state, from frameworks/base/core/proto/android/telephony/enums.proto.
+ optional android.telephony.DataConnectionPowerStateEnum state = 2;
}
/**
@@ -679,15 +640,8 @@
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message WifiSignalStrengthChanged {
- // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
- enum SignalStrength {
- SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
- SIGNAL_STRENGTH_POOR = 1;
- SIGNAL_STRENGTH_MODERATE = 2;
- SIGNAL_STRENGTH_GOOD = 3;
- SIGNAL_STRENGTH_GREAT = 4;
- }
- optional SignalStrength signal_strength = 1;
+ // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
+ optional android.telephony.SignalStrengthEnum signal_strength = 1;
}
/**
@@ -729,15 +683,8 @@
* frameworks/base/core/java/com/android/internal/os/BatteryStatsImpl.java
*/
message PhoneSignalStrengthChanged {
- // TODO: Reference the actual telephony/java/android/telephony/SignalStrength.java states.
- enum SignalStrength {
- SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
- SIGNAL_STRENGTH_POOR = 1;
- SIGNAL_STRENGTH_MODERATE = 2;
- SIGNAL_STRENGTH_GOOD = 3;
- SIGNAL_STRENGTH_GREAT = 4;
- }
- optional SignalStrength signal_strength = 1;
+ // Signal strength, from frameworks/base/core/proto/android/telephony/enums.proto.
+ optional android.telephony.SignalStrengthEnum signal_strength = 1;
}
/**
diff --git a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
index eda16a2..4504a95 100644
--- a/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/MetricConditionLink_e2e_test.cpp
@@ -123,11 +123,13 @@
auto crashEvent10 = CreateAppCrashEvent(appUid, bucketStartTimeNs + 2 * bucketSizeNs - 2);
auto screenTurnedOnEvent =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_ON, bucketStartTimeNs + 2);
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_ON,
+ bucketStartTimeNs + 2);
auto screenTurnedOffEvent =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_OFF, bucketStartTimeNs + 200);
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_OFF,
+ bucketStartTimeNs + 200);
auto screenTurnedOnEvent2 =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_ON,
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_ON,
bucketStartTimeNs + 2 * bucketSizeNs - 100);
auto syncOnEvent1 =
diff --git a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
index e656b98..1186a16 100644
--- a/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
+++ b/cmds/statsd/tests/e2e/WakelockDuration_e2e_test.cpp
@@ -73,11 +73,13 @@
EXPECT_TRUE(processor->mMetricsManagers.begin()->second->isConfigValid());
auto screenTurnedOnEvent =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_ON, bucketStartTimeNs + 1);
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_ON,
+ bucketStartTimeNs + 1);
auto screenTurnedOffEvent =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_OFF, bucketStartTimeNs + 200);
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_OFF,
+ bucketStartTimeNs + 200);
auto screenTurnedOnEvent2 =
- CreateScreenStateChangedEvent(ScreenStateChanged::STATE_ON,
+ CreateScreenStateChangedEvent(android::view::DisplayStateEnum::DISPLAY_STATE_ON,
bucketStartTimeNs + bucketSizeNs + 500);
std::vector<AttributionNode> attributions1 =
@@ -156,7 +158,8 @@
events.clear();
events.push_back(CreateScreenStateChangedEvent(
- ScreenStateChanged::STATE_OFF, bucketStartTimeNs + 2 * bucketSizeNs + 90));
+ android::view::DisplayStateEnum::DISPLAY_STATE_OFF,
+ bucketStartTimeNs + 2 * bucketSizeNs + 90));
events.push_back(CreateAcquireWakelockEvent(
attributions1, "wl3", bucketStartTimeNs + 2 * bucketSizeNs + 100));
events.push_back(CreateReleaseWakelockEvent(
diff --git a/cmds/statsd/tests/statsd_test_util.cpp b/cmds/statsd/tests/statsd_test_util.cpp
index 718b2e1..9f4582d 100644
--- a/cmds/statsd/tests/statsd_test_util.cpp
+++ b/cmds/statsd/tests/statsd_test_util.cpp
@@ -48,7 +48,7 @@
}
AtomMatcher CreateScreenStateChangedAtomMatcher(
- const string& name, ScreenStateChanged::State state) {
+ const string& name, android::view::DisplayStateEnum state) {
AtomMatcher atom_matcher;
atom_matcher.set_id(StringToId(name));
auto simple_atom_matcher = atom_matcher.mutable_simple_atom_matcher();
@@ -60,11 +60,13 @@
}
AtomMatcher CreateScreenTurnedOnAtomMatcher() {
- return CreateScreenStateChangedAtomMatcher("ScreenTurnedOn", ScreenStateChanged::STATE_ON);
+ return CreateScreenStateChangedAtomMatcher("ScreenTurnedOn",
+ android::view::DisplayStateEnum::DISPLAY_STATE_ON);
}
AtomMatcher CreateScreenTurnedOffAtomMatcher() {
- return CreateScreenStateChangedAtomMatcher("ScreenTurnedOff", ScreenStateChanged::STATE_OFF);
+ return CreateScreenStateChangedAtomMatcher("ScreenTurnedOff",
+ ::android::view::DisplayStateEnum::DISPLAY_STATE_OFF);
}
AtomMatcher CreateSyncStateChangedAtomMatcher(
@@ -209,7 +211,7 @@
}
std::unique_ptr<LogEvent> CreateScreenStateChangedEvent(
- const ScreenStateChanged::State state, uint64_t timestampNs) {
+ const android::view::DisplayStateEnum state, uint64_t timestampNs) {
auto event = std::make_unique<LogEvent>(android::util::SCREEN_STATE_CHANGED, timestampNs);
EXPECT_TRUE(event->write(state));
event->init();
@@ -221,7 +223,7 @@
const WakelockStateChanged::State state, uint64_t timestampNs) {
auto event = std::make_unique<LogEvent>(android::util::WAKELOCK_STATE_CHANGED, timestampNs);
event->write(attributions);
- event->write(WakelockStateChanged::PARTIAL);
+ event->write(android::os::WakeLockLevelEnum::PARTIAL_WAKE_LOCK);
event->write(wakelockName);
event->write(state);
event->init();
diff --git a/cmds/statsd/tests/statsd_test_util.h b/cmds/statsd/tests/statsd_test_util.h
index 1fc33de..ff8fef0c 100644
--- a/cmds/statsd/tests/statsd_test_util.h
+++ b/cmds/statsd/tests/statsd_test_util.h
@@ -84,7 +84,7 @@
// Create log event for screen state changed.
std::unique_ptr<LogEvent> CreateScreenStateChangedEvent(
- const ScreenStateChanged::State state, uint64_t timestampNs);
+ const android::view::DisplayStateEnum state, uint64_t timestampNs);
// Create log event for app moving to background.
std::unique_ptr<LogEvent> CreateMoveToBackgroundEvent(const int uid, uint64_t timestampNs);
diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/SequencePusher.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/SequencePusher.java
index d4b2aa4..5dcce9a 100644
--- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/SequencePusher.java
+++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/SequencePusher.java
@@ -90,7 +90,7 @@
case 2:
case 10:
StatsLog.write(StatsLog.CHARGING_STATE_CHANGED,
- StatsLog.CHARGING_STATE_CHANGED__CHARGING_STATE__BATTERY_STATUS_CHARGING
+ StatsLog.CHARGING_STATE_CHANGED__STATE__BATTERY_STATUS_CHARGING
/* charging_state */);
break;
case 3:
@@ -103,7 +103,7 @@
case 4:
case 12:
StatsLog.write(StatsLog.CHARGING_STATE_CHANGED,
- StatsLog.CHARGING_STATE_CHANGED__CHARGING_STATE__BATTERY_STATUS_NOT_CHARGING
+ StatsLog.CHARGING_STATE_CHANGED__STATE__BATTERY_STATUS_NOT_CHARGING
/* charging_state */);
break;
case 5:
@@ -115,7 +115,7 @@
break;
case 6:
StatsLog.write(StatsLog.SCREEN_STATE_CHANGED,
- StatsLog.SCREEN_STATE_CHANGED__DISPLAY_STATE__STATE_ON /* display_state */);
+ StatsLog.SCREEN_STATE_CHANGED__STATE__DISPLAY_STATE_ON /* display_state */);
break;
case 7:
for (int i = 0; i < mBurst; i++) {
@@ -125,7 +125,7 @@
break;
case 14:
StatsLog.write(StatsLog.SCREEN_STATE_CHANGED,
- StatsLog.SCREEN_STATE_CHANGED__DISPLAY_STATE__STATE_OFF /* display_state */);
+ StatsLog.SCREEN_STATE_CHANGED__STATE__DISPLAY_STATE_OFF /* display_state */);
break;
case 15:
for (int i = 0; i < mBurst; i++) {
@@ -147,14 +147,14 @@
public void finish() {
// Screen goes back to off. This will ensure that conditions get back to false.
StatsLog.write(StatsLog.SCREEN_STATE_CHANGED,
- StatsLog.SCREEN_STATE_CHANGED__DISPLAY_STATE__STATE_OFF /* display_state */);
+ StatsLog.SCREEN_STATE_CHANGED__STATE__DISPLAY_STATE_OFF /* display_state */);
for (int i = 0; i < mBurst; i++) {
StatsLog.write(StatsLog.AUDIO_STATE_CHANGED, i /* uid */,
StatsLog.AUDIO_STATE_CHANGED__STATE__OFF /* state */);
}
// Stop charging, to ensure the corresponding durations are closed.
StatsLog.write(StatsLog.CHARGING_STATE_CHANGED,
- StatsLog.CHARGING_STATE_CHANGED__CHARGING_STATE__BATTERY_STATUS_NOT_CHARGING
+ StatsLog.CHARGING_STATE_CHANGED__STATE__BATTERY_STATUS_NOT_CHARGING
/* charging_state */);
// Stop scanning GPS, to ensure the corresponding conditions get back to false.
for (int i = 0; i < mBurst; i++) {
diff --git a/core/java/android/os/BatteryManager.java b/core/java/android/os/BatteryManager.java
index 843bdb5..a734719 100644
--- a/core/java/android/os/BatteryManager.java
+++ b/core/java/android/os/BatteryManager.java
@@ -157,11 +157,11 @@
// values of the "plugged" field in the ACTION_BATTERY_CHANGED intent.
// These must be powers of 2.
/** Power source is an AC charger. */
- public static final int BATTERY_PLUGGED_AC = 1;
+ public static final int BATTERY_PLUGGED_AC = OsProtoEnums.BATTERY_PLUGGED_AC; // = 1
/** Power source is a USB port. */
- public static final int BATTERY_PLUGGED_USB = 2;
+ public static final int BATTERY_PLUGGED_USB = OsProtoEnums.BATTERY_PLUGGED_USB; // = 2
/** Power source is wireless. */
- public static final int BATTERY_PLUGGED_WIRELESS = 4;
+ public static final int BATTERY_PLUGGED_WIRELESS = OsProtoEnums.BATTERY_PLUGGED_WIRELESS; // = 4
/** @hide */
public static final int BATTERY_PLUGGED_ANY =
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index 3d17ffb..811cc5e 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -110,7 +110,7 @@
/* NOTE: Wake lock levels were previously defined as a bit field, except that only a few
* combinations were actually supported so the bit field was removed. This explains
* why the numbering scheme is so odd. If adding a new wake lock level, any unused
- * value can be used.
+ * value (in frameworks/base/core/proto/android/os/enums.proto) can be used.
*/
/**
@@ -121,7 +121,7 @@
* but the CPU will be kept on until all partial wake locks have been released.
* </p>
*/
- public static final int PARTIAL_WAKE_LOCK = 0x00000001;
+ public static final int PARTIAL_WAKE_LOCK = OsProtoEnums.PARTIAL_WAKE_LOCK; // 0x00000001
/**
* Wake lock level: Ensures that the screen is on (but may be dimmed);
@@ -138,7 +138,7 @@
* as the user moves between applications and doesn't require a special permission.
*/
@Deprecated
- public static final int SCREEN_DIM_WAKE_LOCK = 0x00000006;
+ public static final int SCREEN_DIM_WAKE_LOCK = OsProtoEnums.SCREEN_DIM_WAKE_LOCK; // 0x00000006
/**
* Wake lock level: Ensures that the screen is on at full brightness;
@@ -155,7 +155,8 @@
* as the user moves between applications and doesn't require a special permission.
*/
@Deprecated
- public static final int SCREEN_BRIGHT_WAKE_LOCK = 0x0000000a;
+ public static final int SCREEN_BRIGHT_WAKE_LOCK =
+ OsProtoEnums.SCREEN_BRIGHT_WAKE_LOCK; // 0x0000000a
/**
* Wake lock level: Ensures that the screen and keyboard backlight are on at
@@ -172,7 +173,7 @@
* as the user moves between applications and doesn't require a special permission.
*/
@Deprecated
- public static final int FULL_WAKE_LOCK = 0x0000001a;
+ public static final int FULL_WAKE_LOCK = OsProtoEnums.FULL_WAKE_LOCK; // 0x0000001a
/**
* Wake lock level: Turns the screen off when the proximity sensor activates.
@@ -193,7 +194,8 @@
* Cannot be used with {@link #ACQUIRE_CAUSES_WAKEUP}.
* </p>
*/
- public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK = 0x00000020;
+ public static final int PROXIMITY_SCREEN_OFF_WAKE_LOCK =
+ OsProtoEnums.PROXIMITY_SCREEN_OFF_WAKE_LOCK; // 0x00000020
/**
* Wake lock level: Put the screen in a low power state and allow the CPU to suspend
@@ -207,7 +209,7 @@
*
* {@hide}
*/
- public static final int DOZE_WAKE_LOCK = 0x00000040;
+ public static final int DOZE_WAKE_LOCK = OsProtoEnums.DOZE_WAKE_LOCK; // 0x00000040
/**
* Wake lock level: Keep the device awake enough to allow drawing to occur.
@@ -221,7 +223,7 @@
*
* {@hide}
*/
- public static final int DRAW_WAKE_LOCK = 0x00000080;
+ public static final int DRAW_WAKE_LOCK = OsProtoEnums.DRAW_WAKE_LOCK; // 0x00000080
/**
* Mask for the wake lock level component of a combined wake lock level and flags integer.
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 5bd7446..31cfebc 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -267,21 +267,21 @@
*
* @see #getState
*/
- public static final int STATE_UNKNOWN = 0;
+ public static final int STATE_UNKNOWN = ViewProtoEnums.DISPLAY_STATE_UNKNOWN; // 0
/**
* Display state: The display is off.
*
* @see #getState
*/
- public static final int STATE_OFF = 1;
+ public static final int STATE_OFF = ViewProtoEnums.DISPLAY_STATE_OFF; // 1
/**
* Display state: The display is on.
*
* @see #getState
*/
- public static final int STATE_ON = 2;
+ public static final int STATE_ON = ViewProtoEnums.DISPLAY_STATE_ON; // 2
/**
* Display state: The display is dozing in a low power state; it is still
@@ -291,7 +291,7 @@
* @see #getState
* @see android.os.PowerManager#isInteractive
*/
- public static final int STATE_DOZE = 3;
+ public static final int STATE_DOZE = ViewProtoEnums.DISPLAY_STATE_DOZE; // 3
/**
* Display state: The display is dozing in a suspended low power state; it is still
@@ -303,7 +303,7 @@
* @see #getState
* @see android.os.PowerManager#isInteractive
*/
- public static final int STATE_DOZE_SUSPEND = 4;
+ public static final int STATE_DOZE_SUSPEND = ViewProtoEnums.DISPLAY_STATE_DOZE_SUSPEND; // 4
/**
* Display state: The display is on and optimized for VR mode.
@@ -311,7 +311,7 @@
* @see #getState
* @see android.os.PowerManager#isInteractive
*/
- public static final int STATE_VR = 5;
+ public static final int STATE_VR = ViewProtoEnums.DISPLAY_STATE_VR; // 5
/**
* Display state: The display is in a suspended full power state; it is still
@@ -323,7 +323,7 @@
* @see #getState
* @see android.os.PowerManager#isInteractive
*/
- public static final int STATE_ON_SUSPEND = 6;
+ public static final int STATE_ON_SUSPEND = ViewProtoEnums.DISPLAY_STATE_ON_SUSPEND; // 6
/* The color mode constants defined below must be kept in sync with the ones in
* system/core/include/system/graphics-base.h */
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index ee3bec8..fd5fe10 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -41,9 +41,11 @@
import android.os.IBatteryPropertiesRegistrar;
import android.os.Looper;
import android.os.Message;
+import android.os.OsProtoEnums;
import android.os.Parcel;
import android.os.ParcelFormatException;
import android.os.Parcelable;
+import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
@@ -4252,11 +4254,11 @@
getUidStatsLocked(uid).noteStartWakeLocked(pid, name, type, elapsedRealtime);
if (wc != null) {
- StatsLog.write(
- StatsLog.WAKELOCK_STATE_CHANGED, wc.getUids(), wc.getTags(), type, name, 1);
+ StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, wc.getUids(), wc.getTags(),
+ getPowerManagerWakeLockLevel(type), name, 1);
} else {
- StatsLog.write_non_chained(StatsLog.WAKELOCK_STATE_CHANGED, uid, null, type, name,
- 1);
+ StatsLog.write_non_chained(StatsLog.WAKELOCK_STATE_CHANGED, uid, null,
+ getPowerManagerWakeLockLevel(type), name, 1);
}
}
}
@@ -4295,15 +4297,45 @@
getUidStatsLocked(uid).noteStopWakeLocked(pid, name, type, elapsedRealtime);
if (wc != null) {
- StatsLog.write(
- StatsLog.WAKELOCK_STATE_CHANGED, wc.getUids(), wc.getTags(), type, name, 0);
+ StatsLog.write(StatsLog.WAKELOCK_STATE_CHANGED, wc.getUids(), wc.getTags(),
+ getPowerManagerWakeLockLevel(type), name, 0);
} else {
- StatsLog.write_non_chained(StatsLog.WAKELOCK_STATE_CHANGED, uid, null, type, name,
- 0);
+ StatsLog.write_non_chained(StatsLog.WAKELOCK_STATE_CHANGED, uid, null,
+ getPowerManagerWakeLockLevel(type), name, 0);
}
}
}
+ /**
+ * Converts BatteryStats wakelock types back into PowerManager wakelock levels.
+ * This is the inverse map of Notifier.getBatteryStatsWakeLockMonitorType().
+ * These are estimations, since batterystats loses some of the original data.
+ * TODO: Delete this. Instead, StatsLog.write should be called from PowerManager's Notifier.
+ */
+ private int getPowerManagerWakeLockLevel(int battertStatsWakelockType) {
+ switch (battertStatsWakelockType) {
+ // PowerManager.PARTIAL_WAKE_LOCK or PROXIMITY_SCREEN_OFF_WAKE_LOCK
+ case BatteryStats.WAKE_TYPE_PARTIAL:
+ return PowerManager.PARTIAL_WAKE_LOCK;
+
+ // PowerManager.SCREEN_DIM_WAKE_LOCK or SCREEN_BRIGHT_WAKE_LOCK
+ case BatteryStats.WAKE_TYPE_FULL:
+ return PowerManager.FULL_WAKE_LOCK;
+
+ case BatteryStats.WAKE_TYPE_DRAW:
+ return PowerManager.DRAW_WAKE_LOCK;
+
+ // It appears that nothing can ever make a Window and PowerManager lacks an equivalent.
+ case BatteryStats.WAKE_TYPE_WINDOW:
+ Slog.e(TAG, "Illegal window wakelock type observed in batterystats.");
+ return -1;
+
+ default:
+ Slog.e(TAG, "Illegal wakelock type in batterystats: " + battertStatsWakelockType);
+ return -1;
+ }
+ }
+
public void noteStartWakeFromSourceLocked(WorkSource ws, int pid, String name,
String historyName, int type, boolean unimportantForLogging) {
final long elapsedRealtime = mClocks.elapsedRealtime();
@@ -12215,7 +12247,7 @@
}
// This should probably be exposed in the API, though it's not critical
- public static final int BATTERY_PLUGGED_NONE = 0;
+ public static final int BATTERY_PLUGGED_NONE = OsProtoEnums.BATTERY_PLUGGED_NONE; // = 0
public void setBatteryStateLocked(final int status, final int health, final int plugType,
final int level, /* not final */ int temp, final int volt, final int chargeUAh,
diff --git a/core/proto/android/os/batterymanager.proto b/core/proto/android/os/batterymanager.proto
deleted file mode 100644
index 669bf2d..0000000
--- a/core/proto/android/os/batterymanager.proto
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.os;
-
-option java_multiple_files = true;
-
-message BatteryManagerProto {
- enum PlugType {
- PLUG_TYPE_NONE = 0;
- PLUG_TYPE_AC = 1;
- PLUG_TYPE_USB = 2;
- PLUG_TYPE_WIRELESS = 4;
- }
-}
diff --git a/core/proto/android/os/batterystats.proto b/core/proto/android/os/batterystats.proto
index ce1d5c9..9f9fd05 100644
--- a/core/proto/android/os/batterystats.proto
+++ b/core/proto/android/os/batterystats.proto
@@ -21,7 +21,7 @@
import "frameworks/base/core/proto/android/app/jobparameters.proto";
import "frameworks/base/core/proto/android/os/powermanager.proto";
-import "frameworks/base/core/proto/android/telephony/signalstrength.proto";
+import "frameworks/base/core/proto/android/telephony/enums.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
message BatteryStatsProto {
@@ -339,7 +339,7 @@
message PhoneSignalStrength {
option (android.msg_privacy).dest = DEST_AUTOMATIC;
- optional android.telephony.SignalStrengthProto.StrengthName name = 1;
+ optional android.telephony.SignalStrengthEnum name = 1;
optional TimerProto total = 2;
};
repeated PhoneSignalStrength phone_signal_strength = 16;
diff --git a/core/proto/android/os/enums.proto b/core/proto/android/os/enums.proto
new file mode 100644
index 0000000..fe9b7ac
--- /dev/null
+++ b/core/proto/android/os/enums.proto
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2018 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.os;
+
+option java_outer_classname = "OsProtoEnums";
+option java_multiple_files = true;
+
+// These constants are defined in hardware/interfaces/health/1.0/types.hal
+// They are primarily used by android/os/BatteryManager.java.
+enum BatteryHealthEnum {
+ BATTERY_HEALTH_INVALID = 0;
+ BATTERY_HEALTH_UNKNOWN = 1;
+ BATTERY_HEALTH_GOOD = 2;
+ BATTERY_HEALTH_OVERHEAT = 3;
+ BATTERY_HEALTH_DEAD = 4;
+ BATTERY_HEALTH_OVER_VOLTAGE = 5;
+ BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6;
+ BATTERY_HEALTH_COLD = 7;
+}
+
+// Plug states, primarily used by android/os/BatteryManager.java.
+enum BatteryPluggedStateEnum {
+ // Note that NONE is not in BatteryManager.java's constants.
+ BATTERY_PLUGGED_NONE = 0;
+ // Power source is an AC charger.
+ BATTERY_PLUGGED_AC = 1;
+ // Power source is a USB port.
+ BATTERY_PLUGGED_USB = 2;
+ // Power source is wireless.
+ BATTERY_PLUGGED_WIRELESS = 4;
+}
+
+// These constants are defined in hardware/interfaces/health/1.0/types.hal
+// They are primarily used by android/os/BatteryManager.java.
+enum BatteryStatusEnum {
+ BATTERY_STATUS_INVALID = 0;
+ BATTERY_STATUS_UNKNOWN = 1;
+ BATTERY_STATUS_CHARGING = 2;
+ BATTERY_STATUS_DISCHARGING = 3;
+ BATTERY_STATUS_NOT_CHARGING = 4;
+ BATTERY_STATUS_FULL = 5;
+}
+
+// Wakelock types, primarily used by android/os/PowerManager.java.
+enum WakeLockLevelEnum {
+ // NOTE: Wake lock levels were previously defined as a bit field, except
+ // that only a few combinations were actually supported so the bit field
+ // was removed. This explains why the numbering scheme is so odd. If
+ // adding a new wake lock level, any unused value can be used.
+
+ // Ensures that the CPU is running; the screen and keyboard backlight
+ // will be allowed to go off.
+ PARTIAL_WAKE_LOCK = 1;
+
+ // Ensures that the screen is on (but may be dimmed); the keyboard
+ // backlight will be allowed to go off. If the user presses the power
+ // button, then the SCREEN_DIM_WAKE_LOCK will be implicitly released by
+ // the system, causing both the screen and the CPU to be turned off.
+ SCREEN_DIM_WAKE_LOCK = 6 [deprecated = true];
+
+ // Ensures that the screen is on at full brightness; the keyboard
+ // backlight will be allowed to go off. If the user presses the power
+ // button, then the SCREEN_BRIGHT_WAKE_LOCK will be implicitly released
+ // by the system, causing both the screen and the CPU to be turned off.
+ SCREEN_BRIGHT_WAKE_LOCK = 10 [deprecated = true];
+
+ // Ensures that the screen and keyboard backlight are on at full
+ // brightness. If the user presses the power button, then the
+ // FULL_WAKE_LOCK will be implicitly released by the system, causing
+ // both the screen and the CPU to be turned off.
+ FULL_WAKE_LOCK = 26 [deprecated = true];
+
+ // Turns the screen off when the proximity sensor activates. If the
+ // proximity sensor detects that an object is nearby, the screen turns
+ // off immediately. Shortly after the object moves away, the screen
+ // turns on again.
+ // A proximity wake lock does not prevent the device from falling asleep
+ // unlike FULL_WAKE_LOCK, SCREEN_BRIGHT_WAKE_LOCK and
+ // SCREEN_DIM_WAKE_LOCK. If there is no user activity and no other wake
+ // locks are held, then the device will fall asleep (and lock) as usual.
+ // However, the device will not fall asleep while the screen has been
+ // turned off by the proximity sensor because it effectively counts as
+ // ongoing user activity.
+ PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32;
+
+ // Put the screen in a low power state and allow the CPU to suspend if
+ // no other wake locks are held. This is used by the dream manager to
+ // implement doze mode. It currently has no effect unless the power
+ // manager is in the dozing state.
+ DOZE_WAKE_LOCK = 64;
+
+ // Keep the device awake enough to allow drawing to occur. This is used
+ // by the window manager to allow applications to draw while the system
+ // is dozing. It currently has no effect unless the power manager is in
+ // the dozing state.
+ DRAW_WAKE_LOCK = 128;
+}
diff --git a/core/proto/android/os/powermanager.proto b/core/proto/android/os/powermanager.proto
index 8e0a607..a1f53db 100644
--- a/core/proto/android/os/powermanager.proto
+++ b/core/proto/android/os/powermanager.proto
@@ -34,60 +34,6 @@
USER_ACTIVITY_EVENT_ACCESSIBILITY = 3;
}
- enum WakeLockLevel {
- // NOTE: Wake lock levels were previously defined as a bit field, except
- // that only a few combinations were actually supported so the bit field
- // was removed. This explains why the numbering scheme is so odd. If
- // adding a new wake lock level, any unused value can be used.
-
- // Ensures that the CPU is running; the screen and keyboard backlight
- // will be allowed to go off.
- PARTIAL_WAKE_LOCK = 1;
-
- // Ensures that the screen is on (but may be dimmed); the keyboard
- // backlight will be allowed to go off. If the user presses the power
- // button, then the SCREEN_DIM_WAKE_LOCK will be implicitly released by
- // the system, causing both the screen and the CPU to be turned off.
- SCREEN_DIM_WAKE_LOCK = 6 [deprecated = true];
-
- // Ensures that the screen is on at full brightness; the keyboard
- // backlight will be allowed to go off. If the user presses the power
- // button, then the SCREEN_BRIGHT_WAKE_LOCK will be implicitly released
- // by the system, causing both the screen and the CPU to be turned off.
- SCREEN_BRIGHT_WAKE_LOCK = 10 [deprecated = true];
-
- // Ensures that the screen and keyboard backlight are on at full
- // brightness. If the user presses the power button, then the
- // FULL_WAKE_LOCK will be implicitly released by the system, causing
- // both the screen and the CPU to be turned off.
- FULL_WAKE_LOCK = 26 [deprecated = true];
-
- // Turns the screen off when the proximity sensor activates. If the
- // proximity sensor detects that an object is nearby, the screen turns
- // off immediately. Shortly after the object moves away, the screen
- // turns on again.
- // A proximity wake lock does not prevent the device from falling asleep
- // unlike FULL_WAKE_LOCK, SCREEN_BRIGHT_WAKE_LOCK and
- // SCREEN_DIM_WAKE_LOCK. If there is no user activity and no other wake
- // locks are held, then the device will fall asleep (and lock) as usual.
- // However, the device will not fall asleep while the screen has been
- // turned off by the proximity sensor because it effectively counts as
- // ongoing user activity.
- PROXIMITY_SCREEN_OFF_WAKE_LOCK = 32;
-
- // Put the screen in a low power state and allow the CPU to suspend if
- // no other wake locks are held. This is used by the dream manager to
- // implement doze mode. It currently has no effect unless the power
- // manager is in the dozing state.
- DOZE_WAKE_LOCK = 64;
-
- // Keep the device awake enough to allow drawing to occur. This is used
- // by the window manager to allow applications to draw while the system
- // is dozing. It currently has no effect unless the power manager is in
- // the dozing state.
- DRAW_WAKE_LOCK = 128;
- }
-
// WakeLock class in android.os.PowerManager, it is the one used by sdk
message WakeLockProto {
optional string hex_string = 1;
diff --git a/core/proto/android/server/powermanagerservice.proto b/core/proto/android/server/powermanagerservice.proto
index babbef0..b5c3ac0 100644
--- a/core/proto/android/server/powermanagerservice.proto
+++ b/core/proto/android/server/powermanagerservice.proto
@@ -21,13 +21,13 @@
import "frameworks/base/core/proto/android/app/enums.proto";
import "frameworks/base/core/proto/android/content/intent.proto";
-import "frameworks/base/core/proto/android/os/batterymanager.proto";
+import "frameworks/base/core/proto/android/os/enums.proto";
import "frameworks/base/core/proto/android/os/looper.proto";
import "frameworks/base/core/proto/android/os/powermanager.proto";
import "frameworks/base/core/proto/android/os/worksource.proto";
import "frameworks/base/core/proto/android/providers/settings.proto";
import "frameworks/base/core/proto/android/server/wirelesschargerdetector.proto";
-import "frameworks/base/core/proto/android/view/display.proto";
+import "frameworks/base/core/proto/android/view/enums.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
message PowerManagerServiceDumpProto {
@@ -80,7 +80,7 @@
// True if the device is plugged into a power source.
optional bool is_powered = 5;
// The current plug type
- optional .android.os.BatteryManagerProto.PlugType plug_type = 6;
+ optional .android.os.BatteryPluggedStateEnum plug_type = 6;
// The current battery level percentage.
optional int32 battery_level = 7;
// The battery level percentage at the time the dream started.
@@ -197,7 +197,7 @@
optional bool is_on_after_release = 2;
}
- optional .android.os.PowerManagerProto.WakeLockLevel lock_level = 1;
+ optional .android.os.WakeLockLevelEnum lock_level = 1;
optional string tag = 2 [ (.android.privacy).dest = DEST_EXPLICIT ];
optional WakeLockFlagsProto flags = 3;
optional bool is_disabled = 4;
@@ -322,7 +322,7 @@
// Use NaN to disable.
optional float temporary_screen_auto_brightness_adjustment_setting_override = 37;
// The screen state to use while dozing.
- optional .android.view.DisplayProto.DisplayState doze_screen_state_override_from_dream_manager = 38;
+ optional .android.view.DisplayStateEnum doze_screen_state_override_from_dream_manager = 38;
// The screen brightness to use while dozing.
optional float dozed_screen_brightness_override_from_dream_manager = 39;
// Screen brightness settings limits.
diff --git a/core/proto/android/service/battery.proto b/core/proto/android/service/battery.proto
index 42fa72c..34cb229 100644
--- a/core/proto/android/service/battery.proto
+++ b/core/proto/android/service/battery.proto
@@ -20,35 +20,16 @@
option java_multiple_files = true;
option java_outer_classname = "BatteryServiceProto";
-import "frameworks/base/core/proto/android/os/batterymanager.proto";
+import "frameworks/base/core/proto/android/os/enums.proto";
import "frameworks/base/libs/incident/proto/android/privacy.proto";
message BatteryServiceDumpProto {
option (android.msg_privacy).dest = DEST_AUTOMATIC;
- enum BatteryStatus {
- BATTERY_STATUS_INVALID = 0;
- BATTERY_STATUS_UNKNOWN = 1;
- BATTERY_STATUS_CHARGING = 2;
- BATTERY_STATUS_DISCHARGING = 3;
- BATTERY_STATUS_NOT_CHARGING = 4;
- BATTERY_STATUS_FULL = 5;
- }
- enum BatteryHealth {
- BATTERY_HEALTH_INVALID = 0;
- BATTERY_HEALTH_UNKNOWN = 1;
- BATTERY_HEALTH_GOOD = 2;
- BATTERY_HEALTH_OVERHEAT = 3;
- BATTERY_HEALTH_DEAD = 4;
- BATTERY_HEALTH_OVER_VOLTAGE = 5;
- BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6;
- BATTERY_HEALTH_COLD = 7;
- }
-
// If true: UPDATES STOPPED -- use 'reset' to restart
optional bool are_updates_stopped = 1;
// Plugged status of power sources
- optional android.os.BatteryManagerProto.PlugType plugged = 2;
+ optional android.os.BatteryPluggedStateEnum plugged = 2;
// Max current in microamperes. This may be 0 if the device's kernel drivers
// don't support it.
optional int32 max_charging_current = 3;
@@ -58,9 +39,9 @@
// Battery capacity in microampere-hours
optional int32 charge_counter = 5;
// Charging status
- optional BatteryStatus status = 6;
+ optional android.os.BatteryStatusEnum status = 6;
// Battery health
- optional BatteryHealth health = 7;
+ optional android.os.BatteryHealthEnum health = 7;
// True if the battery is present
optional bool is_present = 8;
// Charge level, from 0 through "scale" inclusive
diff --git a/core/proto/android/telephony/enums.proto b/core/proto/android/telephony/enums.proto
new file mode 100644
index 0000000..60f8d8d
--- /dev/null
+++ b/core/proto/android/telephony/enums.proto
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 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.telephony;
+
+option java_outer_classname = "TelephonyProtoEnums";
+option java_multiple_files = true;
+
+// Data conn. power states, primarily used by android/telephony/DataConnectionRealTimeInfo.java.
+enum DataConnectionPowerStateEnum {
+ DATA_CONNECTION_POWER_STATE_LOW = 1;
+ DATA_CONNECTION_POWER_STATE_MEDIUM = 2;
+ DATA_CONNECTION_POWER_STATE_HIGH = 3;
+ DATA_CONNECTION_POWER_STATE_UNKNOWN = 2147483647; // Java Integer.MAX_VALUE;
+}
+
+// Signal strength levels, primarily used by android/telephony/SignalStrength.java.
+enum SignalStrengthEnum {
+ SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
+ SIGNAL_STRENGTH_POOR = 1;
+ SIGNAL_STRENGTH_MODERATE = 2;
+ SIGNAL_STRENGTH_GOOD = 3;
+ SIGNAL_STRENGTH_GREAT = 4;
+}
diff --git a/core/proto/android/telephony/signalstrength.proto b/core/proto/android/telephony/signalstrength.proto
deleted file mode 100644
index 366f1d1..0000000
--- a/core/proto/android/telephony/signalstrength.proto
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * 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";
-option java_package = "android.telephony";
-option java_multiple_files = true;
-
-package android.telephony;
-
-/**
- * An android.telephony.SignalStrength object.
- */
-message SignalStrengthProto {
- enum StrengthName {
- SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
- SIGNAL_STRENGTH_POOR = 1;
- SIGNAL_STRENGTH_MODERATE = 2;
- SIGNAL_STRENGTH_GOOD = 3;
- SIGNAL_STRENGTH_GREAT = 4;
- }
-}
diff --git a/core/proto/android/view/display.proto b/core/proto/android/view/display.proto
index cac0830..30046c3 100644
--- a/core/proto/android/view/display.proto
+++ b/core/proto/android/view/display.proto
@@ -20,24 +20,6 @@
option java_multiple_files = true;
message DisplayProto {
- enum DisplayState {
- // The display state is unknown.
- DISPLAY_STATE_UNKNOWN = 0;
- // The display state is off.
- DISPLAY_STATE_OFF = 1;
- // The display state is on.
- DISPLAY_STATE_ON = 2;
- // The display is dozing in a low power state; it is still on but is
- // optimized for showing system-provided content while the device is
- // non-interactive.
- DISPLAY_STATE_DOZE = 3;
- // The display is dozing in a suspended low power state; it is still on
- // but is optimized for showing static system-provided content while the
- // device is non-interactive.
- DISPLAY_STATE_DOZE_SUSPEND = 4;
- // The display is on and optimized for VR mode.
- DISPLAY_STATE_VR = 5;
- }
enum ColorMode {
COLOR_MODE_INVALID = -1;
COLOR_MODE_BT601_625 = 1;
diff --git a/core/proto/android/view/enums.proto b/core/proto/android/view/enums.proto
new file mode 100644
index 0000000..10785ce
--- /dev/null
+++ b/core/proto/android/view/enums.proto
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2018 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.view;
+
+option java_outer_classname = "ViewProtoEnums";
+option java_multiple_files = true;
+
+// Screen states, primarily used by android/view/Display.java.
+enum DisplayStateEnum {
+ // The display state is unknown.
+ DISPLAY_STATE_UNKNOWN = 0;
+ // The display state is off.
+ DISPLAY_STATE_OFF = 1;
+ // The display state is on.
+ DISPLAY_STATE_ON = 2;
+ // The display is dozing in a low power state; it is still on but is
+ // optimized for showing system-provided content while the device is
+ // non-interactive.
+ DISPLAY_STATE_DOZE = 3;
+ // The display is dozing in a suspended low power state; it is still on
+ // but is optimized for showing static system-provided content while the
+ // device is non-interactive.
+ DISPLAY_STATE_DOZE_SUSPEND = 4;
+ // The display is on and optimized for VR mode.
+ DISPLAY_STATE_VR = 5;
+ // The display is in a suspended full power state; it is still on but the
+ // CPU is not updating it.
+ DISPLAY_STATE_ON_SUSPEND = 6;
+}
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index dc5f5a2..ba9883b 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -43,17 +43,17 @@
import android.hardware.health.V2_0.IHealth;
import android.hardware.health.V2_0.Result;
import android.os.BatteryManager;
-import android.os.BatteryManagerProto;
import android.os.BatteryManagerInternal;
import android.os.BatteryProperty;
import android.os.Binder;
+import android.os.DropBoxManager;
import android.os.FileUtils;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBatteryPropertiesListener;
import android.os.IBatteryPropertiesRegistrar;
import android.os.IBinder;
-import android.os.DropBoxManager;
+import android.os.OsProtoEnums;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
@@ -127,7 +127,7 @@
private static final String DUMPSYS_DATA_PATH = "/data/system/";
// This should probably be exposed in the API, though it's not critical
- private static final int BATTERY_PLUGGED_NONE = 0;
+ private static final int BATTERY_PLUGGED_NONE = OsProtoEnums.BATTERY_PLUGGED_NONE; // = 0
private final Context mContext;
private final IBatteryStats mBatteryStats;
@@ -921,13 +921,13 @@
synchronized (mLock) {
proto.write(BatteryServiceDumpProto.ARE_UPDATES_STOPPED, mUpdatesStopped);
- int batteryPluggedValue = BatteryManagerProto.PLUG_TYPE_NONE;
+ int batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_NONE;
if (mHealthInfo.chargerAcOnline) {
- batteryPluggedValue = BatteryManagerProto.PLUG_TYPE_AC;
+ batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_AC;
} else if (mHealthInfo.chargerUsbOnline) {
- batteryPluggedValue = BatteryManagerProto.PLUG_TYPE_USB;
+ batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_USB;
} else if (mHealthInfo.chargerWirelessOnline) {
- batteryPluggedValue = BatteryManagerProto.PLUG_TYPE_WIRELESS;
+ batteryPluggedValue = OsProtoEnums.BATTERY_PLUGGED_WIRELESS;
}
proto.write(BatteryServiceDumpProto.PLUGGED, batteryPluggedValue);
proto.write(BatteryServiceDumpProto.MAX_CHARGING_CURRENT, mHealthInfo.maxChargingCurrent);
diff --git a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
index f71f58d..fc4e17a 100644
--- a/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
+++ b/telephony/java/android/telephony/DataConnectionRealTimeInfo.java
@@ -28,10 +28,14 @@
public class DataConnectionRealTimeInfo implements Parcelable {
private long mTime; // Time the info was collected since boot in nanos;
- public static final int DC_POWER_STATE_LOW = 1;
- public static final int DC_POWER_STATE_MEDIUM = 2;
- public static final int DC_POWER_STATE_HIGH = 3;
- public static final int DC_POWER_STATE_UNKNOWN = Integer.MAX_VALUE;
+ public static final int DC_POWER_STATE_LOW
+ = TelephonyProtoEnums.DATA_CONNECTION_POWER_STATE_LOW ; // = 1
+ public static final int DC_POWER_STATE_MEDIUM
+ = TelephonyProtoEnums.DATA_CONNECTION_POWER_STATE_MEDIUM; // = 2
+ public static final int DC_POWER_STATE_HIGH
+ = TelephonyProtoEnums.DATA_CONNECTION_POWER_STATE_HIGH; // = 3
+ public static final int DC_POWER_STATE_UNKNOWN
+ = TelephonyProtoEnums.DATA_CONNECTION_POWER_STATE_UNKNOWN; // = Integer.MAX_VALUE
private int mDcPowerState; // DC_POWER_STATE_[LOW | MEDIUM | HIGH | UNKNOWN]
diff --git a/telephony/java/android/telephony/SignalStrength.java b/telephony/java/android/telephony/SignalStrength.java
index fc2ef27..778ca77 100644
--- a/telephony/java/android/telephony/SignalStrength.java
+++ b/telephony/java/android/telephony/SignalStrength.java
@@ -35,15 +35,20 @@
private static final boolean DBG = false;
/** @hide */
- public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN = 0;
+ public static final int SIGNAL_STRENGTH_NONE_OR_UNKNOWN
+ = TelephonyProtoEnums.SIGNAL_STRENGTH_NONE_OR_UNKNOWN; // = 0
/** @hide */
- public static final int SIGNAL_STRENGTH_POOR = 1;
+ public static final int SIGNAL_STRENGTH_POOR
+ = TelephonyProtoEnums.SIGNAL_STRENGTH_POOR; // = 1
/** @hide */
- public static final int SIGNAL_STRENGTH_MODERATE = 2;
+ public static final int SIGNAL_STRENGTH_MODERATE
+ = TelephonyProtoEnums.SIGNAL_STRENGTH_MODERATE; // = 2
/** @hide */
- public static final int SIGNAL_STRENGTH_GOOD = 3;
+ public static final int SIGNAL_STRENGTH_GOOD
+ = TelephonyProtoEnums.SIGNAL_STRENGTH_GOOD; // = 3
/** @hide */
- public static final int SIGNAL_STRENGTH_GREAT = 4;
+ public static final int SIGNAL_STRENGTH_GREAT
+ = TelephonyProtoEnums.SIGNAL_STRENGTH_GREAT; // = 4
/** @hide */
public static final int NUM_SIGNAL_STRENGTH_BINS = 5;
/** @hide */