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.graphics.Rect;
26 import android.os.IBinder;
27 import android.view.autofill.AutofillId;
28 import android.view.autofill.AutofillValue;
29 import android.view.autofill.IAutofillWindowPresenter;
30 import android.view.KeyEvent;
31 
32 import com.android.internal.os.IResultReceiver;
33 
34 /**
35  * Object running in the application process and responsible for autofilling it.
36  *
37  * @hide
38  */
39 oneway interface IAutoFillManagerClient {
40     /**
41      * Notifies the client when the autofill enabled state changed.
42      */
setState(int flags)43     void setState(int flags);
44 
45     /**
46       * Autofills the activity with the contents of a dataset.
47       */
autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values, boolean hideHighlight)48     void autofill(int sessionId, in List<AutofillId> ids, in List<AutofillValue> values,
49             boolean hideHighlight);
50 
51     /**
52      * Autofills the activity with rich content data (e.g. an image) from a dataset.
53      */
autofillContent(int sessionId, in AutofillId id, in ClipData content)54     void autofillContent(int sessionId, in AutofillId id, in ClipData content);
55 
56     /**
57       * Authenticates a fill response or a data set.
58       */
authenticate(int sessionId, int authenticationId, in IntentSender intent, in Intent fillInIntent, boolean authenticateInline)59     void authenticate(int sessionId, int authenticationId, in IntentSender intent,
60             in Intent fillInIntent, boolean authenticateInline);
61 
62     /**
63       * Sets the views to track. If saveOnAllViewsInvisible is set and all these view are invisible
64       * the session is finished automatically.
65       */
setTrackedViews(int sessionId, in @nullable AutofillId[] savableIds, boolean saveOnAllViewsInvisible, boolean saveOnFinish, in @nullable AutofillId[] fillableIds, in AutofillId saveTriggerId)66     void setTrackedViews(int sessionId, in @nullable AutofillId[] savableIds,
67             boolean saveOnAllViewsInvisible, boolean saveOnFinish,
68             in @nullable AutofillId[] fillableIds, in AutofillId saveTriggerId);
69 
70     /**
71      * Requests showing the fill UI.
72      */
requestShowFillUi(int sessionId, in AutofillId id, int width, int height, in Rect anchorBounds, in IAutofillWindowPresenter presenter)73     void requestShowFillUi(int sessionId, in AutofillId id, int width, int height,
74     in Rect anchorBounds, in IAutofillWindowPresenter presenter);
75 
76     /**
77      * Requests hiding the fill UI.
78      */
requestHideFillUi(int sessionId, in AutofillId id)79     void requestHideFillUi(int sessionId, in AutofillId id);
80 
81     /**
82      * Requests hiding the fill UI when it's destroyed
83      */
requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id)84     void requestHideFillUiWhenDestroyed(int sessionId, in AutofillId id);
85 
86     /**
87      * Notifies no fill UI will be shown, and also mark the state as finished if necessary (if
88      * sessionFinishedState != 0).
89      */
notifyNoFillUi(int sessionId, in AutofillId id, int sessionFinishedState)90     void notifyNoFillUi(int sessionId, in AutofillId id, int sessionFinishedState);
91 
92     /**
93      * Notifies that the fill UI was shown by the system (e.g. as inline chips in the keyboard).
94      */
notifyFillUiShown(int sessionId, in AutofillId id)95     void notifyFillUiShown(int sessionId, in AutofillId id);
96 
97     /**
98      * Notifies that the fill UI previously shown by the system has been hidden by the system.
99      *
100      * @see #notifyFillUiShown
101      */
notifyFillUiHidden(int sessionId, in AutofillId id)102     void notifyFillUiHidden(int sessionId, in AutofillId id);
103 
104     /**
105      * Dispatches unhandled keyevent from autofill ui. Autofill ui handles DPAD and ENTER events,
106      * other unhandled keyevents are dispatched to app's window to filter autofill result.
107      * Note this method is not called when autofill ui is in fullscreen mode (TV only).
108      */
dispatchUnhandledKey(int sessionId, in AutofillId id, in KeyEvent keyEvent)109     void dispatchUnhandledKey(int sessionId, in AutofillId id, in KeyEvent keyEvent);
110 
111     /**
112      * Starts the provided intent sender.
113      */
startIntentSender(in IntentSender intentSender, in Intent intent)114     void startIntentSender(in IntentSender intentSender, in Intent intent);
115 
116    /**
117      * Sets the state of the Autofill Save UI for a given session.
118      */
setSaveUiState(int sessionId, boolean shown)119    void setSaveUiState(int sessionId, boolean shown);
120 
121    /**
122      * Marks the state of the session as finished.
123      *
124      * @param newState STATE_FINISHED (because the autofill service returned a null
125      * FillResponse) or STATE_UNKNOWN (because the session was removed).
126      * @param autofillableIds list of ids that could trigger autofill, use to not handle a new
127      * session when they're entered.
128      */
setSessionFinished(int newState, in List<AutofillId> autofillableIds)129    void setSessionFinished(int newState, in List<AutofillId> autofillableIds);
130 
131    /**
132     * Gets a reference to the binder object that can be used by the Augmented Autofill service.
133     *
134     * @param receiver, whose AutofillManager.EXTRA_AUGMENTED_AUTOFILL_CLIENT extra will contain
135     * the reference.
136     */
getAugmentedAutofillClient(in IResultReceiver result)137    void getAugmentedAutofillClient(in IResultReceiver result);
138 
139    /**
140     * Notifies disables autofill for the app or activity.
141     */
notifyDisableAutofill(long disableDuration, in ComponentName componentName)142    void notifyDisableAutofill(long disableDuration, in ComponentName componentName);
143 
144    /**
145     * Requests to show the soft input method if the focus is on the given id.
146     */
requestShowSoftInput(in AutofillId id)147    void requestShowSoftInput(in AutofillId id);
148 
149     /**
150      * Notifies autofill ids that require to show the fill dialog.
151      */
notifyFillDialogTriggerIds(in List<AutofillId> ids)152     void notifyFillDialogTriggerIds(in List<AutofillId> ids);
153 }
154