Merge "More latency tests (1/2)"

This commit is contained in:
Jorim Jaggi
2016-10-10 11:50:35 +00:00
committed by Android (Google) Code Review
6 changed files with 122 additions and 30 deletions

View File

@@ -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;

View File

@@ -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());
}
}

View File

@@ -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
};
/**

View File

@@ -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();

View File

@@ -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");

View File

@@ -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;