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

Commit db041188 authored by Felipe Leme's avatar Felipe Leme
Browse files

Added APIs that let AutofillService implementations set themselves as such.

Bug: 37576671
Test: manual verification
Test: CtsAutoFillServiceTestCases (with new tests) pass

Change-Id: I6fd61f8a2826dbf6b6fce831f3deadf6df025386
parent 9e55fcbd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34942,6 +34942,7 @@ package android.provider {
    field public static final java.lang.String ACTION_PRIVACY_SETTINGS = "android.settings.PRIVACY_SETTINGS";
    field public static final java.lang.String ACTION_QUICK_LAUNCH_SETTINGS = "android.settings.QUICK_LAUNCH_SETTINGS";
    field public static final java.lang.String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
    field public static final java.lang.String ACTION_REQUEST_SET_AUTOFILL_SERVICE = "android.settings.REQUEST_SET_AUTOFILL_SERVICE";
    field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
    field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
    field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
@@ -47835,6 +47836,8 @@ package android.view.autofill {
    method public void cancel();
    method public void commit();
    method public void disableOwnedAutofillServices();
    method public boolean hasEnabledAutofillServices();
    method public boolean isAutofillSupported();
    method public boolean isEnabled();
    method public void notifyValueChanged(android.view.View);
    method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
+3 −0
Original line number Diff line number Diff line
@@ -38035,6 +38035,7 @@ package android.provider {
    field public static final java.lang.String ACTION_PRIVACY_SETTINGS = "android.settings.PRIVACY_SETTINGS";
    field public static final java.lang.String ACTION_QUICK_LAUNCH_SETTINGS = "android.settings.QUICK_LAUNCH_SETTINGS";
    field public static final java.lang.String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
    field public static final java.lang.String ACTION_REQUEST_SET_AUTOFILL_SERVICE = "android.settings.REQUEST_SET_AUTOFILL_SERVICE";
    field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
    field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
    field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
@@ -51418,6 +51419,8 @@ package android.view.autofill {
    method public void cancel();
    method public void commit();
    method public void disableOwnedAutofillServices();
    method public boolean hasEnabledAutofillServices();
    method public boolean isAutofillSupported();
    method public boolean isEnabled();
    method public void notifyValueChanged(android.view.View);
    method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
+3 −0
Original line number Diff line number Diff line
@@ -35079,6 +35079,7 @@ package android.provider {
    field public static final java.lang.String ACTION_PRIVACY_SETTINGS = "android.settings.PRIVACY_SETTINGS";
    field public static final java.lang.String ACTION_QUICK_LAUNCH_SETTINGS = "android.settings.QUICK_LAUNCH_SETTINGS";
    field public static final java.lang.String ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = "android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS";
    field public static final java.lang.String ACTION_REQUEST_SET_AUTOFILL_SERVICE = "android.settings.REQUEST_SET_AUTOFILL_SERVICE";
    field public static final java.lang.String ACTION_SEARCH_SETTINGS = "android.search.action.SEARCH_SETTINGS";
    field public static final java.lang.String ACTION_SECURITY_SETTINGS = "android.settings.SECURITY_SETTINGS";
    field public static final java.lang.String ACTION_SETTINGS = "android.settings.SETTINGS";
@@ -48214,6 +48215,8 @@ package android.view.autofill {
    method public void cancel();
    method public void commit();
    method public void disableOwnedAutofillServices();
    method public boolean hasEnabledAutofillServices();
    method public boolean isAutofillSupported();
    method public boolean isEnabled();
    method public void notifyValueChanged(android.view.View);
    method public void notifyValueChanged(android.view.View, int, android.view.autofill.AutofillValue);
+20 −0
Original line number Diff line number Diff line
@@ -1398,6 +1398,26 @@ public final class Settings {
    public static final String ACTION_ENTERPRISE_PRIVACY_SETTINGS
            = "android.settings.ENTERPRISE_PRIVACY_SETTINGS";

    /**
     * Activity Action: Show screen that let user select its Autofill Service.
     * <p>
     * Input: Intent's data URI set with an application name, using the
     * "package" schema (like "package:com.my.app").
     *
     * <p>
     * Output: {@link android.app.Activity#RESULT_OK} if user selected an Autofill Service belonging
     * to the caller package.
     *
     * <p>
     * <b>NOTE: </b> applications should call
     * {@link android.view.autofill.AutofillManager#hasEnabledAutofillServices()} and
     * {@link android.view.autofill.AutofillManager#isAutofillSupported()} first, and only
     * broadcast this intent if they return {@code false} and {@code true} respectively.
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_REQUEST_SET_AUTOFILL_SERVICE =
            "android.settings.REQUEST_SET_AUTOFILL_SERVICE";

    // End of Intent actions for Settings

    /**
+33 −0
Original line number Diff line number Diff line
@@ -661,6 +661,39 @@ public final class AutofillManager {
        }
    }

    /**
     * Returns {@code true} if the calling application provides a {@link AutofillService} that is
     * enabled for the current user, or {@code false} otherwise.
     */
    public boolean hasEnabledAutofillServices() {
        if (mService == null) return false;

        try {
            return mService.isServiceEnabled(mContext.getUserId(), mContext.getPackageName());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns {@code true} if Autofill is supported for this user.
     *
     * <p>Autofill is typically supported, but it could be unsupported in cases like:
     * <ol>
     *     <li>Low-end devices.
     *     <li>Device policy rules that forbid its usage.
     * </ol>
     */
    public boolean isAutofillSupported() {
        if (mService == null) return false;

        try {
            return mService.isServiceSupported(mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    private AutofillClient getClientLocked() {
        if (mContext instanceof AutofillClient) {
            return (AutofillClient) mContext;
Loading