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.car.watchdog; 18 19 import static com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport.BOILERPLATE_CODE; 20 21 import android.annotation.NonNull; 22 import android.annotation.SystemApi; 23 import android.annotation.UserIdInt; 24 import android.os.Parcelable; 25 26 import com.android.car.internal.ExcludeFromCodeCoverageGeneratedReport; 27 import com.android.car.internal.util.AnnotationValidations; 28 import com.android.car.internal.util.DataClass; 29 30 /** 31 * Killable state for a package. 32 * 33 * @hide 34 */ 35 @SystemApi 36 @DataClass(genToString = true, genHiddenConstructor = true, genHiddenConstDefs = true) 37 public final class PackageKillableState implements Parcelable { 38 /** 39 * A package is killable. 40 */ 41 @KillableState 42 public static final int KILLABLE_STATE_YES = 1; 43 44 /** 45 * A package is not killable. 46 */ 47 @KillableState 48 public static final int KILLABLE_STATE_NO = 2; 49 50 /** 51 * A package is never killable i.e. its setting cannot be updated. 52 */ 53 @KillableState 54 public static final int KILLABLE_STATE_NEVER = 3; 55 56 /** 57 * Name of the package. 58 */ 59 private @NonNull String mPackageName; 60 61 /** 62 * Id of the user. 63 */ 64 private @UserIdInt int mUserId; 65 66 /** 67 * Killable state of the user's package. 68 */ 69 private @KillableState int mKillableState; 70 71 72 73 // Code below generated by codegen v1.0.23. 74 // 75 // DO NOT MODIFY! 76 // CHECKSTYLE:OFF Generated code 77 // 78 // To regenerate run: 79 // $ codegen $ANDROID_BUILD_TOP/packages/services/Car/car-lib/src/android/car/watchdog/PackageKillableState.java 80 // 81 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 82 // Settings > Editor > Code Style > Formatter Control 83 //@formatter:off 84 85 86 /** @hide */ 87 @android.annotation.IntDef(prefix = "KILLABLE_STATE_", value = { 88 KILLABLE_STATE_YES, 89 KILLABLE_STATE_NO, 90 KILLABLE_STATE_NEVER 91 }) 92 @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) 93 @DataClass.Generated.Member 94 public @interface KillableState {} 95 96 /** @hide */ 97 @DataClass.Generated.Member killableStateToString(@illableState int value)98 public static String killableStateToString(@KillableState int value) { 99 switch (value) { 100 case KILLABLE_STATE_YES: 101 return "KILLABLE_STATE_YES"; 102 case KILLABLE_STATE_NO: 103 return "KILLABLE_STATE_NO"; 104 case KILLABLE_STATE_NEVER: 105 return "KILLABLE_STATE_NEVER"; 106 default: return Integer.toHexString(value); 107 } 108 } 109 110 /** 111 * Creates a new PackageKillableState. 112 * 113 * @param packageName 114 * Name of the package. 115 * @param userId 116 * Id of the user. 117 * @param killableState 118 * Killable state of the user's package. 119 * @hide 120 */ 121 @DataClass.Generated.Member PackageKillableState( @onNull String packageName, @UserIdInt int userId, @KillableState int killableState)122 public PackageKillableState( 123 @NonNull String packageName, 124 @UserIdInt int userId, 125 @KillableState int killableState) { 126 this.mPackageName = packageName; 127 AnnotationValidations.validate( 128 NonNull.class, null, mPackageName); 129 this.mUserId = userId; 130 AnnotationValidations.validate( 131 UserIdInt.class, null, mUserId); 132 this.mKillableState = killableState; 133 134 if (!(mKillableState == KILLABLE_STATE_YES) 135 && !(mKillableState == KILLABLE_STATE_NO) 136 && !(mKillableState == KILLABLE_STATE_NEVER)) { 137 throw new java.lang.IllegalArgumentException( 138 "killableState was " + mKillableState + " but must be one of: " 139 + "KILLABLE_STATE_YES(" + KILLABLE_STATE_YES + "), " 140 + "KILLABLE_STATE_NO(" + KILLABLE_STATE_NO + "), " 141 + "KILLABLE_STATE_NEVER(" + KILLABLE_STATE_NEVER + ")"); 142 } 143 144 145 // onConstructed(); // You can define this method to get a callback 146 } 147 148 /** 149 * Name of the package. 150 */ 151 @DataClass.Generated.Member getPackageName()152 public @NonNull String getPackageName() { 153 return mPackageName; 154 } 155 156 /** 157 * Id of the user. 158 */ 159 @DataClass.Generated.Member getUserId()160 public @UserIdInt int getUserId() { 161 return mUserId; 162 } 163 164 /** 165 * Killable state of the user's package. 166 */ 167 @DataClass.Generated.Member getKillableState()168 public @KillableState int getKillableState() { 169 return mKillableState; 170 } 171 172 @Override 173 @DataClass.Generated.Member toString()174 public String toString() { 175 // You can override field toString logic by defining methods like: 176 // String fieldNameToString() { ... } 177 178 return "PackageKillableState { " + 179 "packageName = " + mPackageName + ", " + 180 "userId = " + mUserId + ", " + 181 "killableState = " + killableStateToString(mKillableState) + 182 " }"; 183 } 184 185 @Override 186 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)187 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 188 // You can override field parcelling by defining methods like: 189 // void parcelFieldName(Parcel dest, int flags) { ... } 190 191 dest.writeString(mPackageName); 192 dest.writeInt(mUserId); 193 dest.writeInt(mKillableState); 194 } 195 196 @Override 197 @DataClass.Generated.Member 198 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) describeContents()199 public int describeContents() { return 0; } 200 201 /** @hide */ 202 @SuppressWarnings({"unchecked", "RedundantCast"}) 203 @DataClass.Generated.Member PackageKillableState(@onNull android.os.Parcel in)204 /* package-private */ PackageKillableState(@NonNull android.os.Parcel in) { 205 // You can override field unparcelling by defining methods like: 206 // static FieldType unparcelFieldName(Parcel in) { ... } 207 208 String packageName = in.readString(); 209 int userId = in.readInt(); 210 int killableState = in.readInt(); 211 212 this.mPackageName = packageName; 213 AnnotationValidations.validate( 214 NonNull.class, null, mPackageName); 215 this.mUserId = userId; 216 AnnotationValidations.validate( 217 UserIdInt.class, null, mUserId); 218 this.mKillableState = killableState; 219 220 if (!(mKillableState == KILLABLE_STATE_YES) 221 && !(mKillableState == KILLABLE_STATE_NO) 222 && !(mKillableState == KILLABLE_STATE_NEVER)) { 223 throw new java.lang.IllegalArgumentException( 224 "killableState was " + mKillableState + " but must be one of: " 225 + "KILLABLE_STATE_YES(" + KILLABLE_STATE_YES + "), " 226 + "KILLABLE_STATE_NO(" + KILLABLE_STATE_NO + "), " 227 + "KILLABLE_STATE_NEVER(" + KILLABLE_STATE_NEVER + ")"); 228 } 229 230 231 // onConstructed(); // You can define this method to get a callback 232 } 233 234 @DataClass.Generated.Member 235 public static final @NonNull Parcelable.Creator<PackageKillableState> CREATOR 236 = new Parcelable.Creator<PackageKillableState>() { 237 @Override 238 public PackageKillableState[] newArray(int size) { 239 return new PackageKillableState[size]; 240 } 241 242 @Override 243 public PackageKillableState createFromParcel(@NonNull android.os.Parcel in) { 244 return new PackageKillableState(in); 245 } 246 }; 247 248 @DataClass.Generated( 249 time = 1721755741237L, 250 codegenVersion = "1.0.23", 251 sourceFile = "packages/services/Car/car-lib/src/android/car/watchdog/PackageKillableState.java", 252 inputSignatures = "public static final @android.car.watchdog.PackageKillableState.KillableState int KILLABLE_STATE_YES\npublic static final @android.car.watchdog.PackageKillableState.KillableState int KILLABLE_STATE_NO\npublic static final @android.car.watchdog.PackageKillableState.KillableState int KILLABLE_STATE_NEVER\nprivate @android.annotation.NonNull java.lang.String mPackageName\nprivate @android.annotation.UserIdInt int mUserId\nprivate @android.car.watchdog.PackageKillableState.KillableState int mKillableState\nclass PackageKillableState extends java.lang.Object implements [android.os.Parcelable]\n@com.android.car.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)") 253 @Deprecated 254 @ExcludeFromCodeCoverageGeneratedReport(reason = BOILERPLATE_CODE) __metadata()255 private void __metadata() {} 256 257 258 //@formatter:on 259 // End of generated code 260 261 } 262