1 /* 2 * Copyright (C) 2021 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.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.TestApi; 22 import android.os.CancellationSignal; 23 import android.os.IBinder; 24 import android.os.Parcel; 25 import android.os.Parcelable; 26 27 import com.android.internal.util.DataClass; 28 29 import java.util.Objects; 30 import java.util.concurrent.Executor; 31 import java.util.function.Consumer; 32 33 /** 34 * The class is used to represent a visible activity information. The system provides this to 35 * services that need to know {@link android.service.voice.VoiceInteractionSession.ActivityId}. 36 */ 37 @DataClass( 38 genConstructor = false, 39 genEqualsHashCode = true, 40 genHiddenConstDefs = false, 41 genGetters = false, 42 genToString = true 43 ) 44 public final class VisibleActivityInfo implements Parcelable { 45 46 /** 47 * Indicates that it is a new visible activity. 48 * 49 * @hide 50 */ 51 public static final int TYPE_ACTIVITY_ADDED = 1; 52 53 /** 54 * Indicates that it has become a invisible activity. 55 * 56 * @hide 57 */ 58 public static final int TYPE_ACTIVITY_REMOVED = 2; 59 60 /** 61 * The identifier of the task this activity is in. 62 */ 63 private final int mTaskId; 64 65 /** 66 * Token for targeting this activity for assist purposes. 67 */ 68 @NonNull 69 private final IBinder mAssistToken; 70 71 /** @hide */ 72 @TestApi VisibleActivityInfo( int taskId, @NonNull IBinder assistToken)73 public VisibleActivityInfo( 74 int taskId, 75 @NonNull IBinder assistToken) { 76 Objects.requireNonNull(assistToken); 77 mTaskId = taskId; 78 mAssistToken = assistToken; 79 } 80 81 /** 82 * Returns the {@link android.service.voice.VoiceInteractionSession.ActivityId} of this 83 * visible activity which can be used to interact with an activity, for example through 84 * {@link VoiceInteractionSession#requestDirectActions(VoiceInteractionSession.ActivityId, 85 * CancellationSignal, Executor, Consumer)}. 86 */ getActivityId()87 public @NonNull VoiceInteractionSession.ActivityId getActivityId() { 88 return new VoiceInteractionSession.ActivityId(mTaskId, mAssistToken); 89 } 90 91 92 93 // Code below generated by codegen v1.0.23. 94 // 95 // DO NOT MODIFY! 96 // CHECKSTYLE:OFF Generated code 97 // 98 // To regenerate run: 99 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/voice/VisibleActivityInfo.java 100 // 101 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 102 // Settings > Editor > Code Style > Formatter Control 103 //@formatter:off 104 105 106 @Override 107 @DataClass.Generated.Member toString()108 public String toString() { 109 // You can override field toString logic by defining methods like: 110 // String fieldNameToString() { ... } 111 112 return "VisibleActivityInfo { " + 113 "taskId = " + mTaskId + ", " + 114 "assistToken = " + mAssistToken + 115 " }"; 116 } 117 118 @Override 119 @DataClass.Generated.Member equals(@ullable Object o)120 public boolean equals(@Nullable Object o) { 121 // You can override field equality logic by defining either of the methods like: 122 // boolean fieldNameEquals(VisibleActivityInfo other) { ... } 123 // boolean fieldNameEquals(FieldType otherValue) { ... } 124 125 if (this == o) return true; 126 if (o == null || getClass() != o.getClass()) return false; 127 @SuppressWarnings("unchecked") 128 VisibleActivityInfo that = (VisibleActivityInfo) o; 129 //noinspection PointlessBooleanExpression 130 return true 131 && mTaskId == that.mTaskId 132 && Objects.equals(mAssistToken, that.mAssistToken); 133 } 134 135 @Override 136 @DataClass.Generated.Member hashCode()137 public int hashCode() { 138 // You can override field hashCode logic by defining methods like: 139 // int fieldNameHashCode() { ... } 140 141 int _hash = 1; 142 _hash = 31 * _hash + mTaskId; 143 _hash = 31 * _hash + Objects.hashCode(mAssistToken); 144 return _hash; 145 } 146 147 @Override 148 @DataClass.Generated.Member writeToParcel(@onNull Parcel dest, int flags)149 public void writeToParcel(@NonNull Parcel dest, int flags) { 150 // You can override field parcelling by defining methods like: 151 // void parcelFieldName(Parcel dest, int flags) { ... } 152 153 dest.writeInt(mTaskId); 154 dest.writeStrongBinder(mAssistToken); 155 } 156 157 @Override 158 @DataClass.Generated.Member describeContents()159 public int describeContents() { return 0; } 160 161 /** @hide */ 162 @SuppressWarnings({"unchecked", "RedundantCast"}) 163 @DataClass.Generated.Member VisibleActivityInfo(@onNull Parcel in)164 /* package-private */ VisibleActivityInfo(@NonNull Parcel in) { 165 // You can override field unparcelling by defining methods like: 166 // static FieldType unparcelFieldName(Parcel in) { ... } 167 168 int taskId = in.readInt(); 169 IBinder assistToken = (IBinder) in.readStrongBinder(); 170 171 this.mTaskId = taskId; 172 this.mAssistToken = assistToken; 173 com.android.internal.util.AnnotationValidations.validate( 174 NonNull.class, null, mAssistToken); 175 176 // onConstructed(); // You can define this method to get a callback 177 } 178 179 @DataClass.Generated.Member 180 public static final @NonNull Parcelable.Creator<VisibleActivityInfo> CREATOR 181 = new Parcelable.Creator<VisibleActivityInfo>() { 182 @Override 183 public VisibleActivityInfo[] newArray(int size) { 184 return new VisibleActivityInfo[size]; 185 } 186 187 @Override 188 public VisibleActivityInfo createFromParcel(@NonNull Parcel in) { 189 return new VisibleActivityInfo(in); 190 } 191 }; 192 193 @DataClass.Generated( 194 time = 1632383555284L, 195 codegenVersion = "1.0.23", 196 sourceFile = "frameworks/base/core/java/android/service/voice/VisibleActivityInfo.java", 197 inputSignatures = "public static final int TYPE_ACTIVITY_ADDED\npublic static final int TYPE_ACTIVITY_REMOVED\nprivate final int mTaskId\nprivate final @android.annotation.NonNull android.os.IBinder mAssistToken\npublic @android.annotation.NonNull android.service.voice.VoiceInteractionSession.ActivityId getActivityId()\nclass VisibleActivityInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genEqualsHashCode=true, genHiddenConstDefs=false, genGetters=false, genToString=true)") 198 @Deprecated __metadata()199 private void __metadata() {} 200 201 202 //@formatter:on 203 // End of generated code 204 205 } 206