Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db117605 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Log Content Capture and Augmented Autofill requests."

parents becdfa7a 930f324b
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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();
+9 −3
Original line number Diff line number Diff line
@@ -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;
+4 −5
Original line number Diff line number Diff line
@@ -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);

+7 −0
Original line number Diff line number Diff line
@@ -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
+30 −0
Original line number Diff line number Diff line
@@ -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
Loading