• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.os.Parcelable;
23 
24 import com.android.internal.annotations.Immutable;
25 import com.android.internal.util.DataClass;
26 
27 /**
28  * Description of an app-op that was noted for the current process.
29  *
30  * <p>This is either delivered after a
31  * {@link AppOpsManager.OnOpNotedCallback#onNoted(SyncNotedAppOp) two way binder call} or
32  * when the app
33  * {@link AppOpsManager.OnOpNotedCallback#onSelfNoted(SyncNotedAppOp) notes an app-op for
34  * itself}.
35  */
36 @Immutable
37 /*@DataClass(
38         genEqualsHashCode = true,
39         genConstructor = false
40 )
41 @DataClass.Suppress("getOpCode")*/
42 public final class SyncNotedAppOp implements Parcelable {
43 
44     /** op code of synchronous appop noted */
45     private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mOpCode;
46     /** attributionTag of synchronous appop noted */
47     private final @Nullable String mAttributionTag;
48 
49     /**
50      * Creates a new SyncNotedAppOp.
51      *
52      * @param opCode
53      *   op code of synchronous appop noted
54      * @param attributionTag
55      *   attributionTag of synchronous appop noted
56      */
SyncNotedAppOp(@ntRangefrom = 0L) int opCode, @Nullable String attributionTag)57     public SyncNotedAppOp(@IntRange(from = 0L) int opCode, @Nullable String attributionTag) {
58         this.mOpCode = opCode;
59         com.android.internal.util.AnnotationValidations.validate(
60                 IntRange.class, null, mOpCode,
61                 "from", 0,
62                 "to", AppOpsManager._NUM_OP - 1);
63         this.mAttributionTag = attributionTag;
64     }
65 
66     /**
67      * @return The op that was noted.
68      */
getOp()69     public @NonNull String getOp() {
70         return AppOpsManager.opToPublicName(mOpCode);
71     }
72 
73     // Code below generated by codegen v1.0.14.
74     //
75     // DO NOT MODIFY!
76     // CHECKSTYLE:OFF Generated code
77     //
78     // To regenerate run:
79     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/app/SyncNotedAppOp.java
80     //
81     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
82     //   Settings > Editor > Code Style > Formatter Control
83     //@formatter:off
84 
85 
86     /**
87      * attributionTag of synchronous appop noted
88      */
89     @DataClass.Generated.Member
getAttributionTag()90     public @Nullable String getAttributionTag() {
91         return mAttributionTag;
92     }
93 
94     @Override
95     @DataClass.Generated.Member
equals(@ullable Object o)96     public boolean equals(@Nullable Object o) {
97         // You can override field equality logic by defining either of the methods like:
98         // boolean fieldNameEquals(SyncNotedAppOp other) { ... }
99         // boolean fieldNameEquals(FieldType otherValue) { ... }
100 
101         if (this == o) return true;
102         if (o == null || getClass() != o.getClass()) return false;
103         @SuppressWarnings("unchecked")
104         SyncNotedAppOp that = (SyncNotedAppOp) o;
105         //noinspection PointlessBooleanExpression
106         return true
107                 && mOpCode == that.mOpCode
108                 && java.util.Objects.equals(mAttributionTag, that.mAttributionTag);
109     }
110 
111     @Override
112     @DataClass.Generated.Member
hashCode()113     public int hashCode() {
114         // You can override field hashCode logic by defining methods like:
115         // int fieldNameHashCode() { ... }
116 
117         int _hash = 1;
118         _hash = 31 * _hash + mOpCode;
119         _hash = 31 * _hash + java.util.Objects.hashCode(mAttributionTag);
120         return _hash;
121     }
122 
123     @Override
124     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)125     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
126         // You can override field parcelling by defining methods like:
127         // void parcelFieldName(Parcel dest, int flags) { ... }
128 
129         byte flg = 0;
130         if (mAttributionTag != null) flg |= 0x2;
131         dest.writeByte(flg);
132         dest.writeInt(mOpCode);
133         if (mAttributionTag != null) dest.writeString(mAttributionTag);
134     }
135 
136     @Override
137     @DataClass.Generated.Member
describeContents()138     public int describeContents() { return 0; }
139 
140     /** @hide */
141     @SuppressWarnings({"unchecked", "RedundantCast"})
142     @DataClass.Generated.Member
SyncNotedAppOp(@onNull android.os.Parcel in)143     /* package-private */ SyncNotedAppOp(@NonNull android.os.Parcel in) {
144         // You can override field unparcelling by defining methods like:
145         // static FieldType unparcelFieldName(Parcel in) { ... }
146 
147         byte flg = in.readByte();
148         int opCode = in.readInt();
149         String attributionTag = (flg & 0x2) == 0 ? null : in.readString();
150 
151         this.mOpCode = opCode;
152         com.android.internal.util.AnnotationValidations.validate(
153                 IntRange.class, null, mOpCode,
154                 "from", 0,
155                 "to", AppOpsManager._NUM_OP - 1);
156         this.mAttributionTag = attributionTag;
157 
158         // onConstructed(); // You can define this method to get a callback
159     }
160 
161     @DataClass.Generated.Member
162     public static final @NonNull Parcelable.Creator<SyncNotedAppOp> CREATOR
163             = new Parcelable.Creator<SyncNotedAppOp>() {
164         @Override
165         public SyncNotedAppOp[] newArray(int size) {
166             return new SyncNotedAppOp[size];
167         }
168 
169         @Override
170         public SyncNotedAppOp createFromParcel(@NonNull android.os.Parcel in) {
171             return new SyncNotedAppOp(in);
172         }
173     };
174 
175     /*@DataClass.Generated(
176             time = 1579188889960L,
177             codegenVersion = "1.0.14",
178             sourceFile = "frameworks/base/core/java/android/app/SyncNotedAppOp.java",
179             inputSignatures = "private final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mOpCode\nprivate final @android.annotation.Nullable java.lang.String mAttributionTag\npublic @android.annotation.NonNull java.lang.String getOp()\npublic @android.annotation.SystemApi int getOpCode()\nclass SyncNotedAppOp extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genEqualsHashCode=true, genConstructor=false)")*/
180     @Deprecated
__metadata()181     private void __metadata() {}
182 
183 
184     //@formatter:on
185     // End of generated code
186 
187 }
188