• 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 com.android.server.pm.parsing.pkg;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.content.pm.ActivityInfo;
23 import android.content.pm.ApplicationInfo;
24 import android.content.pm.PackageInfo;
25 import android.content.pm.PackageParser;
26 import android.content.pm.parsing.ParsingPackage;
27 import android.content.pm.parsing.ParsingPackageImpl;
28 import android.content.pm.parsing.component.ParsedActivity;
29 import android.content.pm.parsing.component.ParsedProvider;
30 import android.content.pm.parsing.component.ParsedService;
31 import android.content.res.TypedArray;
32 import android.os.Environment;
33 import android.os.Parcel;
34 import android.os.UserHandle;
35 import android.os.storage.StorageManager;
36 import android.text.TextUtils;
37 
38 import com.android.internal.annotations.VisibleForTesting;
39 import com.android.internal.util.CollectionUtils;
40 import com.android.internal.util.DataClass;
41 import com.android.internal.util.Parcelling.BuiltIn.ForInternedString;
42 import com.android.server.pm.parsing.PackageInfoUtils;
43 
44 import java.io.File;
45 import java.util.UUID;
46 
47 /**
48  * Extensions to {@link ParsingPackageImpl} including fields/state contained in the system server
49  * and not exposed to the core SDK.
50  *
51  * Many of the fields contained here will eventually be moved inside
52  * {@link com.android.server.pm.PackageSetting} or {@link android.content.pm.PackageUserState}.
53  *
54  * @hide
55  */
56 public final class PackageImpl extends ParsingPackageImpl implements ParsedPackage, AndroidPackage {
57 
forParsing(@onNull String packageName, @NonNull String baseCodePath, @NonNull String codePath, @NonNull TypedArray manifestArray, boolean isCoreApp)58     public static PackageImpl forParsing(@NonNull String packageName, @NonNull String baseCodePath,
59             @NonNull String codePath, @NonNull TypedArray manifestArray, boolean isCoreApp) {
60         return new PackageImpl(packageName, baseCodePath, codePath, manifestArray, isCoreApp);
61     }
62 
63     /**
64      * Mock an unavailable {@link AndroidPackage} to use when
65      * removing
66      * a package from the system.
67      * This can occur if the package was installed on a storage device that has since been removed.
68      * Since the infrastructure uses {@link AndroidPackage}, but
69      * for
70      * this case only cares about
71      * volumeUuid, just fake it rather than having separate method paths.
72      */
buildFakeForDeletion(String packageName, String volumeUuid)73     public static AndroidPackage buildFakeForDeletion(String packageName, String volumeUuid) {
74         return ((ParsedPackage) PackageImpl.forTesting(packageName)
75                 .setVolumeUuid(volumeUuid)
76                 .hideAsParsed())
77                 .hideAsFinal();
78     }
79 
80     @VisibleForTesting
forTesting(String packageName)81     public static ParsingPackage forTesting(String packageName) {
82         return forTesting(packageName, "");
83     }
84 
85     @VisibleForTesting
forTesting(String packageName, String baseCodePath)86     public static ParsingPackage forTesting(String packageName, String baseCodePath) {
87         return new PackageImpl(packageName, baseCodePath, baseCodePath, null, false);
88     }
89 
90     @NonNull
91     @DataClass.ParcelWith(ForInternedString.class)
92     private final String manifestPackageName;
93 
94     @Nullable
95     @DataClass.ParcelWith(ForInternedString.class)
96     protected String nativeLibraryDir;
97 
98     @Nullable
99     @DataClass.ParcelWith(ForInternedString.class)
100     protected String nativeLibraryRootDir;
101 
102     @Nullable
103     @DataClass.ParcelWith(ForInternedString.class)
104     protected String primaryCpuAbi;
105     @Nullable
106     @DataClass.ParcelWith(ForInternedString.class)
107     protected String secondaryCpuAbi;
108     @Nullable
109     @DataClass.ParcelWith(ForInternedString.class)
110     protected String secondaryNativeLibraryDir;
111 
112     @Nullable
113     @DataClass.ParcelWith(ForInternedString.class)
114     protected String seInfo;
115     @Nullable
116     @DataClass.ParcelWith(ForInternedString.class)
117     protected String seInfoUser;
118 
119     /**
120      * This is an appId, the uid if the userId is == USER_SYSTEM
121      */
122     private int uid = -1;
123 
124     // This is kept around as a boolean to avoid flag calculation
125     // during ApplicationInfo generation.
126     private boolean nativeLibraryRootRequiresIsa;
127 
128     private int mBooleans;
129 
130     /**
131      * @see ParsingPackageImpl.Booleans
132      */
133     private static class Booleans {
134         @IntDef({
135                 CORE_APP,
136                 SYSTEM,
137                 FACTORY_TEST,
138                 SYSTEM_EXT,
139                 PRIVILEGED,
140                 OEM,
141                 VENDOR,
142                 PRODUCT,
143                 ODM,
144                 SIGNED_WITH_PLATFORM_KEY,
145                 NATIVE_LIBRARY_ROOT_REQUIRES_ISA,
146                 STUB,
147         })
148         public @interface Flags {}
149 
150         private static final int CORE_APP = 1;
151         private static final int SYSTEM = 1 << 1;
152         private static final int FACTORY_TEST = 1 << 2;
153         private static final int SYSTEM_EXT = 1 << 3;
154         private static final int PRIVILEGED = 1 << 4;
155         private static final int OEM = 1 << 5;
156         private static final int VENDOR = 1 << 6;
157         private static final int PRODUCT = 1 << 7;
158         private static final int ODM = 1 << 8;
159         private static final int SIGNED_WITH_PLATFORM_KEY = 1 << 9;
160         private static final int NATIVE_LIBRARY_ROOT_REQUIRES_ISA = 1 << 10;
161         private static final int STUB = 1 << 11;
162     }
163 
setBoolean(@ooleans.Flags int flag, boolean value)164     private ParsedPackage setBoolean(@Booleans.Flags int flag, boolean value) {
165         if (value) {
166             mBooleans |= flag;
167         } else {
168             mBooleans &= ~flag;
169         }
170         return this;
171     }
172 
getBoolean(@ooleans.Flags int flag)173     private boolean getBoolean(@Booleans.Flags int flag) {
174         return (mBooleans & flag) != 0;
175     }
176 
177     // Derived fields
178     private int mBaseAppInfoFlags;
179     private int mBaseAppInfoPrivateFlags;
180     private int mBaseAppInfoPrivateFlagsExt;
181     private String mBaseAppDataCredentialProtectedDirForSystemUser;
182     private String mBaseAppDataDeviceProtectedDirForSystemUser;
183 
184     @VisibleForTesting
PackageImpl(@onNull String packageName, @NonNull String baseApkPath, @NonNull String path, @Nullable TypedArray manifestArray, boolean isCoreApp)185     public PackageImpl(@NonNull String packageName, @NonNull String baseApkPath,
186             @NonNull String path, @Nullable TypedArray manifestArray, boolean isCoreApp) {
187         super(packageName, baseApkPath, path, manifestArray);
188         this.manifestPackageName = this.packageName;
189         setBoolean(Booleans.CORE_APP, isCoreApp);
190     }
191 
192     @Override
hideAsParsed()193     public ParsedPackage hideAsParsed() {
194         super.hideAsParsed();
195         return this;
196     }
197 
198     @Override
hideAsFinal()199     public AndroidPackage hideAsFinal() {
200         // TODO(b/135203078): Lock as immutable
201         assignDerivedFields();
202         return this;
203     }
204 
assignDerivedFields()205     private void assignDerivedFields() {
206         mBaseAppInfoFlags = PackageInfoUtils.appInfoFlags(this, null);
207         mBaseAppInfoPrivateFlags = PackageInfoUtils.appInfoPrivateFlags(this, null);
208         mBaseAppInfoPrivateFlagsExt = PackageInfoUtils.appInfoPrivateFlagsExt(this, null);
209         String baseAppDataDir = Environment.getDataDirectoryPath(getVolumeUuid()) + File.separator;
210         String systemUserSuffix = File.separator + UserHandle.USER_SYSTEM + File.separator;
211         mBaseAppDataCredentialProtectedDirForSystemUser = TextUtils.safeIntern(
212                 baseAppDataDir + Environment.DIR_USER_CE + systemUserSuffix);
213         mBaseAppDataDeviceProtectedDirForSystemUser = TextUtils.safeIntern(
214                 baseAppDataDir + Environment.DIR_USER_DE + systemUserSuffix);
215     }
216 
217     @Override
getLongVersionCode()218     public long getLongVersionCode() {
219         return PackageInfo.composeLongVersionCode(versionCodeMajor, versionCode);
220     }
221 
222     @Override
removePermission(int index)223     public PackageImpl removePermission(int index) {
224         this.permissions.remove(index);
225         return this;
226     }
227 
228     @Override
addUsesOptionalLibrary(int index, String libraryName)229     public PackageImpl addUsesOptionalLibrary(int index, String libraryName) {
230         this.usesOptionalLibraries = CollectionUtils.add(usesOptionalLibraries, index,
231                 TextUtils.safeIntern(libraryName));
232         return this;
233     }
234 
235     @Override
addUsesLibrary(int index, String libraryName)236     public PackageImpl addUsesLibrary(int index, String libraryName) {
237         this.usesLibraries = CollectionUtils.add(usesLibraries, index,
238                 TextUtils.safeIntern(libraryName));
239         return this;
240     }
241 
242     @Override
removeUsesLibrary(String libraryName)243     public PackageImpl removeUsesLibrary(String libraryName) {
244         this.usesLibraries = CollectionUtils.remove(this.usesLibraries, libraryName);
245         return this;
246     }
247 
248     @Override
removeUsesOptionalLibrary(String libraryName)249     public PackageImpl removeUsesOptionalLibrary(String libraryName) {
250         super.removeUsesOptionalLibrary(libraryName);
251         return this;
252     }
253 
254     @Override
setSigningDetails(@ullable PackageParser.SigningDetails value)255     public PackageImpl setSigningDetails(@Nullable PackageParser.SigningDetails value) {
256         super.setSigningDetails(value);
257         return this;
258     }
259 
260     @Override
setRestrictUpdateHash(@ullable byte... value)261     public PackageImpl setRestrictUpdateHash(@Nullable byte... value) {
262         super.setRestrictUpdateHash(value);
263         return this;
264     }
265 
266     @Override
setRealPackage(@ullable String realPackage)267     public PackageImpl setRealPackage(@Nullable String realPackage) {
268         super.setRealPackage(realPackage);
269         return this;
270     }
271 
272     @Override
setPersistent(boolean value)273     public PackageImpl setPersistent(boolean value) {
274         super.setPersistent(value);
275         return this;
276     }
277 
278     @Override
setDefaultToDeviceProtectedStorage(boolean value)279     public PackageImpl setDefaultToDeviceProtectedStorage(boolean value) {
280         super.setDefaultToDeviceProtectedStorage(value);
281         return this;
282     }
283 
284     @Override
setDirectBootAware(boolean value)285     public PackageImpl setDirectBootAware(boolean value) {
286         super.setDirectBootAware(value);
287         return this;
288     }
289 
290     @Override
clearProtectedBroadcasts()291     public PackageImpl clearProtectedBroadcasts() {
292         protectedBroadcasts.clear();
293         return this;
294     }
295 
296     @Override
clearOriginalPackages()297     public PackageImpl clearOriginalPackages() {
298         originalPackages.clear();
299         return this;
300     }
301 
302     @Override
clearAdoptPermissions()303     public PackageImpl clearAdoptPermissions() {
304         adoptPermissions.clear();
305         return this;
306     }
307 
308     @Override
setCodePath(@onNull String value)309     public PackageImpl setCodePath(@NonNull String value) {
310         this.mPath = value;
311         return this;
312     }
313 
314     // TODO(b/135203078): Move PackageManagerService#renameStaticSharedLibraryPackage
315     //  into initial package parsing
316     @Override
setPackageName(@onNull String packageName)317     public PackageImpl setPackageName(@NonNull String packageName) {
318         this.packageName = TextUtils.safeIntern(packageName);
319 
320         int permissionsSize = permissions.size();
321         for (int index = 0; index < permissionsSize; index++) {
322             permissions.get(index).setPackageName(this.packageName);
323         }
324 
325         int permissionGroupsSize = permissionGroups.size();
326         for (int index = 0; index < permissionGroupsSize; index++) {
327             permissionGroups.get(index).setPackageName(this.packageName);
328         }
329 
330         int activitiesSize = activities.size();
331         for (int index = 0; index < activitiesSize; index++) {
332             activities.get(index).setPackageName(this.packageName);
333         }
334 
335         int receiversSize = receivers.size();
336         for (int index = 0; index < receiversSize; index++) {
337             receivers.get(index).setPackageName(this.packageName);
338         }
339 
340         int providersSize = providers.size();
341         for (int index = 0; index < providersSize; index++) {
342             providers.get(index).setPackageName(this.packageName);
343         }
344 
345         int servicesSize = services.size();
346         for (int index = 0; index < servicesSize; index++) {
347             services.get(index).setPackageName(this.packageName);
348         }
349 
350         int instrumentationsSize = instrumentations.size();
351         for (int index = 0; index < instrumentationsSize; index++) {
352             instrumentations.get(index).setPackageName(this.packageName);
353         }
354 
355         return this;
356     }
357 
358     @Override
setAllComponentsDirectBootAware(boolean allComponentsDirectBootAware)359     public PackageImpl setAllComponentsDirectBootAware(boolean allComponentsDirectBootAware) {
360         int activitiesSize = activities.size();
361         for (int index = 0; index < activitiesSize; index++) {
362             activities.get(index).setDirectBootAware(allComponentsDirectBootAware);
363         }
364 
365         int receiversSize = receivers.size();
366         for (int index = 0; index < receiversSize; index++) {
367             receivers.get(index).setDirectBootAware(allComponentsDirectBootAware);
368         }
369 
370         int providersSize = providers.size();
371         for (int index = 0; index < providersSize; index++) {
372             providers.get(index).setDirectBootAware(allComponentsDirectBootAware);
373         }
374 
375         int servicesSize = services.size();
376         for (int index = 0; index < servicesSize; index++) {
377             services.get(index).setDirectBootAware(allComponentsDirectBootAware);
378         }
379 
380         return this;
381     }
382 
383     @Override
setBaseCodePath(@onNull String baseCodePath)384     public PackageImpl setBaseCodePath(@NonNull String baseCodePath) {
385         this.mBaseApkPath = TextUtils.safeIntern(baseCodePath);
386         return this;
387     }
388 
389     @Override
setNativeLibraryDir(@ullable String nativeLibraryDir)390     public PackageImpl setNativeLibraryDir(@Nullable String nativeLibraryDir) {
391         this.nativeLibraryDir = TextUtils.safeIntern(nativeLibraryDir);
392         return this;
393     }
394 
395     @Override
setNativeLibraryRootDir(@ullable String nativeLibraryRootDir)396     public PackageImpl setNativeLibraryRootDir(@Nullable String nativeLibraryRootDir) {
397         this.nativeLibraryRootDir = TextUtils.safeIntern(nativeLibraryRootDir);
398         return this;
399     }
400 
401     @Override
setPrimaryCpuAbi(@ullable String primaryCpuAbi)402     public PackageImpl setPrimaryCpuAbi(@Nullable String primaryCpuAbi) {
403         this.primaryCpuAbi = TextUtils.safeIntern(primaryCpuAbi);
404         return this;
405     }
406 
407     @Override
setSecondaryCpuAbi(@ullable String secondaryCpuAbi)408     public PackageImpl setSecondaryCpuAbi(@Nullable String secondaryCpuAbi) {
409         this.secondaryCpuAbi = TextUtils.safeIntern(secondaryCpuAbi);
410         return this;
411     }
412 
413     @Override
setSecondaryNativeLibraryDir(@ullable String secondaryNativeLibraryDir)414     public PackageImpl setSecondaryNativeLibraryDir(@Nullable String secondaryNativeLibraryDir) {
415         this.secondaryNativeLibraryDir = TextUtils.safeIntern(secondaryNativeLibraryDir);
416         return this;
417     }
418 
419     @Override
setSeInfo(@ullable String seInfo)420     public PackageImpl setSeInfo(@Nullable String seInfo) {
421         this.seInfo = TextUtils.safeIntern(seInfo);
422         return this;
423     }
424 
425     @Override
setSeInfoUser(@ullable String seInfoUser)426     public PackageImpl setSeInfoUser(@Nullable String seInfoUser) {
427         this.seInfoUser = TextUtils.safeIntern(seInfoUser);
428         return this;
429     }
430 
431     @Override
setSplitCodePaths(@ullable String[] splitCodePaths)432     public PackageImpl setSplitCodePaths(@Nullable String[] splitCodePaths) {
433         this.splitCodePaths = splitCodePaths;
434         if (splitCodePaths != null) {
435             int size = splitCodePaths.length;
436             for (int index = 0; index < size; index++) {
437                 this.splitCodePaths[index] = TextUtils.safeIntern(this.splitCodePaths[index]);
438             }
439         }
440         return this;
441     }
442 
443     @Override
capPermissionPriorities()444     public PackageImpl capPermissionPriorities() {
445         int size = permissionGroups.size();
446         for (int index = size - 1; index >= 0; --index) {
447             // TODO(b/135203078): Builder/immutability
448             permissionGroups.get(index).setPriority(0);
449         }
450         return this;
451     }
452 
453     @Override
markNotActivitiesAsNotExportedIfSingleUser()454     public PackageImpl markNotActivitiesAsNotExportedIfSingleUser() {
455         // ignore export request for single user receivers
456         int receiversSize = receivers.size();
457         for (int index = 0; index < receiversSize; index++) {
458             ParsedActivity receiver = receivers.get(index);
459             if ((receiver.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) {
460                 receiver.setExported(false);
461             }
462         }
463 
464         // ignore export request for single user services
465         int servicesSize = services.size();
466         for (int index = 0; index < servicesSize; index++) {
467             ParsedService service = services.get(index);
468             if ((service.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) {
469                 service.setExported(false);
470             }
471         }
472 
473         // ignore export request for single user providers
474         int providersSize = providers.size();
475         for (int index = 0; index < providersSize; index++) {
476             ParsedProvider provider = providers.get(index);
477             if ((provider.getFlags() & ActivityInfo.FLAG_SINGLE_USER) != 0) {
478                 provider.setExported(false);
479             }
480         }
481 
482         return this;
483     }
484 
485     @Override
getStorageUuid()486     public UUID getStorageUuid() {
487         return StorageManager.convert(volumeUuid);
488     }
489 
490     @Deprecated
491     @Override
toAppInfoToString()492     public String toAppInfoToString() {
493         return "PackageImpl{"
494                 + Integer.toHexString(System.identityHashCode(this))
495                 + " " + getPackageName() + "}";
496     }
497 
498     @Override
setCoreApp(boolean coreApp)499     public ParsedPackage setCoreApp(boolean coreApp) {
500         return setBoolean(Booleans.CORE_APP, coreApp);
501     }
502 
503     @Override
setVersionCode(int versionCode)504     public ParsedPackage setVersionCode(int versionCode) {
505         this.versionCode = versionCode;
506         return this;
507     }
508 
509     @Override
setVersionCodeMajor(int versionCodeMajor)510     public ParsedPackage setVersionCodeMajor(int versionCodeMajor) {
511         this.versionCodeMajor = versionCodeMajor;
512         return this;
513     }
514 
515     @Override
toAppInfoWithoutState()516     public ApplicationInfo toAppInfoWithoutState() {
517         ApplicationInfo appInfo = super.toAppInfoWithoutStateWithoutFlags();
518         appInfo.flags = mBaseAppInfoFlags;
519         appInfo.privateFlags = mBaseAppInfoPrivateFlags;
520         appInfo.privateFlagsExt = mBaseAppInfoPrivateFlagsExt;
521         appInfo.nativeLibraryDir = nativeLibraryDir;
522         appInfo.nativeLibraryRootDir = nativeLibraryRootDir;
523         appInfo.nativeLibraryRootRequiresIsa = nativeLibraryRootRequiresIsa;
524         appInfo.primaryCpuAbi = primaryCpuAbi;
525         appInfo.secondaryCpuAbi = secondaryCpuAbi;
526         appInfo.secondaryNativeLibraryDir = secondaryNativeLibraryDir;
527         appInfo.seInfo = seInfo;
528         appInfo.seInfoUser = seInfoUser;
529         appInfo.uid = uid;
530         return appInfo;
531     }
532 
533     @Override
describeContents()534     public int describeContents() {
535         return 0;
536     }
537 
538     @Override
writeToParcel(Parcel dest, int flags)539     public void writeToParcel(Parcel dest, int flags) {
540         super.writeToParcel(dest, flags);
541         sForInternedString.parcel(this.manifestPackageName, dest, flags);
542         dest.writeString(this.nativeLibraryDir);
543         dest.writeString(this.nativeLibraryRootDir);
544         dest.writeBoolean(this.nativeLibraryRootRequiresIsa);
545         sForInternedString.parcel(this.primaryCpuAbi, dest, flags);
546         sForInternedString.parcel(this.secondaryCpuAbi, dest, flags);
547         dest.writeString(this.secondaryNativeLibraryDir);
548         dest.writeString(this.seInfo);
549         dest.writeString(this.seInfoUser);
550         dest.writeInt(this.uid);
551         dest.writeInt(this.mBooleans);
552     }
553 
PackageImpl(Parcel in)554     public PackageImpl(Parcel in) {
555         super(in);
556         this.manifestPackageName = sForInternedString.unparcel(in);
557         this.nativeLibraryDir = in.readString();
558         this.nativeLibraryRootDir = in.readString();
559         this.nativeLibraryRootRequiresIsa = in.readBoolean();
560         this.primaryCpuAbi = sForInternedString.unparcel(in);
561         this.secondaryCpuAbi = sForInternedString.unparcel(in);
562         this.secondaryNativeLibraryDir = in.readString();
563         this.seInfo = in.readString();
564         this.seInfoUser = in.readString();
565         this.uid = in.readInt();
566         this.mBooleans = in.readInt();
567 
568         assignDerivedFields();
569     }
570 
571     public static final Creator<PackageImpl> CREATOR = new Creator<PackageImpl>() {
572         @Override
573         public PackageImpl createFromParcel(Parcel source) {
574             return new PackageImpl(source);
575         }
576 
577         @Override
578         public PackageImpl[] newArray(int size) {
579             return new PackageImpl[size];
580         }
581     };
582 
583     @NonNull
584     @Override
getManifestPackageName()585     public String getManifestPackageName() {
586         return manifestPackageName;
587     }
588 
isStub()589     public boolean isStub() {
590         return getBoolean(Booleans.STUB);
591     }
592 
593     @Nullable
594     @Override
getNativeLibraryDir()595     public String getNativeLibraryDir() {
596         return nativeLibraryDir;
597     }
598 
599     @Nullable
600     @Override
getNativeLibraryRootDir()601     public String getNativeLibraryRootDir() {
602         return nativeLibraryRootDir;
603     }
604 
605     @Override
isNativeLibraryRootRequiresIsa()606     public boolean isNativeLibraryRootRequiresIsa() {
607         return nativeLibraryRootRequiresIsa;
608     }
609 
610     @Nullable
611     @Override
getPrimaryCpuAbi()612     public String getPrimaryCpuAbi() {
613         return primaryCpuAbi;
614     }
615 
616     @Nullable
617     @Override
getSecondaryCpuAbi()618     public String getSecondaryCpuAbi() {
619         return secondaryCpuAbi;
620     }
621 
622     @Nullable
623     @Override
getSecondaryNativeLibraryDir()624     public String getSecondaryNativeLibraryDir() {
625         return secondaryNativeLibraryDir;
626     }
627 
628     @Nullable
629     @Override
getSeInfo()630     public String getSeInfo() {
631         return seInfo;
632     }
633 
634     @Nullable
635     @Override
getSeInfoUser()636     public String getSeInfoUser() {
637         return seInfoUser;
638     }
639 
640     @Override
isCoreApp()641     public boolean isCoreApp() {
642         return getBoolean(Booleans.CORE_APP);
643     }
644 
645     @Override
isSystem()646     public boolean isSystem() {
647         return getBoolean(Booleans.SYSTEM);
648     }
649 
650     @Override
isFactoryTest()651     public boolean isFactoryTest() {
652         return getBoolean(Booleans.FACTORY_TEST);
653     }
654 
655     @Override
isSystemExt()656     public boolean isSystemExt() {
657         return getBoolean(Booleans.SYSTEM_EXT);
658     }
659 
660     @Override
isPrivileged()661     public boolean isPrivileged() {
662         return getBoolean(Booleans.PRIVILEGED);
663     }
664 
665     @Override
isOem()666     public boolean isOem() {
667         return getBoolean(Booleans.OEM);
668     }
669 
670     @Override
isVendor()671     public boolean isVendor() {
672         return getBoolean(Booleans.VENDOR);
673     }
674 
675     @Override
isProduct()676     public boolean isProduct() {
677         return getBoolean(Booleans.PRODUCT);
678     }
679 
680     @Override
isOdm()681     public boolean isOdm() {
682         return getBoolean(Booleans.ODM);
683     }
684 
685     @Override
isSignedWithPlatformKey()686     public boolean isSignedWithPlatformKey() {
687         return getBoolean(Booleans.SIGNED_WITH_PLATFORM_KEY);
688     }
689 
690     /**
691      * This is an appId, the uid if the userId is == USER_SYSTEM
692      */
693     @Override
getUid()694     public int getUid() {
695         return uid;
696     }
697 
698     @DataClass.Generated.Member
setStub(boolean value)699     public PackageImpl setStub(boolean value) {
700         setBoolean(Booleans.STUB, value);
701         return this;
702     }
703 
704     @Override
setNativeLibraryRootRequiresIsa(boolean value)705     public PackageImpl setNativeLibraryRootRequiresIsa(boolean value) {
706         nativeLibraryRootRequiresIsa = value;
707         return this;
708     }
709 
710     @Override
setSystem(boolean value)711     public PackageImpl setSystem(boolean value) {
712         setBoolean(Booleans.SYSTEM, value);
713         return this;
714     }
715 
716     @Override
setFactoryTest(boolean value)717     public PackageImpl setFactoryTest(boolean value) {
718         setBoolean(Booleans.FACTORY_TEST, value);
719         return this;
720     }
721 
722     @Override
setSystemExt(boolean value)723     public PackageImpl setSystemExt(boolean value) {
724         setBoolean(Booleans.SYSTEM_EXT, value);
725         return this;
726     }
727 
728     @Override
setPrivileged(boolean value)729     public PackageImpl setPrivileged(boolean value) {
730         setBoolean(Booleans.PRIVILEGED, value);
731         return this;
732     }
733 
734     @Override
setOem(boolean value)735     public PackageImpl setOem(boolean value) {
736         setBoolean(Booleans.OEM, value);
737         return this;
738     }
739 
740     @Override
setVendor(boolean value)741     public PackageImpl setVendor(boolean value) {
742         setBoolean(Booleans.VENDOR, value);
743         return this;
744     }
745 
746     @Override
setProduct(boolean value)747     public PackageImpl setProduct(boolean value) {
748         setBoolean(Booleans.PRODUCT, value);
749         return this;
750     }
751 
752     @Override
setOdm(boolean value)753     public PackageImpl setOdm(boolean value) {
754         setBoolean(Booleans.ODM, value);
755         return this;
756     }
757 
758     @Override
setSignedWithPlatformKey(boolean value)759     public PackageImpl setSignedWithPlatformKey(boolean value) {
760         setBoolean(Booleans.SIGNED_WITH_PLATFORM_KEY, value);
761         return this;
762     }
763 
764     @Override
setUid(int value)765     public PackageImpl setUid(int value) {
766         uid = value;
767         return this;
768     }
769 
770     // The following methods are explicitly not inside any interface. These are hidden under
771     // PackageImpl which is only accessible to the system server. This is to prevent/discourage
772     // usage of these fields outside of the utility classes.
getBaseAppDataCredentialProtectedDirForSystemUser()773     public String getBaseAppDataCredentialProtectedDirForSystemUser() {
774         return mBaseAppDataCredentialProtectedDirForSystemUser;
775     }
776 
getBaseAppDataDeviceProtectedDirForSystemUser()777     public String getBaseAppDataDeviceProtectedDirForSystemUser() {
778         return mBaseAppDataDeviceProtectedDirForSystemUser;
779     }
780 }
781