1 /* 2 * Copyright (C) 2022 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.data.events; 18 19 import android.annotation.NonNull; 20 import android.content.ComponentName; 21 22 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 23 import com.android.ondevicepersonalization.internal.util.DataClass; 24 import com.android.ondevicepersonalization.services.data.DbUtils; 25 26 /** 27 * Query object for the Query table 28 */ 29 @DataClass(genBuilder = true) 30 public class Query { 31 /** The id of the query. */ 32 private long mQueryId = 0; 33 34 /** Time of the query in milliseconds. */ 35 private final long mTimeMillis; 36 37 /** Package name of the app the made the request */ 38 @NonNull 39 private final String mAppPackageName; 40 41 /** Name of the service that handled the request */ 42 @NonNull 43 private final ComponentName mService; 44 45 /** CertDigest of the service that handled the request */ 46 @NonNull 47 private final String mServiceCertDigest; 48 49 /** Blob representing the query. */ 50 @NonNull 51 private final byte[] mQueryData; 52 53 /** The name of the service */ getServiceName()54 public String getServiceName() { 55 return DbUtils.toTableValue(mService); 56 } 57 58 59 60 // Code below generated by codegen v1.0.23. 61 // 62 // DO NOT MODIFY! 63 // CHECKSTYLE:OFF Generated code 64 // 65 // To regenerate run: 66 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Query.java 67 // 68 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 69 // Settings > Editor > Code Style > Formatter Control 70 //@formatter:off 71 72 73 @DataClass.Generated.Member Query( long queryId, long timeMillis, @NonNull String appPackageName, @NonNull ComponentName service, @NonNull String serviceCertDigest, @NonNull byte[] queryData)74 /* package-private */ Query( 75 long queryId, 76 long timeMillis, 77 @NonNull String appPackageName, 78 @NonNull ComponentName service, 79 @NonNull String serviceCertDigest, 80 @NonNull byte[] queryData) { 81 this.mQueryId = queryId; 82 this.mTimeMillis = timeMillis; 83 this.mAppPackageName = appPackageName; 84 AnnotationValidations.validate( 85 NonNull.class, null, mAppPackageName); 86 this.mService = service; 87 AnnotationValidations.validate( 88 NonNull.class, null, mService); 89 this.mServiceCertDigest = serviceCertDigest; 90 AnnotationValidations.validate( 91 NonNull.class, null, mServiceCertDigest); 92 this.mQueryData = queryData; 93 AnnotationValidations.validate( 94 NonNull.class, null, mQueryData); 95 96 // onConstructed(); // You can define this method to get a callback 97 } 98 99 /** 100 * The id of the query. 101 */ 102 @DataClass.Generated.Member getQueryId()103 public long getQueryId() { 104 return mQueryId; 105 } 106 107 /** 108 * Time of the query in milliseconds. 109 */ 110 @DataClass.Generated.Member getTimeMillis()111 public long getTimeMillis() { 112 return mTimeMillis; 113 } 114 115 /** 116 * Package name of the app the made the request 117 */ 118 @DataClass.Generated.Member getAppPackageName()119 public @NonNull String getAppPackageName() { 120 return mAppPackageName; 121 } 122 123 /** 124 * Name of the service that handled the request 125 */ 126 @DataClass.Generated.Member getService()127 public @NonNull ComponentName getService() { 128 return mService; 129 } 130 131 /** 132 * CertDigest of the service that handled the request 133 */ 134 @DataClass.Generated.Member getServiceCertDigest()135 public @NonNull String getServiceCertDigest() { 136 return mServiceCertDigest; 137 } 138 139 /** 140 * Blob representing the query. 141 */ 142 @DataClass.Generated.Member getQueryData()143 public @NonNull byte[] getQueryData() { 144 return mQueryData; 145 } 146 147 /** 148 * A builder for {@link Query} 149 */ 150 @SuppressWarnings("WeakerAccess") 151 @DataClass.Generated.Member 152 public static class Builder { 153 154 private long mQueryId; 155 private long mTimeMillis; 156 private @NonNull String mAppPackageName; 157 private @NonNull ComponentName mService; 158 private @NonNull String mServiceCertDigest; 159 private @NonNull byte[] mQueryData; 160 161 private long mBuilderFieldsSet = 0L; 162 163 /** 164 * Creates a new Builder. 165 * 166 * @param timeMillis 167 * Time of the query in milliseconds. 168 * @param appPackageName 169 * Package name of the app the made the request 170 * @param service 171 * Name of the service that handled the request 172 * @param serviceCertDigest 173 * CertDigest of the service that handled the request 174 * @param queryData 175 * Blob representing the query. 176 */ Builder( long timeMillis, @NonNull String appPackageName, @NonNull ComponentName service, @NonNull String serviceCertDigest, @NonNull byte[] queryData)177 public Builder( 178 long timeMillis, 179 @NonNull String appPackageName, 180 @NonNull ComponentName service, 181 @NonNull String serviceCertDigest, 182 @NonNull byte[] queryData) { 183 mTimeMillis = timeMillis; 184 mAppPackageName = appPackageName; 185 AnnotationValidations.validate( 186 NonNull.class, null, mAppPackageName); 187 mService = service; 188 AnnotationValidations.validate( 189 NonNull.class, null, mService); 190 mServiceCertDigest = serviceCertDigest; 191 AnnotationValidations.validate( 192 NonNull.class, null, mServiceCertDigest); 193 mQueryData = queryData; 194 AnnotationValidations.validate( 195 NonNull.class, null, mQueryData); 196 } 197 198 /** 199 * The id of the query. 200 */ 201 @DataClass.Generated.Member setQueryId(long value)202 public @NonNull Builder setQueryId(long value) { 203 checkNotUsed(); 204 mBuilderFieldsSet |= 0x1; 205 mQueryId = value; 206 return this; 207 } 208 209 /** 210 * Time of the query in milliseconds. 211 */ 212 @DataClass.Generated.Member setTimeMillis(long value)213 public @NonNull Builder setTimeMillis(long value) { 214 checkNotUsed(); 215 mBuilderFieldsSet |= 0x2; 216 mTimeMillis = value; 217 return this; 218 } 219 220 /** 221 * Package name of the app the made the request 222 */ 223 @DataClass.Generated.Member setAppPackageName(@onNull String value)224 public @NonNull Builder setAppPackageName(@NonNull String value) { 225 checkNotUsed(); 226 mBuilderFieldsSet |= 0x4; 227 mAppPackageName = value; 228 return this; 229 } 230 231 /** 232 * Name of the service that handled the request 233 */ 234 @DataClass.Generated.Member setService(@onNull ComponentName value)235 public @NonNull Builder setService(@NonNull ComponentName value) { 236 checkNotUsed(); 237 mBuilderFieldsSet |= 0x8; 238 mService = value; 239 return this; 240 } 241 242 /** 243 * CertDigest of the service that handled the request 244 */ 245 @DataClass.Generated.Member setServiceCertDigest(@onNull String value)246 public @NonNull Builder setServiceCertDigest(@NonNull String value) { 247 checkNotUsed(); 248 mBuilderFieldsSet |= 0x10; 249 mServiceCertDigest = value; 250 return this; 251 } 252 253 /** 254 * Blob representing the query. 255 */ 256 @DataClass.Generated.Member setQueryData(@onNull byte... value)257 public @NonNull Builder setQueryData(@NonNull byte... value) { 258 checkNotUsed(); 259 mBuilderFieldsSet |= 0x20; 260 mQueryData = value; 261 return this; 262 } 263 264 /** Builds the instance. This builder should not be touched after calling this! */ build()265 public @NonNull Query build() { 266 checkNotUsed(); 267 mBuilderFieldsSet |= 0x40; // Mark builder used 268 269 if ((mBuilderFieldsSet & 0x1) == 0) { 270 mQueryId = 0; 271 } 272 Query o = new Query( 273 mQueryId, 274 mTimeMillis, 275 mAppPackageName, 276 mService, 277 mServiceCertDigest, 278 mQueryData); 279 return o; 280 } 281 checkNotUsed()282 private void checkNotUsed() { 283 if ((mBuilderFieldsSet & 0x40) != 0) { 284 throw new IllegalStateException( 285 "This Builder should not be reused. Use a new Builder instance instead"); 286 } 287 } 288 } 289 290 @DataClass.Generated( 291 time = 1712096323408L, 292 codegenVersion = "1.0.23", 293 sourceFile = "packages/modules/OnDevicePersonalization/src/com/android/ondevicepersonalization/services/data/events/Query.java", 294 inputSignatures = "private long mQueryId\nprivate final long mTimeMillis\nprivate final @android.annotation.NonNull java.lang.String mAppPackageName\nprivate final @android.annotation.NonNull android.content.ComponentName mService\nprivate final @android.annotation.NonNull java.lang.String mServiceCertDigest\nprivate final @android.annotation.NonNull byte[] mQueryData\npublic java.lang.String getServiceName()\nclass Query extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true)") 295 @Deprecated __metadata()296 private void __metadata() {} 297 298 299 //@formatter:on 300 // End of generated code 301 302 } 303