Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 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.app; |
| 18 | |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 19 | import android.annotation.CurrentTimeMillisLong; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 20 | import android.annotation.IntRange; |
| 21 | import android.annotation.NonNull; |
| 22 | import android.annotation.Nullable; |
| 23 | import android.os.Parcelable; |
| 24 | |
| 25 | import com.android.internal.annotations.Immutable; |
| 26 | import com.android.internal.util.DataClass; |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 27 | import com.android.internal.util.Preconditions; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 28 | |
| 29 | /** |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 30 | * When an {@link AppOpsManager#noteOp(String, int, String, String, String) app-op is noted} and the |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 31 | * app the app-op is noted for has a {@link AppOpsManager.OnOpNotedCallback} registered the |
| 32 | * note-event needs to be delivered to the callback. Usually this is done via an |
| 33 | * {@link SyncNotedAppOp}, but in some cases this is not possible. In this case an |
| 34 | * {@link AsyncNotedAppOp} is send to the system server and then forwarded to the |
| 35 | * {@link AppOpsManager.OnOpNotedCallback} in the app. |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 36 | */ |
| 37 | @Immutable |
| 38 | @DataClass(genEqualsHashCode = true, |
| 39 | genAidl = true, |
| 40 | genHiddenConstructor = true) |
| 41 | // - We don't expose the opCode, but rather the public name of the op, hence use a non-standard |
| 42 | // getter |
| 43 | @DataClass.Suppress({"getOpCode"}) |
| 44 | public final class AsyncNotedAppOp implements Parcelable { |
| 45 | /** Op that was noted */ |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 46 | private final @IntRange(from = 0) int mOpCode; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 47 | |
| 48 | /** Uid that noted the op */ |
| 49 | private final @IntRange(from = 0) int mNotingUid; |
| 50 | |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 51 | /** {@link android.content.Context#createAttributionContext attribution tag} */ |
| 52 | private final @Nullable String mAttributionTag; |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 53 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 54 | /** Message associated with the noteOp. This message is set by the app noting the op */ |
| 55 | private final @NonNull String mMessage; |
| 56 | |
| 57 | /** Milliseconds since epoch when the op was noted */ |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 58 | private final @CurrentTimeMillisLong long mTime; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 59 | |
| 60 | /** |
| 61 | * @return Op that was noted. |
| 62 | */ |
| 63 | public @NonNull String getOp() { |
| 64 | return AppOpsManager.opToPublicName(mOpCode); |
| 65 | } |
| 66 | |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 67 | //TODO eugenesusla: support inlinable expressions in annotation params of @DataClass members to |
| 68 | // allow validating via @IntRange(from = 0, to = AppOpsManager._NUM_OP - 1) |
| 69 | private void onConstructed() { |
| 70 | Preconditions.checkArgumentInRange(mOpCode, 0, AppOpsManager._NUM_OP - 1, "opCode"); |
| 71 | } |
| 72 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 73 | |
| 74 | |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 75 | // Code below generated by codegen v1.0.15. |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 76 | // |
| 77 | // DO NOT MODIFY! |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 78 | // CHECKSTYLE:OFF Generated code |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 79 | // |
| 80 | // To regenerate run: |
| 81 | // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/app/AsyncNotedAppOp.java |
| 82 | // |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 83 | // To exclude the generated code from IntelliJ auto-formatting enable (one-time): |
| 84 | // Settings > Editor > Code Style > Formatter Control |
| 85 | //@formatter:off |
| 86 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Creates a new AsyncNotedAppOp. |
| 90 | * |
| 91 | * @param opCode |
| 92 | * Op that was noted |
| 93 | * @param notingUid |
| 94 | * Uid that noted the op |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 95 | * @param attributionTag |
| 96 | * {@link android.content.Context#createAttributionContext attribution tag} |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 97 | * @param message |
| 98 | * Message associated with the noteOp. This message is set by the app noting the op |
| 99 | * @param time |
| 100 | * Milliseconds since epoch when the op was noted |
| 101 | * @hide |
| 102 | */ |
| 103 | @DataClass.Generated.Member |
| 104 | public AsyncNotedAppOp( |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 105 | @IntRange(from = 0) int opCode, |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 106 | @IntRange(from = 0) int notingUid, |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 107 | @Nullable String attributionTag, |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 108 | @NonNull String message, |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 109 | @CurrentTimeMillisLong long time) { |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 110 | this.mOpCode = opCode; |
| 111 | com.android.internal.util.AnnotationValidations.validate( |
| 112 | IntRange.class, null, mOpCode, |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 113 | "from", 0); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 114 | this.mNotingUid = notingUid; |
| 115 | com.android.internal.util.AnnotationValidations.validate( |
| 116 | IntRange.class, null, mNotingUid, |
| 117 | "from", 0); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 118 | this.mAttributionTag = attributionTag; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 119 | this.mMessage = message; |
| 120 | com.android.internal.util.AnnotationValidations.validate( |
| 121 | NonNull.class, null, mMessage); |
| 122 | this.mTime = time; |
| 123 | com.android.internal.util.AnnotationValidations.validate( |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 124 | CurrentTimeMillisLong.class, null, mTime); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 125 | |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 126 | onConstructed(); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Uid that noted the op |
| 131 | */ |
| 132 | @DataClass.Generated.Member |
| 133 | public @IntRange(from = 0) int getNotingUid() { |
| 134 | return mNotingUid; |
| 135 | } |
| 136 | |
| 137 | /** |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 138 | * {@link android.content.Context#createAttributionContext attribution tag} |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 139 | */ |
| 140 | @DataClass.Generated.Member |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 141 | public @Nullable String getAttributionTag() { |
| 142 | return mAttributionTag; |
Philip P. Moltmann | 59076d8 | 2019-08-19 15:00:40 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /** |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 146 | * Message associated with the noteOp. This message is set by the app noting the op |
| 147 | */ |
| 148 | @DataClass.Generated.Member |
| 149 | public @NonNull String getMessage() { |
| 150 | return mMessage; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Milliseconds since epoch when the op was noted |
| 155 | */ |
| 156 | @DataClass.Generated.Member |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 157 | public @CurrentTimeMillisLong long getTime() { |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 158 | return mTime; |
| 159 | } |
| 160 | |
| 161 | @Override |
| 162 | @DataClass.Generated.Member |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 163 | public boolean equals(@Nullable Object o) { |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 164 | // You can override field equality logic by defining either of the methods like: |
| 165 | // boolean fieldNameEquals(AsyncNotedAppOp other) { ... } |
| 166 | // boolean fieldNameEquals(FieldType otherValue) { ... } |
| 167 | |
| 168 | if (this == o) return true; |
| 169 | if (o == null || getClass() != o.getClass()) return false; |
| 170 | @SuppressWarnings("unchecked") |
| 171 | AsyncNotedAppOp that = (AsyncNotedAppOp) o; |
| 172 | //noinspection PointlessBooleanExpression |
| 173 | return true |
| 174 | && mOpCode == that.mOpCode |
| 175 | && mNotingUid == that.mNotingUid |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 176 | && java.util.Objects.equals(mAttributionTag, that.mAttributionTag) |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 177 | && java.util.Objects.equals(mMessage, that.mMessage) |
| 178 | && mTime == that.mTime; |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | @DataClass.Generated.Member |
| 183 | public int hashCode() { |
| 184 | // You can override field hashCode logic by defining methods like: |
| 185 | // int fieldNameHashCode() { ... } |
| 186 | |
| 187 | int _hash = 1; |
| 188 | _hash = 31 * _hash + mOpCode; |
| 189 | _hash = 31 * _hash + mNotingUid; |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 190 | _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 191 | _hash = 31 * _hash + java.util.Objects.hashCode(mMessage); |
| 192 | _hash = 31 * _hash + Long.hashCode(mTime); |
| 193 | return _hash; |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | @DataClass.Generated.Member |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 198 | public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 199 | // You can override field parcelling by defining methods like: |
| 200 | // void parcelFieldName(Parcel dest, int flags) { ... } |
| 201 | |
| 202 | byte flg = 0; |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 203 | if (mAttributionTag != null) flg |= 0x4; |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 204 | dest.writeByte(flg); |
| 205 | dest.writeInt(mOpCode); |
| 206 | dest.writeInt(mNotingUid); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 207 | if (mAttributionTag != null) dest.writeString(mAttributionTag); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 208 | dest.writeString(mMessage); |
| 209 | dest.writeLong(mTime); |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | @DataClass.Generated.Member |
| 214 | public int describeContents() { return 0; } |
| 215 | |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 216 | /** @hide */ |
| 217 | @SuppressWarnings({"unchecked", "RedundantCast"}) |
| 218 | @DataClass.Generated.Member |
| 219 | /* package-private */ AsyncNotedAppOp(@NonNull android.os.Parcel in) { |
| 220 | // You can override field unparcelling by defining methods like: |
| 221 | // static FieldType unparcelFieldName(Parcel in) { ... } |
| 222 | |
| 223 | byte flg = in.readByte(); |
| 224 | int opCode = in.readInt(); |
| 225 | int notingUid = in.readInt(); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 226 | String attributionTag = (flg & 0x4) == 0 ? null : in.readString(); |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 227 | String message = in.readString(); |
| 228 | long time = in.readLong(); |
| 229 | |
| 230 | this.mOpCode = opCode; |
| 231 | com.android.internal.util.AnnotationValidations.validate( |
| 232 | IntRange.class, null, mOpCode, |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 233 | "from", 0); |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 234 | this.mNotingUid = notingUid; |
| 235 | com.android.internal.util.AnnotationValidations.validate( |
| 236 | IntRange.class, null, mNotingUid, |
| 237 | "from", 0); |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 238 | this.mAttributionTag = attributionTag; |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 239 | this.mMessage = message; |
| 240 | com.android.internal.util.AnnotationValidations.validate( |
| 241 | NonNull.class, null, mMessage); |
| 242 | this.mTime = time; |
| 243 | com.android.internal.util.AnnotationValidations.validate( |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 244 | CurrentTimeMillisLong.class, null, mTime); |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 245 | |
Eugene Susla | 5fc2d76 | 2020-03-04 13:53:10 -0800 | [diff] [blame] | 246 | onConstructed(); |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 247 | } |
| 248 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 249 | @DataClass.Generated.Member |
| 250 | public static final @NonNull Parcelable.Creator<AsyncNotedAppOp> CREATOR |
| 251 | = new Parcelable.Creator<AsyncNotedAppOp>() { |
| 252 | @Override |
| 253 | public AsyncNotedAppOp[] newArray(int size) { |
| 254 | return new AsyncNotedAppOp[size]; |
| 255 | } |
| 256 | |
| 257 | @Override |
Eugene Susla | 1bfb5e7 | 2019-10-16 10:12:47 -0700 | [diff] [blame] | 258 | public AsyncNotedAppOp createFromParcel(@NonNull android.os.Parcel in) { |
| 259 | return new AsyncNotedAppOp(in); |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 260 | } |
| 261 | }; |
| 262 | |
| 263 | @DataClass.Generated( |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 264 | time = 1583866239013L, |
Philip P. Moltmann | 5892a8f | 2020-03-03 12:05:55 -0800 | [diff] [blame] | 265 | codegenVersion = "1.0.15", |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 266 | sourceFile = "frameworks/base/core/java/android/app/AsyncNotedAppOp.java", |
Philip P. Moltmann | 12ac3f4 | 2020-03-05 15:01:29 -0800 | [diff] [blame^] | 267 | inputSignatures = "private final @android.annotation.IntRange(from=0L) int mOpCode\nprivate final @android.annotation.IntRange(from=0L) int mNotingUid\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\nprivate final @android.annotation.NonNull java.lang.String mMessage\nprivate final @android.annotation.CurrentTimeMillisLong long mTime\npublic @android.annotation.NonNull java.lang.String getOp()\nprivate void onConstructed()\nclass AsyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genHiddenConstructor=true)") |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 268 | @Deprecated |
| 269 | private void __metadata() {} |
| 270 | |
Philip P. Moltmann | da554e4 | 2019-12-20 11:21:02 -0800 | [diff] [blame] | 271 | |
| 272 | //@formatter:on |
| 273 | // End of generated code |
| 274 | |
Philip P. Moltmann | 2b08aaf | 2019-06-10 08:49:11 -0700 | [diff] [blame] | 275 | } |