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 com.android.server.pm.parsing.pkg;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.content.pm.ActivityInfo;
22 import android.content.pm.ConfigurationInfo;
23 import android.content.pm.FeatureGroupInfo;
24 import android.content.pm.FeatureInfo;
25 import android.content.pm.InstrumentationInfo;
26 import android.content.pm.PackageInfo;
27 import android.content.pm.PermissionInfo;
28 import android.content.pm.ProviderInfo;
29 import android.content.pm.ServiceInfo;
30 import android.content.pm.parsing.component.ParsedActivity;
31 import android.content.pm.parsing.component.ParsedInstrumentation;
32 import android.content.pm.parsing.component.ParsedPermission;
33 import android.content.pm.parsing.component.ParsedProvider;
34 import android.content.pm.parsing.component.ParsedService;
35 
36 import com.android.internal.R;
37 
38 import java.util.List;
39 
40 /**
41  * Container for fields that are eventually exposed through {@link PackageInfo}.
42  *
43  * Done to separate the meaningless, re-directed JavaDoc for methods and to separate what's
44  * exposed vs not exposed to core.
45  *
46  * @hide
47  */
48 interface PkgPackageInfo {
49 
50     /**
51      * @see PackageInfo#overlayCategory
52      * @see R.styleable#AndroidManifestResourceOverlay_category
53      */
54     @Nullable
getOverlayCategory()55     String getOverlayCategory();
56 
57     /**
58      * @see PackageInfo#overlayPriority
59      * @see R.styleable#AndroidManifestResourceOverlay_priority
60      */
getOverlayPriority()61     int getOverlayPriority();
62 
63     /**
64      * @see PackageInfo#overlayTarget
65      * @see R.styleable#AndroidManifestResourceOverlay_targetPackage
66      */
67     @Nullable
getOverlayTarget()68     String getOverlayTarget();
69 
70     /**
71      * @see PackageInfo#targetOverlayableName
72      * @see R.styleable#AndroidManifestResourceOverlay_targetName
73      */
74     @Nullable
getOverlayTargetName()75     String getOverlayTargetName();
76 
77     /**
78      * @see PackageInfo#sharedUserId
79      * @see R.styleable#AndroidManifest_sharedUserId
80      */
81     @Deprecated
82     @Nullable
getSharedUserId()83     String getSharedUserId();
84 
85     /**
86      * @see PackageInfo#sharedUserLabel
87      * @see R.styleable#AndroidManifest_sharedUserLabel
88      */
89     @Deprecated
getSharedUserLabel()90     int getSharedUserLabel();
91 
92     /**
93      * The required account type without which this application will not function.
94      *
95      * @see PackageInfo#requiredAccountType
96      * @see R.styleable#AndroidManifestApplication_requiredAccountType
97      */
98     @Nullable
getRequiredAccountType()99     String getRequiredAccountType();
100 
101     /**
102      * The restricted account authenticator type that is used by this application
103      *
104      * @see PackageInfo#restrictedAccountType
105      * @see R.styleable#AndroidManifestApplication_restrictedAccountType
106      */
107     @Nullable
getRestrictedAccountType()108     String getRestrictedAccountType();
109 
110     /** @see PackageInfo#splitRevisionCodes */
getSplitRevisionCodes()111     int[] getSplitRevisionCodes();
112 
113     /** @see PackageInfo#getLongVersionCode() */
getLongVersionCode()114     long getLongVersionCode();
115 
116     /** @see PackageInfo#versionCode */
117     @Deprecated
getVersionCode()118     int getVersionCode();
119 
120     /** @see PackageInfo#versionCodeMajor */
getVersionCodeMajor()121     int getVersionCodeMajor();
122 
123     /** @see PackageInfo#versionName */
124     @Nullable
getVersionName()125     String getVersionName();
126 
127     /** @see PackageInfo#mOverlayIsStatic */
isOverlayIsStatic()128     boolean isOverlayIsStatic();
129 
130     /**
131      * @see PackageInfo#requiredForAllUsers
132      * @see R.styleable#AndroidManifestApplication_requiredForAllUsers
133      */
isRequiredForAllUsers()134     boolean isRequiredForAllUsers();
135 
136     /**
137      * @see PackageInfo#reqFeatures
138      * @see R.styleable#AndroidManifestUsesFeature
139      */
140     @NonNull
getReqFeatures()141     List<FeatureInfo> getReqFeatures();
142 
143     /**
144      * @see PackageInfo#configPreferences
145      * @see R.styleable#AndroidManifestUsesConfiguration
146      */
147     @NonNull
getConfigPreferences()148     List<ConfigurationInfo> getConfigPreferences();
149 
150     /**
151      * @see PackageInfo#featureGroups
152      * @see R.styleable#AndroidManifestUsesFeature
153      */
154     @NonNull
getFeatureGroups()155     List<FeatureGroupInfo> getFeatureGroups();
156 
157     /**
158      * Whether or not the package is a stub and must be replaced by the full version.
159      *
160      * @see PackageInfo#isStub
161      */
isStub()162     boolean isStub();
163 
164     /**
165      * For marking packages required for a minimal boot state, through the "coreApp" manifest
166      * attribute.
167      * @see PackageInfo#coreApp
168      */
isCoreApp()169     boolean isCoreApp();
170 
171     /**
172      * All the permissions declared. This is an effective set, and may include permissions
173      * transformed from split/migrated permissions from previous versions, so may not be exactly
174      * what the package declares in its manifest.
175      * @see PackageInfo#requestedPermissions
176      * @see R.styleable#AndroidManifestUsesPermission
177      */
178     @NonNull
getRequestedPermissions()179     List<String> getRequestedPermissions();
180 
181     /**
182      * @see ActivityInfo
183      * @see PackageInfo#activities
184      */
185     @NonNull
getActivities()186     List<ParsedActivity> getActivities();
187 
188     /**
189      * @see InstrumentationInfo
190      * @see PackageInfo#instrumentation
191      */
192     @NonNull
getInstrumentations()193     List<ParsedInstrumentation> getInstrumentations();
194 
195     /**
196      * @see PermissionInfo
197      * @see PackageInfo#permissions
198      */
199     @NonNull
getPermissions()200     List<ParsedPermission> getPermissions();
201 
202     /**
203      * @see ProviderInfo
204      * @see PackageInfo#providers
205      */
206     @NonNull
getProviders()207     List<ParsedProvider> getProviders();
208 
209     /**
210      * Since they share several attributes, receivers are parsed as {@link ParsedActivity}, even
211      * though they represent different functionality.
212      * TODO(b/135203078): Reconsider this and maybe make ParsedReceiver so it's not so confusing
213      * @see ActivityInfo
214      * @see PackageInfo#receivers
215      */
216     @NonNull
getReceivers()217     List<ParsedActivity> getReceivers();
218 
219     /**
220      * @see ServiceInfo
221      * @see PackageInfo#services
222      */
223     @NonNull
getServices()224     List<ParsedService> getServices();
225 }
226