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 android.permission; 18 19 import android.annotation.CurrentTimeMillisLong; 20 import android.annotation.FlaggedApi; 21 import android.annotation.NonNull; 22 import android.annotation.Nullable; 23 import android.annotation.SystemApi; 24 import android.os.Parcelable; 25 26 import com.android.internal.util.DataClass; 27 28 /** 29 * Represents the usage of a permission group by an app. Supports package name, user, permission 30 * group, persistent device Id, whether or not the access is running or recent, whether the access 31 * is tied to a phone call, and an optional special attribution tag, label and proxy label. 32 * 33 * @hide 34 */ 35 @SystemApi 36 @DataClass( 37 genHiddenConstructor = true, 38 genEqualsHashCode = true, 39 genToString = true 40 ) 41 public final class PermissionGroupUsage implements Parcelable { 42 43 private final @NonNull String mPackageName; 44 private final int mUid; 45 private final long mLastAccessTimeMillis; 46 private final @NonNull String mPermissionGroupName; 47 private final boolean mActive; 48 private final boolean mPhoneCall; 49 private final @Nullable CharSequence mAttributionTag; 50 private final @Nullable CharSequence mAttributionLabel; 51 private final @Nullable CharSequence mProxyLabel; 52 private final @NonNull String mPersistentDeviceId; 53 54 55 56 // Code below generated by codegen v1.0.23. 57 // 58 // DO NOT MODIFY! 59 // CHECKSTYLE:OFF Generated code 60 // 61 // To regenerate run: 62 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/permission/PermissionGroupUsage.java 63 // 64 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 65 // Settings > Editor > Code Style > Formatter Control 66 //@formatter:off 67 68 69 /** 70 * Creates a new PermissionGroupUsage. 71 * 72 * @hide 73 */ 74 @DataClass.Generated.Member PermissionGroupUsage( @onNull String packageName, int uid, long lastAccessTimeMillis, @NonNull String permissionGroupName, boolean active, boolean phoneCall, @Nullable CharSequence attributionTag, @Nullable CharSequence attributionLabel, @Nullable CharSequence proxyLabel, @NonNull String persistentDeviceId)75 public PermissionGroupUsage( 76 @NonNull String packageName, 77 int uid, 78 long lastAccessTimeMillis, 79 @NonNull String permissionGroupName, 80 boolean active, 81 boolean phoneCall, 82 @Nullable CharSequence attributionTag, 83 @Nullable CharSequence attributionLabel, 84 @Nullable CharSequence proxyLabel, 85 @NonNull String persistentDeviceId) { 86 this.mPackageName = packageName; 87 com.android.internal.util.AnnotationValidations.validate( 88 NonNull.class, null, mPackageName); 89 this.mUid = uid; 90 this.mLastAccessTimeMillis = lastAccessTimeMillis; 91 this.mPermissionGroupName = permissionGroupName; 92 com.android.internal.util.AnnotationValidations.validate( 93 NonNull.class, null, mPermissionGroupName); 94 this.mActive = active; 95 this.mPhoneCall = phoneCall; 96 this.mAttributionTag = attributionTag; 97 this.mAttributionLabel = attributionLabel; 98 this.mProxyLabel = proxyLabel; 99 this.mPersistentDeviceId = persistentDeviceId; 100 com.android.internal.util.AnnotationValidations.validate( 101 NonNull.class, null, mPersistentDeviceId); 102 103 // onConstructed(); // You can define this method to get a callback 104 } 105 106 /** 107 * @return Package name for the usage 108 */ 109 @DataClass.Generated.Member getPackageName()110 public @NonNull String getPackageName() { 111 return mPackageName; 112 } 113 114 /** 115 * @return UID for the usage 116 */ 117 @DataClass.Generated.Member getUid()118 public int getUid() { 119 return mUid; 120 } 121 122 /** 123 * @return Last access time in millis for the usage 124 */ 125 @CurrentTimeMillisLong 126 @DataClass.Generated.Member getLastAccessTimeMillis()127 public long getLastAccessTimeMillis() { 128 return mLastAccessTimeMillis; 129 } 130 131 /** 132 * @return Permission group name for the usage 133 */ 134 @DataClass.Generated.Member getPermissionGroupName()135 public @NonNull String getPermissionGroupName() { 136 return mPermissionGroupName; 137 } 138 139 /** 140 * @return If usage is active 141 */ 142 @DataClass.Generated.Member isActive()143 public boolean isActive() { 144 return mActive; 145 } 146 147 /** 148 * @return If usage is a phone call 149 */ 150 @DataClass.Generated.Member isPhoneCall()151 public boolean isPhoneCall() { 152 return mPhoneCall; 153 } 154 155 /** 156 * @return Attribution tag associated with the usage 157 */ 158 @DataClass.Generated.Member getAttributionTag()159 public @Nullable CharSequence getAttributionTag() { 160 return mAttributionTag; 161 } 162 163 /** 164 * @return Attribution label associated with the usage 165 */ 166 @DataClass.Generated.Member getAttributionLabel()167 public @Nullable CharSequence getAttributionLabel() { 168 return mAttributionLabel; 169 } 170 171 /** 172 * @return Proxy label associated with the usage 173 */ 174 @DataClass.Generated.Member getProxyLabel()175 public @Nullable CharSequence getProxyLabel() { 176 return mProxyLabel; 177 } 178 179 @DataClass.Generated.Member 180 @FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED) getPersistentDeviceId()181 public @NonNull String getPersistentDeviceId() { 182 return mPersistentDeviceId; 183 } 184 185 @Override 186 @DataClass.Generated.Member toString()187 public String toString() { 188 // You can override field toString logic by defining methods like: 189 // String fieldNameToString() { ... } 190 191 return "PermissionGroupUsage { " + 192 "packageName = " + mPackageName + ", " + 193 "uid = " + mUid + ", " + 194 "lastAccessTimeMillis = " + mLastAccessTimeMillis + ", " + 195 "permissionGroupName = " + mPermissionGroupName + ", " + 196 "active = " + mActive + ", " + 197 "phoneCall = " + mPhoneCall + ", " + 198 "attributionTag = " + mAttributionTag + ", " + 199 "attributionLabel = " + mAttributionLabel + ", " + 200 "proxyLabel = " + mProxyLabel + ", " + 201 "persistentDeviceId = " + mPersistentDeviceId + 202 " }"; 203 } 204 205 @Override 206 @DataClass.Generated.Member equals(@ullable Object o)207 public boolean equals(@Nullable Object o) { 208 // You can override field equality logic by defining either of the methods like: 209 // boolean fieldNameEquals(PermissionGroupUsage other) { ... } 210 // boolean fieldNameEquals(FieldType otherValue) { ... } 211 212 if (this == o) return true; 213 if (o == null || getClass() != o.getClass()) return false; 214 @SuppressWarnings("unchecked") 215 PermissionGroupUsage that = (PermissionGroupUsage) o; 216 //noinspection PointlessBooleanExpression 217 return true 218 && java.util.Objects.equals(mPackageName, that.mPackageName) 219 && mUid == that.mUid 220 && mLastAccessTimeMillis == that.mLastAccessTimeMillis 221 && java.util.Objects.equals(mPermissionGroupName, that.mPermissionGroupName) 222 && mActive == that.mActive 223 && mPhoneCall == that.mPhoneCall 224 && java.util.Objects.equals(mAttributionTag, that.mAttributionTag) 225 && java.util.Objects.equals(mAttributionLabel, that.mAttributionLabel) 226 && java.util.Objects.equals(mProxyLabel, that.mProxyLabel) 227 && java.util.Objects.equals(mPersistentDeviceId, that.mPersistentDeviceId); 228 } 229 230 @Override 231 @DataClass.Generated.Member hashCode()232 public int hashCode() { 233 // You can override field hashCode logic by defining methods like: 234 // int fieldNameHashCode() { ... } 235 236 int _hash = 1; 237 _hash = 31 * _hash + java.util.Objects.hashCode(mPackageName); 238 _hash = 31 * _hash + mUid; 239 _hash = 31 * _hash + Long.hashCode(mLastAccessTimeMillis); 240 _hash = 31 * _hash + java.util.Objects.hashCode(mPermissionGroupName); 241 _hash = 31 * _hash + Boolean.hashCode(mActive); 242 _hash = 31 * _hash + Boolean.hashCode(mPhoneCall); 243 _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag); 244 _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionLabel); 245 _hash = 31 * _hash + java.util.Objects.hashCode(mProxyLabel); 246 _hash = 31 * _hash + java.util.Objects.hashCode(mPersistentDeviceId); 247 return _hash; 248 } 249 250 @Override 251 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)252 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 253 // You can override field parcelling by defining methods like: 254 // void parcelFieldName(Parcel dest, int flags) { ... } 255 256 int flg = 0; 257 if (mActive) flg |= 0x10; 258 if (mPhoneCall) flg |= 0x20; 259 if (mAttributionTag != null) flg |= 0x40; 260 if (mAttributionLabel != null) flg |= 0x80; 261 if (mProxyLabel != null) flg |= 0x100; 262 dest.writeInt(flg); 263 dest.writeString(mPackageName); 264 dest.writeInt(mUid); 265 dest.writeLong(mLastAccessTimeMillis); 266 dest.writeString(mPermissionGroupName); 267 if (mAttributionTag != null) dest.writeCharSequence(mAttributionTag); 268 if (mAttributionLabel != null) dest.writeCharSequence(mAttributionLabel); 269 if (mProxyLabel != null) dest.writeCharSequence(mProxyLabel); 270 dest.writeString(mPersistentDeviceId); 271 } 272 273 @Override 274 @DataClass.Generated.Member describeContents()275 public int describeContents() { return 0; } 276 277 /** @hide */ 278 @SuppressWarnings({"unchecked", "RedundantCast"}) 279 @DataClass.Generated.Member PermissionGroupUsage(@onNull android.os.Parcel in)280 /* package-private */ PermissionGroupUsage(@NonNull android.os.Parcel in) { 281 // You can override field unparcelling by defining methods like: 282 // static FieldType unparcelFieldName(Parcel in) { ... } 283 284 int flg = in.readInt(); 285 boolean active = (flg & 0x10) != 0; 286 boolean phoneCall = (flg & 0x20) != 0; 287 String packageName = in.readString(); 288 int uid = in.readInt(); 289 long lastAccessTimeMillis = in.readLong(); 290 String permissionGroupName = in.readString(); 291 CharSequence attributionTag = (flg & 0x40) == 0 ? null : (CharSequence) in.readCharSequence(); 292 CharSequence attributionLabel = (flg & 0x80) == 0 ? null : (CharSequence) in.readCharSequence(); 293 CharSequence proxyLabel = (flg & 0x100) == 0 ? null : (CharSequence) in.readCharSequence(); 294 String persistentDeviceId = in.readString(); 295 296 this.mPackageName = packageName; 297 com.android.internal.util.AnnotationValidations.validate( 298 NonNull.class, null, mPackageName); 299 this.mUid = uid; 300 this.mLastAccessTimeMillis = lastAccessTimeMillis; 301 this.mPermissionGroupName = permissionGroupName; 302 com.android.internal.util.AnnotationValidations.validate( 303 NonNull.class, null, mPermissionGroupName); 304 this.mActive = active; 305 this.mPhoneCall = phoneCall; 306 this.mAttributionTag = attributionTag; 307 this.mAttributionLabel = attributionLabel; 308 this.mProxyLabel = proxyLabel; 309 this.mPersistentDeviceId = persistentDeviceId; 310 com.android.internal.util.AnnotationValidations.validate( 311 NonNull.class, null, mPersistentDeviceId); 312 313 // onConstructed(); // You can define this method to get a callback 314 } 315 316 @DataClass.Generated.Member 317 public static final @NonNull Parcelable.Creator<PermissionGroupUsage> CREATOR 318 = new Parcelable.Creator<PermissionGroupUsage>() { 319 @Override 320 public PermissionGroupUsage[] newArray(int size) { 321 return new PermissionGroupUsage[size]; 322 } 323 324 @Override 325 public PermissionGroupUsage createFromParcel(@NonNull android.os.Parcel in) { 326 return new PermissionGroupUsage(in); 327 } 328 }; 329 330 @DataClass.Generated( 331 time = 1706285211875L, 332 codegenVersion = "1.0.23", 333 sourceFile = "frameworks/base/core/java/android/permission/PermissionGroupUsage.java", 334 inputSignatures = "private final @android.annotation.NonNull java.lang.String mPackageName\nprivate final int mUid\nprivate final long mLastAccessTimeMillis\nprivate final @android.annotation.NonNull java.lang.String mPermissionGroupName\nprivate final boolean mActive\nprivate final boolean mPhoneCall\nprivate final @android.annotation.Nullable java.lang.CharSequence mAttributionTag\nprivate final @android.annotation.Nullable java.lang.CharSequence mAttributionLabel\nprivate final @android.annotation.Nullable java.lang.CharSequence mProxyLabel\nprivate final @android.annotation.NonNull java.lang.String mPersistentDeviceId\nclass PermissionGroupUsage extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genEqualsHashCode=true, genToString=true)") 335 @Deprecated __metadata()336 private void __metadata() {} 337 338 339 //@formatter:on 340 // End of generated code 341 342 } 343