Merge "Add autofill feature API" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a402d6dd2f
@@ -10632,6 +10632,7 @@ package android.content.pm {
|
||||
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
|
||||
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
|
||||
field public static final java.lang.String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
|
||||
field public static final java.lang.String FEATURE_AUTOFILL = "android.software.autofill";
|
||||
field public static final java.lang.String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
|
||||
field public static final java.lang.String FEATURE_BACKUP = "android.software.backup";
|
||||
field public static final java.lang.String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
|
||||
|
||||
@@ -11320,6 +11320,7 @@ package android.content.pm {
|
||||
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
|
||||
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
|
||||
field public static final java.lang.String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
|
||||
field public static final java.lang.String FEATURE_AUTOFILL = "android.software.autofill";
|
||||
field public static final java.lang.String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
|
||||
field public static final java.lang.String FEATURE_BACKUP = "android.software.backup";
|
||||
field public static final java.lang.String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
|
||||
|
||||
@@ -10672,6 +10672,7 @@ package android.content.pm {
|
||||
field public static final java.lang.String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency";
|
||||
field public static final java.lang.String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output";
|
||||
field public static final java.lang.String FEATURE_AUDIO_PRO = "android.hardware.audio.pro";
|
||||
field public static final java.lang.String FEATURE_AUTOFILL = "android.software.autofill";
|
||||
field public static final java.lang.String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive";
|
||||
field public static final java.lang.String FEATURE_BACKUP = "android.software.backup";
|
||||
field public static final java.lang.String FEATURE_BLUETOOTH = "android.hardware.bluetooth";
|
||||
|
||||
@@ -641,7 +641,8 @@ final class SystemServiceRegistry {
|
||||
new CachedServiceFetcher<PrintManager>() {
|
||||
@Override
|
||||
public PrintManager createService(ContextImpl ctx) throws ServiceNotFoundException {
|
||||
IBinder iBinder = ServiceManager.getServiceOrThrow(Context.PRINT_SERVICE);
|
||||
// Get the services without throwing as this is an optional feature
|
||||
IBinder iBinder = ServiceManager.getService(Context.PRINT_SERVICE);
|
||||
IPrintManager service = IPrintManager.Stub.asInterface(iBinder);
|
||||
return new PrintManager(ctx.getOuterContext(), service, UserHandle.myUserId(),
|
||||
UserHandle.getAppId(Process.myUid()));
|
||||
@@ -652,8 +653,9 @@ final class SystemServiceRegistry {
|
||||
@Override
|
||||
public CompanionDeviceManager createService(ContextImpl ctx)
|
||||
throws ServiceNotFoundException {
|
||||
// Get the services without throwing as this is an optional feature
|
||||
IBinder iBinder =
|
||||
ServiceManager.getServiceOrThrow(Context.COMPANION_DEVICE_SERVICE);
|
||||
ServiceManager.getService(Context.COMPANION_DEVICE_SERVICE);
|
||||
ICompanionDeviceManager service =
|
||||
ICompanionDeviceManager.Stub.asInterface(iBinder);
|
||||
return new CompanionDeviceManager(service, ctx);
|
||||
@@ -833,7 +835,8 @@ final class SystemServiceRegistry {
|
||||
new CachedServiceFetcher<AutofillManager>() {
|
||||
@Override
|
||||
public AutofillManager createService(ContextImpl ctx) throws ServiceNotFoundException {
|
||||
IBinder b = ServiceManager.getServiceOrThrow(Context.AUTOFILL_MANAGER_SERVICE);
|
||||
// Get the services without throwing as this is an optional feature
|
||||
IBinder b = ServiceManager.getService(Context.AUTOFILL_MANAGER_SERVICE);
|
||||
IAutoFillManager service = IAutoFillManager.Stub.asInterface(b);
|
||||
return new AutofillManager(ctx.getOuterContext(), service);
|
||||
}});
|
||||
|
||||
@@ -2402,6 +2402,15 @@ public abstract class PackageManager {
|
||||
public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE
|
||||
= "android.hardware.vr.high_performance";
|
||||
|
||||
/**
|
||||
* Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
|
||||
* The device supports autofill of user credentials, addresses, credit cards, etc
|
||||
* via integration with {@link android.service.autofill.AutofillService autofill
|
||||
* providers}.
|
||||
*/
|
||||
@SdkConstant(SdkConstantType.FEATURE)
|
||||
public static final String FEATURE_AUTOFILL = "android.software.autofill";
|
||||
|
||||
/**
|
||||
* Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}:
|
||||
* The device implements headtracking suitable for a VR device.
|
||||
|
||||
@@ -309,7 +309,6 @@ public final class FillResponse implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds a new {@link FillResponse} instance. You must provide at least
|
||||
* one dataset or some savable ids or an authentication with a presentation
|
||||
|
||||
@@ -192,6 +192,9 @@ public final class AutofillManager {
|
||||
* {@hide}
|
||||
*/
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
mLastAutofilledData = savedInstanceState.getParcelable(LAST_AUTOFILLED_DATA_TAG);
|
||||
|
||||
@@ -237,6 +240,9 @@ public final class AutofillManager {
|
||||
* {@hide}
|
||||
*/
|
||||
public void onAttachedToWindow(@NonNull IBinder windowToken) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (mSessionId == NO_SESSION) {
|
||||
return;
|
||||
@@ -258,6 +264,9 @@ public final class AutofillManager {
|
||||
* {@hide}
|
||||
*/
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (mSessionId != NO_SESSION) {
|
||||
outState.putInt(SESSION_ID_TAG, mSessionId);
|
||||
@@ -278,6 +287,9 @@ public final class AutofillManager {
|
||||
* @return whether autofill is enabled for the current user.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
if (!hasAutofillFeature()) {
|
||||
return false;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
return mEnabled;
|
||||
@@ -294,6 +306,9 @@ public final class AutofillManager {
|
||||
* @param view view requesting the new autofill context.
|
||||
*/
|
||||
public void requestAutofill(@NonNull View view) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
|
||||
@@ -320,6 +335,9 @@ public final class AutofillManager {
|
||||
* @param bounds child boundaries, relative to the top window.
|
||||
*/
|
||||
public void requestAutofill(@NonNull View view, int childId, @NonNull Rect bounds) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
|
||||
@@ -339,6 +357,9 @@ public final class AutofillManager {
|
||||
* @param view {@link View} that was entered.
|
||||
*/
|
||||
public void notifyViewEntered(@NonNull View view) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
AutofillCallback callback = null;
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
@@ -372,6 +393,9 @@ public final class AutofillManager {
|
||||
* @param view {@link View} that was exited.
|
||||
*/
|
||||
public void notifyViewExited(@NonNull View view) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
|
||||
@@ -392,6 +416,9 @@ public final class AutofillManager {
|
||||
* @param bounds child boundaries, relative to the top window.
|
||||
*/
|
||||
public void notifyViewEntered(@NonNull View view, int childId, @NonNull Rect bounds) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
AutofillCallback callback = null;
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
@@ -426,6 +453,9 @@ public final class AutofillManager {
|
||||
* @param childId id identifying the virtual child inside the view.
|
||||
*/
|
||||
public void notifyViewExited(@NonNull View view, int childId) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
ensureServiceClientAddedIfNeededLocked();
|
||||
|
||||
@@ -444,6 +474,9 @@ public final class AutofillManager {
|
||||
* @param view view whose value changed.
|
||||
*/
|
||||
public void notifyValueChanged(View view) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
AutofillId id = null;
|
||||
boolean valueWasRead = false;
|
||||
AutofillValue value = null;
|
||||
@@ -486,7 +519,6 @@ public final class AutofillManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called to indicate the value of an autofillable virtual {@link View} changed.
|
||||
*
|
||||
@@ -495,6 +527,9 @@ public final class AutofillManager {
|
||||
* @param value new value of the child.
|
||||
*/
|
||||
public void notifyValueChanged(View view, int childId, AutofillValue value) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (!mEnabled || mSessionId == NO_SESSION) {
|
||||
return;
|
||||
@@ -512,6 +547,9 @@ public final class AutofillManager {
|
||||
* call this method after the form is submitted and another page is rendered.
|
||||
*/
|
||||
public void commit() {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (!mEnabled && mSessionId == NO_SESSION) {
|
||||
return;
|
||||
@@ -528,6 +566,9 @@ public final class AutofillManager {
|
||||
* call this method if the user does not post the form but moves to another form in this page.
|
||||
*/
|
||||
public void cancel() {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (!mEnabled && mSessionId == NO_SESSION) {
|
||||
return;
|
||||
@@ -542,6 +583,9 @@ public final class AutofillManager {
|
||||
* will be disabled.
|
||||
*/
|
||||
public void disableOwnedAutofillServices() {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
mService.disableOwnedAutofillServices(mContext.getUserId());
|
||||
} catch (RemoteException e) {
|
||||
@@ -558,6 +602,9 @@ public final class AutofillManager {
|
||||
|
||||
/** @hide */
|
||||
public void onAuthenticationResult(Intent data) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
// TODO(b/33197203): the result code is being ignored, so this method is not reliably
|
||||
// handling the cases where it's not RESULT_OK: it works fine if the service does not
|
||||
// set the EXTRA_AUTHENTICATION_RESULT extra, but it could cause weird results if the
|
||||
@@ -672,6 +719,9 @@ public final class AutofillManager {
|
||||
* @param callback callback to receive events.
|
||||
*/
|
||||
public void registerCallback(@Nullable AutofillCallback callback) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (callback == null) return;
|
||||
|
||||
@@ -694,6 +744,9 @@ public final class AutofillManager {
|
||||
* @param callback callback to stop receiving events.
|
||||
*/
|
||||
public void unregisterCallback(@Nullable AutofillCallback callback) {
|
||||
if (!hasAutofillFeature()) {
|
||||
return;
|
||||
}
|
||||
synchronized (mLock) {
|
||||
if (callback == null || mCallback == null || callback != mCallback) return;
|
||||
|
||||
@@ -871,6 +924,10 @@ public final class AutofillManager {
|
||||
return view;
|
||||
}
|
||||
|
||||
private boolean hasAutofillFeature() {
|
||||
return mService != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for auto-fill related events.
|
||||
*
|
||||
|
||||
@@ -1541,9 +1541,11 @@ public final class SystemServer {
|
||||
mSystemServiceManager.startService(RetailDemoModeService.class);
|
||||
traceEnd();
|
||||
|
||||
traceBeginAndSlog("StartAutoFillService");
|
||||
mSystemServiceManager.startService(AUTO_FILL_MANAGER_SERVICE_CLASS);
|
||||
traceEnd();
|
||||
if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_AUTOFILL)) {
|
||||
traceBeginAndSlog("StartAutoFillService");
|
||||
mSystemServiceManager.startService(AUTO_FILL_MANAGER_SERVICE_CLASS);
|
||||
traceEnd();
|
||||
}
|
||||
|
||||
// It is now time to start up the app processes...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user