diff options
author | Jorim Jaggi <jjaggi@google.com> | 2016-10-10 11:50:35 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-10-10 11:50:39 +0000 |
commit | 1edc4ac74ffae9bda6fdd66413cc2e09f42c0b35 (patch) | |
tree | f2c0ccf28f5afd1a0067312912cdbae34480face | |
parent | b1ce491d787b5504d1bf4ffcdf7cd6cbebacdbad (diff) | |
parent | c3fe204780fb99b1d2563a9e4bb6c082b7517aed (diff) |
Merge "More latency tests (1/2)"
6 files changed, 122 insertions, 30 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java b/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java index f1b61269dd67..4b4cd868e9d3 100644 --- a/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java +++ b/packages/Keyguard/src/com/android/keyguard/LatencyTracker.java @@ -71,12 +71,18 @@ public class LatencyTracker { */ public static final int ACTION_CHECK_CREDENTIAL_UNLOCKED = 4; + /** + * Time it takes to turn on the screen. + */ + public static final int ACTION_TURN_ON_SCREEN = 5; + private static final String[] NAMES = new String[] { "expand panel", "toggle recents", "fingerprint wake-and-unlock", "check credential", - "check credential unlocked" }; + "check credential unlocked", + "turn on screen" }; private static LatencyTracker sLatencyTracker; diff --git a/packages/SystemUI/src/com/android/systemui/LatencyTester.java b/packages/SystemUI/src/com/android/systemui/LatencyTester.java new file mode 100644 index 000000000000..c14b17fed60c --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/LatencyTester.java @@ -0,0 +1,81 @@ +/* + * 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.systemui; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; +import android.os.Build; +import android.os.PowerManager; +import android.os.SystemClock; + +import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.LatencyTracker; +import com.android.systemui.statusbar.phone.FingerprintUnlockController; +import com.android.systemui.statusbar.phone.PhoneStatusBar; + +/** + * Class that only runs on debuggable builds that listens to broadcasts that simulate actions in the + * system that are used for testing the latency. + */ +public class LatencyTester extends SystemUI { + + private static final String ACTION_FINGERPRINT_WAKE = + "com.android.systemui.latency.ACTION_FINGERPRINT_WAKE"; + private static final String ACTION_TURN_ON_SCREEN = + "com.android.systemui.latency.ACTION_TURN_ON_SCREEN"; + + @Override + public void start() { + if (!Build.IS_DEBUGGABLE) { + return; + } + + IntentFilter filter = new IntentFilter(); + filter.addAction(ACTION_FINGERPRINT_WAKE); + filter.addAction(ACTION_TURN_ON_SCREEN); + mContext.registerReceiver(new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (ACTION_FINGERPRINT_WAKE.equals(action)) { + fakeWakeAndUnlock(); + } else if (ACTION_TURN_ON_SCREEN.equals(action)) { + fakeTurnOnScreen(); + } + } + }, filter); + } + + private void fakeTurnOnScreen() { + PowerManager powerManager = mContext.getSystemService(PowerManager.class); + if (LatencyTracker.isEnabled(mContext)) { + LatencyTracker.getInstance(mContext).onActionStart( + LatencyTracker.ACTION_TURN_ON_SCREEN); + } + powerManager.wakeUp(SystemClock.uptimeMillis(), "android.policy:LATENCY_TESTS"); + } + + private void fakeWakeAndUnlock() { + FingerprintUnlockController fingerprintUnlockController = getComponent(PhoneStatusBar.class) + .getFingerprintUnlockController(); + fingerprintUnlockController.onFingerprintAcquired(); + fingerprintUnlockController.onFingerprintAuthenticated( + KeyguardUpdateMonitor.getCurrentUser()); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java index e300aff96c9f..bfc86425be69 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIApplication.java @@ -29,11 +29,22 @@ import android.os.SystemProperties; import android.os.UserHandle; import android.util.Log; +import com.android.systemui.keyboard.KeyboardUI; +import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.media.RingtonePlayer; import com.android.systemui.plugins.OverlayPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.PluginManager; +import com.android.systemui.power.PowerUI; +import com.android.systemui.recents.Recents; +import com.android.systemui.shortcut.ShortcutKeyDispatcher; import com.android.systemui.stackdivider.Divider; +import com.android.systemui.statusbar.SystemBars; import com.android.systemui.statusbar.phone.PhoneStatusBar; +import com.android.systemui.tuner.TunerService; +import com.android.systemui.tv.pip.PipUI; +import com.android.systemui.usb.StorageNotification; +import com.android.systemui.volume.VolumeUI; import java.util.HashMap; import java.util.Map; @@ -50,19 +61,20 @@ public class SystemUIApplication extends Application { * The classes of the stuff to start. */ private final Class<?>[] SERVICES = new Class[] { - com.android.systemui.tuner.TunerService.class, - com.android.systemui.keyguard.KeyguardViewMediator.class, - com.android.systemui.recents.Recents.class, - com.android.systemui.volume.VolumeUI.class, + TunerService.class, + KeyguardViewMediator.class, + Recents.class, + VolumeUI.class, Divider.class, - com.android.systemui.statusbar.SystemBars.class, - com.android.systemui.usb.StorageNotification.class, - com.android.systemui.power.PowerUI.class, - com.android.systemui.media.RingtonePlayer.class, - com.android.systemui.keyboard.KeyboardUI.class, - com.android.systemui.tv.pip.PipUI.class, - com.android.systemui.shortcut.ShortcutKeyDispatcher.class, - com.android.systemui.VendorServices.class + SystemBars.class, + StorageNotification.class, + PowerUI.class, + RingtonePlayer.class, + KeyboardUI.class, + PipUI.class, + ShortcutKeyDispatcher.class, + VendorServices.class, + LatencyTester.class }; /** @@ -70,8 +82,8 @@ public class SystemUIApplication extends Application { * above. */ private final Class<?>[] SERVICES_PER_USER = new Class[] { - com.android.systemui.recents.Recents.class, - com.android.systemui.tv.pip.PipUI.class + Recents.class, + PipUI.class }; /** diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index b9e8acbf1eae..24247e4b86eb 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -73,6 +73,7 @@ import com.android.keyguard.KeyguardDisplayManager; import com.android.keyguard.KeyguardSecurityView; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.keyguard.LatencyTracker; import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.SystemUI; import com.android.systemui.SystemUIFactory; @@ -1894,6 +1895,9 @@ public class KeyguardViewMediator extends SystemUI { private void handleNotifyScreenTurnedOn() { Trace.beginSection("KeyguardViewMediator#handleNotifyScreenTurnedOn"); + if (LatencyTracker.isEnabled(mContext)) { + LatencyTracker.getInstance(mContext).onActionEnd(LatencyTracker.ACTION_TURN_ON_SCREEN); + } synchronized (this) { if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOn"); mStatusBarKeyguardViewManager.onScreenTurnedOn(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java index c04ebb0c35f5..42d9433b4367 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java @@ -42,8 +42,6 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { private static final boolean DEBUG_FP_WAKELOCK = KeyguardConstants.DEBUG_FP_WAKELOCK; private static final long FINGERPRINT_WAKELOCK_TIMEOUT_MS = 15 * 1000; private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock"; - private static final String ACTION_FINGERPRINT_WAKE_FAKE = - "com.android.systemui.ACTION_FINGERPRINT_WAKE_FAKE"; /** * Mode in which we don't need to wake up the device when we get a fingerprint. @@ -123,14 +121,6 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { mScrimController = scrimController; mPhoneStatusBar = phoneStatusBar; mUnlockMethodCache = unlockMethodCache; - if (Build.IS_DEBUGGABLE) { - context.registerReceiver(new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - fakeWakeAndUnlock(); - } - }, new IntentFilter(ACTION_FINGERPRINT_WAKE_FAKE)); - } } public void setStatusBarKeyguardViewManager( @@ -159,11 +149,6 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { } } - public void fakeWakeAndUnlock() { - onFingerprintAcquired(); - onFingerprintAuthenticated(KeyguardUpdateMonitor.getCurrentUser()); - } - @Override public void onFingerprintAcquired() { Trace.beginSection("FingerprintUnlockController#onFingerprintAcquired"); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 01aca1cb2a8d..221cc916bfa4 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -2984,6 +2984,10 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, return mGestureRec; } + public FingerprintUnlockController getFingerprintUnlockController() { + return mFingerprintUnlockController; + } + private void setNavigationIconHints(int hints) { if (hints == mNavigationIconHints) return; |