• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.ondevicepersonalization;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcelable;
21 
22 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
23 import com.android.ondevicepersonalization.internal.util.DataClass;
24 
25 /**
26  * App usage status for app usage histogram.
27  *
28  * @hide
29  */
30 @DataClass(genBuilder = true, genEqualsHashCode = true)
31 public final class AppUsageStatus implements Parcelable {
32     /** Package name. */
33     @NonNull String mPackageName;
34 
35     /** Total time spent on the app in the past 30 days in milliseconds. */
36     @NonNull long mTotalTimeUsedInMillis;
37 
38 
39 
40     // Code below generated by codegen v1.0.23.
41     //
42     // DO NOT MODIFY!
43     // CHECKSTYLE:OFF Generated code
44     //
45     // To regenerate run:
46     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/AppUsageStatus.java
47     //
48     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
49     //   Settings > Editor > Code Style > Formatter Control
50     //@formatter:off
51 
52 
53     @DataClass.Generated.Member
AppUsageStatus( @onNull String packageName, @NonNull long totalTimeUsedInMillis)54     /* package-private */ AppUsageStatus(
55             @NonNull String packageName,
56             @NonNull long totalTimeUsedInMillis) {
57         this.mPackageName = packageName;
58         AnnotationValidations.validate(
59                 NonNull.class, null, mPackageName);
60         this.mTotalTimeUsedInMillis = totalTimeUsedInMillis;
61         AnnotationValidations.validate(
62                 NonNull.class, null, mTotalTimeUsedInMillis);
63 
64         // onConstructed(); // You can define this method to get a callback
65     }
66 
67     /**
68      * Package name.
69      */
70     @DataClass.Generated.Member
getPackageName()71     public @NonNull String getPackageName() {
72         return mPackageName;
73     }
74 
75     /**
76      * Total time spent on the app in the past 30 days in milliseconds.
77      */
78     @DataClass.Generated.Member
getTotalTimeUsedInMillis()79     public @NonNull long getTotalTimeUsedInMillis() {
80         return mTotalTimeUsedInMillis;
81     }
82 
83     @Override
84     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)85     public boolean equals(@android.annotation.Nullable Object o) {
86         // You can override field equality logic by defining either of the methods like:
87         // boolean fieldNameEquals(AppUsageStatus other) { ... }
88         // boolean fieldNameEquals(FieldType otherValue) { ... }
89 
90         if (this == o) return true;
91         if (o == null || getClass() != o.getClass()) return false;
92         @SuppressWarnings("unchecked")
93         AppUsageStatus that = (AppUsageStatus) o;
94         //noinspection PointlessBooleanExpression
95         return true
96                 && java.util.Objects.equals(mPackageName, that.mPackageName)
97                 && mTotalTimeUsedInMillis == that.mTotalTimeUsedInMillis;
98     }
99 
100     @Override
101     @DataClass.Generated.Member
hashCode()102     public int hashCode() {
103         // You can override field hashCode logic by defining methods like:
104         // int fieldNameHashCode() { ... }
105 
106         int _hash = 1;
107         _hash = 31 * _hash + java.util.Objects.hashCode(mPackageName);
108         _hash = 31 * _hash + Long.hashCode(mTotalTimeUsedInMillis);
109         return _hash;
110     }
111 
112     @Override
113     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)114     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
115         // You can override field parcelling by defining methods like:
116         // void parcelFieldName(Parcel dest, int flags) { ... }
117 
118         dest.writeString(mPackageName);
119         dest.writeLong(mTotalTimeUsedInMillis);
120     }
121 
122     @Override
123     @DataClass.Generated.Member
describeContents()124     public int describeContents() { return 0; }
125 
126     /** @hide */
127     @SuppressWarnings({"unchecked", "RedundantCast"})
128     @DataClass.Generated.Member
AppUsageStatus(@onNull android.os.Parcel in)129     /* package-private */ AppUsageStatus(@NonNull android.os.Parcel in) {
130         // You can override field unparcelling by defining methods like:
131         // static FieldType unparcelFieldName(Parcel in) { ... }
132 
133         String packageName = in.readString();
134         long totalTimeUsedInMillis = in.readLong();
135 
136         this.mPackageName = packageName;
137         AnnotationValidations.validate(
138                 NonNull.class, null, mPackageName);
139         this.mTotalTimeUsedInMillis = totalTimeUsedInMillis;
140         AnnotationValidations.validate(
141                 NonNull.class, null, mTotalTimeUsedInMillis);
142 
143         // onConstructed(); // You can define this method to get a callback
144     }
145 
146     @DataClass.Generated.Member
147     public static final @NonNull Parcelable.Creator<AppUsageStatus> CREATOR
148             = new Parcelable.Creator<AppUsageStatus>() {
149         @Override
150         public AppUsageStatus[] newArray(int size) {
151             return new AppUsageStatus[size];
152         }
153 
154         @Override
155         public AppUsageStatus createFromParcel(@NonNull android.os.Parcel in) {
156             return new AppUsageStatus(in);
157         }
158     };
159 
160     /**
161      * A builder for {@link AppUsageStatus}
162      */
163     @SuppressWarnings("WeakerAccess")
164     @DataClass.Generated.Member
165     public static final class Builder {
166 
167         private @NonNull String mPackageName;
168         private @NonNull long mTotalTimeUsedInMillis;
169 
170         private long mBuilderFieldsSet = 0L;
171 
172         /**
173          * Creates a new Builder.
174          *
175          * @param packageName
176          *   Package name.
177          * @param totalTimeUsedInMillis
178          *   Total time spent on the app in the past 30 days in milliseconds.
179          */
Builder( @onNull String packageName, @NonNull long totalTimeUsedInMillis)180         public Builder(
181                 @NonNull String packageName,
182                 @NonNull long totalTimeUsedInMillis) {
183             mPackageName = packageName;
184             AnnotationValidations.validate(
185                     NonNull.class, null, mPackageName);
186             mTotalTimeUsedInMillis = totalTimeUsedInMillis;
187             AnnotationValidations.validate(
188                     NonNull.class, null, mTotalTimeUsedInMillis);
189         }
190 
Builder()191         public Builder() {
192         }
193 
194         /**
195          * Package name.
196          */
197         @DataClass.Generated.Member
setPackageName(@onNull String value)198         public @NonNull Builder setPackageName(@NonNull String value) {
199             checkNotUsed();
200             mBuilderFieldsSet |= 0x1;
201             mPackageName = value;
202             return this;
203         }
204 
205         /**
206          * Total time spent on the app in the past 30 days in milliseconds.
207          */
208         @DataClass.Generated.Member
setTotalTimeUsedInMillis(@onNull long value)209         public @NonNull Builder setTotalTimeUsedInMillis(@NonNull long value) {
210             checkNotUsed();
211             mBuilderFieldsSet |= 0x2;
212             mTotalTimeUsedInMillis = value;
213             return this;
214         }
215 
216         /** Builds the instance. This builder should not be touched after calling this! */
build()217         public @NonNull AppUsageStatus build() {
218             checkNotUsed();
219             mBuilderFieldsSet |= 0x4; // Mark builder used
220 
221             AppUsageStatus o = new AppUsageStatus(
222                     mPackageName,
223                     mTotalTimeUsedInMillis);
224             return o;
225         }
226 
checkNotUsed()227         private void checkNotUsed() {
228             if ((mBuilderFieldsSet & 0x4) != 0) {
229                 throw new IllegalStateException(
230                         "This Builder should not be reused. Use a new Builder instance instead");
231             }
232         }
233     }
234 
235     @DataClass.Generated(
236             time = 1676499898093L,
237             codegenVersion = "1.0.23",
238             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/AppUsageStatus.java",
239             inputSignatures = " @android.annotation.NonNull java.lang.String mPackageName\n @android.annotation.NonNull long mTotalTimeUsedInMillis\nclass AppUsageStatus extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
240     @Deprecated
__metadata()241     private void __metadata() {}
242 
243 
244     //@formatter:on
245     // End of generated code
246 
247 }
248