summaryrefslogtreecommitdiff
path: root/packages/Keyguard/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Keyguard/src')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java15
-rw-r--r--packages/Keyguard/src/com/android/keyguard/LatencyTracker.java143
-rw-r--r--packages/Keyguard/src/com/android/systemui/EventLogTags.logtags68
3 files changed, 226 insertions, 0 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
index 766eab7e3bf3..1a61f7a0d847 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java
@@ -16,6 +16,9 @@
package com.android.keyguard;
+import static com.android.keyguard.LatencyTracker.ACTION_CHECK_CREDENTIAL;
+import static com.android.keyguard.LatencyTracker.ACTION_CHECK_CREDENTIAL_UNLOCKED;
+
import android.content.Context;
import android.os.AsyncTask;
import android.os.CountDownTimer;
@@ -132,6 +135,10 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
return;
}
+ if (LatencyTracker.isEnabled(mContext)) {
+ LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL);
+ LatencyTracker.getInstance(mContext).onActionStart(ACTION_CHECK_CREDENTIAL_UNLOCKED);
+ }
mPendingLockCheck = LockPatternChecker.checkPassword(
mLockPatternUtils,
entry,
@@ -140,12 +147,20 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
@Override
public void onEarlyMatched() {
+ if (LatencyTracker.isEnabled(mContext)) {
+ LatencyTracker.getInstance(mContext).onActionEnd(
+ ACTION_CHECK_CREDENTIAL);
+ }
onPasswordChecked(userId, true /* matched */, 0 /* timeoutMs */,
true /* isValidPassword */);
}
@Override
public void onChecked(boolean matched, int timeoutMs) {
+ if (LatencyTracker.isEnabled(mContext)) {
+ LatencyTracker.getInstance(mContext).onActionEnd(
+ ACTION_CHECK_CREDENTIAL_UNLOCKED);
+ }
setPasswordEntryInputEnabled(true);
mPendingLockCheck = null;
if (!matched) {
diff --git a/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java b/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java
new file mode 100644
index 000000000000..f1b61269dd67
--- /dev/null
+++ b/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2016 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
+ */
+
+package com.android.keyguard;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.Build;
+import android.os.SystemClock;
+import android.os.SystemProperties;
+import android.os.Trace;
+import android.util.EventLog;
+import android.util.Log;
+import android.util.SparseLongArray;
+
+import com.android.systemui.EventLogTags;
+
+/**
+ * Class to track various latencies in SystemUI. It then outputs the latency to logcat so these
+ * latencies can be captured by tests and then used for dashboards.
+ * <p>
+ * This is currently only in Keyguard so it can be shared between SystemUI and Keyguard, but
+ * eventually we'd want to merge these two packages together so Keyguard can use common classes
+ * that are shared with SystemUI.
+ */
+public class LatencyTracker {
+
+ private static final String ACTION_RELOAD_PROPERTY =
+ "com.android.systemui.RELOAD_LATENCY_TRACKER_PROPERTY";
+
+ private static final String TAG = "LatencyTracker";
+
+ /**
+ * Time it takes until the first frame of the notification panel to be displayed while expanding
+ */
+ public static final int ACTION_EXPAND_PANEL = 0;
+
+ /**
+ * Time it takes until the first frame of recents is drawn after invoking it with the button.
+ */
+ public static final int ACTION_TOGGLE_RECENTS = 1;
+
+ /**
+ * Time between we get a fingerprint acquired signal until we start with the unlock animation
+ */
+ public static final int ACTION_FINGERPRINT_WAKE_AND_UNLOCK = 2;
+
+ /**
+ * Time it takes to check PIN/Pattern/Password.
+ */
+ public static final int ACTION_CHECK_CREDENTIAL = 3;
+
+ /**
+ * Time it takes to check fully PIN/Pattern/Password, i.e. that's the time spent including the
+ * actions to unlock a user.
+ */
+ public static final int ACTION_CHECK_CREDENTIAL_UNLOCKED = 4;
+
+ private static final String[] NAMES = new String[] {
+ "expand panel",
+ "toggle recents",
+ "fingerprint wake-and-unlock",
+ "check credential",
+ "check credential unlocked" };
+
+ private static LatencyTracker sLatencyTracker;
+
+ private final SparseLongArray mStartRtc = new SparseLongArray();
+ private boolean mEnabled;
+
+ public static LatencyTracker getInstance(Context context) {
+ if (sLatencyTracker == null) {
+ sLatencyTracker = new LatencyTracker(context);
+ }
+ return sLatencyTracker;
+ }
+
+ private LatencyTracker(Context context) {
+ context.registerReceiver(new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ reloadProperty();
+ }
+ }, new IntentFilter(ACTION_RELOAD_PROPERTY));
+ reloadProperty();
+ }
+
+ private void reloadProperty() {
+ mEnabled = SystemProperties.getBoolean("debug.systemui.latency_tracking", false);
+ }
+
+ public static boolean isEnabled(Context ctx) {
+ return Build.IS_DEBUGGABLE && getInstance(ctx).mEnabled;
+ }
+
+ /**
+ * Notifies that an action is starting. This needs to be called from the main thread.
+ *
+ * @param action The action to start. One of the ACTION_* values.
+ */
+ public void onActionStart(int action) {
+ if (!mEnabled) {
+ return;
+ }
+ Trace.asyncTraceBegin(Trace.TRACE_TAG_APP, NAMES[action], 0);
+ mStartRtc.put(action, SystemClock.elapsedRealtime());
+ }
+
+ /**
+ * Notifies that an action has ended. This needs to be called from the main thread.
+ *
+ * @param action The action to end. One of the ACTION_* values.
+ */
+ public void onActionEnd(int action) {
+ if (!mEnabled) {
+ return;
+ }
+ long endRtc = SystemClock.elapsedRealtime();
+ long startRtc = mStartRtc.get(action, -1);
+ if (startRtc == -1) {
+ return;
+ }
+ Trace.asyncTraceEnd(Trace.TRACE_TAG_APP, NAMES[action], 0);
+ long duration = endRtc - startRtc;
+ Log.i(TAG, "action=" + action + " latency=" + duration);
+ EventLog.writeEvent(EventLogTags.SYSUI_LATENCY, action, (int) duration);
+ }
+}
diff --git a/packages/Keyguard/src/com/android/systemui/EventLogTags.logtags b/packages/Keyguard/src/com/android/systemui/EventLogTags.logtags
new file mode 100644
index 000000000000..d4149ea6d68f
--- /dev/null
+++ b/packages/Keyguard/src/com/android/systemui/EventLogTags.logtags
@@ -0,0 +1,68 @@
+# See system/core/logcat/event.logtags for a description of the format of this file.
+
+option java_package com.android.systemui;
+
+# ---------------------------
+# PhoneStatusBar.java
+# ---------------------------
+36000 sysui_statusbar_touch (type|1),(x|1),(y|1),(disable1|1),(disable2|1)
+36001 sysui_heads_up_status (key|3),(visible|1)
+36002 sysui_fullscreen_notification (key|3)
+36003 sysui_heads_up_escalation (key|3)
+# sysui_status_bar_state: Logged whenever the status bar / keyguard state changes
+## state: 0: SHADE, 1: KEYGUARD, 2: SHADE_LOCKED
+## keyguardShowing: 1: Keyguard shown to the user (or keyguardOccluded)
+## keyguardOccluded: 1: Keyguard active, but another activity is occluding it
+## bouncerShowing: 1: Bouncer currently shown to the user
+## secure: 1: The user has set up a secure unlock method (PIN, password, etc.)
+## currentlyInsecure: 1: No secure unlock method set up (!secure), or trusted environment (TrustManager)
+36004 sysui_status_bar_state (state|1),(keyguardShowing|1),(keyguardOccluded|1),(bouncerShowing|1),(secure|1),(currentlyInsecure|1)
+
+# ---------------------------
+# PhoneStatusBarView.java
+# ---------------------------
+36010 sysui_panelbar_touch (type|1),(x|1),(y|1),(enabled|1)
+
+# ---------------------------
+# NotificationPanelView.java
+# ---------------------------
+36020 sysui_notificationpanel_touch (type|1),(x|1),(y|1)
+## type: 1: SWIPE_UP_UNLOCK Swiped up to dismiss the lockscreen.
+## 2: SWIPE_DOWN_FULL_SHADE Swiped down to enter full shade.
+## 3: TAP_UNLOCK_HINT Tapped in empty area, causes unlock hint.
+## 4: SWIPE_CAMERA Swiped the camera icon, launches.
+## 5: SWIPE_DIALER Swiped the dialer icon, launches.
+## 6: TAP_LOCK Tapped the (unlocked) lock icon, locks the device.
+## 7: TAP_NOTIFICATION_ACTIVATE Tapped a lockscreen notification, causes "tap again" hint.
+## Note: Second tap logged as notification_clicked.
+36021 sysui_lockscreen_gesture (type|1),(lengthDp|1),(velocityDp|1)
+
+# ---------------------------
+# SettingsPanelView.java
+# ---------------------------
+36030 sysui_quickpanel_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# PanelHolder.java
+# ---------------------------
+36040 sysui_panelholder_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# SearchPanelView.java
+# ---------------------------
+36050 sysui_searchpanel_touch (type|1),(x|1),(y|1)
+
+# ---------------------------
+# Recents.java, RecentsSystemUser.java
+# ---------------------------
+## type: 1: USER_BIND_SERVICE Secondary user tries binding to the system sysui service
+## 2: USER_SYSTEM_BOUND Secondary user is bound to the system sysui service
+## 3: USER_SYSTEM_UNBOUND Secondary user loses connection after system sysui has died
+## 4: SYSTEM_REGISTER_USER System sysui registers user's callbacks
+## 5: SYSTEM_UNREGISTER_USER System sysui unregisters user's callbacks (after death)
+36060 sysui_recents_connection (type|1),(user|1)
+
+# ---------------------------
+# LatencyTracker.java
+# ---------------------------
+36070 sysui_latency (action|1|5),(latency|1|3)