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

Commit 559e21d7 authored by Felipe Leme's avatar Felipe Leme
Browse files

New APIs for Augmented Autofill whitelisting, plus some spring cleaning...

Test: m update-api # they're not implemented yet
Test: atest CtsAutoFillServiceTestCases:android.autofillservice.cts.augmented.AugmentedLoginActivityTest # for sanity checking

Bug: 123100824
Bug: 111330312
Bug: 123233342

Change-Id: I9f6b9067f743b7590cc8b32b42b8fff230f9a3d8
parent f1cef973
Loading
Loading
Loading
Loading
+13 −5
Original line number Diff line number Diff line
@@ -5985,10 +5985,7 @@ package android.service.autofill.augmented {
    method public int getTaskId();
  }
  public final class FillResponse implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.autofill.augmented.FillResponse> CREATOR;
  public final class FillResponse {
  }
  public static final class FillResponse.Builder {
@@ -6002,7 +5999,6 @@ package android.service.autofill.augmented {
    ctor public FillWindow();
    method public void destroy();
    method public boolean update(@NonNull android.service.autofill.augmented.PresentationParams.Area, @NonNull android.view.View, long);
    field public static final long FLAG_METADATA_ADDRESS = 1L; // 0x1L
  }
  public abstract class PresentationParams {
@@ -9036,6 +9032,18 @@ package android.view.accessibility {
}
package android.view.autofill {
  public final class AutofillManager {
    method @NonNull public java.util.Set<android.content.ComponentName> getAugmentedAutofillDisabledActivities();
    method @NonNull public java.util.Set<java.lang.String> getAugmentedAutofillDisabledPackages();
    method public void setActivityAugmentedAutofillEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public void setPackageAugmentedAutofillEnabled(@NonNull String, boolean);
  }
}
package android.view.contentcapture {
  public final class ContentCaptureContext implements android.os.Parcelable {
+7 −5
Original line number Diff line number Diff line
@@ -1679,10 +1679,7 @@ package android.service.autofill.augmented {
    method public int getTaskId();
  }

  public final class FillResponse implements android.os.Parcelable {
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.autofill.augmented.FillResponse> CREATOR;
  public final class FillResponse {
  }

  public static final class FillResponse.Builder {
@@ -1696,7 +1693,6 @@ package android.service.autofill.augmented {
    ctor public FillWindow();
    method public void destroy();
    method public boolean update(@NonNull android.service.autofill.augmented.PresentationParams.Area, @NonNull android.view.View, long);
    field public static final long FLAG_METADATA_ADDRESS = 1L; // 0x1L
  }

  public abstract class PresentationParams {
@@ -2328,6 +2324,12 @@ package android.view.autofill {
  }

  public final class AutofillManager {
    method @NonNull public java.util.Set<android.content.ComponentName> getAugmentedAutofillDisabledActivities();
    method @NonNull public java.util.Set<java.lang.String> getAugmentedAutofillDisabledPackages();
    method public void setActivityAugmentedAutofillEnabled(@NonNull android.content.ComponentName, boolean);
    method public void setAugmentedAutofillWhitelist(@Nullable java.util.List<java.lang.String>, @Nullable java.util.List<android.content.ComponentName>);
    method public void setPackageAugmentedAutofillEnabled(@NonNull String, boolean);
    field public static final int FLAG_SMART_SUGGESTION_SYSTEM = 1; // 0x1
    field public static final int MAX_TEMP_AUGMENTED_SERVICE_DURATION_MS = 120000; // 0x1d4c0
  }

+7 −10
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ public abstract class AugmentedAutofillService extends Service {

    private static final String TAG = AugmentedAutofillService.class.getSimpleName();

    // TODO(b/111330312): STOPSHIP use dynamic value, or change to false
    // TODO(b/123100811): STOPSHIP use dynamic value, or change to false
    static final boolean DEBUG = true;
    static final boolean VERBOSE = false;

@@ -127,8 +127,6 @@ public abstract class AugmentedAutofillService extends Service {
        return false;
    }

    // TODO(b/111330312): add methods to disable autofill per app / activity?

    /**
     * Asks the service to handle an "augmented" autofill request.
     *
@@ -175,12 +173,11 @@ public abstract class AugmentedAutofillService extends Service {
                    focusedValue, requestTime, callback);
            mAutofillProxies.put(sessionId,  proxy);
        } else {
            // TODO(b/111330312): figure out if it's ok to reuse the proxy; add logging
            // TODO(b/111330312): also make sure to cover scenario on CTS test
            // TODO(b/123099468): figure out if it's ok to reuse the proxy; add logging
            if (DEBUG) Log.d(TAG, "Reusing proxy for session " + sessionId);
            proxy.update(focusedId, focusedValue);
        }
        // TODO(b/111330312): set cancellation signal
        // TODO(b/123101711): set cancellation signal
        final CancellationSignal cancellationSignal = null;
        onFillRequest(new FillRequest(proxy), cancellationSignal, new FillController(proxy),
                new FillCallback(proxy));
@@ -193,7 +190,7 @@ public abstract class AugmentedAutofillService extends Service {
                final int sessionId = mAutofillProxies.keyAt(i);
                final AutofillProxy proxy = mAutofillProxies.valueAt(i);
                if (proxy == null) {
                    // TODO(b/111330312): this might be fine, in which case we should logv it
                    // TODO(b/123100811): this might be fine, in which case we should logv it
                    Log.w(TAG, "No proxy for session " + sessionId);
                    return;
                }
@@ -303,7 +300,7 @@ public abstract class AugmentedAutofillService extends Service {
            this.mFocusedId = focusedId;
            this.mFocusedValue = focusedValue;
            this.mRequestTime = requestTime;
            // TODO(b/111330312): linkToDeath
            // TODO(b/123099468): linkToDeath
        }

        @NonNull
@@ -366,7 +363,7 @@ public abstract class AugmentedAutofillService extends Service {

        private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue) {
            synchronized (mLock) {
                // TODO(b/111330312): should we close the popupwindow if the focused id changed?
                // TODO(b/123099468): should we close the popupwindow if the focused id changed?
                mFocusedId = focusedId;
                mFocusedValue = focusedValue;
            }
@@ -425,7 +422,7 @@ public abstract class AugmentedAutofillService extends Service {
                default:
                    Slog.w(TAG, "invalid event reported: " + event);
            }
            // TODO(b/111330312): log metrics as well
            // TODO(b/122858578): log metrics as well
        }

        public void dump(@NonNull String prefix, @NonNull PrintWriter pw) {
+3 −2
Original line number Diff line number Diff line
@@ -59,7 +59,8 @@ public final class FillCallback {
        if (fillWindow != null) {
            fillWindow.show();
        }
        // TODO(b/111330312): properly implement on server-side by updating the Session state
        // accordingly (and adding CTS tests)
        // TODO(b/123099468): must notify the server so it can update the session state to avoid
        // showing conflicting UIs (for example, if a new request is made to the main autofill
        // service and it now wants to show something).
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -29,7 +29,7 @@ import android.view.autofill.AutofillValue;
 * @hide
 */
@SystemApi
// TODO(b/111330312): pass a requestId and/or sessionId
// TODO(b/123100811): pass a requestId and/or sessionId?
@TestApi
// TODO(b/122654591): @TestApi is needed because CtsAutoFillServiceTestCases hosts the service
// in the same package as the test, and that module is compiled with SDK=test_current
Loading