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