Merge "Log Content Capture and Augmented Autofill requests."

This commit is contained in:
TreeHugger Robot
2019-01-17 20:01:46 +00:00
committed by Android (Google) Code Review
7 changed files with 72 additions and 11 deletions

View File

@@ -139,6 +139,14 @@ public abstract class AbstractRemoteService<S extends AbstractRemoteService<S, I
return mDestroyed;
}
/**
* Gets the name of the service.
*/
@NonNull
public final ComponentName getComponentName() {
return mComponentName;
}
private void handleOnConnectedStateChangedInternal(boolean connected) {
if (connected) {
handlePendingRequests();

View File

@@ -252,9 +252,8 @@ public final class AutofillManagerService
@Override // from AbstractMasterSystemService
protected AutofillManagerServiceImpl newServiceLocked(@UserIdInt int resolvedUserId,
boolean disabled) {
return new AutofillManagerServiceImpl(this, mLock, mRequestsHistory,
mUiLatencyHistory, mWtfHistory, resolvedUserId, mUi, mAutofillCompatState,
disabled);
return new AutofillManagerServiceImpl(this, mLock, mUiLatencyHistory,
mWtfHistory, resolvedUserId, mUi, mAutofillCompatState, disabled);
}
@Override // AbstractMasterSystemService
@@ -291,6 +290,13 @@ public final class AutofillManagerService
return mSupportedSmartSuggestionModes;
}
/**
* Logs a request so it's dumped later...
*/
void logRequestLocked(@NonNull String historyItem) {
mRequestsHistory.log(historyItem);
}
// Called by AutofillManagerServiceImpl, doesn't need to check permission
boolean isInstantServiceAllowed() {
return mAllowInstantService;

View File

@@ -108,7 +108,6 @@ final class AutofillManagerServiceImpl
private static final Random sRandom = new Random();
private final LocalLog mRequestsHistory;
private final LocalLog mUiLatencyHistory;
private final LocalLog mWtfHistory;
private final FieldClassificationStrategy mFieldClassificationStrategy;
@@ -166,12 +165,12 @@ final class AutofillManagerServiceImpl
@Nullable
private RemoteAugmentedAutofillService mRemoteAugmentedAutofillService;
AutofillManagerServiceImpl(AutofillManagerService master, Object lock, LocalLog requestsHistory,
AutofillManagerServiceImpl(AutofillManagerService master, Object lock,
LocalLog uiLatencyHistory, LocalLog wtfHistory, int userId, AutoFillUI ui,
AutofillCompatState autofillCompatState, boolean disabled) {
AutofillCompatState autofillCompatState,
boolean disabled) {
super(master, lock, userId);
mRequestsHistory = requestsHistory;
mUiLatencyHistory = uiLatencyHistory;
mWtfHistory = wtfHistory;
mUi = ui;
@@ -310,7 +309,7 @@ final class AutofillManagerServiceImpl
+ " s=" + mInfo.getServiceInfo().packageName
+ " u=" + mUserId + " i=" + autofillId + " b=" + virtualBounds
+ " hc=" + hasCallback + " f=" + flags;
mRequestsHistory.log(historyItem);
mMaster.logRequestLocked(historyItem);
newSession.updateLocked(autofillId, virtualBounds, value, ACTION_START_SESSION, flags);

View File

@@ -2610,6 +2610,13 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
+ " when server returned null for session " + this.id);
}
final String historyItem =
"aug:id=" + id + " u=" + uid + " m=" + mode
+ " a=" + ComponentName.flattenToShortString(mComponentName)
+ " f=" + mCurrentViewId
+ " s=" + remoteService.getComponentName();
mService.getMaster().logRequestLocked(historyItem);
final AutofillValue currentValue = mViewStates.get(mCurrentViewId).getCurrentValue();
// TODO(b/111330312): we might need to add a new state in the AutofillManager to optimize

View File

@@ -32,6 +32,7 @@ import android.os.ResultReceiver;
import android.os.ShellCallback;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.LocalLog;
import android.util.Slog;
import android.view.contentcapture.IContentCaptureManager;
@@ -69,6 +70,8 @@ public final class ContentCaptureManagerService extends
private final LocalService mLocalService = new LocalService();
private final LocalLog mRequestsHistory = new LocalLog(20);
public ContentCaptureManagerService(@NonNull Context context) {
super(context, new FrameworkResourcesServiceNameResolver(context,
com.android.internal.R.string.config_defaultContentCaptureService),
@@ -154,6 +157,13 @@ public final class ContentCaptureManagerService extends
}
}
/**
* Logs a request so it's dumped later...
*/
void logRequestLocked(@NonNull String historyItem) {
mRequestsHistory.log(historyItem);
}
private ActivityManagerInternal getAmInternal() {
synchronized (mLock) {
if (mAm == null) {
@@ -217,9 +227,29 @@ public final class ContentCaptureManagerService extends
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpPermission(getContext(), TAG, pw)) return;
boolean showHistory = true;
if (args != null) {
for (String arg : args) {
switch(arg) {
case "--no-history":
showHistory = false;
break;
case "--help":
pw.println("Usage: dumpsys content_capture [--no-history]");
return;
default:
Slog.w(TAG, "Ignoring invalid dump arg: " + arg);
}
}
}
synchronized (mLock) {
dumpLocked("", pw);
}
if (showHistory) {
pw.println(); pw.println("Requests history:"); pw.println();
mRequestsHistory.reverseDump(fd, pw, args);
}
}
@Override

View File

@@ -85,7 +85,6 @@ final class ContentCapturePerUserService
ContentCapturePerUserService(@NonNull ContentCaptureManagerService master,
@NonNull Object lock, boolean disabled, @UserIdInt int userId) {
super(master, lock, userId);
updateRemoteServiceLocked(disabled);
}
@@ -170,14 +169,24 @@ final class ContentCapturePerUserService
@NonNull ComponentName componentName, int taskId, int displayId,
@NonNull String sessionId, int uid, int flags,
@NonNull IResultReceiver clientReceiver) {
if (!isEnabledLocked()) {
final ComponentName serviceComponentName = getServiceComponentName();
final boolean enabled = isEnabledLocked();
final String historyItem =
"id=" + sessionId + " uid=" + uid
+ " a=" + ComponentName.flattenToShortString(componentName)
+ " t=" + taskId + " d=" + displayId
+ " s=" + ComponentName.flattenToShortString(serviceComponentName)
+ " u=" + mUserId + " f=" + flags + (enabled ? "" : " (disabled)");
mMaster.logRequestLocked(historyItem);
if (!enabled) {
// TODO: it would be better to split in differet reasons, like
// STATE_DISABLED_NO_SERVICE and STATE_DISABLED_BY_DEVICE_POLICY
setClientState(clientReceiver, STATE_DISABLED | STATE_NO_SERVICE,
/* binder= */ null);
return;
}
final ComponentName serviceComponentName = getServiceComponentName();
if (serviceComponentName == null) {
// TODO(b/111276913): this happens when the system service is starting, we should
// probably handle it in a more elegant way (like waiting for boot_complete or

View File

@@ -83,6 +83,8 @@ final class ContentCaptureServerSession {
*/
@GuardedBy("mLock")
public void sendActivitySnapshotLocked(@NonNull SnapshotData snapshotData) {
mService.getMaster().logRequestLocked("snapshot: id=" + mId);
mRemoteService.onActivitySnapshotRequest(mId, snapshotData);
}