• 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.adservices.ondevicepersonalization;
18 
19 import android.annotation.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.os.Parcelable;
22 
23 import com.android.adservices.ondevicepersonalization.flags.Flags;
24 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
25 import com.android.ondevicepersonalization.internal.util.DataClass;
26 
27 /**
28  * Information about apps.
29  *
30  */
31 @DataClass(genHiddenBuilder = true, genEqualsHashCode = true)
32 public final class AppInfo implements Parcelable {
33     /** Whether the app is installed. */
34     private boolean mInstalled = false;
35 
36     /**
37      * Creates a new AppInfo.
38      *
39      * @param installed {@code true} if the app is installed.
40      */
41     @FlaggedApi(Flags.FLAG_DATA_CLASS_MISSING_CTORS_AND_GETTERS_ENABLED)
AppInfo(boolean installed)42     public AppInfo(boolean installed) {
43         this.mInstalled = installed;
44     }
45 
46     // Code below generated by codegen v1.0.23.
47     //
48     // DO NOT MODIFY!
49     // CHECKSTYLE:OFF Generated code
50     //
51     // To regenerate run:
52     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/AppInfo.java
53     //
54     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
55     //   Settings > Editor > Code Style > Formatter Control
56     //@formatter:off
57 
58     /**
59      * Whether the app is installed.
60      */
61     @DataClass.Generated.Member
isInstalled()62     public @NonNull boolean isInstalled() {
63         return mInstalled;
64     }
65 
66     @Override
67     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)68     public boolean equals(@android.annotation.Nullable Object o) {
69         // You can override field equality logic by defining either of the methods like:
70         // boolean fieldNameEquals(AppInfo other) { ... }
71         // boolean fieldNameEquals(FieldType otherValue) { ... }
72 
73         if (this == o) return true;
74         if (o == null || getClass() != o.getClass()) return false;
75         @SuppressWarnings("unchecked")
76         AppInfo that = (AppInfo) o;
77         //noinspection PointlessBooleanExpression
78         return true
79                 && mInstalled == that.mInstalled;
80     }
81 
82     @Override
83     @DataClass.Generated.Member
hashCode()84     public int hashCode() {
85         // You can override field hashCode logic by defining methods like:
86         // int fieldNameHashCode() { ... }
87 
88         int _hash = 1;
89         _hash = 31 * _hash + Boolean.hashCode(mInstalled);
90         return _hash;
91     }
92 
93     @Override
94     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)95     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
96         // You can override field parcelling by defining methods like:
97         // void parcelFieldName(Parcel dest, int flags) { ... }
98 
99         byte flg = 0;
100         if (mInstalled) flg |= 0x1;
101         dest.writeByte(flg);
102     }
103 
104     @Override
105     @DataClass.Generated.Member
describeContents()106     public int describeContents() { return 0; }
107 
108     /** @hide */
109     @SuppressWarnings({"unchecked", "RedundantCast"})
110     @DataClass.Generated.Member
AppInfo(@onNull android.os.Parcel in)111     /* package-private */ AppInfo(@NonNull android.os.Parcel in) {
112         // You can override field unparcelling by defining methods like:
113         // static FieldType unparcelFieldName(Parcel in) { ... }
114 
115         byte flg = in.readByte();
116         boolean installed = (flg & 0x1) != 0;
117 
118         this.mInstalled = installed;
119         AnnotationValidations.validate(
120                 NonNull.class, null, mInstalled);
121 
122         // onConstructed(); // You can define this method to get a callback
123     }
124 
125     @DataClass.Generated.Member
126     public static final @NonNull Parcelable.Creator<AppInfo> CREATOR
127             = new Parcelable.Creator<AppInfo>() {
128         @Override
129         public AppInfo[] newArray(int size) {
130             return new AppInfo[size];
131         }
132 
133         @Override
134         public AppInfo createFromParcel(@NonNull android.os.Parcel in) {
135             return new AppInfo(in);
136         }
137     };
138 
139     /**
140      * A builder for {@link AppInfo}
141      * @hide
142      */
143     @SuppressWarnings("WeakerAccess")
144     @DataClass.Generated.Member
145     public static final class Builder {
146 
147         private @NonNull boolean mInstalled;
148 
149         private long mBuilderFieldsSet = 0L;
150 
Builder()151         public Builder() {
152         }
153 
154         /**
155          * Whether the app is installed.
156          */
157         @DataClass.Generated.Member
setInstalled(@onNull boolean value)158         public @NonNull Builder setInstalled(@NonNull boolean value) {
159             checkNotUsed();
160             mBuilderFieldsSet |= 0x1;
161             mInstalled = value;
162             return this;
163         }
164 
165         /** Builds the instance. This builder should not be touched after calling this! */
build()166         public @NonNull AppInfo build() {
167             checkNotUsed();
168             mBuilderFieldsSet |= 0x2; // Mark builder used
169 
170             if ((mBuilderFieldsSet & 0x1) == 0) {
171                 mInstalled = false;
172             }
173             AppInfo o = new AppInfo(
174                     mInstalled);
175             return o;
176         }
177 
checkNotUsed()178         private void checkNotUsed() {
179             if ((mBuilderFieldsSet & 0x2) != 0) {
180                 throw new IllegalStateException(
181                         "This Builder should not be reused. Use a new Builder instance instead");
182             }
183         }
184     }
185 
186     @DataClass.Generated(
187             time = 1695492606666L,
188             codegenVersion = "1.0.23",
189             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/AppInfo.java",
190             inputSignatures = " @android.annotation.NonNull boolean mInstalled\nclass AppInfo extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genHiddenBuilder=true, genEqualsHashCode=true)")
191     @Deprecated
__metadata()192     private void __metadata() {}
193 
194 
195     //@formatter:on
196     // End of generated code
197 
198 }
199