OSDN Git Service

Atom: ResourceConfigurationChanged
authorTej Singh <singhtejinder@google.com>
Thu, 15 Feb 2018 19:30:01 +0000 (11:30 -0800)
committerTej Singh <singhtejinder@google.com>
Tue, 6 Mar 2018 00:27:08 +0000 (16:27 -0800)
Logs when the configuration changes, such as when the screen orientation
changes. Logs information including font scale, screen width/height,
screen orientation, color mode.

Test: verified atom appears in adb logcat -b stats when screen
orientation changes.

Change-Id: Ifc3f3c62c5e386960b77d78f2ff2f17fc27db2b8

cmds/statsd/src/atoms.proto
services/core/java/com/android/server/am/ActivityManagerService.java

index 8e06504..fa96e11 100644 (file)
@@ -105,6 +105,7 @@ message Atom {
         KeyguardBouncerStateChanged keyguard_bouncer_state_changed = 63;
         KeyguardBouncerPasswordEntered keyguard_bouncer_password_entered = 64;
         AppDied app_died=65;
+        ResourceConfigurationChanged resource_configuration_changed = 66;
         // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
     }
 
@@ -810,6 +811,98 @@ message KeyguardBouncerPasswordEntered {
     optional BouncerResult result = 1;
 }
 
+/*
+ * Logs changes to the configuration of the device. The configuration is defined
+ * in frameworks/base/core/java/android/content/res/Configuration.java
+ * More documentation is at https://d.android.com/reference/android/content/res/Configuration.html
+ * Please go there to interpret the possible values each field can be.
+ *
+ * Logged from:
+ *   frameworks/base/services/core/java/com/android/server/am/ActivityManagerService.java
+ */
+message ResourceConfigurationChanged {
+    // Bit mask of color capabilities of the screen.
+    // Contains information about the color gamut and hdr mode of the screen.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#colorMode
+    optional int32 colorMode = 1;
+
+    // The target screen density being rendered to.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#densityDpi
+    optional int32 densityDpi = 2;
+
+    // Current user preference for the scaling factor for fonts,
+    // relative to the base density scaling.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#fontScale
+    optional float fontScale = 3;
+
+    // Flag indicating whether the hard keyboard is hidden.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#hardKeyboardHidden
+    optional int32 hardKeyboardHidden = 4;
+
+    // The type of keyboard attached to the device.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#keyboard
+    optional int32 keyboard = 5;
+
+    // Flag indicating whether any keyboard is available. Takes soft keyboards into account.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#keyboardHidden
+    optional int32 keyboardHideen = 6;
+
+    // IMSI MCC (Mobile Country Code), corresponding to mcc resource qualifier.
+    // 0 if undefined.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#mcc
+    optional int32 mcc = 7;
+
+    // IMSI MNC (Mobile Network Code), corresponding to mnc resource qualifier.
+    // 0 if undefined. Note: the actual MNC may be 0, to check for this use the
+    // MNC_ZERO symbol defined in Configuration.java.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#mnc
+    optional int32 mnc = 8;
+
+    // The kind of navigation available on the device.
+    // See: https://developer.android.com/reference/android/content/res/Configuration.html#navigation
+    optional int32 navigation = 9;
+
+    // Flag indicating whether the navigation is available.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#navigationHidden
+    optional int32 navigationHidden = 10;
+
+    // Overall orientation of the screen.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#orientation
+    optional int32 orientation = 11;
+
+    // The current height of the available screen space, in dp units.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#screenHeightDp
+    optional int32 screenHeightDp = 12;
+
+    // Bit mask of overall layout of the screen.
+    // Contains information about screen size, whether the screen is wider/taller
+    // than normal, whether the screen layout is right-tl-left or left-to-right,
+    // and whether the screen has a rounded shape.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#screenLayout
+    optional int32 screenLayout = 13;
+
+    // Current width of the available screen space, in dp units.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#screenWidthDp
+    optional int32 screenWidthDp = 14;
+
+    // The smallest screen size an application will see in normal operation.
+    // This is the smallest value of both screenWidthDp and screenHeightDp
+    // in portrait and landscape.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#smallestScreenWidthDp
+    optional int32 smallestScreenWidthDp = 15;
+
+    // The type of touch screen attached to the device.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#touchscreen
+    optional int32 touchscreen = 16;
+
+    // Bit mask of the ui mode.
+    // Contains information about the overall ui mode of the device.
+    // Eg: NORMAL, DESK, CAR, TELEVISION, WATCH, VR_HEADSET
+    // Also contains information about whether the device is in night mode.
+    // See: https://d.android.com/reference/android/content/res/Configuration.html#uiMode
+    optional int32 uiMode = 17;
+}
+
 /**
  * Logs the duration of a davey (jank of >=700ms) when it occurs
  *
index 0de4f86..17eabb9 100644 (file)
@@ -22160,6 +22160,25 @@ public class ActivityManagerService extends IActivityManager.Stub
                 "Updating global configuration to: " + values);
 
         EventLog.writeEvent(EventLogTags.CONFIGURATION_CHANGED, changes);
+        StatsLog.write(StatsLog.RESOURCE_CONFIGURATION_CHANGED,
+                values.colorMode,
+                values.densityDpi,
+                values.fontScale,
+                values.hardKeyboardHidden,
+                values.keyboard,
+                values.keyboardHidden,
+                values.mcc,
+                values.mnc,
+                values.navigation,
+                values.navigationHidden,
+                values.orientation,
+                values.screenHeightDp,
+                values.screenLayout,
+                values.screenWidthDp,
+                values.smallestScreenWidthDp,
+                values.touchscreen,
+                values.uiMode);
+
 
         if (!initLocale && !values.getLocales().isEmpty() && values.userSetLocale) {
             final LocaleList locales = values.getLocales();