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