diff options
7 files changed, 72 insertions, 11 deletions
diff --git a/core/java/com/android/internal/infra/AbstractRemoteService.java b/core/java/com/android/internal/infra/AbstractRemoteService.java index 594595843ca7..72c67d7ddc08 100644 --- a/core/java/com/android/internal/infra/AbstractRemoteService.java +++ b/core/java/com/android/internal/infra/AbstractRemoteService.java @@ -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(); diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java index 24fd7b9ae71d..09d926c62c77 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java @@ -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; diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java index a6bb049602a0..b3cd3ec8d675 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java +++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java @@ -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; @@ -301,7 +300,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); diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index cf4963c1bebf..76430eb42cc3 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -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 diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java index dc0f6028b0f8..e4bbcd67d4df 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java @@ -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 diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java index 09aa4212654e..2a373654f0a0 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java @@ -77,7 +77,6 @@ final class ContentCapturePerUserService ContentCapturePerUserService(@NonNull ContentCaptureManagerService master, @NonNull Object lock, boolean disabled, @UserIdInt int userId) { super(master, lock, userId); - updateRemoteServiceLocked(disabled); } @@ -162,14 +161,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, ContentCaptureSession.STATE_DISABLED_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 diff --git a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java index ebe0083b398e..3c52e17ce1e8 100644 --- a/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java +++ b/services/contentcapture/java/com/android/server/contentcapture/ContentCaptureServerSession.java @@ -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); } |