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 com.android.internal.app;
18 
19 import android.annotation.IntRange;
20 import android.annotation.NonNull;
21 import android.app.AppOpsManager;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 import com.android.internal.annotations.Immutable;
26 import com.android.internal.util.DataClass;
27 
28 /**
29  * Configuration for AppOps access messages sampling.
30  */
31 @Immutable
32 /*@DataClass*/
33 public final class MessageSamplingConfig implements Parcelable {
34     /** Op code targeted during current sampling session */
35     private final @IntRange(from = -1L, to = AppOpsManager._NUM_OP - 1) int mSampledOpCode;
36     /** Range of ops which should be reported during current sampling session */
37     private final @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int mAcceptableLeftDistance;
38     /** Expiration time for this sampling config */
39     private final @IntRange(from = 0L) long mExpirationTimeSinceBootMillis;
40 
41 
42 
43 
44 
45 
46 
47     // Code below generated by codegen v1.0.14.
48     //
49     // DO NOT MODIFY!
50     // CHECKSTYLE:OFF Generated code
51     //
52     // To regenerate run:
53     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/com/android/internal/app/MessageSamplingConfig.java
54     //
55     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
56     //   Settings > Editor > Code Style > Formatter Control
57     //@formatter:off
58 
59 
60     /**
61      * Creates a new MessageSamplingConfig.
62      *
63      * @param sampledOpCode
64      *   Op code targeted during current sampling session
65      * @param acceptableLeftDistance
66      *   Range of ops which should be reported during current sampling session
67      * @param expirationTimeSinceBootMillis
68      *   Expiration time for this sampling config
69      */
70     @DataClass.Generated.Member
MessageSamplingConfig( @ntRangefrom = -1L, to = AppOpsManager._NUM_OP - 1) int sampledOpCode, @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int acceptableLeftDistance, @IntRange(from = 0L) long expirationTimeSinceBootMillis)71     public MessageSamplingConfig(
72             @IntRange(from = -1L, to = AppOpsManager._NUM_OP - 1) int sampledOpCode,
73             @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int acceptableLeftDistance,
74             @IntRange(from = 0L) long expirationTimeSinceBootMillis) {
75         this.mSampledOpCode = sampledOpCode;
76         com.android.internal.util.AnnotationValidations.validate(
77                 IntRange.class, null, mSampledOpCode,
78                 "from", -1L,
79                 "to", AppOpsManager._NUM_OP - 1);
80         this.mAcceptableLeftDistance = acceptableLeftDistance;
81         com.android.internal.util.AnnotationValidations.validate(
82                 IntRange.class, null, mAcceptableLeftDistance,
83                 "from", 0L,
84                 "to", AppOpsManager._NUM_OP - 1);
85         this.mExpirationTimeSinceBootMillis = expirationTimeSinceBootMillis;
86         com.android.internal.util.AnnotationValidations.validate(
87                 IntRange.class, null, mExpirationTimeSinceBootMillis,
88                 "from", 0L);
89 
90         // onConstructed(); // You can define this method to get a callback
91     }
92 
93     /**
94      * Op code targeted during current sampling session
95      */
96     @DataClass.Generated.Member
getSampledOpCode()97     public @IntRange(from = -1L, to = AppOpsManager._NUM_OP - 1) int getSampledOpCode() {
98         return mSampledOpCode;
99     }
100 
101     /**
102      * Range of ops which should be reported during current sampling session
103      */
104     @DataClass.Generated.Member
getAcceptableLeftDistance()105     public @IntRange(from = 0L, to = AppOpsManager._NUM_OP - 1) int getAcceptableLeftDistance() {
106         return mAcceptableLeftDistance;
107     }
108 
109     /**
110      * Expiration time for this sampling config
111      */
112     @DataClass.Generated.Member
getExpirationTimeSinceBootMillis()113     public @IntRange(from = 0L) long getExpirationTimeSinceBootMillis() {
114         return mExpirationTimeSinceBootMillis;
115     }
116 
117     @Override
118     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)119     public void writeToParcel(@NonNull Parcel dest, int flags) {
120         // You can override field parcelling by defining methods like:
121         // void parcelFieldName(Parcel dest, int flags) { ... }
122 
123         dest.writeInt(mSampledOpCode);
124         dest.writeInt(mAcceptableLeftDistance);
125         dest.writeLong(mExpirationTimeSinceBootMillis);
126     }
127 
128     @Override
129     @DataClass.Generated.Member
describeContents()130     public int describeContents() { return 0; }
131 
132     /** @hide */
133     @SuppressWarnings({"unchecked", "RedundantCast"})
134     @DataClass.Generated.Member
MessageSamplingConfig(@onNull Parcel in)135     /* package-private */ MessageSamplingConfig(@NonNull Parcel in) {
136         // You can override field unparcelling by defining methods like:
137         // static FieldType unparcelFieldName(Parcel in) { ... }
138 
139         int sampledOpCode = in.readInt();
140         int acceptableLeftDistance = in.readInt();
141         long expirationTimeSinceBootMillis = in.readLong();
142 
143         this.mSampledOpCode = sampledOpCode;
144         com.android.internal.util.AnnotationValidations.validate(
145                 IntRange.class, null, mSampledOpCode,
146                 "from", -1L,
147                 "to", AppOpsManager._NUM_OP - 1);
148         this.mAcceptableLeftDistance = acceptableLeftDistance;
149         com.android.internal.util.AnnotationValidations.validate(
150                 IntRange.class, null, mAcceptableLeftDistance,
151                 "from", 0L,
152                 "to", AppOpsManager._NUM_OP - 1);
153         this.mExpirationTimeSinceBootMillis = expirationTimeSinceBootMillis;
154         com.android.internal.util.AnnotationValidations.validate(
155                 IntRange.class, null, mExpirationTimeSinceBootMillis,
156                 "from", 0L);
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<MessageSamplingConfig> CREATOR
163             = new Parcelable.Creator<MessageSamplingConfig>() {
164         @Override
165         public MessageSamplingConfig[] newArray(int size) {
166             return new MessageSamplingConfig[size];
167         }
168 
169         @Override
170         public MessageSamplingConfig createFromParcel(@NonNull Parcel in) {
171             return new MessageSamplingConfig(in);
172         }
173     };
174 
175     /*@DataClass.Generated(
176             time = 1580691255495L,
177             codegenVersion = "1.0.14",
178             sourceFile = "frameworks/base/core/java/com/android/internal/app/MessageSamplingConfig.java",
179             inputSignatures = "private final @android.annotation.IntRange(from=-1L, to=AppOpsManager._NUM_OP - 1) int mSampledOpCode\nprivate final @android.annotation.IntRange(from=0L, to=AppOpsManager._NUM_OP - 1) int mAcceptableLeftDistance\nprivate final @android.annotation.IntRange(from=0L) long mExpirationTimeSinceBootMillis\nclass MessageSamplingConfig extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass")*/
180     @Deprecated
__metadata()181     private void __metadata() {}
182 
183 
184     //@formatter:on
185     // End of generated code
186 
187 }
188