1 /*
2  * Copyright (C) 2018 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 package android.service.autofill.augmented;
17 
18 import android.annotation.NonNull;
19 import android.annotation.Nullable;
20 import android.annotation.SystemApi;
21 import android.annotation.TestApi;
22 import android.content.ComponentName;
23 import android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy;
24 import android.view.autofill.AutofillId;
25 import android.view.autofill.AutofillValue;
26 import android.view.inputmethod.InlineSuggestionsRequest;
27 
28 import com.android.internal.util.DataClass;
29 
30 /**
31  * Represents a request to augment-fill an activity.
32  * @hide
33  */
34 @SystemApi
35 // TODO(b/123100811): pass a requestId and/or sessionId?
36 @TestApi
37 @DataClass(
38         genToString = true,
39         genBuilder = false,
40         genHiddenConstructor = true)
41 @DataClass.Suppress({"getProxy"})
42 public final class FillRequest {
43 
44     private final @NonNull AutofillProxy mProxy;
45 
46     //TODO(b/146901891): add detailed docs once we have stable APIs.
47     /**
48      * An optional request for inline suggestions.
49      */
50     private final @Nullable InlineSuggestionsRequest mInlineSuggestionsRequest;
51 
52     /**
53      * Gets the task of the activity associated with this request.
54      */
getTaskId()55     public int getTaskId() {
56         return mProxy.mTaskId;
57     }
58 
59     /**
60      * Gets the name of the activity associated with this request.
61      */
62     @NonNull
getActivityComponent()63     public ComponentName getActivityComponent() {
64         return mProxy.mComponentName;
65     }
66 
67     /**
68      * Gets the id of the field that triggered the request.
69      */
70     @NonNull
getFocusedId()71     public AutofillId getFocusedId() {
72         return mProxy.getFocusedId();
73     }
74 
75     /**
76      * Gets the current value of the field that triggered the request.
77      */
78     @NonNull
getFocusedValue()79     public AutofillValue getFocusedValue() {
80         return mProxy.getFocusedValue();
81     }
82 
83     /**
84      * Gets the Smart Suggestions object used to embed the autofill UI.
85      *
86      * @return object used to embed the autofill UI, or {@code null} if not supported.
87      */
88     @Nullable
getPresentationParams()89     public PresentationParams getPresentationParams() {
90         return mProxy.getSmartSuggestionParams();
91     }
92 
proxyToString()93     String proxyToString() {
94         return "FillRequest[act=" + getActivityComponent().flattenToShortString()
95                 + ", id=" + mProxy.getFocusedId() + "]";
96     }
97 
98 
99 
100 
101     // Code below generated by codegen v1.0.14.
102     //
103     // DO NOT MODIFY!
104     // CHECKSTYLE:OFF Generated code
105     //
106     // To regenerate run:
107     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/augmented/FillRequest.java
108     //
109     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
110     //   Settings > Editor > Code Style > Formatter Control
111     //@formatter:off
112 
113 
114     /**
115      * Creates a new FillRequest.
116      *
117      * @param inlineSuggestionsRequest
118      *   An optional request for inline suggestions.
119      * @hide
120      */
121     @DataClass.Generated.Member
FillRequest( @onNull AutofillProxy proxy, @Nullable InlineSuggestionsRequest inlineSuggestionsRequest)122     public FillRequest(
123             @NonNull AutofillProxy proxy,
124             @Nullable InlineSuggestionsRequest inlineSuggestionsRequest) {
125         this.mProxy = proxy;
126         com.android.internal.util.AnnotationValidations.validate(
127                 NonNull.class, null, mProxy);
128         this.mInlineSuggestionsRequest = inlineSuggestionsRequest;
129 
130         // onConstructed(); // You can define this method to get a callback
131     }
132 
133     /**
134      * An optional request for inline suggestions.
135      */
136     @DataClass.Generated.Member
getInlineSuggestionsRequest()137     public @Nullable InlineSuggestionsRequest getInlineSuggestionsRequest() {
138         return mInlineSuggestionsRequest;
139     }
140 
141     @Override
142     @DataClass.Generated.Member
toString()143     public String toString() {
144         // You can override field toString logic by defining methods like:
145         // String fieldNameToString() { ... }
146 
147         return "FillRequest { " +
148                 "proxy = " + proxyToString() + ", " +
149                 "inlineSuggestionsRequest = " + mInlineSuggestionsRequest +
150         " }";
151     }
152 
153     @DataClass.Generated(
154             time = 1577399314707L,
155             codegenVersion = "1.0.14",
156             sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillRequest.java",
157             inputSignatures = "private final @android.annotation.NonNull android.service.autofill.augmented.AugmentedAutofillService.AutofillProxy mProxy\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\npublic  int getTaskId()\npublic @android.annotation.NonNull android.content.ComponentName getActivityComponent()\npublic @android.annotation.NonNull android.view.autofill.AutofillId getFocusedId()\npublic @android.annotation.NonNull android.view.autofill.AutofillValue getFocusedValue()\npublic @android.annotation.Nullable android.service.autofill.augmented.PresentationParams getPresentationParams()\n  java.lang.String proxyToString()\nclass FillRequest extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genToString=true, genBuilder=false, genHiddenConstructor=true)")
158     @Deprecated
__metadata()159     private void __metadata() {}
160 
161 
162     //@formatter:on
163     // End of generated code
164 
165 }
166