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 com.android.internal.pm.pkg.component;
18 
19 import static com.android.internal.pm.parsing.pkg.PackageImpl.sForInternedString;
20 
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 import android.text.TextUtils;
26 
27 import com.android.internal.annotations.VisibleForTesting;
28 import com.android.internal.util.DataClass;
29 import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;
30 
31 import libcore.util.EmptyArray;
32 
33 /**
34  * @hide
35  */
36 @DataClass(genGetters = true, genSetters = true, genBuilder = false, genParcelable = false)
37 @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
38 public class ParsedMainComponentImpl extends ParsedComponentImpl implements ParsedMainComponent,
39         Parcelable {
40 
41     @Nullable
42     @DataClass.ParcelWith(ForInternedString.class)
43     private String processName;
44     private boolean directBootAware;
45     private boolean enabled = true;
46     private boolean exported;
47     private int order;
48 
49     @Nullable
50     private String splitName;
51     @Nullable
52     private String[] attributionTags;
53 
ParsedMainComponentImpl()54     public ParsedMainComponentImpl() {
55     }
56 
ParsedMainComponentImpl(ParsedMainComponent other)57     public ParsedMainComponentImpl(ParsedMainComponent other) {
58         super(other);
59         this.processName = other.getProcessName();
60         this.directBootAware = other.isDirectBootAware();
61         this.enabled = other.isEnabled();
62         this.exported = other.isExported();
63         this.order = other.getOrder();
64         this.splitName = other.getSplitName();
65         this.attributionTags = other.getAttributionTags();
66     }
67 
setProcessName(String processName)68     public ParsedMainComponentImpl setProcessName(String processName) {
69         this.processName = TextUtils.safeIntern(processName);
70         return this;
71     }
72 
73     /**
74      * A main component's name is a class name. This makes code slightly more readable.
75      */
getClassName()76     public String getClassName() {
77         return getName();
78     }
79 
80     @NonNull
81     @Override
getAttributionTags()82     public String[] getAttributionTags() {
83         return attributionTags == null ? EmptyArray.STRING : attributionTags;
84     }
85 
86     @Override
describeContents()87     public int describeContents() {
88         return 0;
89     }
90 
91     @Override
writeToParcel(Parcel dest, int flags)92     public void writeToParcel(Parcel dest, int flags) {
93         super.writeToParcel(dest, flags);
94         sForInternedString.parcel(this.processName, dest, flags);
95         dest.writeBoolean(this.directBootAware);
96         dest.writeBoolean(this.enabled);
97         dest.writeBoolean(this.exported);
98         dest.writeInt(this.order);
99         dest.writeString(this.splitName);
100         dest.writeString8Array(this.attributionTags);
101     }
102 
ParsedMainComponentImpl(Parcel in)103     protected ParsedMainComponentImpl(Parcel in) {
104         super(in);
105         this.processName = sForInternedString.unparcel(in);
106         this.directBootAware = in.readBoolean();
107         this.enabled = in.readBoolean();
108         this.exported = in.readBoolean();
109         this.order = in.readInt();
110         this.splitName = in.readString();
111         this.attributionTags = in.createString8Array();
112     }
113 
114     public static final Parcelable.Creator<ParsedMainComponentImpl> CREATOR =
115             new Parcelable.Creator<ParsedMainComponentImpl>() {
116                 @Override
117                 public ParsedMainComponentImpl createFromParcel(Parcel source) {
118                     return new ParsedMainComponentImpl(source);
119                 }
120 
121                 @Override
122                 public ParsedMainComponentImpl[] newArray(int size) {
123                     return new ParsedMainComponentImpl[size];
124                 }
125             };
126 
127 
128 
129     // Code below generated by codegen v1.0.23.
130     //
131     // DO NOT MODIFY!
132     // CHECKSTYLE:OFF Generated code
133     //
134     // To regenerate run:
135     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/com/android/internal/pm/pkg/component/ParsedMainComponentImpl.java
136     //
137     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
138     //   Settings > Editor > Code Style > Formatter Control
139     //@formatter:off
140 
141 
142     @DataClass.Generated.Member
ParsedMainComponentImpl( @ullable String processName, boolean directBootAware, boolean enabled, boolean exported, int order, @Nullable String splitName, @Nullable String[] attributionTags)143     public ParsedMainComponentImpl(
144             @Nullable String processName,
145             boolean directBootAware,
146             boolean enabled,
147             boolean exported,
148             int order,
149             @Nullable String splitName,
150             @Nullable String[] attributionTags) {
151         this.processName = processName;
152         this.directBootAware = directBootAware;
153         this.enabled = enabled;
154         this.exported = exported;
155         this.order = order;
156         this.splitName = splitName;
157         this.attributionTags = attributionTags;
158 
159         // onConstructed(); // You can define this method to get a callback
160     }
161 
162     @DataClass.Generated.Member
getProcessName()163     public @Nullable String getProcessName() {
164         return processName;
165     }
166 
167     @DataClass.Generated.Member
isDirectBootAware()168     public boolean isDirectBootAware() {
169         return directBootAware;
170     }
171 
172     @DataClass.Generated.Member
isEnabled()173     public boolean isEnabled() {
174         return enabled;
175     }
176 
177     @DataClass.Generated.Member
isExported()178     public boolean isExported() {
179         return exported;
180     }
181 
182     @DataClass.Generated.Member
getOrder()183     public int getOrder() {
184         return order;
185     }
186 
187     @DataClass.Generated.Member
getSplitName()188     public @Nullable String getSplitName() {
189         return splitName;
190     }
191 
192     @DataClass.Generated.Member
setDirectBootAware( boolean value)193     public @NonNull ParsedMainComponentImpl setDirectBootAware( boolean value) {
194         directBootAware = value;
195         return this;
196     }
197 
198     @DataClass.Generated.Member
setEnabled( boolean value)199     public @NonNull ParsedMainComponentImpl setEnabled( boolean value) {
200         enabled = value;
201         return this;
202     }
203 
204     @DataClass.Generated.Member
setExported( boolean value)205     public @NonNull ParsedMainComponentImpl setExported( boolean value) {
206         exported = value;
207         return this;
208     }
209 
210     @DataClass.Generated.Member
setOrder( int value)211     public @NonNull ParsedMainComponentImpl setOrder( int value) {
212         order = value;
213         return this;
214     }
215 
216     @DataClass.Generated.Member
setSplitName(@onNull String value)217     public @NonNull ParsedMainComponentImpl setSplitName(@NonNull String value) {
218         splitName = value;
219         return this;
220     }
221 
222     @DataClass.Generated.Member
setAttributionTags(@onNull String... value)223     public @NonNull ParsedMainComponentImpl setAttributionTags(@NonNull String... value) {
224         attributionTags = value;
225         return this;
226     }
227 
228     @DataClass.Generated(
229             time = 1701447884766L,
230             codegenVersion = "1.0.23",
231             sourceFile = "frameworks/base/core/java/com/android/internal/pm/pkg/component/ParsedMainComponentImpl.java",
232             inputSignatures = "private @android.annotation.Nullable @com.android.internal.util.DataClass.ParcelWith(com.android.internal.util.Parcelling.BuiltIn.ForInternedString.class) java.lang.String processName\nprivate  boolean directBootAware\nprivate  boolean enabled\nprivate  boolean exported\nprivate  int order\nprivate @android.annotation.Nullable java.lang.String splitName\nprivate @android.annotation.Nullable java.lang.String[] attributionTags\npublic static final  android.os.Parcelable.Creator<com.android.internal.pm.pkg.component.ParsedMainComponentImpl> CREATOR\npublic  com.android.internal.pm.pkg.component.ParsedMainComponentImpl setProcessName(java.lang.String)\npublic  java.lang.String getClassName()\npublic @android.annotation.NonNull @java.lang.Override java.lang.String[] getAttributionTags()\npublic @java.lang.Override int describeContents()\npublic @java.lang.Override void writeToParcel(android.os.Parcel,int)\nclass ParsedMainComponentImpl extends com.android.internal.pm.pkg.component.ParsedComponentImpl implements [com.android.internal.pm.pkg.component.ParsedMainComponent, android.os.Parcelable]\n@com.android.internal.util.DataClass(genGetters=true, genSetters=true, genBuilder=false, genParcelable=false)")
233     @Deprecated
__metadata()234     private void __metadata() {}
235 
236 
237     //@formatter:on
238     // End of generated code
239 
240 }
241