Debian Codegraph @

core/java/android/app/SyncNotedAppOp.java

raw symbols SCIP
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
19 import android.annotation.IntRange;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.annotation.TestApi;
23 import android.os.Parcelable;
24
25 import com.android.internal.annotations.Immutable;
26 import com.android.internal.util.DataClass;
27
28 /**
29 * Description of an app-op that was noted for the current process.
30 *
31 * Note: package name is currently unused in the system.
32 *
33 * <p>This is either delivered after a
34 * {@link AppOpsManager.OnOpNotedCallback#onNoted(SyncNotedAppOp) two way binder call} or
35 * when the app
36 * {@link AppOpsManager.OnOpNotedCallback#onSelfNoted(SyncNotedAppOp) notes an app-op for
37 * itself}.
38 */
39 @Immutable
40 @DataClass(
41 genEqualsHashCode = true,
42 genAidl = true,
43 genConstructor = false,
44 genToString = true
45 )
46 @DataClass.Suppress({"getOpCode", "getOpMode"})
47 public final class SyncNotedAppOp implements Parcelable {
48
49 /** mode returned by the system on a call to note/startOp, if applicable */
50 private final int mOpMode;
51 /** op code of synchronous appop noted */
52 private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mOpCode;
53 /** attributionTag of synchronous appop noted */
54 private final @Nullable String mAttributionTag;
55 /**
56 * The package this op applies to
57 * @hide
58 */
59 private final @NonNull String mPackageName;
60
61 /**
62 * Native code relies on parcel ordering, do not change
63 * @hide
64 */
65 @TestApi
66 public SyncNotedAppOp(int opMode, @IntRange(from = 0L) int opCode,
67 @Nullable String attributionTag, @NonNull String packageName) {
68 this.mOpCode = opCode;
69 com.android.internal.util.AnnotationValidations.validate(
70 IntRange.class, null, mOpCode,
71 "from", 0,
72 "to", AppOpsManager._NUM_OP - 1);
73 this.mAttributionTag = attributionTag;
74 this.mOpMode = opMode;
75 this.mPackageName = packageName;
76 }
77
78 /**
79 * Creates a new SyncNotedAppOp.
80 *
81 * @param opCode
82 * op code of synchronous appop noted
83 * @param attributionTag
84 * attributionTag of synchronous appop noted
85 */
86 public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag) {
87 this(AppOpsManager.MODE_IGNORED, opCode, attributionTag, ActivityThread
88 .currentPackageName());
89 }
90
91 /**
92 * Creates a new SyncNotedAppOp.
93 *
94 * @param opCode
95 * op code of synchronous appop noted
96 * @param attributionTag
97 * attributionTag of synchronous appop noted
98 * @param packageName
99 * The package this op applies to
100 *
101 * @hide
102 */
103 public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag,
104 @NonNull String packageName) {
105 this(AppOpsManager.MODE_IGNORED, opCode, attributionTag, packageName);
106 }
107
108 /**
109 * @return The op that was noted.
110 */
111 public @NonNull String getOp() {
112 return AppOpsManager.opToPublicName(mOpCode);
113 }
114
115 /**
116 * @hide
117 */
118 public int getOpMode() {
119 return mOpMode;
120 }
121
122 private String opCodeToString() {
123 return getOp();
124 }
125
126
127
128 // Code below generated by codegen v1.0.23.
129 //
130 // DO NOT MODIFY!
131 // CHECKSTYLE:OFF Generated code
132 //
133 // To regenerate run:
134 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/app/SyncNotedAppOp.java
135 //
136 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
137 // Settings > Editor > Code Style > Formatter Control
138 //@formatter:off
139
140
141 /**
142 * attributionTag of synchronous appop noted
143 */
144 @DataClass.Generated.Member
145 public @Nullable String getAttributionTag() {
146 return mAttributionTag;
147 }
148
149 /**
150 * The package this op applies to
151 *
152 * @hide
153 */
154 @DataClass.Generated.Member
155 public @NonNull String getPackageName() {
156 return mPackageName;
157 }
158
159 @Override
160 @DataClass.Generated.Member
161 public String toString() {
162 // You can override field toString logic by defining methods like:
163 // String fieldNameToString() { ... }
164
165 return "SyncNotedAppOp { " +
166 "opMode = " + mOpMode + ", " +
167 "opCode = " + opCodeToString() + ", " +
168 "attributionTag = " + mAttributionTag + ", " +
169 "packageName = " + mPackageName +
170 " }";
171 }
172
173 @Override
174 @DataClass.Generated.Member
175 public boolean equals(@Nullable Object o) {
176 // You can override field equality logic by defining either of the methods like:
177 // boolean fieldNameEquals(SyncNotedAppOp other) { ... }
178 // boolean fieldNameEquals(FieldType otherValue) { ... }
179
180 if (this == o) return true;
181 if (o == null || getClass() != o.getClass()) return false;
182 @SuppressWarnings("unchecked")
183 SyncNotedAppOp that = (SyncNotedAppOp) o;
184 //noinspection PointlessBooleanExpression
185 return true
186 && mOpMode == that.mOpMode
187 && mOpCode == that.mOpCode
188 && java.util.Objects.equals(mAttributionTag, that.mAttributionTag)
189 && java.util.Objects.equals(mPackageName, that.mPackageName);
190 }
191
192 @Override
193 @DataClass.Generated.Member
194 public int hashCode() {
195 // You can override field hashCode logic by defining methods like:
196 // int fieldNameHashCode() { ... }
197
198 int _hash = 1;
199 _hash = 31 * _hash + mOpMode;
200 _hash = 31 * _hash + mOpCode;
201 _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag);
202 _hash = 31 * _hash + java.util.Objects.hashCode(mPackageName);
203 return _hash;
204 }
205
206 @Override
207 @DataClass.Generated.Member
208 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
209 // You can override field parcelling by defining methods like:
210 // void parcelFieldName(Parcel dest, int flags) { ... }
211
212 byte flg = 0;
213 if (mAttributionTag != null) flg |= 0x4;
214 dest.writeByte(flg);
215 dest.writeInt(mOpMode);
216 dest.writeInt(mOpCode);
217 if (mAttributionTag != null) dest.writeString(mAttributionTag);
218 dest.writeString(mPackageName);
219 }
220
221 @Override
222 @DataClass.Generated.Member
223 public int describeContents() { return 0; }
224
225 /** @hide */
226 @SuppressWarnings({"unchecked", "RedundantCast"})
227 @DataClass.Generated.Member
228 /* package-private */ SyncNotedAppOp(@NonNull android.os.Parcel in) {
229 // You can override field unparcelling by defining methods like:
230 // static FieldType unparcelFieldName(Parcel in) { ... }
231
232 byte flg = in.readByte();
233 int opMode = in.readInt();
234 int opCode = in.readInt();
235 String attributionTag = (flg & 0x4) == 0 ? null : in.readString();
236 String packageName = in.readString();
237
238 this.mOpMode = opMode;
239 this.mOpCode = opCode;
240 com.android.internal.util.AnnotationValidations.validate(
241 IntRange.class, null, mOpCode,
242 "from", 0L,
243 "to", AppOpsManager._NUM_OP - 1);
244 this.mAttributionTag = attributionTag;
245 this.mPackageName = packageName;
246 com.android.internal.util.AnnotationValidations.validate(
247 NonNull.class, null, mPackageName);
248
249 // onConstructed(); // You can define this method to get a callback
250 }
251
252 @DataClass.Generated.Member
253 public static final @NonNull Parcelable.Creator<SyncNotedAppOp> CREATOR
254 = new Parcelable.Creator<SyncNotedAppOp>() {
255 @Override
256 public SyncNotedAppOp[] newArray(int size) {
257 return new SyncNotedAppOp[size];
258 }
259
260 @Override
261 public SyncNotedAppOp createFromParcel(@NonNull android.os.Parcel in) {
262 return new SyncNotedAppOp(in);
263 }
264 };
265
266 @DataClass.Generated(
267 time = 1643320427700L,
268 codegenVersion = "1.0.23",
269 sourceFile = "frameworks/base/core/java/android/app/SyncNotedAppOp.java",
270 inputSignatures = "private final int mOpMode\nprivate final @android.annotation.IntRange int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\nprivate final @android.annotation.NonNull java.lang.String mPackageName\npublic @android.annotation.NonNull java.lang.String getOp()\npublic int getOpMode()\nprivate java.lang.String opCodeToString()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genAidl=true, genConstructor=false, genToString=true)")
271 @Deprecated
272 private void __metadata() {}
273
274
275 //@formatter:on
276 // End of generated code
277
278 }