| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.service.autofill; |
| 18 |
|
| 19 |
import static android.view.autofill.Helper.sDebug; |
| 20 |
|
| 21 |
import android.annotation.NonNull; |
| 22 |
import android.annotation.Nullable; |
| 23 |
import android.app.assist.AssistStructure; |
| 24 |
import android.app.assist.AssistStructure.ViewNode; |
| 25 |
import android.os.Bundle; |
| 26 |
import android.os.CancellationSignal; |
| 27 |
import android.os.Parcel; |
| 28 |
import android.os.Parcelable; |
| 29 |
import android.util.ArrayMap; |
| 30 |
import android.util.SparseIntArray; |
| 31 |
import android.view.autofill.AutofillId; |
| 32 |
|
| 33 |
import com.android.internal.util.DataClass; |
| 34 |
|
| 35 |
import java.util.LinkedList; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
@DataClass( |
| 52 |
genHiddenConstructor = true, |
| 53 |
genAidl = false) |
| 54 |
public final class FillContext implements Parcelable { |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
private final int mRequestId; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
private final @NonNull AssistStructure mStructure; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
private final @NonNull AutofillId mFocusedId; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
private transient @Nullable ArrayMap<AutofillId, AssistStructure.ViewNode> mViewNodeLookupTable; |
| 79 |
|
| 80 |
|
| 81 |
@Override |
| 82 |
public String toString() { |
| 83 |
if (!sDebug) return super.toString(); |
| 84 |
|
| 85 |
return "FillContext [reqId=" + mRequestId + ", focusedId=" + mFocusedId + "]"; |
| 86 |
} |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
@NonNull public ViewNode[] findViewNodesByAutofillIds(@NonNull AutofillId[] ids) { |
| 98 |
final LinkedList<ViewNode> nodesToProcess = new LinkedList<>(); |
| 99 |
final ViewNode[] foundNodes = new AssistStructure.ViewNode[ids.length]; |
| 100 |
|
| 101 |
|
| 102 |
final SparseIntArray missingNodeIndexes = new SparseIntArray(ids.length); |
| 103 |
|
| 104 |
for (int i = 0; i < ids.length; i++) { |
| 105 |
if (mViewNodeLookupTable != null) { |
| 106 |
int lookupTableIndex = mViewNodeLookupTable.indexOfKey(ids[i]); |
| 107 |
|
| 108 |
if (lookupTableIndex >= 0) { |
| 109 |
foundNodes[i] = mViewNodeLookupTable.valueAt(lookupTableIndex); |
| 110 |
} else { |
| 111 |
missingNodeIndexes.put(i, 0); |
| 112 |
} |
| 113 |
} else { |
| 114 |
missingNodeIndexes.put(i, 0); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
final int numWindowNodes = mStructure.getWindowNodeCount(); |
| 119 |
for (int i = 0; i < numWindowNodes; i++) { |
| 120 |
nodesToProcess.add(mStructure.getWindowNodeAt(i).getRootViewNode()); |
| 121 |
} |
| 122 |
|
| 123 |
while (missingNodeIndexes.size() > 0 && !nodesToProcess.isEmpty()) { |
| 124 |
final ViewNode node = nodesToProcess.removeFirst(); |
| 125 |
|
| 126 |
for (int i = 0; i < missingNodeIndexes.size(); i++) { |
| 127 |
final int index = missingNodeIndexes.keyAt(i); |
| 128 |
final AutofillId id = ids[index]; |
| 129 |
|
| 130 |
if (id.equals(node.getAutofillId())) { |
| 131 |
foundNodes[index] = node; |
| 132 |
|
| 133 |
if (mViewNodeLookupTable == null) { |
| 134 |
mViewNodeLookupTable = new ArrayMap<>(ids.length); |
| 135 |
} |
| 136 |
|
| 137 |
mViewNodeLookupTable.put(id, node); |
| 138 |
|
| 139 |
missingNodeIndexes.removeAt(i); |
| 140 |
break; |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
for (int i = 0; i < node.getChildCount(); i++) { |
| 145 |
nodesToProcess.addLast(node.getChildAt(i)); |
| 146 |
} |
| 147 |
} |
| 148 |
|
| 149 |
|
| 150 |
for (int i = 0; i < missingNodeIndexes.size(); i++) { |
| 151 |
if (mViewNodeLookupTable == null) { |
| 152 |
mViewNodeLookupTable = new ArrayMap<>(missingNodeIndexes.size()); |
| 153 |
} |
| 154 |
|
| 155 |
mViewNodeLookupTable.put(ids[missingNodeIndexes.keyAt(i)], null); |
| 156 |
} |
| 157 |
|
| 158 |
return foundNodes; |
| 159 |
} |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
@DataClass.Generated.Member |
| 187 |
public FillContext( |
| 188 |
int requestId, |
| 189 |
@NonNull AssistStructure structure, |
| 190 |
@NonNull AutofillId focusedId) { |
| 191 |
this.mRequestId = requestId; |
| 192 |
this.mStructure = structure; |
| 193 |
com.android.internal.util.AnnotationValidations.validate( |
| 194 |
NonNull.class, null, mStructure); |
| 195 |
this.mFocusedId = focusedId; |
| 196 |
com.android.internal.util.AnnotationValidations.validate( |
| 197 |
NonNull.class, null, mFocusedId); |
| 198 |
|
| 199 |
|
| 200 |
} |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
@DataClass.Generated.Member |
| 209 |
public int getRequestId() { |
| 210 |
return mRequestId; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
@DataClass.Generated.Member |
| 217 |
public @NonNull AssistStructure getStructure() { |
| 218 |
return mStructure; |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
@DataClass.Generated.Member |
| 225 |
public @NonNull AutofillId getFocusedId() { |
| 226 |
return mFocusedId; |
| 227 |
} |
| 228 |
|
| 229 |
@Override |
| 230 |
@DataClass.Generated.Member |
| 231 |
public void writeToParcel(Parcel dest, int flags) { |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
dest.writeInt(mRequestId); |
| 236 |
dest.writeTypedObject(mStructure, flags); |
| 237 |
dest.writeTypedObject(mFocusedId, flags); |
| 238 |
} |
| 239 |
|
| 240 |
@Override |
| 241 |
@DataClass.Generated.Member |
| 242 |
public int describeContents() { return 0; } |
| 243 |
|
| 244 |
@DataClass.Generated.Member |
| 245 |
public static final @NonNull Parcelable.Creator<FillContext> CREATOR |
| 246 |
= new Parcelable.Creator<FillContext>() { |
| 247 |
@Override |
| 248 |
public FillContext[] newArray(int size) { |
| 249 |
return new FillContext[size]; |
| 250 |
} |
| 251 |
|
| 252 |
@Override |
| 253 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 254 |
public FillContext createFromParcel(Parcel in) { |
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
int requestId = in.readInt(); |
| 259 |
AssistStructure structure = (AssistStructure) in.readTypedObject(AssistStructure.CREATOR); |
| 260 |
AutofillId focusedId = (AutofillId) in.readTypedObject(AutofillId.CREATOR); |
| 261 |
return new FillContext( |
| 262 |
requestId, |
| 263 |
structure, |
| 264 |
focusedId); |
| 265 |
} |
| 266 |
}; |
| 267 |
|
| 268 |
@DataClass.Generated( |
| 269 |
time = 1565152135263L, |
| 270 |
codegenVersion = "1.0.0", |
| 271 |
sourceFile = "frameworks/base/core/java/android/service/autofill/FillContext.java", |
| 272 |
inputSignatures = "private final int mRequestId\nprivate final @android.annotation.NonNull android.app.assist.AssistStructure mStructure\nprivate final @android.annotation.NonNull android.view.autofill.AutofillId mFocusedId\nprivate transient @android.annotation.Nullable android.util.ArrayMap<android.view.autofill.AutofillId,android.app.assist.AssistStructure.ViewNode> mViewNodeLookupTable\npublic @java.lang.Override java.lang.String toString()\npublic @android.annotation.NonNull android.app.assist.AssistStructure.ViewNode[] findViewNodesByAutofillIds(android.view.autofill.AutofillId[])\nclass FillContext extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genAidl=false)") |
| 273 |
@Deprecated |
| 274 |
private void __metadata() {} |
| 275 |
|
| 276 |
} |