• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.content.pm.parsing.component;
18 
19 import static android.content.pm.parsing.ParsingPackageImpl.sForInternedString;
20 
21 import android.annotation.Nullable;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 import android.text.TextUtils;
25 
26 import com.android.internal.util.DataClass;
27 import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;
28 
29 /** @hide */
30 public class ParsedMainComponent extends ParsedComponent {
31 
32     @Nullable
33     @DataClass.ParcelWith(ForInternedString.class)
34     private String processName;
35     boolean directBootAware;
36     boolean enabled = true;
37     boolean exported;
38     int order;
39 
40     @Nullable
41     String splitName;
42     @Nullable
43     String[] attributionTags;
44 
ParsedMainComponent()45     public ParsedMainComponent() {
46     }
47 
ParsedMainComponent(ParsedMainComponent other)48     public ParsedMainComponent(ParsedMainComponent other) {
49         super(other);
50         this.processName = other.processName;
51         this.directBootAware = other.directBootAware;
52         this.enabled = other.enabled;
53         this.exported = other.exported;
54         this.order = other.order;
55         this.splitName = other.splitName;
56         this.attributionTags = other.attributionTags;
57     }
58 
setProcessName(String processName)59     public ParsedMainComponent setProcessName(String processName) {
60         this.processName = TextUtils.safeIntern(processName);
61         return this;
62     }
63 
setEnabled(boolean enabled)64     public ParsedMainComponent setEnabled(boolean enabled) {
65         this.enabled = enabled;
66         return this;
67     }
68 
69     /**
70      * A main component's name is a class name. This makes code slightly more readable.
71      */
getClassName()72     public String getClassName() {
73         return getName();
74     }
75 
76     @Override
describeContents()77     public int describeContents() {
78         return 0;
79     }
80 
81     @Override
writeToParcel(Parcel dest, int flags)82     public void writeToParcel(Parcel dest, int flags) {
83         super.writeToParcel(dest, flags);
84         sForInternedString.parcel(this.processName, dest, flags);
85         dest.writeBoolean(this.directBootAware);
86         dest.writeBoolean(this.enabled);
87         dest.writeBoolean(this.exported);
88         dest.writeInt(this.order);
89         dest.writeString(this.splitName);
90         dest.writeString8Array(this.attributionTags);
91     }
92 
ParsedMainComponent(Parcel in)93     protected ParsedMainComponent(Parcel in) {
94         super(in);
95         this.processName = sForInternedString.unparcel(in);
96         this.directBootAware = in.readBoolean();
97         this.enabled = in.readBoolean();
98         this.exported = in.readBoolean();
99         this.order = in.readInt();
100         this.splitName = in.readString();
101         this.attributionTags = in.createString8Array();
102     }
103 
104     public static final Parcelable.Creator<ParsedMainComponent> CREATOR =
105             new Parcelable.Creator<ParsedMainComponent>() {
106                 @Override
107                 public ParsedMainComponent createFromParcel(Parcel source) {
108                     return new ParsedMainComponent(source);
109                 }
110 
111                 @Override
112                 public ParsedMainComponent[] newArray(int size) {
113                     return new ParsedMainComponent[size];
114                 }
115             };
116 
117     @Nullable
getProcessName()118     public String getProcessName() {
119         return processName;
120     }
121 
isDirectBootAware()122     public boolean isDirectBootAware() {
123         return directBootAware;
124     }
125 
isEnabled()126     public boolean isEnabled() {
127         return enabled;
128     }
129 
isExported()130     public boolean isExported() {
131         return exported;
132     }
133 
getOrder()134     public int getOrder() {
135         return order;
136     }
137 
138     @Nullable
getSplitName()139     public String getSplitName() {
140         return splitName;
141     }
142 
143     @Nullable
getAttributionTags()144     public String[] getAttributionTags() {
145         return attributionTags;
146     }
147 
setDirectBootAware(boolean value)148     public ParsedMainComponent setDirectBootAware(boolean value) {
149         directBootAware = value;
150         return this;
151     }
152 
setExported(boolean value)153     public ParsedMainComponent setExported(boolean value) {
154         exported = value;
155         return this;
156     }
157 
setSplitName(@ullable String value)158     public ParsedMainComponent setSplitName(@Nullable String value) {
159         splitName = value;
160         return this;
161     }
162 
setAttributionTags(@ullable String[] value)163     public ParsedMainComponent setAttributionTags(@Nullable String[] value) {
164         attributionTags = value;
165         return this;
166     }
167 }
168