Loading api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10203,6 +10203,7 @@ package android.service.autofill.augmented { method public void onConnected(); method public void onDisconnected(); method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback); method public final boolean requestAutofill(@NonNull android.content.ComponentName, @NonNull android.view.autofill.AutofillId); field public static final String SERVICE_INTERFACE = "android.service.autofill.augmented.AugmentedAutofillService"; } api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3205,6 +3205,7 @@ package android.service.autofill.augmented { method public void onConnected(); method public void onDisconnected(); method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback); method public final boolean requestAutofill(@NonNull android.content.ComponentName, @NonNull android.view.autofill.AutofillId); field public static final String SERVICE_INTERFACE = "android.service.autofill.augmented.AugmentedAutofillService"; } Loading core/java/android/service/autofill/augmented/AugmentedAutofillService.java +42 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,8 @@ public abstract class AugmentedAutofillService extends Service { private SparseArray<AutofillProxy> mAutofillProxies; private AutofillProxy mAutofillProxyForLastRequest; // Used for metrics / debug only private ComponentName mServiceComponentName; Loading Loading @@ -157,6 +159,38 @@ public abstract class AugmentedAutofillService extends Service { public void onConnected() { } /** * The child class of the service can call this method to initiate an Autofill flow. * * <p> The request would be respected only if the previous augmented autofill request was * made for the same {@code activityComponent} and {@code autofillId}, and the field is * currently on focus. * * <p> The request would start a new autofill flow. It doesn't guarantee that the * {@link AutofillManager} will proceed with the request. * * @param activityComponent the client component for which the autofill is requested for * @param autofillId the client field id for which the autofill is requested for * @return true if the request makes the {@link AutofillManager} start a new Autofill flow, * false otherwise. */ public final boolean requestAutofill(@NonNull ComponentName activityComponent, @NonNull AutofillId autofillId) { // TODO(b/149531989): revisit this. The request should start a new autofill session // rather than reusing the existing session. final AutofillProxy proxy = mAutofillProxyForLastRequest; if (proxy == null || !proxy.mComponentName.equals(activityComponent) || !proxy.mFocusedId.equals(autofillId)) { return false; } try { return proxy.requestAutofill(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } return false; } /** * Asks the service to handle an "augmented" autofill request. * Loading Loading @@ -241,6 +275,7 @@ public abstract class AugmentedAutofillService extends Service { } catch (RemoteException e) { e.rethrowFromSystemServer(); } mAutofillProxyForLastRequest = proxy; onFillRequest(new FillRequest(proxy, inlineSuggestionsRequest), cancellationSignal, new FillController(proxy), new FillCallback(proxy)); } Loading Loading @@ -268,6 +303,7 @@ public abstract class AugmentedAutofillService extends Service { proxy.destroy(); } mAutofillProxies.clear(); mAutofillProxyForLastRequest = null; } } Loading @@ -287,6 +323,7 @@ public abstract class AugmentedAutofillService extends Service { } } mAutofillProxies = null; mAutofillProxyForLastRequest = null; } @Override Loading Loading @@ -481,6 +518,11 @@ public abstract class AugmentedAutofillService extends Service { mClient.requestHideFillUi(mSessionId, mFocusedId); } private boolean requestAutofill() throws RemoteException { return mClient.requestAutofill(mSessionId, mFocusedId); } private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue, @NonNull IFillCallback callback, @NonNull CancellationSignal cancellationSignal) { synchronized (mLock) { Loading core/java/android/view/autofill/AutofillManager.java +38 −7 Original line number Diff line number Diff line Loading @@ -3366,14 +3366,8 @@ public final class AutofillManager { final AutofillManager afm = mAfm.get(); if (afm == null) return null; final AutofillClient client = afm.getClient(); if (client == null) { Log.w(TAG, "getViewCoordinates(" + id + "): no autofill client"); return null; } final View view = client.autofillClientFindViewByAutofillIdTraversal(id); final View view = getView(afm, id); if (view == null) { Log.w(TAG, "getViewCoordinates(" + id + "): could not find view"); return null; } final Rect windowVisibleDisplayFrame = new Rect(); Loading Loading @@ -3414,5 +3408,42 @@ public final class AutofillManager { afm.post(() -> afm.requestHideFillUi(id, false)); } } @Override public boolean requestAutofill(int sessionId, AutofillId id) { final AutofillManager afm = mAfm.get(); if (afm == null || afm.mSessionId != sessionId) { if (sDebug) { Slog.d(TAG, "Autofill not available or sessionId doesn't match"); } return false; } final View view = getView(afm, id); if (view == null || !view.isFocused()) { if (sDebug) { Slog.d(TAG, "View not available or is not on focus"); } return false; } if (sVerbose) { Log.v(TAG, "requestAutofill() by AugmentedAutofillService."); } afm.post(() -> afm.requestAutofill(view)); return true; } @Nullable private View getView(@NonNull AutofillManager afm, @NonNull AutofillId id) { final AutofillClient client = afm.getClient(); if (client == null) { Log.w(TAG, "getView(" + id + "): no autofill client"); return null; } View view = client.autofillClientFindViewByAutofillIdTraversal(id); if (view == null) { Log.w(TAG, "getView(" + id + "): could not find view"); } return view; } } } core/java/android/view/autofill/IAugmentedAutofillManagerClient.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,10 @@ interface IAugmentedAutofillManagerClient { * Requests hiding the fill UI. */ void requestHideFillUi(int sessionId, in AutofillId id); /** * Requests to start a new autofill flow. Returns true if the autofill request is made to * {@link AutofillManager#requestAutofill(View)}. */ boolean requestAutofill(int sessionId, in AutofillId id); } Loading
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -10203,6 +10203,7 @@ package android.service.autofill.augmented { method public void onConnected(); method public void onDisconnected(); method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback); method public final boolean requestAutofill(@NonNull android.content.ComponentName, @NonNull android.view.autofill.AutofillId); field public static final String SERVICE_INTERFACE = "android.service.autofill.augmented.AugmentedAutofillService"; }
api/test-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -3205,6 +3205,7 @@ package android.service.autofill.augmented { method public void onConnected(); method public void onDisconnected(); method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback); method public final boolean requestAutofill(@NonNull android.content.ComponentName, @NonNull android.view.autofill.AutofillId); field public static final String SERVICE_INTERFACE = "android.service.autofill.augmented.AugmentedAutofillService"; } Loading
core/java/android/service/autofill/augmented/AugmentedAutofillService.java +42 −0 Original line number Diff line number Diff line Loading @@ -89,6 +89,8 @@ public abstract class AugmentedAutofillService extends Service { private SparseArray<AutofillProxy> mAutofillProxies; private AutofillProxy mAutofillProxyForLastRequest; // Used for metrics / debug only private ComponentName mServiceComponentName; Loading Loading @@ -157,6 +159,38 @@ public abstract class AugmentedAutofillService extends Service { public void onConnected() { } /** * The child class of the service can call this method to initiate an Autofill flow. * * <p> The request would be respected only if the previous augmented autofill request was * made for the same {@code activityComponent} and {@code autofillId}, and the field is * currently on focus. * * <p> The request would start a new autofill flow. It doesn't guarantee that the * {@link AutofillManager} will proceed with the request. * * @param activityComponent the client component for which the autofill is requested for * @param autofillId the client field id for which the autofill is requested for * @return true if the request makes the {@link AutofillManager} start a new Autofill flow, * false otherwise. */ public final boolean requestAutofill(@NonNull ComponentName activityComponent, @NonNull AutofillId autofillId) { // TODO(b/149531989): revisit this. The request should start a new autofill session // rather than reusing the existing session. final AutofillProxy proxy = mAutofillProxyForLastRequest; if (proxy == null || !proxy.mComponentName.equals(activityComponent) || !proxy.mFocusedId.equals(autofillId)) { return false; } try { return proxy.requestAutofill(); } catch (RemoteException e) { e.rethrowFromSystemServer(); } return false; } /** * Asks the service to handle an "augmented" autofill request. * Loading Loading @@ -241,6 +275,7 @@ public abstract class AugmentedAutofillService extends Service { } catch (RemoteException e) { e.rethrowFromSystemServer(); } mAutofillProxyForLastRequest = proxy; onFillRequest(new FillRequest(proxy, inlineSuggestionsRequest), cancellationSignal, new FillController(proxy), new FillCallback(proxy)); } Loading Loading @@ -268,6 +303,7 @@ public abstract class AugmentedAutofillService extends Service { proxy.destroy(); } mAutofillProxies.clear(); mAutofillProxyForLastRequest = null; } } Loading @@ -287,6 +323,7 @@ public abstract class AugmentedAutofillService extends Service { } } mAutofillProxies = null; mAutofillProxyForLastRequest = null; } @Override Loading Loading @@ -481,6 +518,11 @@ public abstract class AugmentedAutofillService extends Service { mClient.requestHideFillUi(mSessionId, mFocusedId); } private boolean requestAutofill() throws RemoteException { return mClient.requestAutofill(mSessionId, mFocusedId); } private void update(@NonNull AutofillId focusedId, @NonNull AutofillValue focusedValue, @NonNull IFillCallback callback, @NonNull CancellationSignal cancellationSignal) { synchronized (mLock) { Loading
core/java/android/view/autofill/AutofillManager.java +38 −7 Original line number Diff line number Diff line Loading @@ -3366,14 +3366,8 @@ public final class AutofillManager { final AutofillManager afm = mAfm.get(); if (afm == null) return null; final AutofillClient client = afm.getClient(); if (client == null) { Log.w(TAG, "getViewCoordinates(" + id + "): no autofill client"); return null; } final View view = client.autofillClientFindViewByAutofillIdTraversal(id); final View view = getView(afm, id); if (view == null) { Log.w(TAG, "getViewCoordinates(" + id + "): could not find view"); return null; } final Rect windowVisibleDisplayFrame = new Rect(); Loading Loading @@ -3414,5 +3408,42 @@ public final class AutofillManager { afm.post(() -> afm.requestHideFillUi(id, false)); } } @Override public boolean requestAutofill(int sessionId, AutofillId id) { final AutofillManager afm = mAfm.get(); if (afm == null || afm.mSessionId != sessionId) { if (sDebug) { Slog.d(TAG, "Autofill not available or sessionId doesn't match"); } return false; } final View view = getView(afm, id); if (view == null || !view.isFocused()) { if (sDebug) { Slog.d(TAG, "View not available or is not on focus"); } return false; } if (sVerbose) { Log.v(TAG, "requestAutofill() by AugmentedAutofillService."); } afm.post(() -> afm.requestAutofill(view)); return true; } @Nullable private View getView(@NonNull AutofillManager afm, @NonNull AutofillId id) { final AutofillClient client = afm.getClient(); if (client == null) { Log.w(TAG, "getView(" + id + "): no autofill client"); return null; } View view = client.autofillClientFindViewByAutofillIdTraversal(id); if (view == null) { Log.w(TAG, "getView(" + id + "): could not find view"); } return view; } } }
core/java/android/view/autofill/IAugmentedAutofillManagerClient.aidl +6 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,10 @@ interface IAugmentedAutofillManagerClient { * Requests hiding the fill UI. */ void requestHideFillUi(int sessionId, in AutofillId id); /** * Requests to start a new autofill flow. Returns true if the autofill request is made to * {@link AutofillManager#requestAutofill(View)}. */ boolean requestAutofill(int sessionId, in AutofillId id); }