1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.view.autofill;
18 
19 import java.util.List;
20 
21 import android.content.ClipData;
22 import android.content.ComponentName;
23 import android.content.Intent;
24 import android.content.IntentSender;
25 import android.credentials.GetCredentialResponse;
26 import android.graphics.Rect;
27 import android.os.IBinder;
28 import android.view.autofill.AutofillId;
29 import android.view.autofill.AutofillValue;
30 import android.view.autofill.IAutofillWindowPresenter;
31 import android.view.KeyEvent;
32 
33 import com.android.internal.os.IResultReceiver;
34 
35 /**
36  * Object running in the application process and responsible for autofilling it.
37  *
38  * @hide
39  */
40 oneway interface IAutoFillManagerClient {
41     /**
42      * Notifies the client when the autofill enabled state changed.
43      */
setState(int flags)44     void setState(int flags);
45 
46     /**
47       * Autofills the activity with the contents of a dataset.
48       */
autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values, boolean hideHighlight)49     void autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values,
50             boolean hideHighlight);
51 
onGetCredentialResponse(int sessionId, in AutofillId id, in GetCredentialResponse response)52     void onGetCredentialResponse(int sessionId, in AutofillId id,
53                  in GetCredentialResponse response);
54 
onGetCredentialException(int sessionId, in AutofillId id, in String errorType, in String errorMsg)55     void onGetCredentialException(int sessionId, in AutofillId id,
56                      in String errorType, in String errorMsg);
57 
58     /**
59      * Autofills the activity with rich content data (e.g. an image) from a dataset.
60      */
autofillContent(int sessionId, in AutofillId id, in ClipData content)61     void autofillContent(int sessionId, in AutofillId id, in ClipData content);
62 
63     /**
64       * Authenticates a fill response or a data set.
65       */
authenticate(int sessionId, int authenticationId, in IntentSender intent, in Intent fillInIntent, boolean authenticateInline)66     void authenticate(int sessionId, int authenticationId, in IntentSender intent,
67             in Intent fillInIntent, boolean authenticateInline);
68 
69     /**
70       * Sets the views to track. If saveOnAllViewsInvisible is set and all these view are invisible
71       * the session is finished automatically.
72       */
setTrackedViews(int sessionId, in @nullable AutofillId[] savableIds, boolean saveOnAllViewsInvisible, boolean saveOnFinish, in @nullable AutofillId[] fillableIds, in AutofillId saveTriggerId)73     void setTrackedViews(int sessionId, in @nullable AutofillId[] savableIds,
74             boolean saveOnAllViewsInvisible, boolean saveOnFinish,
75             in @nullable AutofillId[] fillableIds, in AutofillId saveTriggerId);
76 
77     /**
78      * Requests showing the fill UI.
79      */
requestShowFillUi(int sessionId, in AutofillId id, int width, int height, in Rect anchorBounds, in IAutofillWindowPresenter presenter)80     void requestShowFillUi(int sessionId, in AutofillId id, int width, int height,
81     in Rect anchorBounds, in IAutofillWindowPresenter presenter);
82 
83     /**
84      * Requests hiding the fill UI.
85      */
requestHideFillUi(int sessionId, in AutofillId id)86     void requestHideFillUi(int sessionId, in AutofillId id);
87 
88     /**
89      * Requests hiding the fill UI when it's destroyed
90      */
requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id)91     void requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id);
92 
93     /**
94      * Notifies no fill UI will be shown, and also mark the state as finished if necessary (if
95      * sessionFinishedState != 0).
96      */
notifyNoFillUi(int sessionId, in AutofillId id, int sessionFinishedState)97     void notifyNoFillUi(int sessionId, in AutofillId id, int sessionFinishedState);
98 
99     /**
100      * Notifies that the fill UI was shown by the system (e.g. as inline chips in the keyboard).
101      */
notifyFillUiShown(int sessionId, in AutofillId id)102     void notifyFillUiShown(int sessionId, in AutofillId id);
103 
104     /**
105      * Notifies that the fill UI previously shown by the system has been hidden by the system.
106      *
107      * @see #notifyFillUiShown
108      */
notifyFillUiHidden(int sessionId, in AutofillId id)109     void notifyFillUiHidden(int sessionId, in AutofillId id);
110 
111     /**
112      * Dispatches unhandled keyevent from autofill ui. Autofill ui handles DPAD and ENTER events,
113      * other unhandled keyevents are dispatched to app's window to filter autofill result.
114      * Note this method is not called when autofill ui is in fullscreen mode (TV only).
115      */
dispatchUnhandledKey(int sessionId, in AutofillId id, in KeyEvent keyEvent)116     void dispatchUnhandledKey(int sessionId, in AutofillId id, in KeyEvent keyEvent);
117 
118     /**
119      * Starts the provided intent sender.
120      */
startIntentSender(in IntentSender intentSender, in Intent intent)121     void startIntentSender(in IntentSender intentSender, in Intent intent);
122 
123    /**
124      * Sets the state of the Autofill Save UI for a given session.
125      */
setSaveUiState(int sessionId, boolean shown)126    void setSaveUiState(int sessionId, boolean shown);
127 
128    /**
129      * Marks the state of the session as finished.
130      *
131      * @param newState STATE_FINISHED (because the autofill service returned a null
132      * FillResponse) or STATE_UNKNOWN (because the session was removed).
133      * @param autofillableIds list of ids that could trigger autofill, use to not handle a new
134      * session when they're entered.
135      */
setSessionFinished(int newState, in List<AutofillId> autofillableIds)136    void setSessionFinished(int newState, in List<AutofillId> autofillableIds);
137 
138    /**
139     * Gets a reference to the binder object that can be used by the Augmented Autofill service.
140     *
141     * @param receiver, whose AutofillManager.EXTRA_AUGMENTED_AUTOFILL_CLIENT extra will contain
142     * the reference.
143     */
getAugmentedAutofillClient(in IResultReceiver result)144    void getAugmentedAutofillClient(in IResultReceiver result);
145 
146    /**
147     * Notifies disables autofill for the app or activity.
148     */
notifyDisableAutofill(long disableDuration, in ComponentName componentName)149    void notifyDisableAutofill(long disableDuration, in ComponentName componentName);
150 
151    /**
152     * Requests to show the soft input method if the focus is on the given id.
153     */
requestShowSoftInput(in AutofillId id)154    void requestShowSoftInput(in AutofillId id);
155 
156     /**
157      * Notifies autofill ids that require to show the fill dialog.
158      */
notifyFillDialogTriggerIds(in List<AutofillId> ids)159     void notifyFillDialogTriggerIds(in List<AutofillId> ids);
160 }
161