summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Alex Salo <asalo@google.com> 2019-01-31 02:27:42 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-31 02:27:42 +0000
commit4d35df367be5a900829bcac236b9cc671a5e82d1 (patch)
tree4909656ddd3cc95deb3ed35d7f63bb4ac2d51f1d
parentd0eca3b3f62a672a524a8713332b92d9e6b18e98 (diff)
parentd7c3eefece3da6c8b6819168e2e34dcf3a56391e (diff)
Merge "Add screen timeout extension event to statsd"
-rw-r--r--cmds/statsd/src/atoms.proto139
-rw-r--r--services/core/java/com/android/server/power/AttentionDetector.java19
2 files changed, 95 insertions, 63 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index 6f01d7cdd073..427662aa9eaa 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -234,6 +234,7 @@ message Atom {
BluetoothBondStateChanged bluetooth_bond_state_changed = 165;
BluetoothClassicPairingEventReported bluetooth_classic_pairing_event_reported = 166;
BluetoothSmpPairingEventReported bluetooth_smp_pairing_event_reported = 167;
+ ScreenTimeoutExtensionReported screen_timeout_extension_reported = 168;
}
// Pulled events will start at field 10000.
@@ -4983,17 +4984,17 @@ message GnssConfigurationReported {
* packages/apps/Nfc/src/com/android/nfc/cardemulation/AidRoutingManager.java
*/
message NfcErrorOccurred {
- enum Type {
- UNKNOWN = 0;
- CMD_TIMEOUT = 1;
- ERROR_NOTIFICATION = 2;
- AID_OVERFLOW = 3;
- }
- optional Type type = 1;
- // If it's nci cmd timeout, log the timeout command.
- optional uint32 nci_cmd = 2;
+ enum Type {
+ UNKNOWN = 0;
+ CMD_TIMEOUT = 1;
+ ERROR_NOTIFICATION = 2;
+ AID_OVERFLOW = 3;
+ }
+ optional Type type = 1;
+ // If it's nci cmd timeout, log the timeout command.
+ optional uint32 nci_cmd = 2;
- optional uint32 error_ntf_status_code = 3;
+ optional uint32 error_ntf_status_code = 3;
}
/**
@@ -5002,14 +5003,14 @@ message NfcErrorOccurred {
* packages/apps/Nfc/src/com/android/nfc/NfcService.java
*/
message NfcStateChanged {
- enum State {
- UNKNOWN = 0;
- OFF = 1;
- ON = 2;
- ON_LOCKED = 3; // Secure Nfc enabled.
- CRASH_RESTART = 4; // NfcService watchdog timeout restart.
- }
- optional State state = 1;
+ enum State {
+ UNKNOWN = 0;
+ OFF = 1;
+ ON = 2;
+ ON_LOCKED = 3; // Secure Nfc enabled.
+ CRASH_RESTART = 4; // NfcService watchdog timeout restart.
+ }
+ optional State state = 1;
}
/**
@@ -5018,12 +5019,12 @@ message NfcStateChanged {
* packages/apps/Nfc/src/com/android/nfc/P2pLinkManager.java
*/
message NfcBeamOccurred {
- enum Operation {
- UNKNOWN = 0;
- SEND = 1;
- RECEIVE = 2;
- }
- optional Operation operation = 1;
+ enum Operation {
+ UNKNOWN = 0;
+ SEND = 1;
+ RECEIVE = 2;
+ }
+ optional Operation operation = 1;
}
/**
@@ -5033,16 +5034,16 @@ message NfcBeamOccurred {
* packages/apps/Nfc/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java
*/
message NfcCardemulationOccurred {
- enum Category {
- UNKNOWN = 0;
- HCE_PAYMENT = 1;
- HCE_OTHER = 2;
- OFFHOST = 3;
- }
- // Transaction belongs to HCE payment or HCE other category, or offhost.
- optional Category category = 1;
- // SeName from transaction: SIMx, eSEx, HCE, HCEF.
- optional string se_name = 2;
+ enum Category {
+ UNKNOWN = 0;
+ HCE_PAYMENT = 1;
+ HCE_OTHER = 2;
+ OFFHOST = 3;
+ }
+ // Transaction belongs to HCE payment or HCE other category, or offhost.
+ optional Category category = 1;
+ // SeName from transaction: SIMx, eSEx, HCE, HCEF.
+ optional string se_name = 2;
}
/**
@@ -5051,16 +5052,16 @@ message NfcCardemulationOccurred {
* packages/apps/Nfc/src/com/android/nfc/NfcDispatcher.java
*/
message NfcTagOccurred {
- enum Type {
- UNKNOWN = 0;
- URL = 1;
- BT_PAIRING = 2;
- PROVISION = 3;
- WIFI_CONNECT = 4;
- APP_LAUNCH = 5;
- OTHERS = 6;
- }
- optional Type type = 1;
+ enum Type {
+ UNKNOWN = 0;
+ URL = 1;
+ BT_PAIRING = 2;
+ PROVISION = 3;
+ WIFI_CONNECT = 4;
+ APP_LAUNCH = 5;
+ OTHERS = 6;
+ }
+ optional Type type = 1;
}
/**
@@ -5080,18 +5081,18 @@ message NfcHceTransactionOccurred {
* packages/apps/SecureElement/src/com/android/se/Terminal.java
*/
message SeStateChanged {
- enum State {
- UNKNOWN = 0;
- INITIALIZED = 1;
- DISCONNECTED = 2;
- CONNECTED = 3;
- HALCRASH = 4;
- }
- optional State state = 1;
+ enum State {
+ UNKNOWN = 0;
+ INITIALIZED = 1;
+ DISCONNECTED = 2;
+ CONNECTED = 3;
+ HALCRASH = 4;
+ }
+ optional State state = 1;
- optional string state_change_reason = 2;
- // SIMx or eSEx.
- optional string terminal = 3;
+ optional string state_change_reason = 2;
+ // SIMx or eSEx.
+ optional string terminal = 3;
}
/**
@@ -5100,15 +5101,15 @@ message SeStateChanged {
* packages/apps/SecureElement/src/com/android/se/Terminal.java
*/
message SeOmapiReported {
- enum Operation {
- UNKNOWN = 0;
- OPEN_CHANNEL = 1;
- }
- optional Operation operation = 1;
- // SIMx or eSEx.
- optional string terminal = 2;
+ enum Operation {
+ UNKNOWN = 0;
+ OPEN_CHANNEL = 1;
+ }
+ optional Operation operation = 1;
+ // SIMx or eSEx.
+ optional string terminal = 2;
- optional string package_name = 3;
+ optional string package_name = 3;
}
/**
@@ -5290,3 +5291,15 @@ message ScheduledJobConstraintChanged {
}
optional State state = 4;
}
+
+/**
+ * Logs PowerManagerService screen timeout resets (extensions) that happen when an attention check
+ * returns true.
+ *
+ * Logged from:
+ * frameworks/base/services/core/java/com/android/server/power/PowerManagerService.java
+ */
+message ScreenTimeoutExtensionReported {
+ // Describes how many times in a row did the power manager reset the screen off timeout.
+ optional uint32 consecutive_timeout_extended_count = 1;
+}
diff --git a/services/core/java/com/android/server/power/AttentionDetector.java b/services/core/java/com/android/server/power/AttentionDetector.java
index a2c8dace9510..4186154016e2 100644
--- a/services/core/java/com/android/server/power/AttentionDetector.java
+++ b/services/core/java/com/android/server/power/AttentionDetector.java
@@ -24,11 +24,13 @@ import android.os.PowerManagerInternal;
import android.os.SystemClock;
import android.service.attention.AttentionService;
import android.util.Slog;
+import android.util.StatsLog;
import com.android.internal.annotations.VisibleForTesting;
import com.android.server.LocalServices;
import java.io.PrintWriter;
+import java.util.concurrent.atomic.AtomicLong;
/**
* Class responsible for checking if the user is currently paying attention to the phone and
@@ -79,6 +81,11 @@ public class AttentionDetector {
*/
private int mWakefulness;
+ /**
+ * Describes how many times in a row was the timeout extended.
+ */
+ private AtomicLong mConsecutiveTimeoutExtendedCount = new AtomicLong(0);
+
@VisibleForTesting
final AttentionCallbackInternal mCallback = new AttentionCallbackInternal() {
@@ -95,6 +102,8 @@ public class AttentionDetector {
}
if (result == AttentionService.ATTENTION_SUCCESS_PRESENT) {
mOnUserAttention.run();
+ } else {
+ resetConsecutiveExtensionCount();
}
}
}
@@ -176,6 +185,7 @@ public class AttentionDetector {
public int onUserActivity(long eventTime, int event) {
switch (event) {
case PowerManager.USER_ACTIVITY_EVENT_ATTENTION:
+ mConsecutiveTimeoutExtendedCount.incrementAndGet();
return 0;
case PowerManager.USER_ACTIVITY_EVENT_OTHER:
case PowerManager.USER_ACTIVITY_EVENT_BUTTON:
@@ -183,6 +193,7 @@ public class AttentionDetector {
case PowerManager.USER_ACTIVITY_EVENT_ACCESSIBILITY:
cancelCurrentRequestIfAny();
mLastUserActivityTime = eventTime;
+ resetConsecutiveExtensionCount();
return 1;
default:
if (DEBUG) {
@@ -196,6 +207,7 @@ public class AttentionDetector {
mWakefulness = wakefulness;
if (wakefulness != PowerManagerInternal.WAKEFULNESS_AWAKE) {
cancelCurrentRequestIfAny();
+ resetConsecutiveExtensionCount();
}
}
@@ -206,6 +218,13 @@ public class AttentionDetector {
}
}
+ private void resetConsecutiveExtensionCount() {
+ final long previousCount = mConsecutiveTimeoutExtendedCount.getAndSet(0);
+ if (previousCount > 0) {
+ StatsLog.write(StatsLog.SCREEN_TIMEOUT_EXTENSION_REPORTED, previousCount);
+ }
+ }
+
@VisibleForTesting
int getRequestCode() {
return (int) (mLastUserActivityTime % Integer.MAX_VALUE);