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