Merge "Logs how long it took to show the Autofill UI after a field was focused." into oc-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f6704f882a
@@ -4532,6 +4532,12 @@ message MetricsEvent {
|
|||||||
// OS: O MR
|
// OS: O MR
|
||||||
AUTOFILL_SERVICE_DISABLED_SELF = 1135;
|
AUTOFILL_SERVICE_DISABLED_SELF = 1135;
|
||||||
|
|
||||||
|
// Counter showing how long it took (in ms) to show the autofill UI after a field was focused
|
||||||
|
// Tag FIELD_AUTOFILL_SERVICE: Package of service that processed the request
|
||||||
|
// Package: Package of the autofill service
|
||||||
|
// OS: O MR
|
||||||
|
AUTOFILL_UI_LATENCY = 1136;
|
||||||
|
|
||||||
// ---- End O-MR1 Constants, all O-MR1 constants go above this line ----
|
// ---- End O-MR1 Constants, all O-MR1 constants go above this line ----
|
||||||
|
|
||||||
// Add new aosp constants above this line.
|
// Add new aosp constants above this line.
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
private final SparseBooleanArray mDisabledUsers = new SparseBooleanArray();
|
private final SparseBooleanArray mDisabledUsers = new SparseBooleanArray();
|
||||||
|
|
||||||
private final LocalLog mRequestsHistory = new LocalLog(20);
|
private final LocalLog mRequestsHistory = new LocalLog(20);
|
||||||
|
private final LocalLog mUiLatencyHistory = new LocalLog(20);
|
||||||
|
|
||||||
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
@@ -306,7 +307,7 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
AutofillManagerServiceImpl service = mServicesCache.get(resolvedUserId);
|
AutofillManagerServiceImpl service = mServicesCache.get(resolvedUserId);
|
||||||
if (service == null) {
|
if (service == null) {
|
||||||
service = new AutofillManagerServiceImpl(mContext, mLock, mRequestsHistory,
|
service = new AutofillManagerServiceImpl(mContext, mLock, mRequestsHistory,
|
||||||
resolvedUserId, mUi, mDisabledUsers.get(resolvedUserId));
|
mUiLatencyHistory, resolvedUserId, mUi, mDisabledUsers.get(resolvedUserId));
|
||||||
mServicesCache.put(userId, service);
|
mServicesCache.put(userId, service);
|
||||||
}
|
}
|
||||||
return service;
|
return service;
|
||||||
@@ -736,6 +737,8 @@ public final class AutofillManagerService extends SystemService {
|
|||||||
if (showHistory) {
|
if (showHistory) {
|
||||||
pw.println("Requests history:");
|
pw.println("Requests history:");
|
||||||
mRequestsHistory.reverseDump(fd, pw, args);
|
mRequestsHistory.reverseDump(fd, pw, args);
|
||||||
|
pw.println("UI latency history:");
|
||||||
|
mUiLatencyHistory.reverseDump(fd, pw, args);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
setDebugLocked(oldDebug);
|
setDebugLocked(oldDebug);
|
||||||
|
|||||||
@@ -100,6 +100,8 @@ final class AutofillManagerServiceImpl {
|
|||||||
private static final Random sRandom = new Random();
|
private static final Random sRandom = new Random();
|
||||||
|
|
||||||
private final LocalLog mRequestsHistory;
|
private final LocalLog mRequestsHistory;
|
||||||
|
private final LocalLog mUiLatencyHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether service was disabled for user due to {@link UserManager} restrictions.
|
* Whether service was disabled for user due to {@link UserManager} restrictions.
|
||||||
*/
|
*/
|
||||||
@@ -141,10 +143,11 @@ final class AutofillManagerServiceImpl {
|
|||||||
private long mLastPrune = 0;
|
private long mLastPrune = 0;
|
||||||
|
|
||||||
AutofillManagerServiceImpl(Context context, Object lock, LocalLog requestsHistory,
|
AutofillManagerServiceImpl(Context context, Object lock, LocalLog requestsHistory,
|
||||||
int userId, AutoFillUI ui, boolean disabled) {
|
LocalLog uiLatencyHistory, int userId, AutoFillUI ui, boolean disabled) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mLock = lock;
|
mLock = lock;
|
||||||
mRequestsHistory = requestsHistory;
|
mRequestsHistory = requestsHistory;
|
||||||
|
mUiLatencyHistory = uiLatencyHistory;
|
||||||
mUserId = userId;
|
mUserId = userId;
|
||||||
mUi = ui;
|
mUi = ui;
|
||||||
updateLocked(disabled);
|
updateLocked(disabled);
|
||||||
@@ -399,7 +402,7 @@ final class AutofillManagerServiceImpl {
|
|||||||
|
|
||||||
final Session newSession = new Session(this, mUi, mContext, mHandlerCaller, mUserId, mLock,
|
final Session newSession = new Session(this, mUi, mContext, mHandlerCaller, mUserId, mLock,
|
||||||
sessionId, uid, activityToken, appCallbackToken, hasCallback,
|
sessionId, uid, activityToken, appCallbackToken, hasCallback,
|
||||||
mInfo.getServiceInfo().getComponentName(), packageName);
|
mUiLatencyHistory, mInfo.getServiceInfo().getComponentName(), packageName);
|
||||||
mSessions.put(newSession.id, newSession);
|
mSessions.put(newSession.id, newSession);
|
||||||
|
|
||||||
return newSession;
|
return newSession;
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import android.os.Bundle;
|
|||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
|
import android.os.SystemClock;
|
||||||
import android.service.autofill.AutofillService;
|
import android.service.autofill.AutofillService;
|
||||||
import android.service.autofill.Dataset;
|
import android.service.autofill.Dataset;
|
||||||
import android.service.autofill.FillContext;
|
import android.service.autofill.FillContext;
|
||||||
@@ -61,8 +62,10 @@ import android.service.autofill.SaveRequest;
|
|||||||
import android.service.autofill.ValueFinder;
|
import android.service.autofill.ValueFinder;
|
||||||
import android.util.ArrayMap;
|
import android.util.ArrayMap;
|
||||||
import android.util.ArraySet;
|
import android.util.ArraySet;
|
||||||
|
import android.util.LocalLog;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
import android.util.TimeUtils;
|
||||||
import android.view.autofill.AutofillId;
|
import android.view.autofill.AutofillId;
|
||||||
import android.view.autofill.AutofillManager;
|
import android.view.autofill.AutofillManager;
|
||||||
import android.view.autofill.AutofillValue;
|
import android.view.autofill.AutofillValue;
|
||||||
@@ -176,6 +179,20 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
@GuardedBy("mLock")
|
@GuardedBy("mLock")
|
||||||
private PendingUi mPendingSaveUi;
|
private PendingUi mPendingSaveUi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the session started (using elapsed time since boot).
|
||||||
|
*/
|
||||||
|
private final long mStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When the UI was shown for the first time (using elapsed time since boot).
|
||||||
|
*/
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private long mUiShownTime;
|
||||||
|
|
||||||
|
@GuardedBy("mLock")
|
||||||
|
private final LocalLog mUiLatencyHistory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receiver of assist data from the app's {@link Activity}.
|
* Receiver of assist data from the app's {@link Activity}.
|
||||||
*/
|
*/
|
||||||
@@ -397,10 +414,11 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
Session(@NonNull AutofillManagerServiceImpl service, @NonNull AutoFillUI ui,
|
Session(@NonNull AutofillManagerServiceImpl service, @NonNull AutoFillUI ui,
|
||||||
@NonNull Context context, @NonNull HandlerCaller handlerCaller, int userId,
|
@NonNull Context context, @NonNull HandlerCaller handlerCaller, int userId,
|
||||||
@NonNull Object lock, int sessionId, int uid, @NonNull IBinder activityToken,
|
@NonNull Object lock, int sessionId, int uid, @NonNull IBinder activityToken,
|
||||||
@NonNull IBinder client, boolean hasCallback,
|
@NonNull IBinder client, boolean hasCallback, @NonNull LocalLog uiLatencyHistory,
|
||||||
@NonNull ComponentName componentName, @NonNull String packageName) {
|
@NonNull ComponentName componentName, @NonNull String packageName) {
|
||||||
id = sessionId;
|
id = sessionId;
|
||||||
this.uid = uid;
|
this.uid = uid;
|
||||||
|
mStartTime = SystemClock.elapsedRealtime();
|
||||||
mService = service;
|
mService = service;
|
||||||
mLock = lock;
|
mLock = lock;
|
||||||
mUi = ui;
|
mUi = ui;
|
||||||
@@ -408,6 +426,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
mRemoteFillService = new RemoteFillService(context, componentName, userId, this);
|
mRemoteFillService = new RemoteFillService(context, componentName, userId, this);
|
||||||
mActivityToken = activityToken;
|
mActivityToken = activityToken;
|
||||||
mHasCallback = hasCallback;
|
mHasCallback = hasCallback;
|
||||||
|
mUiLatencyHistory = uiLatencyHistory;
|
||||||
mPackageName = packageName;
|
mPackageName = packageName;
|
||||||
mClient = IAutoFillManagerClient.Stub.asInterface(client);
|
mClient = IAutoFillManagerClient.Stub.asInterface(client);
|
||||||
|
|
||||||
@@ -1347,6 +1366,31 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
|
|
||||||
getUiForShowing().showFillUi(filledId, response, filterText,
|
getUiForShowing().showFillUi(filledId, response, filterText,
|
||||||
mService.getServicePackageName(), mPackageName, this);
|
mService.getServicePackageName(), mPackageName, this);
|
||||||
|
|
||||||
|
synchronized (mLock) {
|
||||||
|
if (mUiShownTime == 0) {
|
||||||
|
// Log first time UI is shown.
|
||||||
|
mUiShownTime = SystemClock.elapsedRealtime();
|
||||||
|
final long duration = mUiShownTime - mStartTime;
|
||||||
|
if (sDebug) {
|
||||||
|
final StringBuilder msg = new StringBuilder("1st UI for ")
|
||||||
|
.append(mActivityToken)
|
||||||
|
.append(" shown in ");
|
||||||
|
TimeUtils.formatDuration(duration, msg);
|
||||||
|
Slog.d(TAG, msg.toString());
|
||||||
|
}
|
||||||
|
final StringBuilder historyLog = new StringBuilder("id=").append(id)
|
||||||
|
.append(" app=").append(mActivityToken)
|
||||||
|
.append(" svc=").append(mService.getServicePackageName())
|
||||||
|
.append(" latency=");
|
||||||
|
TimeUtils.formatDuration(duration, historyLog);
|
||||||
|
mUiLatencyHistory.log(historyLog.toString());
|
||||||
|
|
||||||
|
final LogMaker metricsLog = newLogMaker(MetricsEvent.AUTOFILL_UI_LATENCY)
|
||||||
|
.setCounterValue((int) duration);
|
||||||
|
mMetricsLogger.write(metricsLog);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isDestroyed() {
|
boolean isDestroyed() {
|
||||||
@@ -1655,6 +1699,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
|
|||||||
pw.print(prefix); pw.print("uid: "); pw.println(uid);
|
pw.print(prefix); pw.print("uid: "); pw.println(uid);
|
||||||
pw.print(prefix); pw.print("mPackagename: "); pw.println(mPackageName);
|
pw.print(prefix); pw.print("mPackagename: "); pw.println(mPackageName);
|
||||||
pw.print(prefix); pw.print("mActivityToken: "); pw.println(mActivityToken);
|
pw.print(prefix); pw.print("mActivityToken: "); pw.println(mActivityToken);
|
||||||
|
pw.print(prefix); pw.print("mStartTime: "); pw.println(mStartTime);
|
||||||
|
pw.print(prefix); pw.print("Time to show UI: ");
|
||||||
|
if (mUiShownTime == 0) {
|
||||||
|
pw.println("N/A");
|
||||||
|
} else {
|
||||||
|
TimeUtils.formatDuration(mUiShownTime - mStartTime, pw);
|
||||||
|
pw.println();
|
||||||
|
}
|
||||||
pw.print(prefix); pw.print("mResponses: ");
|
pw.print(prefix); pw.print("mResponses: ");
|
||||||
if (mResponses == null) {
|
if (mResponses == null) {
|
||||||
pw.println("null");
|
pw.println("null");
|
||||||
|
|||||||
Reference in New Issue
Block a user