1 /* 2 * Copyright (C) 2024 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.service.voice; 18 19 import android.annotation.IntDef; 20 import android.annotation.IntRange; 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.annotation.SuppressLint; 24 import android.annotation.SystemApi; 25 import android.os.Parcel; 26 import android.os.Parcelable; 27 28 import com.android.internal.util.DataClass; 29 30 import java.lang.annotation.Retention; 31 import java.lang.annotation.RetentionPolicy; 32 33 /** 34 * Represents a result supporting the visual query attention. 35 * 36 * @hide 37 */ 38 @DataClass( 39 genConstructor = false, 40 genBuilder = true, 41 genEqualsHashCode = true, 42 genHiddenConstDefs = true, 43 genParcelable = true, 44 genToString = true 45 ) 46 @SystemApi 47 @SuppressLint("UnflaggedApi") // b/325678077 flags not supported in isolated process 48 public final class VisualQueryAttentionResult implements Parcelable { 49 50 /** Intention type to allow the system to listen to audio-visual query interactions. */ 51 @SuppressLint("UnflaggedApi") // b/325678077 flags not supported in isolated process 52 public static final int INTERACTION_INTENTION_AUDIO_VISUAL = 0; 53 54 /** Intention type to allow the system to listen to visual accessibility query interactions. */ 55 @SuppressLint("UnflaggedApi") // b/325678077 flags not supported in isolated process 56 public static final int INTERACTION_INTENTION_VISUAL_ACCESSIBILITY = 1; 57 58 /** 59 * Intention of interaction associated with the attention result that the device should listen 60 * to after the attention signal is gained. 61 */ 62 private final @InteractionIntention int mInteractionIntention; 63 defaultInteractionIntention()64 private static @InteractionIntention int defaultInteractionIntention() { 65 return INTERACTION_INTENTION_AUDIO_VISUAL; 66 } 67 68 /** 69 * Integer value denoting the level of user engagement of the attention. System will 70 * also use this to adjust the intensity of UI indicators. 71 * 72 * The value can be between 1 and 100 (inclusive). The default value is set to be 100 which is 73 * defined as a complete engagement, which leads to the same UI result as the legacy 74 * {@link VisualQueryDetectionService#gainedAttention()}. 75 * 76 * Different values of engagement level corresponds to various SysUI effects. Within the same 77 * interaction intention, higher value of engagement level will lead to stronger visual 78 * presentation of the device attention UI. 79 */ 80 @IntRange(from = 1, to = 100) 81 private final int mEngagementLevel; 82 defaultEngagementLevel()83 private static int defaultEngagementLevel() { 84 return 100; 85 } 86 87 /** 88 * Provides an instance of {@link Builder} with state corresponding to this instance. 89 * 90 * @hide 91 */ buildUpon()92 public Builder buildUpon() { 93 return new Builder() 94 .setInteractionIntention(mInteractionIntention) 95 .setEngagementLevel(mEngagementLevel); 96 } 97 98 /** 99 * TODO(b/301491148): Remove suppressLint on generated API when fixed or sdk finalized. 100 * Codegen does not support flaggedAPI, so needs to review manually on the generated code 101 * and makes sure the following: 102 * 1. SuppressLint is added back to the API after each run of codegen 103 * 2. No unwanted method is modified due to suppressLint annotation 104 * 105 * Run $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/voice/VisualQueryAttentionResult.java 106 * for codegen on new APIs. 107 */ 108 109 110 111 // Code below generated by codegen v1.0.23. 112 // 113 // DO NOT MODIFY! 114 // CHECKSTYLE:OFF Generated code 115 // 116 // To regenerate run: 117 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/voice/VisualQueryAttentionResult.java 118 // 119 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 120 // Settings > Editor > Code Style > Formatter Control 121 //@formatter:off 122 123 124 /** @hide */ 125 @IntDef(prefix = "INTERACTION_INTENTION_", value = { 126 INTERACTION_INTENTION_AUDIO_VISUAL, 127 INTERACTION_INTENTION_VISUAL_ACCESSIBILITY 128 }) 129 @Retention(RetentionPolicy.SOURCE) 130 @DataClass.Generated.Member 131 public @interface InteractionIntention {} 132 133 /** @hide */ 134 @DataClass.Generated.Member interactionIntentionToString(@nteractionIntention int value)135 public static String interactionIntentionToString(@InteractionIntention int value) { 136 switch (value) { 137 case INTERACTION_INTENTION_AUDIO_VISUAL: 138 return "INTERACTION_INTENTION_AUDIO_VISUAL"; 139 case INTERACTION_INTENTION_VISUAL_ACCESSIBILITY: 140 return "INTERACTION_INTENTION_VISUAL_ACCESSIBILITY"; 141 default: return Integer.toHexString(value); 142 } 143 } 144 145 @DataClass.Generated.Member VisualQueryAttentionResult( @nteractionIntention int interactionIntention, @IntRange(from = 1, to = 100) int engagementLevel)146 /* package-private */ VisualQueryAttentionResult( 147 @InteractionIntention int interactionIntention, 148 @IntRange(from = 1, to = 100) int engagementLevel) { 149 this.mInteractionIntention = interactionIntention; 150 151 if (!(mInteractionIntention == INTERACTION_INTENTION_AUDIO_VISUAL) 152 && !(mInteractionIntention == INTERACTION_INTENTION_VISUAL_ACCESSIBILITY)) { 153 throw new java.lang.IllegalArgumentException( 154 "interactionIntention was " + mInteractionIntention + " but must be one of: " 155 + "INTERACTION_INTENTION_AUDIO_VISUAL(" + INTERACTION_INTENTION_AUDIO_VISUAL + "), " 156 + "INTERACTION_INTENTION_VISUAL_ACCESSIBILITY(" + INTERACTION_INTENTION_VISUAL_ACCESSIBILITY + ")"); 157 } 158 159 this.mEngagementLevel = engagementLevel; 160 com.android.internal.util.AnnotationValidations.validate( 161 IntRange.class, null, mEngagementLevel, 162 "from", 1, 163 "to", 100); 164 165 // onConstructed(); // You can define this method to get a callback 166 } 167 168 /** 169 * Intention of interaction associated with the attention result that the device should listen 170 * to after the attention signal is gained. 171 */ 172 @DataClass.Generated.Member 173 @SuppressLint("UnflaggedApi") getInteractionIntention()174 public @InteractionIntention int getInteractionIntention() { 175 return mInteractionIntention; 176 } 177 178 /** 179 * Integer value denoting the level of user engagement of the attention. System will 180 * also use this to adjust the intensity of UI indicators. 181 * 182 * The value can be between 1 and 100 (inclusive). The default value is set to be 100 which is 183 * defined as a complete engagement, which leads to the same UI result as the legacy 184 * {@link VisualQueryDetectionService#gainedAttention()}. 185 * 186 * Different values of engagement level corresponds to various SysUI effects. Within the same 187 * interaction intention, higher value of engagement level will lead to stronger visual 188 * presentation of the device attention UI. 189 */ 190 @DataClass.Generated.Member 191 @SuppressLint("UnflaggedApi") getEngagementLevel()192 public @IntRange(from = 1, to = 100) int getEngagementLevel() { 193 return mEngagementLevel; 194 } 195 196 @Override 197 @DataClass.Generated.Member toString()198 public String toString() { 199 // You can override field toString logic by defining methods like: 200 // String fieldNameToString() { ... } 201 202 return "VisualQueryAttentionResult { " + 203 "interactionIntention = " + mInteractionIntention + ", " + 204 "engagementLevel = " + mEngagementLevel + 205 " }"; 206 } 207 208 @Override 209 @DataClass.Generated.Member equals(@ullable Object o)210 public boolean equals(@Nullable Object o) { 211 // You can override field equality logic by defining either of the methods like: 212 // boolean fieldNameEquals(VisualQueryAttentionResult other) { ... } 213 // boolean fieldNameEquals(FieldType otherValue) { ... } 214 215 if (this == o) return true; 216 if (o == null || getClass() != o.getClass()) return false; 217 @SuppressWarnings("unchecked") 218 VisualQueryAttentionResult that = (VisualQueryAttentionResult) o; 219 //noinspection PointlessBooleanExpression 220 return true 221 && mInteractionIntention == that.mInteractionIntention 222 && mEngagementLevel == that.mEngagementLevel; 223 } 224 225 @Override 226 @DataClass.Generated.Member hashCode()227 public int hashCode() { 228 // You can override field hashCode logic by defining methods like: 229 // int fieldNameHashCode() { ... } 230 231 int _hash = 1; 232 _hash = 31 * _hash + mInteractionIntention; 233 _hash = 31 * _hash + mEngagementLevel; 234 return _hash; 235 } 236 237 @Override 238 @DataClass.Generated.Member 239 @SuppressLint("UnflaggedApi") writeToParcel(@onNull Parcel dest, int flags)240 public void writeToParcel(@NonNull Parcel dest, int flags) { 241 // You can override field parcelling by defining methods like: 242 // void parcelFieldName(Parcel dest, int flags) { ... } 243 244 dest.writeInt(mInteractionIntention); 245 dest.writeInt(mEngagementLevel); 246 } 247 248 @Override 249 @DataClass.Generated.Member 250 @SuppressLint("UnflaggedApi") describeContents()251 public int describeContents() { return 0; } 252 253 /** @hide */ 254 @SuppressWarnings({"unchecked", "RedundantCast"}) 255 @DataClass.Generated.Member VisualQueryAttentionResult(@onNull Parcel in)256 /* package-private */ VisualQueryAttentionResult(@NonNull Parcel in) { 257 // You can override field unparcelling by defining methods like: 258 // static FieldType unparcelFieldName(Parcel in) { ... } 259 260 int interactionIntention = in.readInt(); 261 int engagementLevel = in.readInt(); 262 263 this.mInteractionIntention = interactionIntention; 264 if (!(mInteractionIntention == INTERACTION_INTENTION_AUDIO_VISUAL) 265 && !(mInteractionIntention == INTERACTION_INTENTION_VISUAL_ACCESSIBILITY)) { 266 throw new java.lang.IllegalArgumentException( 267 "interactionIntention was " + mInteractionIntention + " but must be one of: " 268 + "INTERACTION_INTENTION_AUDIO_VISUAL(" + INTERACTION_INTENTION_AUDIO_VISUAL + "), " 269 + "INTERACTION_INTENTION_VISUAL_ACCESSIBILITY(" + INTERACTION_INTENTION_VISUAL_ACCESSIBILITY + ")"); 270 } 271 this.mEngagementLevel = engagementLevel; 272 com.android.internal.util.AnnotationValidations.validate( 273 IntRange.class, null, mEngagementLevel, 274 "from", 1, 275 "to", 100); 276 277 // onConstructed(); // You can define this method to get a callback 278 } 279 280 @DataClass.Generated.Member 281 @SuppressLint("UnflaggedApi") 282 public static final @NonNull Parcelable.Creator<VisualQueryAttentionResult> CREATOR 283 = new Parcelable.Creator<VisualQueryAttentionResult>() { 284 @Override 285 public VisualQueryAttentionResult[] newArray(int size) { 286 return new VisualQueryAttentionResult[size]; 287 } 288 289 @Override 290 public VisualQueryAttentionResult createFromParcel(@NonNull Parcel in) { 291 return new VisualQueryAttentionResult(in); 292 } 293 }; 294 295 /** 296 * A builder for {@link VisualQueryAttentionResult} 297 */ 298 @SuppressWarnings("WeakerAccess") 299 @DataClass.Generated.Member 300 @SuppressLint("UnflaggedApi") 301 public static final class Builder { 302 303 private @InteractionIntention int mInteractionIntention; 304 private @IntRange(from = 1, to = 100) int mEngagementLevel; 305 306 private long mBuilderFieldsSet = 0L; 307 308 @SuppressLint("UnflaggedApi") Builder()309 public Builder() { 310 } 311 312 /** 313 * Intention of interaction associated with the attention result that the device should listen 314 * to after the attention signal is gained. 315 */ 316 @DataClass.Generated.Member 317 @SuppressLint("UnflaggedApi") setInteractionIntention(@nteractionIntention int value)318 public @NonNull Builder setInteractionIntention(@InteractionIntention int value) { 319 checkNotUsed(); 320 mBuilderFieldsSet |= 0x1; 321 mInteractionIntention = value; 322 return this; 323 } 324 325 /** 326 * Integer value denoting the level of user engagement of the attention. System will 327 * also use this to adjust the intensity of UI indicators. 328 * 329 * The value can be between 1 and 100 (inclusive). The default value is set to be 100 which is 330 * defined as a complete engagement, which leads to the same UI result as the legacy 331 * {@link VisualQueryDetectionService#gainedAttention()}. 332 * 333 * Different values of engagement level corresponds to various SysUI effects. Within the same 334 * interaction intention, higher value of engagement level will lead to stronger visual 335 * presentation of the device attention UI. 336 */ 337 @DataClass.Generated.Member 338 @SuppressLint("UnflaggedApi") setEngagementLevel(@ntRangefrom = 1, to = 100) int value)339 public @NonNull Builder setEngagementLevel(@IntRange(from = 1, to = 100) int value) { 340 checkNotUsed(); 341 mBuilderFieldsSet |= 0x2; 342 mEngagementLevel = value; 343 return this; 344 } 345 346 /** Builds the instance. This builder should not be touched after calling this! */ 347 @SuppressLint("UnflaggedApi") build()348 public @NonNull VisualQueryAttentionResult build() { 349 checkNotUsed(); 350 mBuilderFieldsSet |= 0x4; // Mark builder used 351 352 if ((mBuilderFieldsSet & 0x1) == 0) { 353 mInteractionIntention = defaultInteractionIntention(); 354 } 355 if ((mBuilderFieldsSet & 0x2) == 0) { 356 mEngagementLevel = defaultEngagementLevel(); 357 } 358 VisualQueryAttentionResult o = new VisualQueryAttentionResult( 359 mInteractionIntention, 360 mEngagementLevel); 361 return o; 362 } 363 checkNotUsed()364 private void checkNotUsed() { 365 if ((mBuilderFieldsSet & 0x4) != 0) { 366 throw new IllegalStateException( 367 "This Builder should not be reused. Use a new Builder instance instead"); 368 } 369 } 370 } 371 372 @DataClass.Generated( 373 time = 1710979945907L, 374 codegenVersion = "1.0.23", 375 sourceFile = "frameworks/base/core/java/android/service/voice/VisualQueryAttentionResult.java", 376 inputSignatures = "public static final @android.annotation.SuppressLint int INTERACTION_INTENTION_AUDIO_VISUAL\npublic static final @android.annotation.SuppressLint int INTERACTION_INTENTION_VISUAL_ACCESSIBILITY\nprivate final @android.service.voice.VisualQueryAttentionResult.InteractionIntention int mInteractionIntention\nprivate final @android.annotation.IntRange int mEngagementLevel\nprivate static @android.service.voice.VisualQueryAttentionResult.InteractionIntention int defaultInteractionIntention()\nprivate static int defaultEngagementLevel()\npublic android.service.voice.VisualQueryAttentionResult.Builder buildUpon()\nclass VisualQueryAttentionResult extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=true, genEqualsHashCode=true, genHiddenConstDefs=true, genParcelable=true, genToString=true)") 377 @Deprecated __metadata()378 private void __metadata() {} 379 380 381 //@formatter:on 382 // End of generated code 383 384 } 385