1 /* 2 * Copyright (C) 2023 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 com.android.ondevicepersonalization.services.statsd; 18 19 import static com.android.ondevicepersonalization.OnDevicePersonalizationStatsLog.ON_DEVICE_PERSONALIZATION_API_CALLED__API_CLASS__UNKNOWN; 20 21 import android.annotation.Nullable; 22 23 import com.android.ondevicepersonalization.internal.util.DataClass; 24 25 /** 26 * Class holds OnDevicePersonalizationApiCalled defined at 27 * frameworks/proto_logging/stats/atoms/ondevicepersonalization/ondevicepersonalization_extension_atoms.proto 28 */ 29 @DataClass(genBuilder = true, genEqualsHashCode = true) 30 public class ApiCallStats { 31 private int mApiClass = ON_DEVICE_PERSONALIZATION_API_CALLED__API_CLASS__UNKNOWN; 32 private final int mApiName; 33 private int mLatencyMillis = 0; 34 private int mResponseCode = 0; 35 private int mOverheadLatencyMillis = 0; 36 37 private int mAppUid = 0; 38 @Nullable private String mSdkPackageName = ""; 39 private int mRpcCallLatencyMillis = 0; 40 private int mRpcReturnLatencyMillis = 0; 41 42 43 44 // Code below generated by codegen v1.0.23. 45 // 46 // DO NOT MODIFY! 47 // CHECKSTYLE:OFF Generated code 48 // 49 // To regenerate run: 50 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/statsd/ApiCallStats.java 51 // 52 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 53 // Settings > Editor > Code Style > Formatter Control 54 //@formatter:off 55 56 57 @DataClass.Generated.Member ApiCallStats( int apiClass, int apiName, int latencyMillis, int responseCode, int overheadLatencyMillis, int appUid, @Nullable String sdkPackageName, int rpcCallLatencyMillis, int rpcReturnLatencyMillis)58 /* package-private */ ApiCallStats( 59 int apiClass, 60 int apiName, 61 int latencyMillis, 62 int responseCode, 63 int overheadLatencyMillis, 64 int appUid, 65 @Nullable String sdkPackageName, 66 int rpcCallLatencyMillis, 67 int rpcReturnLatencyMillis) { 68 this.mApiClass = apiClass; 69 this.mApiName = apiName; 70 this.mLatencyMillis = latencyMillis; 71 this.mResponseCode = responseCode; 72 this.mOverheadLatencyMillis = overheadLatencyMillis; 73 this.mAppUid = appUid; 74 this.mSdkPackageName = sdkPackageName; 75 this.mRpcCallLatencyMillis = rpcCallLatencyMillis; 76 this.mRpcReturnLatencyMillis = rpcReturnLatencyMillis; 77 78 // onConstructed(); // You can define this method to get a callback 79 } 80 81 @DataClass.Generated.Member getApiClass()82 public int getApiClass() { 83 return mApiClass; 84 } 85 86 @DataClass.Generated.Member getApiName()87 public int getApiName() { 88 return mApiName; 89 } 90 91 @DataClass.Generated.Member getLatencyMillis()92 public int getLatencyMillis() { 93 return mLatencyMillis; 94 } 95 96 @DataClass.Generated.Member getResponseCode()97 public int getResponseCode() { 98 return mResponseCode; 99 } 100 101 @DataClass.Generated.Member getOverheadLatencyMillis()102 public int getOverheadLatencyMillis() { 103 return mOverheadLatencyMillis; 104 } 105 106 @DataClass.Generated.Member getAppUid()107 public int getAppUid() { 108 return mAppUid; 109 } 110 111 @DataClass.Generated.Member getSdkPackageName()112 public @Nullable String getSdkPackageName() { 113 return mSdkPackageName; 114 } 115 116 @DataClass.Generated.Member getRpcCallLatencyMillis()117 public int getRpcCallLatencyMillis() { 118 return mRpcCallLatencyMillis; 119 } 120 121 @DataClass.Generated.Member getRpcReturnLatencyMillis()122 public int getRpcReturnLatencyMillis() { 123 return mRpcReturnLatencyMillis; 124 } 125 126 @Override 127 @DataClass.Generated.Member equals(@ullable Object o)128 public boolean equals(@Nullable Object o) { 129 // You can override field equality logic by defining either of the methods like: 130 // boolean fieldNameEquals(ApiCallStats other) { ... } 131 // boolean fieldNameEquals(FieldType otherValue) { ... } 132 133 if (this == o) return true; 134 if (o == null || getClass() != o.getClass()) return false; 135 @SuppressWarnings("unchecked") 136 ApiCallStats that = (ApiCallStats) o; 137 //noinspection PointlessBooleanExpression 138 return true 139 && mApiClass == that.mApiClass 140 && mApiName == that.mApiName 141 && mLatencyMillis == that.mLatencyMillis 142 && mResponseCode == that.mResponseCode 143 && mOverheadLatencyMillis == that.mOverheadLatencyMillis 144 && mAppUid == that.mAppUid 145 && java.util.Objects.equals(mSdkPackageName, that.mSdkPackageName) 146 && mRpcCallLatencyMillis == that.mRpcCallLatencyMillis 147 && mRpcReturnLatencyMillis == that.mRpcReturnLatencyMillis; 148 } 149 150 @Override 151 @DataClass.Generated.Member hashCode()152 public int hashCode() { 153 // You can override field hashCode logic by defining methods like: 154 // int fieldNameHashCode() { ... } 155 156 int _hash = 1; 157 _hash = 31 * _hash + mApiClass; 158 _hash = 31 * _hash + mApiName; 159 _hash = 31 * _hash + mLatencyMillis; 160 _hash = 31 * _hash + mResponseCode; 161 _hash = 31 * _hash + mOverheadLatencyMillis; 162 _hash = 31 * _hash + mAppUid; 163 _hash = 31 * _hash + java.util.Objects.hashCode(mSdkPackageName); 164 _hash = 31 * _hash + mRpcCallLatencyMillis; 165 _hash = 31 * _hash + mRpcReturnLatencyMillis; 166 return _hash; 167 } 168 169 /** 170 * A builder for {@link ApiCallStats} 171 */ 172 @SuppressWarnings("WeakerAccess") 173 @DataClass.Generated.Member 174 public static class Builder { 175 176 private int mApiClass; 177 private int mApiName; 178 private int mLatencyMillis; 179 private int mResponseCode; 180 private int mOverheadLatencyMillis; 181 private int mAppUid; 182 private @Nullable String mSdkPackageName; 183 private int mRpcCallLatencyMillis; 184 private int mRpcReturnLatencyMillis; 185 186 private long mBuilderFieldsSet = 0L; 187 Builder( int apiName)188 public Builder( 189 int apiName) { 190 mApiName = apiName; 191 } 192 193 @DataClass.Generated.Member setApiClass(int value)194 public @android.annotation.NonNull Builder setApiClass(int value) { 195 checkNotUsed(); 196 mBuilderFieldsSet |= 0x1; 197 mApiClass = value; 198 return this; 199 } 200 201 @DataClass.Generated.Member setApiName(int value)202 public @android.annotation.NonNull Builder setApiName(int value) { 203 checkNotUsed(); 204 mBuilderFieldsSet |= 0x2; 205 mApiName = value; 206 return this; 207 } 208 209 @DataClass.Generated.Member setLatencyMillis(int value)210 public @android.annotation.NonNull Builder setLatencyMillis(int value) { 211 checkNotUsed(); 212 mBuilderFieldsSet |= 0x4; 213 mLatencyMillis = value; 214 return this; 215 } 216 217 @DataClass.Generated.Member setResponseCode(int value)218 public @android.annotation.NonNull Builder setResponseCode(int value) { 219 checkNotUsed(); 220 mBuilderFieldsSet |= 0x8; 221 mResponseCode = value; 222 return this; 223 } 224 225 @DataClass.Generated.Member setOverheadLatencyMillis(int value)226 public @android.annotation.NonNull Builder setOverheadLatencyMillis(int value) { 227 checkNotUsed(); 228 mBuilderFieldsSet |= 0x10; 229 mOverheadLatencyMillis = value; 230 return this; 231 } 232 233 @DataClass.Generated.Member setAppUid(int value)234 public @android.annotation.NonNull Builder setAppUid(int value) { 235 checkNotUsed(); 236 mBuilderFieldsSet |= 0x20; 237 mAppUid = value; 238 return this; 239 } 240 241 @DataClass.Generated.Member setSdkPackageName(@ndroid.annotation.NonNull String value)242 public @android.annotation.NonNull Builder setSdkPackageName(@android.annotation.NonNull String value) { 243 checkNotUsed(); 244 mBuilderFieldsSet |= 0x40; 245 mSdkPackageName = value; 246 return this; 247 } 248 249 @DataClass.Generated.Member setRpcCallLatencyMillis(int value)250 public @android.annotation.NonNull Builder setRpcCallLatencyMillis(int value) { 251 checkNotUsed(); 252 mBuilderFieldsSet |= 0x80; 253 mRpcCallLatencyMillis = value; 254 return this; 255 } 256 257 @DataClass.Generated.Member setRpcReturnLatencyMillis(int value)258 public @android.annotation.NonNull Builder setRpcReturnLatencyMillis(int value) { 259 checkNotUsed(); 260 mBuilderFieldsSet |= 0x100; 261 mRpcReturnLatencyMillis = value; 262 return this; 263 } 264 265 /** Builds the instance. This builder should not be touched after calling this! */ build()266 public @android.annotation.NonNull ApiCallStats build() { 267 checkNotUsed(); 268 mBuilderFieldsSet |= 0x200; // Mark builder used 269 270 if ((mBuilderFieldsSet & 0x1) == 0) { 271 mApiClass = ON_DEVICE_PERSONALIZATION_API_CALLED__API_CLASS__UNKNOWN; 272 } 273 if ((mBuilderFieldsSet & 0x4) == 0) { 274 mLatencyMillis = 0; 275 } 276 if ((mBuilderFieldsSet & 0x8) == 0) { 277 mResponseCode = 0; 278 } 279 if ((mBuilderFieldsSet & 0x10) == 0) { 280 mOverheadLatencyMillis = 0; 281 } 282 if ((mBuilderFieldsSet & 0x20) == 0) { 283 mAppUid = 0; 284 } 285 if ((mBuilderFieldsSet & 0x40) == 0) { 286 mSdkPackageName = ""; 287 } 288 if ((mBuilderFieldsSet & 0x80) == 0) { 289 mRpcCallLatencyMillis = 0; 290 } 291 if ((mBuilderFieldsSet & 0x100) == 0) { 292 mRpcReturnLatencyMillis = 0; 293 } 294 ApiCallStats o = new ApiCallStats( 295 mApiClass, 296 mApiName, 297 mLatencyMillis, 298 mResponseCode, 299 mOverheadLatencyMillis, 300 mAppUid, 301 mSdkPackageName, 302 mRpcCallLatencyMillis, 303 mRpcReturnLatencyMillis); 304 return o; 305 } 306 checkNotUsed()307 private void checkNotUsed() { 308 if ((mBuilderFieldsSet & 0x200) != 0) { 309 throw new IllegalStateException( 310 "This Builder should not be reused. Use a new Builder instance instead"); 311 } 312 } 313 } 314 315 @DataClass.Generated( 316 time = 1716244029076L, 317 codegenVersion = "1.0.23", 318 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/statsd/ApiCallStats.java", 319 inputSignatures = "private int mApiClass\nprivate final int mApiName\nprivate int mLatencyMillis\nprivate int mResponseCode\nprivate int mOverheadLatencyMillis\nprivate int mAppUid\nprivate @android.annotation.Nullable java.lang.String mSdkPackageName\nprivate int mRpcCallLatencyMillis\nprivate int mRpcReturnLatencyMillis\nclass ApiCallStats extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 320 @Deprecated __metadata()321 private void __metadata() {} 322 323 324 //@formatter:on 325 // End of generated code 326 327 } 328