Merge "Allow users to manually request Autofill."
This commit is contained in:
committed by
Android (Google) Code Review
commit
5bf03b7640
@@ -1790,6 +1790,7 @@ package android {
|
||||
field public static final int accessibilityActionSetProgress = 16908349; // 0x102003d
|
||||
field public static final int accessibilityActionShowOnScreen = 16908342; // 0x1020036
|
||||
field public static final int addToDictionary = 16908330; // 0x102002a
|
||||
field public static final int autofill = 16908355; // 0x1020043
|
||||
field public static final int background = 16908288; // 0x1020000
|
||||
field public static final int button1 = 16908313; // 0x1020019
|
||||
field public static final int button2 = 16908314; // 0x102001a
|
||||
@@ -36806,7 +36807,7 @@ package android.service.autofill {
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method public void onConnected();
|
||||
method public void onDisconnected();
|
||||
method public abstract void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, int, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public abstract void onSaveRequest(android.app.assist.AssistStructure, android.os.Bundle, android.service.autofill.SaveCallback);
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.service.autofill.AutofillService";
|
||||
field public static final java.lang.String SERVICE_META_DATA = "android.autofill";
|
||||
@@ -45487,7 +45488,7 @@ package android.view {
|
||||
method public void setActivated(boolean);
|
||||
method public void setAlpha(float);
|
||||
method public void setAnimation(android.view.animation.Animation);
|
||||
method public void setAutofillHint(java.lang.String[]);
|
||||
method public void setAutofillHint(java.lang.String...);
|
||||
method public void setAutofillMode(int);
|
||||
method public void setBackground(android.graphics.drawable.Drawable);
|
||||
method public void setBackgroundColor(int);
|
||||
@@ -47570,6 +47571,7 @@ package android.view.autofill {
|
||||
public final class AutofillManager {
|
||||
method public void cancel();
|
||||
method public void commit();
|
||||
method public boolean isEnabled();
|
||||
method public void notifyValueChanged(android.view.View);
|
||||
method public void notifyViewEntered(android.view.View);
|
||||
method public void notifyViewExited(android.view.View);
|
||||
@@ -47577,9 +47579,12 @@ package android.view.autofill {
|
||||
method public void notifyVirtualViewEntered(android.view.View, int, android.graphics.Rect);
|
||||
method public void notifyVirtualViewExited(android.view.View, int);
|
||||
method public void registerCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
method public void requestAutofill(android.view.View);
|
||||
method public void requestAutofill(android.view.View, int, android.graphics.Rect);
|
||||
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
|
||||
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
|
||||
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
|
||||
}
|
||||
|
||||
public static abstract class AutofillManager.AutofillCallback {
|
||||
|
||||
@@ -1907,6 +1907,7 @@ package android {
|
||||
field public static final int accessibilityActionSetProgress = 16908349; // 0x102003d
|
||||
field public static final int accessibilityActionShowOnScreen = 16908342; // 0x1020036
|
||||
field public static final int addToDictionary = 16908330; // 0x102002a
|
||||
field public static final int autofill = 16908355; // 0x1020043
|
||||
field public static final int background = 16908288; // 0x1020000
|
||||
field public static final int button1 = 16908313; // 0x1020019
|
||||
field public static final int button2 = 16908314; // 0x102001a
|
||||
@@ -39844,7 +39845,7 @@ package android.service.autofill {
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method public void onConnected();
|
||||
method public void onDisconnected();
|
||||
method public abstract void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, int, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public abstract void onSaveRequest(android.app.assist.AssistStructure, android.os.Bundle, android.service.autofill.SaveCallback);
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.service.autofill.AutofillService";
|
||||
field public static final java.lang.String SERVICE_META_DATA = "android.autofill";
|
||||
@@ -48954,7 +48955,7 @@ package android.view {
|
||||
method public void setActivated(boolean);
|
||||
method public void setAlpha(float);
|
||||
method public void setAnimation(android.view.animation.Animation);
|
||||
method public void setAutofillHint(java.lang.String[]);
|
||||
method public void setAutofillHint(java.lang.String...);
|
||||
method public void setAutofillMode(int);
|
||||
method public void setBackground(android.graphics.drawable.Drawable);
|
||||
method public void setBackgroundColor(int);
|
||||
@@ -51040,6 +51041,7 @@ package android.view.autofill {
|
||||
public final class AutofillManager {
|
||||
method public void cancel();
|
||||
method public void commit();
|
||||
method public boolean isEnabled();
|
||||
method public void notifyValueChanged(android.view.View);
|
||||
method public void notifyViewEntered(android.view.View);
|
||||
method public void notifyViewExited(android.view.View);
|
||||
@@ -51047,9 +51049,12 @@ package android.view.autofill {
|
||||
method public void notifyVirtualViewEntered(android.view.View, int, android.graphics.Rect);
|
||||
method public void notifyVirtualViewExited(android.view.View, int);
|
||||
method public void registerCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
method public void requestAutofill(android.view.View);
|
||||
method public void requestAutofill(android.view.View, int, android.graphics.Rect);
|
||||
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
|
||||
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
|
||||
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
|
||||
}
|
||||
|
||||
public static abstract class AutofillManager.AutofillCallback {
|
||||
|
||||
@@ -1790,6 +1790,7 @@ package android {
|
||||
field public static final int accessibilityActionSetProgress = 16908349; // 0x102003d
|
||||
field public static final int accessibilityActionShowOnScreen = 16908342; // 0x1020036
|
||||
field public static final int addToDictionary = 16908330; // 0x102002a
|
||||
field public static final int autofill = 16908355; // 0x1020043
|
||||
field public static final int background = 16908288; // 0x1020000
|
||||
field public static final int button1 = 16908313; // 0x1020019
|
||||
field public static final int button2 = 16908314; // 0x102001a
|
||||
@@ -36950,7 +36951,7 @@ package android.service.autofill {
|
||||
method public final android.os.IBinder onBind(android.content.Intent);
|
||||
method public void onConnected();
|
||||
method public void onDisconnected();
|
||||
method public abstract void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public void onFillRequest(android.app.assist.AssistStructure, android.os.Bundle, int, android.os.CancellationSignal, android.service.autofill.FillCallback);
|
||||
method public abstract void onSaveRequest(android.app.assist.AssistStructure, android.os.Bundle, android.service.autofill.SaveCallback);
|
||||
field public static final java.lang.String SERVICE_INTERFACE = "android.service.autofill.AutofillService";
|
||||
field public static final java.lang.String SERVICE_META_DATA = "android.autofill";
|
||||
@@ -45850,7 +45851,7 @@ package android.view {
|
||||
method public void setActivated(boolean);
|
||||
method public void setAlpha(float);
|
||||
method public void setAnimation(android.view.animation.Animation);
|
||||
method public void setAutofillHint(java.lang.String[]);
|
||||
method public void setAutofillHint(java.lang.String...);
|
||||
method public void setAutofillMode(int);
|
||||
method public void setBackground(android.graphics.drawable.Drawable);
|
||||
method public void setBackgroundColor(int);
|
||||
@@ -47939,6 +47940,7 @@ package android.view.autofill {
|
||||
public final class AutofillManager {
|
||||
method public void cancel();
|
||||
method public void commit();
|
||||
method public boolean isEnabled();
|
||||
method public void notifyValueChanged(android.view.View);
|
||||
method public void notifyViewEntered(android.view.View);
|
||||
method public void notifyViewExited(android.view.View);
|
||||
@@ -47946,9 +47948,12 @@ package android.view.autofill {
|
||||
method public void notifyVirtualViewEntered(android.view.View, int, android.graphics.Rect);
|
||||
method public void notifyVirtualViewExited(android.view.View, int);
|
||||
method public void registerCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
method public void requestAutofill(android.view.View);
|
||||
method public void requestAutofill(android.view.View, int, android.graphics.Rect);
|
||||
method public void unregisterCallback(android.view.autofill.AutofillManager.AutofillCallback);
|
||||
field public static final java.lang.String EXTRA_ASSIST_STRUCTURE = "android.view.autofill.extra.ASSIST_STRUCTURE";
|
||||
field public static final java.lang.String EXTRA_AUTHENTICATION_RESULT = "android.view.autofill.extra.AUTHENTICATION_RESULT";
|
||||
field public static final int FLAG_MANUAL_REQUEST = 1; // 0x1
|
||||
}
|
||||
|
||||
public static abstract class AutofillManager.AutofillCallback {
|
||||
|
||||
@@ -30,6 +30,7 @@ import android.os.IBinder;
|
||||
import android.os.ICancellationSignal;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.autofill.AutofillManager;
|
||||
|
||||
import com.android.internal.os.SomeArgs;
|
||||
|
||||
@@ -90,6 +91,8 @@ public abstract class AutofillService extends Service {
|
||||
private static final int MSG_ON_FILL_REQUEST = 3;
|
||||
private static final int MSG_ON_SAVE_REQUEST = 4;
|
||||
|
||||
private static final int UNUSED_ARG = -1;
|
||||
|
||||
private final IAutoFillService mInterface = new IAutoFillService.Stub() {
|
||||
@Override
|
||||
public void onInit(IAutoFillServiceConnection connection) {
|
||||
@@ -102,14 +105,14 @@ public abstract class AutofillService extends Service {
|
||||
|
||||
@Override
|
||||
public void onFillRequest(AssistStructure structure, Bundle extras,
|
||||
IFillCallback callback) {
|
||||
IFillCallback callback, int flags) {
|
||||
ICancellationSignal transport = CancellationSignal.createTransport();
|
||||
try {
|
||||
callback.onCancellable(transport);
|
||||
} catch (RemoteException e) {
|
||||
e.rethrowFromSystemServer();
|
||||
}
|
||||
mHandlerCaller.obtainMessageOOOO(MSG_ON_FILL_REQUEST, structure,
|
||||
mHandlerCaller.obtainMessageIIOOOO(MSG_ON_FILL_REQUEST, flags, UNUSED_ARG, structure,
|
||||
CancellationSignal.fromTransport(transport), extras, callback)
|
||||
.sendToTarget();
|
||||
}
|
||||
@@ -135,8 +138,9 @@ public abstract class AutofillService extends Service {
|
||||
final Bundle extras = (Bundle) args.arg3;
|
||||
final IFillCallback callback = (IFillCallback) args.arg4;
|
||||
final FillCallback fillCallback = new FillCallback(callback);
|
||||
final int flags = msg.arg1;
|
||||
args.recycle();
|
||||
onFillRequest(structure, extras, cancellation, fillCallback);
|
||||
onFillRequest(structure, extras, flags, cancellation, fillCallback);
|
||||
break;
|
||||
} case MSG_ON_SAVE_REQUEST: {
|
||||
final SomeArgs args = (SomeArgs) msg.obj;
|
||||
@@ -188,7 +192,6 @@ public abstract class AutofillService extends Service {
|
||||
* <p>You should generally do initialization here rather than in {@link #onCreate}.
|
||||
*/
|
||||
public void onConnected() {
|
||||
//TODO(b/33197203): is not called anymore, fix it!
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,11 +209,25 @@ public abstract class AutofillService extends Service {
|
||||
* as well as when filling different sections of the UI as the system will try to
|
||||
* aggressively unbind from the service to conserve resources. See {@link
|
||||
* FillResponse} Javadoc for examples of multiple-sections requests.
|
||||
* @param flags either {@code 0} or {@link AutofillManager#FLAG_MANUAL_REQUEST}.
|
||||
* @param cancellationSignal signal for observing cancellation requests. The system will use
|
||||
* this to notify you that the fill result is no longer needed and you should stop
|
||||
* handling this fill request in order to save resources.
|
||||
* @param callback object used to notify the result of the request.
|
||||
*/
|
||||
public void onFillRequest(@NonNull AssistStructure structure, @Nullable Bundle data, int flags,
|
||||
@NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback) {
|
||||
//TODO(b/33197203): make non-abstract once older method is removed
|
||||
onFillRequest(structure, data, cancellationSignal, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
* @deprecated - use {@link #onFillRequest(AssistStructure, Bundle, int,
|
||||
* CancellationSignal, FillCallback)} instead
|
||||
*/
|
||||
//TODO(b/33197203): remove once clients are not using anymore
|
||||
@Deprecated
|
||||
public abstract void onFillRequest(@NonNull AssistStructure structure, @Nullable Bundle data,
|
||||
@NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback);
|
||||
|
||||
@@ -238,7 +255,6 @@ public abstract class AutofillService extends Service {
|
||||
* <p> At this point this service may no longer be an active {@link AutofillService}.
|
||||
*/
|
||||
public void onDisconnected() {
|
||||
//TODO(b/33197203): is not called anymore, fix it!
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ public final class FillCallback {
|
||||
/**
|
||||
* Notifies the Android System that an
|
||||
* {@link AutofillService#onFillRequest(android.app.assist.AssistStructure, Bundle,
|
||||
* android.os.CancellationSignal, FillCallback)} was successfully fulfilled by the service.
|
||||
* int, android.os.CancellationSignal, FillCallback)} was successfully fulfilled by the service.
|
||||
*
|
||||
* @param response autofill information for that activity, or {@code null} when the activity
|
||||
* cannot be autofilled (for example, if it only contains read-only fields). See
|
||||
@@ -56,7 +56,7 @@ public final class FillCallback {
|
||||
/**
|
||||
* Notifies the Android System that an
|
||||
* {@link AutofillService#onFillRequest(android.app.assist.AssistStructure,
|
||||
* Bundle, android.os.CancellationSignal, FillCallback)}
|
||||
* Bundle, int, android.os.CancellationSignal, FillCallback)}
|
||||
* could not be fulfilled by the service.
|
||||
*
|
||||
* @param message error message to be displayed to the user.
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.ArrayList;
|
||||
/**
|
||||
* Response for a {@link
|
||||
* AutofillService#onFillRequest(android.app.assist.AssistStructure,
|
||||
* Bundle, android.os.CancellationSignal, FillCallback)}.
|
||||
* Bundle, int, android.os.CancellationSignal, FillCallback)}.
|
||||
*
|
||||
* <p>The response typically contains one or more {@link Dataset}s, each representing a set of
|
||||
* fields that can be autofilled together, and the Android system displays a dataset picker UI
|
||||
@@ -269,8 +269,8 @@ public final class FillResponse implements Parcelable {
|
||||
* Sets a {@link Bundle} that will be passed to subsequent APIs that
|
||||
* manipulate this response. For example, they are passed to subsequent
|
||||
* calls to {@link AutofillService#onFillRequest(
|
||||
* android.app.assist.AssistStructure, Bundle, android.os.CancellationSignal,
|
||||
* FillCallback)} and {@link AutofillService#onSaveRequest(
|
||||
* android.app.assist.AssistStructure, Bundle, int,
|
||||
* android.os.CancellationSignal, FillCallback)} and {@link AutofillService#onSaveRequest(
|
||||
* android.app.assist.AssistStructure, Bundle, SaveCallback)}.
|
||||
*
|
||||
* @param extras The response extras.
|
||||
|
||||
@@ -31,7 +31,7 @@ import com.android.internal.os.IResultReceiver;
|
||||
oneway interface IAutoFillService {
|
||||
void onInit(in IAutoFillServiceConnection connection);
|
||||
void onFillRequest(in AssistStructure structure, in Bundle extras,
|
||||
in IFillCallback callback);
|
||||
in IFillCallback callback, int flags);
|
||||
void onSaveRequest(in AssistStructure structure, in Bundle extras,
|
||||
in ISaveCallback callback);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,6 @@ public final class SaveInfo implements Parcelable {
|
||||
*/
|
||||
public static final int SAVE_DATA_TYPE_PASSWORD = 1;
|
||||
|
||||
|
||||
/**
|
||||
* Type used on when the {@link FillResponse} represents a physical address (such as street,
|
||||
* city, state, etc).
|
||||
|
||||
@@ -350,7 +350,7 @@ public abstract class ViewStructure {
|
||||
* Sets whether the data on this node is sensitive; if it is, then its content (text, autofill
|
||||
* value, etc..) is striped before calls to {@link
|
||||
* android.service.autofill.AutofillService#onFillRequest(android.app.assist.AssistStructure,
|
||||
* Bundle, android.os.CancellationSignal, android.service.autofill.FillCallback)}.
|
||||
* Bundle, int, android.os.CancellationSignal, android.service.autofill.FillCallback)}.
|
||||
*
|
||||
* <p>By default, all nodes are assumed to be sensitive, and only nodes that does not have PII
|
||||
* (Personally Identifiable Information - sensitive data such as email addresses, credit card
|
||||
@@ -360,8 +360,8 @@ public abstract class ViewStructure {
|
||||
* <p>Notice that the content of even sensitive nodes are sent to the service (through the
|
||||
* {@link
|
||||
* android.service.autofill.AutofillService#onSaveRequest(android.app.assist.AssistStructure,
|
||||
* Bundle, android.service.autofill.SaveCallback)} call) when the user consented to save the
|
||||
* data, so it is important to set the content of sensitive nodes as well, but mark them as
|
||||
* Bundle, android.service.autofill.SaveCallback)} call) when the user consented to save
|
||||
* thedata, so it is important to set the content of sensitive nodes as well, but mark them as
|
||||
* sensitive.
|
||||
*
|
||||
* <p>Should only be set when the node is used for autofill purposes - it will be ignored
|
||||
|
||||
@@ -71,10 +71,17 @@ public final class AutofillManager {
|
||||
public static final String EXTRA_AUTHENTICATION_RESULT =
|
||||
"android.view.autofill.extra.AUTHENTICATION_RESULT";
|
||||
|
||||
/** @hide */ public static final int FLAG_START_SESSION = 0x1;
|
||||
/** @hide */ public static final int FLAG_VIEW_ENTERED = 0x2;
|
||||
/** @hide */ public static final int FLAG_VIEW_EXITED = 0x4;
|
||||
/** @hide */ public static final int FLAG_VALUE_CHANGED = 0x8;
|
||||
// Public flags start from the lowest bit
|
||||
/**
|
||||
* Indicates autofill was explicitly requested by the user.
|
||||
*/
|
||||
public static final int FLAG_MANUAL_REQUEST = 0x1;
|
||||
|
||||
// Private flags start from the highest bit
|
||||
/** @hide */ public static final int FLAG_START_SESSION = 0x80000000;
|
||||
/** @hide */ public static final int FLAG_VIEW_ENTERED = 0x40000000;
|
||||
/** @hide */ public static final int FLAG_VIEW_EXITED = 0x20000000;
|
||||
/** @hide */ public static final int FLAG_VALUE_CHANGED = 0x10000000;
|
||||
|
||||
private final Rect mTempRect = new Rect();
|
||||
|
||||
@@ -120,6 +127,66 @@ public final class AutofillManager {
|
||||
mService = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkes whether autofill is enabled for the current user.
|
||||
*
|
||||
* <p>Typically used to determine whether the option to explicitly request autofill should
|
||||
* be offered - see {@link #requestAutofill(View)}.
|
||||
*
|
||||
* @return whether autofill is enabled for the current user.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
ensureServiceClientAddedIfNeeded();
|
||||
return mEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly requests a new autofill context.
|
||||
*
|
||||
* <p>Normally, the autofill context is automatically started when autofillable views are
|
||||
* focused, but this method should be used in the cases where it must be explicitly requested,
|
||||
* like a view that provides a contextual menu allowing users to autofill the activity.
|
||||
*
|
||||
* @param view view requesting the new autofill context.
|
||||
*/
|
||||
public void requestAutofill(@NonNull View view) {
|
||||
ensureServiceClientAddedIfNeeded();
|
||||
|
||||
if (!mEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Rect bounds = mTempRect;
|
||||
view.getBoundsOnScreen(bounds);
|
||||
final AutofillId id = getAutofillId(view);
|
||||
final AutofillValue value = view.getAutofillValue();
|
||||
|
||||
startSession(id, view.getWindowToken(), bounds, value, FLAG_MANUAL_REQUEST);
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly requests a new autofill context for virtual views.
|
||||
*
|
||||
* <p>Normally, the autofill context is automatically started when autofillable views are
|
||||
* focused, but this method should be used in the cases where it must be explicitly requested,
|
||||
* like a virtual view that provides a contextual menu allowing users to autofill the activity.
|
||||
*
|
||||
* @param view the {@link View} whose descendant is the virtual view.
|
||||
* @param childId id identifying the virtual child inside the view.
|
||||
* @param bounds child boundaries, relative to the top window.
|
||||
*/
|
||||
public void requestAutofill(@NonNull View view, int childId, @NonNull Rect bounds) {
|
||||
ensureServiceClientAddedIfNeeded();
|
||||
|
||||
if (!mEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
final AutofillId id = getAutofillId(view, childId);
|
||||
startSession(id, view.getWindowToken(), bounds, null, FLAG_MANUAL_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called when a {@link View} that supports autofill is entered.
|
||||
*
|
||||
@@ -139,7 +206,7 @@ public final class AutofillManager {
|
||||
|
||||
if (!mHasSession) {
|
||||
// Starts new session.
|
||||
startSession(id, view.getWindowToken(), bounds, value);
|
||||
startSession(id, view.getWindowToken(), bounds, value, 0);
|
||||
} else {
|
||||
// Update focus on existing session.
|
||||
updateSession(id, bounds, value, FLAG_VIEW_ENTERED);
|
||||
@@ -181,7 +248,7 @@ public final class AutofillManager {
|
||||
|
||||
if (!mHasSession) {
|
||||
// Starts new session.
|
||||
startSession(id, view.getWindowToken(), bounds, null);
|
||||
startSession(id, view.getWindowToken(), bounds, null, 0);
|
||||
} else {
|
||||
// Update focus on existing session.
|
||||
updateSession(id, bounds, null, FLAG_VIEW_ENTERED);
|
||||
@@ -224,16 +291,16 @@ public final class AutofillManager {
|
||||
/**
|
||||
* Called to indicate the value of an autofillable virtual {@link View} changed.
|
||||
*
|
||||
* @param parent parent view whose value changed.
|
||||
* @param view the {@link View} whose descendant is the virtual view.
|
||||
* @param childId id identifying the virtual child inside the parent view.
|
||||
* @param value new value of the child.
|
||||
*/
|
||||
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
|
||||
public void notifyVirtualValueChanged(View view, int childId, AutofillValue value) {
|
||||
if (!mEnabled || !mHasSession) {
|
||||
return;
|
||||
}
|
||||
|
||||
final AutofillId id = getAutofillId(parent, childId);
|
||||
final AutofillId id = getAutofillId(view, childId);
|
||||
updateSession(id, null, value, FLAG_VALUE_CHANGED);
|
||||
}
|
||||
|
||||
@@ -305,15 +372,16 @@ public final class AutofillManager {
|
||||
}
|
||||
|
||||
private void startSession(AutofillId id, IBinder windowToken, Rect bounds,
|
||||
AutofillValue value) {
|
||||
AutofillValue value, int flags) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "startSession(): id=" + id + ", bounds=" + bounds + ", value=" + value);
|
||||
Log.d(TAG, "startSession(): id=" + id + ", bounds=" + bounds + ", value=" + value
|
||||
+ ", flags=" + flags);
|
||||
}
|
||||
|
||||
try {
|
||||
mService.startSession(mContext.getActivityToken(), windowToken,
|
||||
mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
|
||||
mCallback != null);
|
||||
mCallback != null, flags);
|
||||
final AutofillClient client = getClient();
|
||||
if (client != null) {
|
||||
client.resetableStateAvailable();
|
||||
|
||||
@@ -32,7 +32,7 @@ interface IAutoFillManager {
|
||||
boolean addClient(in IAutoFillManagerClient client, int userId);
|
||||
oneway void startSession(in IBinder activityToken, IBinder windowToken, in IBinder appCallback,
|
||||
in AutofillId autoFillId, in Rect bounds, in AutofillValue value, int userId,
|
||||
boolean hasCallback);
|
||||
boolean hasCallback, int flags);
|
||||
oneway void updateSession(in IBinder activityToken, in AutofillId id, in Rect bounds,
|
||||
in AutofillValue value, int flags, int userId);
|
||||
oneway void finishSession(in IBinder activityToken, int userId);
|
||||
|
||||
@@ -157,6 +157,7 @@ public class Editor {
|
||||
private static final int MENU_ITEM_ORDER_SELECT_ALL = 9;
|
||||
private static final int MENU_ITEM_ORDER_REPLACE = 10;
|
||||
private static final int MENU_ITEM_ORDER_PROCESS_TEXT_INTENT_ACTIONS_START = 11;
|
||||
private static final int MENU_ITEM_ORDER_AUTOFILL = 12;
|
||||
|
||||
// Each Editor manages its own undo stack.
|
||||
private final UndoManager mUndoManager = new UndoManager();
|
||||
@@ -2644,6 +2645,10 @@ public class Editor {
|
||||
.setAlphabeticShortcut('a')
|
||||
.setEnabled(mTextView.canSelectAllText())
|
||||
.setOnMenuItemClickListener(mOnContextMenuItemClickListener);
|
||||
menu.add(Menu.NONE, TextView.ID_AUTOFILL, MENU_ITEM_ORDER_AUTOFILL,
|
||||
com.android.internal.R.string.autofill)
|
||||
.setEnabled(mTextView.canRequestAutofill())
|
||||
.setOnMenuItemClickListener(mOnContextMenuItemClickListener);
|
||||
|
||||
mPreserveSelection = true;
|
||||
}
|
||||
@@ -3828,6 +3833,12 @@ public class Editor {
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
|
||||
if (mTextView.canRequestAutofill()) {
|
||||
menu.add(Menu.NONE, TextView.ID_AUTOFILL, MENU_ITEM_ORDER_AUTOFILL,
|
||||
com.android.internal.R.string.autofill)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
|
||||
updateSelectAllItem(menu);
|
||||
updateReplaceItem(menu);
|
||||
}
|
||||
|
||||
@@ -10012,6 +10012,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
|
||||
// TODO(b/33197203): add unit/CTS tests for autofill methods
|
||||
|
||||
boolean canRequestAutofill() {
|
||||
final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
|
||||
if (afm != null) {
|
||||
return afm.isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void requestAutofill() {
|
||||
final AutofillManager afm = mContext.getSystemService(AutofillManager.class);
|
||||
if (afm != null) {
|
||||
afm.requestAutofill(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void autofill(AutofillValue value) {
|
||||
if (value.isText()) {
|
||||
@@ -10481,6 +10496,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
static final int ID_PASTE_AS_PLAIN_TEXT = android.R.id.pasteAsPlainText;
|
||||
static final int ID_REPLACE = android.R.id.replaceText;
|
||||
static final int ID_ASSIST = android.R.id.textAssist;
|
||||
static final int ID_AUTOFILL = android.R.id.autofill;
|
||||
|
||||
/**
|
||||
* Called when a context menu option for the text view is selected. Currently
|
||||
@@ -10545,6 +10561,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
||||
case ID_SHARE:
|
||||
shareSelectedText();
|
||||
return true;
|
||||
|
||||
case ID_AUTOFILL:
|
||||
requestAutofill();
|
||||
stopTextActionMode();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -138,4 +138,8 @@
|
||||
|
||||
<!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_MOVE_WINDOW}. -->
|
||||
<item type="id" name="accessibilityActionMoveWindow" />
|
||||
|
||||
<!-- Action used to manually trigger an autofill request -->
|
||||
<item type="id" name="autofill" />
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -2815,6 +2815,7 @@
|
||||
<public-group type="id" first-id="0x01020041">
|
||||
<public name="textAssist" />
|
||||
<public name="accessibilityActionMoveWindow" />
|
||||
<public name="autofill" />
|
||||
</public-group>
|
||||
|
||||
|
||||
|
||||
@@ -2640,6 +2640,9 @@
|
||||
<!-- Item on EditText context menu. This action is used to redo a text edit operation. -->
|
||||
<string name="redo">Redo</string>
|
||||
|
||||
<!-- Item on EditText context menu. This action is used to request autofill. -->
|
||||
<string name="autofill">Autofill</string>
|
||||
|
||||
<!-- Text selection contextual mode title, displayed in the CAB. [CHAR LIMIT=20] -->
|
||||
<string name="textSelectionCABTitle">Text selection</string>
|
||||
|
||||
|
||||
@@ -2841,11 +2841,13 @@
|
||||
<java-symbol type="dimen" name="autofill_fill_min_margin" />
|
||||
<java-symbol type="layout" name="autofill_save"/>
|
||||
<java-symbol type="layout" name="autofill_dataset_picker"/>
|
||||
<java-symbol type="id" name="autofill" />
|
||||
<java-symbol type="id" name="autofill_save_title" />
|
||||
<java-symbol type="id" name="autofill_save_subtitle" />
|
||||
<java-symbol type="id" name="autofill_save_no" />
|
||||
<java-symbol type="id" name="autofill_save_yes" />
|
||||
<java-symbol type="id" name="autofill_save_close" />
|
||||
<java-symbol type="string" name="autofill" />
|
||||
<java-symbol type="string" name="autofill_save_title" />
|
||||
<java-symbol type="string" name="autofill_save_title_with_type" />
|
||||
<java-symbol type="string" name="autofill_save_yes" />
|
||||
|
||||
@@ -316,13 +316,13 @@ public final class AutofillManagerService extends SystemService {
|
||||
@Override
|
||||
public void startSession(IBinder activityToken, IBinder windowToken, IBinder appCallback,
|
||||
AutofillId autofillId, Rect bounds, AutofillValue value, int userId,
|
||||
boolean hasCallback) {
|
||||
boolean hasCallback, int flags) {
|
||||
// TODO(b/33197203): make sure it's called by resumed / focused activity
|
||||
|
||||
synchronized (mLock) {
|
||||
final AutofillManagerServiceImpl service = getServiceForUserLocked(userId);
|
||||
service.startSessionLocked(activityToken, windowToken, appCallback,
|
||||
autofillId, bounds, value, hasCallback);
|
||||
autofillId, bounds, value, hasCallback, flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ import com.android.server.autofill.ui.AutoFillUI;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@@ -171,7 +170,7 @@ final class AutofillManagerServiceImpl {
|
||||
structure.sanitizeForParceling(true);
|
||||
|
||||
// TODO(b/33197203): Need to pipe the bundle
|
||||
session.mRemoteFillService.onFillRequest(structure, null);
|
||||
session.mRemoteFillService.onFillRequest(structure, null, session.mFlags);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -286,7 +285,8 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
|
||||
void startSessionLocked(IBinder activityToken, IBinder windowToken, IBinder appCallbackToken,
|
||||
AutofillId autofillId, Rect bounds, AutofillValue value, boolean hasCallback) {
|
||||
AutofillId autofillId, Rect bounds, AutofillValue value, boolean hasCallback,
|
||||
int flags) {
|
||||
if (!hasService()) {
|
||||
return;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ final class AutofillManagerServiceImpl {
|
||||
final String historyItem = "s=" + mInfo.getServiceInfo().packageName
|
||||
+ " u=" + mUserId + " a=" + activityToken
|
||||
|
||||
+ " i=" + autofillId + " b=" + bounds + " hc=" + hasCallback;
|
||||
+ " i=" + autofillId + " b=" + bounds + " hc=" + hasCallback + " f=" + flags;
|
||||
mRequestsHistory.log(historyItem);
|
||||
|
||||
// TODO(b/33197203): Handle partitioning
|
||||
@@ -305,7 +305,7 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
|
||||
final Session newSession = createSessionByTokenLocked(activityToken,
|
||||
windowToken, appCallbackToken, hasCallback);
|
||||
windowToken, appCallbackToken, hasCallback, flags);
|
||||
newSession.updateLocked(autofillId, bounds, value, FLAG_START_SESSION);
|
||||
}
|
||||
|
||||
@@ -338,9 +338,9 @@ final class AutofillManagerServiceImpl {
|
||||
}
|
||||
|
||||
private Session createSessionByTokenLocked(IBinder activityToken, IBinder windowToken,
|
||||
IBinder appCallbackToken, boolean hasCallback) {
|
||||
IBinder appCallbackToken, boolean hasCallback, int flags) {
|
||||
final Session newSession = new Session(mContext, activityToken,
|
||||
windowToken, appCallbackToken, hasCallback);
|
||||
windowToken, appCallbackToken, hasCallback, flags);
|
||||
mSessions.put(activityToken, newSession);
|
||||
|
||||
/*
|
||||
@@ -630,13 +630,19 @@ final class AutofillManagerServiceImpl {
|
||||
*/
|
||||
private boolean mHasCallback;
|
||||
|
||||
/**
|
||||
* Flags used to start the session.
|
||||
*/
|
||||
private int mFlags;
|
||||
|
||||
private Session(Context context, IBinder activityToken, IBinder windowToken,
|
||||
IBinder client, boolean hasCallback) {
|
||||
IBinder client, boolean hasCallback, int flags) {
|
||||
mRemoteFillService = new RemoteFillService(context,
|
||||
mInfo.getServiceInfo().getComponentName(), mUserId, this);
|
||||
mActivityToken = activityToken;
|
||||
mWindowToken = windowToken;
|
||||
mHasCallback = hasCallback;
|
||||
mFlags = flags;
|
||||
|
||||
mClient = IAutoFillManagerClient.Stub.asInterface(client);
|
||||
try {
|
||||
@@ -856,7 +862,8 @@ final class AutofillManagerServiceImpl {
|
||||
} else {
|
||||
if (state.mAutofillValue == null || state.mAutofillValue.isEmpty()) {
|
||||
if (DEBUG) {
|
||||
Slog.d(TAG, "finishSessionLocked(): empty value for " + id );
|
||||
Slog.d(TAG, "finishSessionLocked(): empty value for " + id + ": "
|
||||
+ state.mAutofillValue);
|
||||
}
|
||||
allRequiredAreNotEmpty = false;
|
||||
break;
|
||||
@@ -1101,6 +1108,7 @@ final class AutofillManagerServiceImpl {
|
||||
|
||||
void dumpLocked(String prefix, PrintWriter pw) {
|
||||
pw.print(prefix); pw.print("mActivityToken: "); pw.println(mActivityToken);
|
||||
pw.print(prefix); pw.print("mFlags: "); pw.println(mFlags);
|
||||
pw.print(prefix); pw.print("mCurrentResponse: "); pw.println(mCurrentResponse);
|
||||
pw.print(prefix); pw.print("mAutoFilledDataset: "); pw.println(mAutoFilledDataset);
|
||||
pw.print(prefix); pw.print("mCurrentViewStates: "); pw.println(mCurrentViewState);
|
||||
|
||||
@@ -132,9 +132,10 @@ final class RemoteFillService implements DeathRecipient {
|
||||
mCallbacks.onServiceDied(this);
|
||||
}
|
||||
|
||||
public void onFillRequest(@NonNull AssistStructure structure, @Nullable Bundle extras) {
|
||||
public void onFillRequest(@NonNull AssistStructure structure, @Nullable Bundle extras,
|
||||
int flags) {
|
||||
cancelScheduledUnbind();
|
||||
final PendingFillRequest request = new PendingFillRequest(structure, extras, this);
|
||||
final PendingFillRequest request = new PendingFillRequest(structure, extras, this, flags);
|
||||
mHandler.obtainMessageO(MyHandler.MSG_ON_PENDING_REQUEST, request).sendToTarget();
|
||||
}
|
||||
|
||||
@@ -418,11 +419,13 @@ final class RemoteFillService implements DeathRecipient {
|
||||
private final IFillCallback mCallback;
|
||||
private ICancellationSignal mCancellation;
|
||||
private boolean mCancelled;
|
||||
private int mFlags;
|
||||
|
||||
public PendingFillRequest(AssistStructure structure,
|
||||
Bundle extras, RemoteFillService service) {
|
||||
Bundle extras, RemoteFillService service, int flags) {
|
||||
mStructure = structure;
|
||||
mExtras = extras;
|
||||
mFlags = flags;
|
||||
mWeakService = new WeakReference<>(service);
|
||||
mCallback = new IFillCallback.Stub() {
|
||||
@Override
|
||||
@@ -469,7 +472,7 @@ final class RemoteFillService implements DeathRecipient {
|
||||
if (remoteService != null) {
|
||||
try {
|
||||
remoteService.mAutoFillService.onFillRequest(mStructure,
|
||||
mExtras, mCallback);
|
||||
mExtras, mCallback, mFlags);
|
||||
synchronized (mLock) {
|
||||
mStructure = null;
|
||||
mExtras = null;
|
||||
|
||||
Reference in New Issue
Block a user