summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt3
-rw-r--r--api/system-current.txt3
-rw-r--r--api/test-current.txt3
-rwxr-xr-xcore/java/android/provider/Settings.java20
-rw-r--r--core/java/android/view/autofill/AutofillManager.java33
-rw-r--r--core/java/android/view/autofill/IAutoFillManager.aidl2
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerService.java17
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java13
8 files changed, 91 insertions, 3 deletions
diff --git a/api/current.txt b/api/current.txt
index 2316d41fa559..46da5a5b0f28 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -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);
diff --git a/api/system-current.txt b/api/system-current.txt
index 3e42e8395cb3..115a61bee72e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -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);
diff --git a/api/test-current.txt b/api/test-current.txt
index e1ad7ac3a1f2..d8e53d9075a3 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -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);
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 088448007df2..dcb35d62ab2b 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -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
/**
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index b9d42f68c6d1..acdc7333e6b1 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -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;
diff --git a/core/java/android/view/autofill/IAutoFillManager.aidl b/core/java/android/view/autofill/IAutoFillManager.aidl
index df777c4a6869..9417bd07a267 100644
--- a/core/java/android/view/autofill/IAutoFillManager.aidl
+++ b/core/java/android/view/autofill/IAutoFillManager.aidl
@@ -44,4 +44,6 @@ interface IAutoFillManager {
void setAuthenticationResult(in Bundle data, int sessionId, int userId);
void setHasCallback(int sessionId, int userId, boolean hasIt);
void disableOwnedAutofillServices(int userId);
+ boolean isServiceSupported(int userId);
+ boolean isServiceEnabled(int userId, String packageName);
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
index 41ead8e3db50..88adbf420957 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
@@ -73,6 +73,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* Entry point service for autofill management.
@@ -483,6 +484,22 @@ public final class AutofillManagerService extends SystemService {
}
@Override
+ public boolean isServiceSupported(int userId) {
+ synchronized (mLock) {
+ return !mDisabledUsers.get(userId);
+ }
+ }
+
+ @Override
+ public boolean isServiceEnabled(int userId, String packageName) {
+ synchronized (mLock) {
+ final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
+ if (service == null) return false;
+ return Objects.equals(packageName, service.getPackageName());
+ }
+ }
+
+ @Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
synchronized (mLock) {
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index c2799304bf7a..be1567ea0de4 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -188,11 +188,10 @@ final class AutofillManagerServiceImpl {
}
CharSequence getServiceName() {
- if (mInfo == null) {
+ final String packageName = getPackageName();
+ if (packageName == null) {
return null;
}
- final ComponentName serviceComponent = mInfo.getServiceInfo().getComponentName();
- final String packageName = serviceComponent.getPackageName();
try {
final PackageManager pm = mContext.getPackageManager();
@@ -204,6 +203,14 @@ final class AutofillManagerServiceImpl {
}
}
+ String getPackageName() {
+ if (mInfo == null) {
+ return null;
+ }
+ final ComponentName serviceComponent = mInfo.getServiceInfo().getComponentName();
+ return serviceComponent.getPackageName();
+ }
+
private String getComponentNameFromSettings() {
return Settings.Secure.getStringForUser(
mContext.getContentResolver(), Settings.Secure.AUTOFILL_SERVICE, mUserId);