Added LatencyTimer to ease latency measurements
new file: core/java/android/os/LatencyTimer.java modified: core/java/android/view/MotionEvent.java modified: core/java/android/view/ViewRoot.java modified: services/java/com/android/server/InputDevice.java modified: services/java/com/android/server/KeyInputQueue.java modified: services/java/com/android/server/WindowManagerService.java
This commit is contained in:
@@ -63,6 +63,7 @@ import android.os.Binder;
|
||||
import android.os.Debug;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.LatencyTimer;
|
||||
import android.os.LocalPowerManager;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
@@ -133,7 +134,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
static final boolean DEBUG_STARTING_WINDOW = false;
|
||||
static final boolean DEBUG_REORDER = false;
|
||||
static final boolean SHOW_TRANSACTIONS = false;
|
||||
|
||||
static final boolean MEASURE_LATENCY = false;
|
||||
static private LatencyTimer lt;
|
||||
|
||||
static final boolean PROFILE_ORIENTATION = false;
|
||||
static final boolean BLUR = true;
|
||||
static final boolean localLOGV = DEBUG;
|
||||
@@ -495,6 +498,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
|
||||
private WindowManagerService(Context context, PowerManagerService pm,
|
||||
boolean haveInputMethods) {
|
||||
if (MEASURE_LATENCY) {
|
||||
lt = new LatencyTimer(100, 1000);
|
||||
}
|
||||
|
||||
mContext = context;
|
||||
mHaveInputMethods = haveInputMethods;
|
||||
mLimitedAlphaCompositing = context.getResources().getBoolean(
|
||||
@@ -3775,9 +3782,17 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
if (DEBUG_INPUT || WindowManagerPolicy.WATCH_POINTER) Log.v(TAG,
|
||||
"dispatchPointer " + ev);
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("3 Wait for last dispatch ", System.nanoTime() - qev.whenNano);
|
||||
}
|
||||
|
||||
Object targetObj = mKeyWaiter.waitForNextEventTarget(null, qev,
|
||||
ev, true, false);
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("3 Last dispatch finished ", System.nanoTime() - qev.whenNano);
|
||||
}
|
||||
|
||||
int action = ev.getAction();
|
||||
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
@@ -3814,6 +3829,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
WindowState target = (WindowState)targetObj;
|
||||
|
||||
final long eventTime = ev.getEventTime();
|
||||
final long eventTimeNano = ev.getEventTimeNano();
|
||||
|
||||
//Log.i(TAG, "Sending " + ev + " to " + target);
|
||||
|
||||
@@ -3832,6 +3848,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
}
|
||||
}
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("4 in dispatchPointer ", System.nanoTime() - eventTimeNano);
|
||||
}
|
||||
|
||||
if ((target.mAttrs.flags &
|
||||
WindowManager.LayoutParams.FLAG_IGNORE_CHEEK_PRESSES) != 0) {
|
||||
//target wants to ignore fat touch events
|
||||
@@ -3914,6 +3934,10 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
}
|
||||
}
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("5 in dispatchPointer ", System.nanoTime() - eventTimeNano);
|
||||
}
|
||||
|
||||
synchronized(mWindowMap) {
|
||||
if (qev != null && action == MotionEvent.ACTION_MOVE) {
|
||||
mKeyWaiter.bindTargetWindowLocked(target,
|
||||
@@ -3951,7 +3975,16 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
if (DEBUG_INPUT || DEBUG_FOCUS || WindowManagerPolicy.WATCH_POINTER) {
|
||||
Log.v(TAG, "Delivering pointer " + qev + " to " + target);
|
||||
}
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("6 before svr->client ipc ", System.nanoTime() - eventTimeNano);
|
||||
}
|
||||
|
||||
target.mClient.dispatchPointer(ev, eventTime);
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("7 after svr->client ipc ", System.nanoTime() - eventTimeNano);
|
||||
}
|
||||
return true;
|
||||
} catch (android.os.RemoteException e) {
|
||||
Log.i(TAG, "WINDOW DIED during motion dispatch: " + target);
|
||||
@@ -5072,7 +5105,7 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public boolean detectSafeMode() {
|
||||
mSafeMode = mPolicy.detectSafeMode();
|
||||
@@ -5137,9 +5170,13 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
if (DEBUG_INPUT && ev != null) Log.v(
|
||||
TAG, "Event: type=" + ev.classType + " data=" + ev.event);
|
||||
|
||||
if (MEASURE_LATENCY) {
|
||||
lt.sample("2 got event ", System.nanoTime() - ev.whenNano);
|
||||
}
|
||||
|
||||
try {
|
||||
if (ev != null) {
|
||||
curTime = ev.when;
|
||||
curTime = SystemClock.uptimeMillis();
|
||||
int eventType;
|
||||
if (ev.classType == RawInputEvent.CLASS_TOUCHSCREEN) {
|
||||
eventType = eventType((MotionEvent)ev.event);
|
||||
@@ -5150,11 +5187,9 @@ public class WindowManagerService extends IWindowManager.Stub implements Watchdo
|
||||
eventType = LocalPowerManager.OTHER_EVENT;
|
||||
}
|
||||
try {
|
||||
long now = SystemClock.uptimeMillis();
|
||||
|
||||
if ((now - mLastBatteryStatsCallTime)
|
||||
if ((curTime - mLastBatteryStatsCallTime)
|
||||
>= MIN_TIME_BETWEEN_USERACTIVITIES) {
|
||||
mLastBatteryStatsCallTime = now;
|
||||
mLastBatteryStatsCallTime = curTime;
|
||||
mBatteryStats.noteInputEvent();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
|
||||
Reference in New Issue
Block a user