1 /*
2  * Copyright (C) 2011 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;
18 
19 import static android.app.admin.flags.Flags.crossUserSuspensionEnabledRo;
20 import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE;
21 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
22 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
23 import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
24 
25 import android.annotation.IntDef;
26 import android.annotation.NonNull;
27 import android.annotation.Nullable;
28 import android.annotation.UserIdInt;
29 import android.content.ComponentName;
30 import android.content.pm.ApplicationInfo;
31 import android.content.pm.PackageManager;
32 import android.content.pm.SharedLibraryInfo;
33 import android.content.pm.SigningDetails;
34 import android.content.pm.SigningInfo;
35 import android.content.pm.UserInfo;
36 import android.content.pm.UserPackage;
37 import android.content.pm.overlay.OverlayPaths;
38 import android.os.UserHandle;
39 import android.os.incremental.IncrementalManager;
40 import android.service.pm.PackageProto;
41 import android.service.pm.PackageProto.UserInfoProto.ArchiveState.ArchiveActivityInfo;
42 import android.text.TextUtils;
43 import android.util.ArrayMap;
44 import android.util.ArraySet;
45 import android.util.SparseArray;
46 import android.util.proto.ProtoOutputStream;
47 
48 import com.android.internal.annotations.VisibleForTesting;
49 import com.android.internal.pm.parsing.pkg.AndroidPackageInternal;
50 import com.android.internal.util.CollectionUtils;
51 import com.android.internal.util.DataClass;
52 import com.android.server.pm.parsing.pkg.AndroidPackageUtils;
53 import com.android.server.pm.permission.LegacyPermissionDataProvider;
54 import com.android.server.pm.permission.LegacyPermissionState;
55 import com.android.server.pm.pkg.AndroidPackage;
56 import com.android.server.pm.pkg.ArchiveState;
57 import com.android.server.pm.pkg.PackageState;
58 import com.android.server.pm.pkg.PackageStateInternal;
59 import com.android.server.pm.pkg.PackageStateUnserialized;
60 import com.android.server.pm.pkg.PackageUserState;
61 import com.android.server.pm.pkg.PackageUserStateImpl;
62 import com.android.server.pm.pkg.PackageUserStateInternal;
63 import com.android.server.pm.pkg.SharedLibrary;
64 import com.android.server.pm.pkg.SharedLibraryWrapper;
65 import com.android.server.pm.pkg.SuspendParams;
66 import com.android.server.utils.SnapshotCache;
67 import com.android.server.utils.WatchedArraySet;
68 
69 import libcore.util.EmptyArray;
70 
71 import java.io.File;
72 import java.util.ArrayList;
73 import java.util.Arrays;
74 import java.util.Collection;
75 import java.util.Collections;
76 import java.util.LinkedHashSet;
77 import java.util.List;
78 import java.util.Map;
79 import java.util.Objects;
80 import java.util.Set;
81 import java.util.UUID;
82 
83 /**
84  * Settings data for a particular package we know about.
85  *
86  * @hide
87  */
88 @DataClass(genGetters = true, genConstructor = false, genSetters = false, genBuilder = false)
89 @DataClass.Suppress({"getSnapshot", "getBooleans"})
90 public class PackageSetting extends SettingBase implements PackageStateInternal {
91 
92     // Use a bitset to store boolean data to save memory
93     private static class Booleans {
94         @IntDef({
95                 INSTALL_PERMISSION_FIXED,
96                 UPDATE_AVAILABLE,
97                 FORCE_QUERYABLE_OVERRIDE,
98                 SCANNED_AS_STOPPED_SYSTEM_APP,
99                 PENDING_RESTORE,
100         })
101         public @interface Flags {
102         }
103         private static final int INSTALL_PERMISSION_FIXED = 1;
104         private static final int UPDATE_AVAILABLE = 1 << 1;
105         private static final int FORCE_QUERYABLE_OVERRIDE = 1 << 2;
106         private static final int SCANNED_AS_STOPPED_SYSTEM_APP = 1 << 3;
107         private static final int PENDING_RESTORE = 1 << 4;
108     }
109     private int mBooleans;
110 
setBoolean(@ooleans.Flags int flag, boolean value)111     private void setBoolean(@Booleans.Flags int flag, boolean value) {
112         if (value) {
113             mBooleans |= flag;
114         } else {
115             mBooleans &= ~flag;
116         }
117     }
118 
getBoolean(@ooleans.Flags int flag)119     private boolean getBoolean(@Booleans.Flags int flag) {
120         return (mBooleans & flag) != 0;
121     }
122 
123     /**
124      * The shared user ID lets us link this object to {@link SharedUserSetting}.
125      */
126     private int mSharedUserAppId;
127 
128     @Nullable
129     private Map<String, Set<String>> mimeGroups;
130 
131     // TODO(b/314036181): encapsulate all these fields for usesSdk, instead of having three
132     //  separate arrays.
133     @Nullable
134     private String[] usesSdkLibraries;
135 
136     @Nullable
137     private long[] usesSdkLibrariesVersionsMajor;
138     @Nullable
139     private boolean[] usesSdkLibrariesOptional;
140 
141     @Nullable
142     private String[] usesStaticLibraries;
143 
144     @Nullable
145     private long[] usesStaticLibrariesVersions;
146 
147     /**
148      * The path under which native libraries have been unpacked. This path is
149      * always derived at runtime, and is only stored here for cleanup when a
150      * package is uninstalled.
151      */
152     @Nullable
153     @Deprecated
154     private String legacyNativeLibraryPath;
155 
156     @NonNull
157     private String mName;
158 
159     @Nullable
160     private String mRealName;
161 
162     private int mAppId;
163 
164     /**
165      * It is expected that all code that uses a {@link PackageSetting} understands this inner field
166      * may be null. Note that this relationship only works one way. It should not be possible to
167      * have an entry inside {@link PackageManagerService#mPackages} without a corresponding
168      * {@link PackageSetting} inside {@link Settings#mPackages}.
169      *
170      * @see PackageState#getAndroidPackage()
171      */
172     @Nullable
173     private AndroidPackageInternal pkg;
174 
175     /** @see AndroidPackage#getPath() */
176     @NonNull
177     private File mPath;
178     @NonNull
179     private String mPathString;
180     @Nullable
181     private LinkedHashSet<File> mOldPaths;
182 
183     private float mLoadingProgress;
184     private long mLoadingCompletedTime;
185 
186     @Nullable
187     private String mPrimaryCpuAbi;
188 
189     @Nullable
190     private String mSecondaryCpuAbi;
191 
192     @Nullable
193     private String mCpuAbiOverride;
194 
195     private long mLastModifiedTime;
196     private long lastUpdateTime;
197     private long versionCode;
198 
199     @NonNull
200     private PackageSignatures signatures;
201 
202     @NonNull
203     private PackageKeySetData keySetData = new PackageKeySetData();
204 
205     // TODO: Access is not locked.
206     @NonNull
207     private final SparseArray<PackageUserStateImpl> mUserStates = new SparseArray<>();
208 
209     @NonNull
210     private InstallSource installSource;
211 
212     /** @see PackageState#getVolumeUuid() */
213     @Nullable
214     private String volumeUuid;
215 
216     /** @see PackageState#getCategoryOverride() */
217     private int categoryOverride = ApplicationInfo.CATEGORY_UNDEFINED;
218 
219     @NonNull
220     private final PackageStateUnserialized pkgState = new PackageStateUnserialized(this);
221 
222     @NonNull
223     private UUID mDomainSetId;
224 
225     @Nullable
226     private String mAppMetadataFilePath;
227 
228     private int mAppMetadataSource = PackageManager.APP_METADATA_SOURCE_UNKNOWN;
229 
230     private int mTargetSdkVersion;
231 
232     @Nullable
233     private byte[] mRestrictUpdateHash;
234 
235     /**
236      * Snapshot support.
237      */
238     @NonNull
239     private final SnapshotCache<PackageSetting> mSnapshot;
240 
makeCache()241     private SnapshotCache<PackageSetting> makeCache() {
242         return new SnapshotCache<PackageSetting>(this, this) {
243             @Override
244             public PackageSetting createSnapshot() {
245                 return new PackageSetting(mSource, true);
246             }};
247     }
248 
249     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
250     public PackageSetting(@NonNull String name, @Nullable String realName, @NonNull File path,
251                           int pkgFlags, int pkgPrivateFlags, @NonNull UUID domainSetId) {
252         super(pkgFlags, pkgPrivateFlags);
253         this.mName = name;
254         this.mRealName = realName;
255         this.mPath = path;
256         this.mPathString = path.toString();
257         this.signatures = new PackageSignatures();
258         this.installSource = InstallSource.EMPTY;
259         this.mDomainSetId = domainSetId;
260         mSnapshot = makeCache();
261     }
262 
263     /**
264      * New instance of PackageSetting replicating the original settings.
265      * Note that it keeps the same PackageParser.Package instance.
266      */
267     PackageSetting(PackageSetting orig) {
268         this(orig, false);
269     }
270 
271     /**
272      * New instance of PackageSetting with one-level-deep cloning.
273      * <p>
274      * IMPORTANT: With a shallow copy, we do NOT create new contained objects.
275      * This means, for example, changes to the user state of the original PackageSetting
276      * will also change the user state in its copy.
277      */
278     PackageSetting(PackageSetting base, String realPkgName) {
279         this(base, false);
280         this.mRealName = realPkgName;
281     }
282 
283     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
284     public PackageSetting(@NonNull PackageSetting original, boolean sealedSnapshot)  {
285         super(original);
286         copyPackageSetting(original, sealedSnapshot);
287         if (sealedSnapshot) {
288             mSnapshot = new SnapshotCache.Sealed();
289         } else {
290             mSnapshot = makeCache();
291         }
292     }
293 
294     /**
295      * Return the package snapshot.
296      */
297     public PackageSetting snapshot() {
298         return mSnapshot.snapshot();
299     }
300 
301     public void dumpDebug(ProtoOutputStream proto, long fieldId, List<UserInfo> users,
302             LegacyPermissionDataProvider dataProvider) {
303         final long packageToken = proto.start(fieldId);
304         proto.write(PackageProto.NAME, (mRealName != null ? mRealName : mName));
305         proto.write(PackageProto.UID, mAppId);
306         proto.write(PackageProto.VERSION_CODE, versionCode);
307         proto.write(PackageProto.UPDATE_TIME_MS, lastUpdateTime);
308         proto.write(PackageProto.INSTALLER_NAME, installSource.mInstallerPackageName);
309 
310         if (pkg != null) {
311             proto.write(PackageProto.VERSION_STRING, pkg.getVersionName());
312 
313             long splitToken = proto.start(PackageProto.SPLITS);
314             proto.write(PackageProto.SplitProto.NAME, "base");
315             proto.write(PackageProto.SplitProto.REVISION_CODE, pkg.getBaseRevisionCode());
316             proto.end(splitToken);
317 
318             for (int i = 0; i < pkg.getSplitNames().length; i++) {
319                 splitToken = proto.start(PackageProto.SPLITS);
320                 proto.write(PackageProto.SplitProto.NAME, pkg.getSplitNames()[i]);
321                 proto.write(PackageProto.SplitProto.REVISION_CODE,
322                         pkg.getSplitRevisionCodes()[i]);
323                 proto.end(splitToken);
324             }
325 
326             long sourceToken = proto.start(PackageProto.INSTALL_SOURCE);
327             proto.write(PackageProto.InstallSourceProto.INITIATING_PACKAGE_NAME,
328                     installSource.mInitiatingPackageName);
329             proto.write(PackageProto.InstallSourceProto.ORIGINATING_PACKAGE_NAME,
330                     installSource.mOriginatingPackageName);
331             proto.write(PackageProto.InstallSourceProto.UPDATE_OWNER_PACKAGE_NAME,
332                     installSource.mUpdateOwnerPackageName);
333             proto.end(sourceToken);
334         }
335         proto.write(PackageProto.StatesProto.IS_LOADING, isLoading());
336         writeUsersInfoToProto(proto, PackageProto.USERS);
337         writePackageUserPermissionsProto(proto, PackageProto.USER_PERMISSIONS, users, dataProvider);
338         proto.end(packageToken);
339     }
340 
341     public PackageSetting setAppId(int appId) {
342         this.mAppId = appId;
343         onChanged();
344         return this;
345     }
346 
347     public PackageSetting setCpuAbiOverride(String cpuAbiOverrideString) {
348         this.mCpuAbiOverride = cpuAbiOverrideString;
349         onChanged();
350         return this;
351     }
352 
353     /**
354      * In case of replacing an old package, restore the first install timestamps if it was installed
355      * for the same users
356      */
357     public PackageSetting setFirstInstallTimeFromReplaced(PackageStateInternal replacedPkgSetting,
358             int[] userIds) {
359         for (int userId = 0; userId < userIds.length; userId++) {
360             final long previousFirstInstallTime =
361                     replacedPkgSetting.getUserStateOrDefault(userId).getFirstInstallTimeMillis();
362             if (previousFirstInstallTime != 0) {
363                 modifyUserState(userId).setFirstInstallTimeMillis(previousFirstInstallTime);
364             }
365         }
366         onChanged();
367         return this;
368     }
369 
370     /**
371      * Set the time for the first time when an app is installed for a user. If userId specifies all
372      * users, set the same timestamp for all the users.
373      */
374     public PackageSetting setFirstInstallTime(long firstInstallTime, int userId) {
375         if (userId == UserHandle.USER_ALL) {
376             int userStateCount = mUserStates.size();
377             for (int i = 0; i < userStateCount; i++) {
378                 mUserStates.valueAt(i).setFirstInstallTimeMillis(firstInstallTime);
379             }
380         } else {
381             modifyUserState(userId).setFirstInstallTimeMillis(firstInstallTime);
382         }
383         onChanged();
384         return this;
385     }
386 
387     public PackageSetting setForceQueryableOverride(boolean forceQueryableOverride) {
388         setBoolean(Booleans.FORCE_QUERYABLE_OVERRIDE, forceQueryableOverride);
389         onChanged();
390         return this;
391     }
392 
393     public PackageSetting setInstallerPackage(@Nullable String installerPackageName,
394             int installerPackageUid) {
395         installSource = installSource.setInstallerPackage(installerPackageName,
396                 installerPackageUid);
397         onChanged();
398         return this;
399     }
400 
401     public PackageSetting setUpdateOwnerPackage(@Nullable String updateOwnerPackageName) {
402         installSource = installSource.setUpdateOwnerPackageName(updateOwnerPackageName);
403         onChanged();
404         return this;
405     }
406 
407     public PackageSetting setInstallSource(InstallSource installSource) {
408         this.installSource = Objects.requireNonNull(installSource);
409         onChanged();
410         return this;
411     }
412 
413     PackageSetting removeInstallerPackage(@Nullable String packageName) {
414         installSource = installSource.removeInstallerPackage(packageName);
415         onChanged();
416         return this;
417     }
418 
419     public PackageSetting setIsOrphaned(boolean isOrphaned) {
420         installSource = installSource.setIsOrphaned(isOrphaned);
421         onChanged();
422         return this;
423     }
424 
425     public PackageSetting setKeySetData(PackageKeySetData keySetData) {
426         this.keySetData = keySetData;
427         onChanged();
428         return this;
429     }
430 
431     public PackageSetting setLastModifiedTime(long timeStamp) {
432         this.mLastModifiedTime = timeStamp;
433         onChanged();
434         return this;
435     }
436 
437     public PackageSetting setLastUpdateTime(long lastUpdateTime) {
438         this.lastUpdateTime = lastUpdateTime;
439         onChanged();
440         return this;
441     }
442 
443     public PackageSetting setLongVersionCode(long versionCode) {
444         this.versionCode = versionCode;
445         onChanged();
446         return this;
447     }
448 
449     public boolean setMimeGroup(String mimeGroup, ArraySet<String> newMimeTypes) {
450         Set<String> oldMimeTypes = mimeGroups == null ? null : mimeGroups.get(mimeGroup);
451         if (oldMimeTypes == null) {
452             throw new IllegalArgumentException("Unknown MIME group " + mimeGroup
453                     + " for package " + mName);
454         }
455 
456         boolean hasChanges = !newMimeTypes.equals(oldMimeTypes);
457         mimeGroups.put(mimeGroup, newMimeTypes);
458         if (hasChanges) {
459             onChanged();
460         }
461         return hasChanges;
462     }
463 
464     // TODO: Remove, only commit package when it's actually finalized
465     public PackageSetting setPkg(AndroidPackage pkg) {
466         this.pkg = (AndroidPackageInternal) pkg;
467         onChanged();
468         return this;
469     }
470 
471     /**
472      * Notify {@link #onChanged()}  if the parameter {@code usesLibraryFiles} is different from
473      * {@link #getUsesLibraryFiles()}.
474      *
475      * @param usesLibraryFiles the new uses library files
476      * @return {@code this}
477      */
478     public PackageSetting setPkgStateLibraryFiles(@NonNull Collection<String> usesLibraryFiles) {
479         final Collection<String> oldUsesLibraryFiles = getUsesLibraryFiles();
480         if (oldUsesLibraryFiles.size() != usesLibraryFiles.size()
481                 || !oldUsesLibraryFiles.containsAll(usesLibraryFiles)) {
482             pkgState.setUsesLibraryFiles(new ArrayList<>(usesLibraryFiles));
483             onChanged();
484         }
485         return this;
486     }
487 
488     public PackageSetting setPrimaryCpuAbi(String primaryCpuAbiString) {
489         this.mPrimaryCpuAbi = primaryCpuAbiString;
490         onChanged();
491         return this;
492     }
493 
494     public PackageSetting setSecondaryCpuAbi(String secondaryCpuAbiString) {
495         this.mSecondaryCpuAbi = secondaryCpuAbiString;
496         onChanged();
497         return this;
498     }
499 
500     public PackageSetting setSignatures(PackageSignatures signatures) {
501         this.signatures = signatures;
502         onChanged();
503         return this;
504     }
505 
506     public PackageSetting setVolumeUuid(String volumeUuid) {
507         this.volumeUuid = volumeUuid;
508         onChanged();
509         return this;
510     }
511 
512     @Override
513     public boolean isExternalStorage() {
514         return (getFlags() & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0;
515     }
516 
517     public PackageSetting setUpdateAvailable(boolean updateAvailable) {
518         setBoolean(Booleans.UPDATE_AVAILABLE, updateAvailable);
519         onChanged();
520         return this;
521     }
522 
523     public PackageSetting setSharedUserAppId(int sharedUserAppId) {
524         mSharedUserAppId = sharedUserAppId;
525         onChanged();
526         return this;
527     }
528 
529     public PackageSetting setTargetSdkVersion(int targetSdkVersion) {
530         mTargetSdkVersion = targetSdkVersion;
531         onChanged();
532         return this;
533     }
534 
535     public PackageSetting setRestrictUpdateHash(byte[] restrictUpdateHash) {
536         mRestrictUpdateHash = restrictUpdateHash;
537         onChanged();
538         return this;
539     }
540 
541     @Override
542     public int getSharedUserAppId() {
543         return mSharedUserAppId;
544     }
545 
546     @Override
547     public boolean hasSharedUser() {
548         return mSharedUserAppId > 0;
549     }
550 
551     /**
552      * @see PackageState#isPendingRestore()
553      */
554     public PackageSetting setPendingRestore(boolean value) {
555         setBoolean(Booleans.PENDING_RESTORE, value);
556         onChanged();
557         return this;
558     }
559 
560     @Override
561     public boolean isPendingRestore() {
562         return getBoolean(Booleans.PENDING_RESTORE);
563     }
564 
565     @Override
566     public String toString() {
567         return "PackageSetting{"
568                 + Integer.toHexString(System.identityHashCode(this))
569                 + " " + mName + "/" + mAppId + "}";
570     }
571 
572     private void copyMimeGroups(@Nullable Map<String, Set<String>> newMimeGroups) {
573         if (newMimeGroups == null) {
574             mimeGroups = null;
575             return;
576         }
577 
578         mimeGroups = new ArrayMap<>(newMimeGroups.size());
579         for (String mimeGroup : newMimeGroups.keySet()) {
580             Set<String> mimeTypes = newMimeGroups.get(mimeGroup);
581 
582             if (mimeTypes != null) {
583                 mimeGroups.put(mimeGroup, new ArraySet<>(mimeTypes));
584             } else {
585                 mimeGroups.put(mimeGroup, new ArraySet<>());
586             }
587         }
588     }
589 
590     /** Updates all fields in the current setting from another. */
591     public void updateFrom(PackageSetting other) {
592         copyPackageSetting(other, false /* sealedSnapshot */);
593 
594         Set<String> mimeGroupNames = other.mimeGroups != null ? other.mimeGroups.keySet() : null;
595         updateMimeGroups(mimeGroupNames);
596 
597         onChanged();
598     }
599 
600     /**
601      * Updates declared MIME groups, removing no longer declared groups
602      * and keeping previous state of MIME groups
603      */
604     PackageSetting updateMimeGroups(@Nullable Set<String> newMimeGroupNames) {
605         if (newMimeGroupNames == null) {
606             mimeGroups = null;
607             return this;
608         }
609 
610         if (mimeGroups == null) {
611             // set mimeGroups to empty map to avoid repeated null-checks in the next loop
612             mimeGroups = Collections.emptyMap();
613         }
614 
615         ArrayMap<String, Set<String>> updatedMimeGroups =
616                 new ArrayMap<>(newMimeGroupNames.size());
617 
618         for (String mimeGroup : newMimeGroupNames) {
619             if (mimeGroups.containsKey(mimeGroup)) {
620                 updatedMimeGroups.put(mimeGroup, mimeGroups.get(mimeGroup));
621             } else {
622                 updatedMimeGroups.put(mimeGroup, new ArraySet<>());
623             }
624         }
625         onChanged();
626         mimeGroups = updatedMimeGroups;
627         return this;
628     }
629 
630     @Deprecated
631     @Override
632     public LegacyPermissionState getLegacyPermissionState() {
633         return super.getLegacyPermissionState();
634     }
635 
636     public PackageSetting setInstallPermissionsFixed(boolean installPermissionsFixed) {
637         setBoolean(Booleans.INSTALL_PERMISSION_FIXED, installPermissionsFixed);
638         return this;
639     }
640 
641     public boolean isPrivileged() {
642         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_PRIVILEGED) != 0;
643     }
644 
645     public boolean isOem() {
646         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_OEM) != 0;
647     }
648 
649     public boolean isVendor() {
650         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_VENDOR) != 0;
651     }
652 
653     public boolean isProduct() {
654         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_PRODUCT) != 0;
655     }
656 
657     @Override
658     public boolean isRequiredForSystemUser() {
659         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_REQUIRED_FOR_SYSTEM_USER) != 0;
660     }
661 
662     public boolean isSystemExt() {
663         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_SYSTEM_EXT) != 0;
664     }
665 
666     public boolean isOdm() {
667         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_ODM) != 0;
668     }
669 
670     public boolean isSystem() {
671         return (getFlags() & ApplicationInfo.FLAG_SYSTEM) != 0;
672     }
673 
674     public boolean isRequestLegacyExternalStorage() {
675         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_REQUEST_LEGACY_EXTERNAL_STORAGE)
676                 != 0;
677     }
678 
679     public boolean isUserDataFragile() {
680         return (getPrivateFlags() & ApplicationInfo.PRIVATE_FLAG_HAS_FRAGILE_USER_DATA)
681                 != 0;
682     }
683 
684     public SigningDetails getSigningDetails() {
685         return signatures.mSigningDetails;
686     }
687 
688     public PackageSetting setSigningDetails(SigningDetails signingDetails) {
689         // TODO: Immutability
690         signatures.mSigningDetails = signingDetails;
691         onChanged();
692         return this;
693     }
694 
695     public void copyPackageSetting(PackageSetting other, boolean sealedSnapshot) {
696         super.copySettingBase(other);
697         mBooleans = other.mBooleans;
698         mSharedUserAppId = other.mSharedUserAppId;
699         mLoadingProgress = other.mLoadingProgress;
700         mLoadingCompletedTime = other.mLoadingCompletedTime;
701         legacyNativeLibraryPath = other.legacyNativeLibraryPath;
702         mName = other.mName;
703         mRealName = other.mRealName;
704         mAppId = other.mAppId;
705         pkg = other.pkg;
706         mPath = other.mPath;
707         mPathString = other.mPathString;
708         mOldPaths = other.mOldPaths == null ? null : new LinkedHashSet<>(other.mOldPaths);
709         mPrimaryCpuAbi = other.mPrimaryCpuAbi;
710         mSecondaryCpuAbi = other.mSecondaryCpuAbi;
711         mCpuAbiOverride = other.mCpuAbiOverride;
712         mLastModifiedTime = other.mLastModifiedTime;
713         lastUpdateTime = other.lastUpdateTime;
714         versionCode = other.versionCode;
715         signatures = other.signatures;
716         keySetData = new PackageKeySetData(other.keySetData);
717         installSource = other.installSource;
718         volumeUuid = other.volumeUuid;
719         categoryOverride = other.categoryOverride;
720         mDomainSetId = other.mDomainSetId;
721         mAppMetadataFilePath = other.mAppMetadataFilePath;
722         mAppMetadataSource = other.mAppMetadataSource;
723         mTargetSdkVersion = other.mTargetSdkVersion;
724         mRestrictUpdateHash = other.mRestrictUpdateHash == null
725                 ? null : other.mRestrictUpdateHash.clone();
726 
727         usesSdkLibraries = other.usesSdkLibraries != null
728                 ? Arrays.copyOf(other.usesSdkLibraries,
729                 other.usesSdkLibraries.length) : null;
730         usesSdkLibrariesVersionsMajor = other.usesSdkLibrariesVersionsMajor != null
731                 ? Arrays.copyOf(other.usesSdkLibrariesVersionsMajor,
732                 other.usesSdkLibrariesVersionsMajor.length) : null;
733         usesSdkLibrariesOptional = other.usesSdkLibrariesOptional != null
734                 ? Arrays.copyOf(other.usesSdkLibrariesOptional,
735                 other.usesSdkLibrariesOptional.length) : null;
736 
737         usesStaticLibraries = other.usesStaticLibraries != null
738                 ? Arrays.copyOf(other.usesStaticLibraries,
739                 other.usesStaticLibraries.length) : null;
740         usesStaticLibrariesVersions = other.usesStaticLibrariesVersions != null
741                 ? Arrays.copyOf(other.usesStaticLibrariesVersions,
742                 other.usesStaticLibrariesVersions.length) : null;
743         mUserStates.clear();
744         for (int i = 0; i < other.mUserStates.size(); i++) {
745             if (sealedSnapshot) {
746                 mUserStates.put(other.mUserStates.keyAt(i),
747                         other.mUserStates.valueAt(i).snapshot());
748             } else {
749                 var userState = other.mUserStates.valueAt(i);
750                 userState.setWatchable(this);
751                 mUserStates.put(other.mUserStates.keyAt(i), userState);
752             }
753         }
754 
755         copyMimeGroups(other.mimeGroups);
756         pkgState.updateFrom(other.pkgState);
757         onChanged();
758     }
759 
760     @VisibleForTesting
761     PackageUserStateImpl modifyUserState(int userId) {
762         PackageUserStateImpl state = mUserStates.get(userId);
763         if (state == null) {
764             state = new PackageUserStateImpl(this);
765             mUserStates.put(userId, state);
766             onChanged();
767         }
768         return state;
769     }
770 
771     public PackageUserStateImpl getOrCreateUserState(@UserIdInt int userId) {
772         PackageUserStateImpl state = mUserStates.get(userId);
773         if (state == null) {
774             state = new PackageUserStateImpl(this);
775             mUserStates.put(userId, state);
776         }
777         return state;
778     }
779 
780     @NonNull
781     public PackageUserStateInternal readUserState(int userId) {
782         PackageUserStateInternal state = mUserStates.get(userId);
783         if (state == null) {
784             return PackageUserStateInternal.DEFAULT;
785         }
786         return state;
787     }
788 
789     void setEnabled(int state, int userId, String callingPackage) {
790         modifyUserState(userId)
791                 .setEnabledState(state)
792                 .setLastDisableAppCaller(callingPackage);
793         onChanged();
794     }
795 
796     int getEnabled(int userId) {
797         return readUserState(userId).getEnabledState();
798     }
799 
800     void setInstalled(boolean inst, int userId) {
801         modifyUserState(userId).setInstalled(inst);
802         onChanged();
803     }
804 
805     void setArchiveState(ArchiveState archiveState, int userId) {
806         modifyUserState(userId).setArchiveState(archiveState);
807         onChanged();
808     }
809 
810     boolean getInstalled(int userId) {
811         return readUserState(userId).isInstalled();
812     }
813 
814     boolean isArchived(int userId) {
815         return PackageArchiver.isArchived(readUserState(userId));
816     }
817 
818     int getInstallReason(int userId) {
819         return readUserState(userId).getInstallReason();
820     }
821 
822     void setInstallReason(int installReason, int userId) {
823         modifyUserState(userId).setInstallReason(installReason);
824         onChanged();
825     }
826 
827     int getUninstallReason(int userId) {
828         return readUserState(userId).getUninstallReason();
829     }
830 
831     void setUninstallReason(@PackageManager.UninstallReason int uninstallReason, int userId) {
832         modifyUserState(userId).setUninstallReason(uninstallReason);
833         onChanged();
834     }
835 
836     @NonNull
837     OverlayPaths getOverlayPaths(int userId) {
838         return readUserState(userId).getOverlayPaths();
839     }
840 
841     boolean setOverlayPathsForLibrary(String libName, OverlayPaths overlayPaths, int userId) {
842         boolean changed = modifyUserState(userId)
843                 .setSharedLibraryOverlayPaths(libName, overlayPaths);
844         onChanged();
845         return changed;
846     }
847 
848     boolean isInstalledOnAnyOtherUser(int[] allUsers, int currentUser) {
849         for (int user: allUsers) {
850             if (user == currentUser) {
851                 continue;
852             }
853             final PackageUserStateInternal userState = readUserState(user);
854             if (userState.isInstalled()) {
855                 return true;
856             }
857         }
858         return false;
859     }
860 
861     boolean hasDataOnAnyOtherUser(int[] allUsers, int currentUser) {
862         for (int user: allUsers) {
863             if (user == currentUser) {
864                 continue;
865             }
866             final PackageUserStateInternal userState = readUserState(user);
867             if (userState.dataExists()) {
868                 return true;
869             }
870         }
871         return false;
872     }
873 
874     int[] queryInstalledUsers(int[] users, boolean installed) {
875         int num = 0;
876         for (int user : users) {
877             if (getInstalled(user) == installed) {
878                 num++;
879             }
880         }
881         int[] res = new int[num];
882         num = 0;
883         for (int user : users) {
884             if (getInstalled(user) == installed) {
885                 res[num] = user;
886                 num++;
887             }
888         }
889         return res;
890     }
891 
892     int[] queryUsersInstalledOrHasData(int[] users) {
893         int num = 0;
894         for (int user : users) {
895             if (getInstalled(user) || readUserState(user).dataExists()) {
896                 num++;
897             }
898         }
899         int[] res = new int[num];
900         num = 0;
901         for (int user : users) {
902             if (getInstalled(user) || readUserState(user).dataExists()) {
903                 res[num] = user;
904                 num++;
905             }
906         }
907         return res;
908     }
909 
910     long getCeDataInode(int userId) {
911         return readUserState(userId).getCeDataInode();
912     }
913 
914     long getDeDataInode(int userId) {
915         return readUserState(userId).getDeDataInode();
916     }
917 
918     void setCeDataInode(long ceDataInode, int userId) {
919         modifyUserState(userId).setCeDataInode(ceDataInode);
920         onChanged();
921     }
922 
923     void setDeDataInode(long deDataInode, int userId) {
924         modifyUserState(userId).setDeDataInode(deDataInode);
925         onChanged();
926     }
927 
928     boolean getStopped(int userId) {
929         return readUserState(userId).isStopped();
930     }
931 
932     void setStopped(boolean stop, int userId) {
933         modifyUserState(userId).setStopped(stop);
934         onChanged();
935     }
936 
937     public PackageSetting setScannedAsStoppedSystemApp(boolean stop) {
938         setBoolean(Booleans.SCANNED_AS_STOPPED_SYSTEM_APP, stop);
939         onChanged();
940         return this;
941     }
942 
943     boolean getNotLaunched(int userId) {
944         return readUserState(userId).isNotLaunched();
945     }
946 
947     void setNotLaunched(boolean stop, int userId) {
948         modifyUserState(userId).setNotLaunched(stop);
949         onChanged();
950     }
951 
952     boolean getHidden(int userId) {
953         return readUserState(userId).isHidden();
954     }
955 
956     void setHidden(boolean hidden, int userId) {
957         modifyUserState(userId).setHidden(hidden);
958         onChanged();
959     }
960 
961     int getDistractionFlags(int userId) {
962         return readUserState(userId).getDistractionFlags();
963     }
964 
965     void setDistractionFlags(int distractionFlags, int userId) {
966         modifyUserState(userId).setDistractionFlags(distractionFlags);
967         onChanged();
968     }
969 
970     public boolean getInstantApp(int userId) {
971         return readUserState(userId).isInstantApp();
972     }
973 
974     void setInstantApp(boolean instantApp, int userId) {
975         modifyUserState(userId).setInstantApp(instantApp);
976         onChanged();
977     }
978 
979     boolean getVirtualPreload(int userId) {
980         return readUserState(userId).isVirtualPreload();
981     }
982 
983     void setVirtualPreload(boolean virtualPreload, int userId) {
984         modifyUserState(userId).setVirtualPreload(virtualPreload);
985         onChanged();
986     }
987 
988     void setUserState(int userId, long ceDataInode, long deDataInode, int enabled,
989                       boolean installed, boolean stopped, boolean notLaunched, boolean hidden,
990                       int distractionFlags, ArrayMap<UserPackage, SuspendParams> suspendParams,
991                       boolean instantApp, boolean virtualPreload, String lastDisableAppCaller,
992                       ArraySet<String> enabledComponents, ArraySet<String> disabledComponents,
993                       int installReason, int uninstallReason,
994                       String harmfulAppWarning, String splashScreenTheme,
995                       long firstInstallTime, int aspectRatio, ArchiveState archiveState) {
996         modifyUserState(userId)
997                 .setSuspendParams(suspendParams)
998                 .setCeDataInode(ceDataInode)
999                 .setDeDataInode(deDataInode)
1000                 .setEnabledState(enabled)
1001                 .setInstalled(installed)
1002                 .setStopped(stopped)
1003                 .setNotLaunched(notLaunched)
1004                 .setHidden(hidden)
1005                 .setDistractionFlags(distractionFlags)
1006                 .setLastDisableAppCaller(lastDisableAppCaller)
1007                 .setEnabledComponents(enabledComponents)
1008                 .setDisabledComponents(disabledComponents)
1009                 .setInstallReason(installReason)
1010                 .setUninstallReason(uninstallReason)
1011                 .setInstantApp(instantApp)
1012                 .setVirtualPreload(virtualPreload)
1013                 .setHarmfulAppWarning(harmfulAppWarning)
1014                 .setSplashScreenTheme(splashScreenTheme)
1015                 .setFirstInstallTimeMillis(firstInstallTime)
1016                 .setMinAspectRatio(aspectRatio)
1017                 .setArchiveState(archiveState);
1018         onChanged();
1019     }
1020 
1021     void setUserState(int userId, PackageUserStateInternal otherState) {
1022         setUserState(userId, otherState.getCeDataInode(), otherState.getDeDataInode(),
1023                 otherState.getEnabledState(), otherState.isInstalled(), otherState.isStopped(),
1024                 otherState.isNotLaunched(), otherState.isHidden(), otherState.getDistractionFlags(),
1025                 otherState.getSuspendParams() == null
1026                         ? null : otherState.getSuspendParams().untrackedStorage(),
1027                 otherState.isInstantApp(), otherState.isVirtualPreload(),
1028                 otherState.getLastDisableAppCaller(),
1029                 otherState.getEnabledComponentsNoCopy() == null
1030                         ? null : otherState.getEnabledComponentsNoCopy().untrackedStorage(),
1031                 otherState.getDisabledComponentsNoCopy() == null
1032                         ? null : otherState.getDisabledComponentsNoCopy().untrackedStorage(),
1033                 otherState.getInstallReason(), otherState.getUninstallReason(),
1034                 otherState.getHarmfulAppWarning(), otherState.getSplashScreenTheme(),
1035                 otherState.getFirstInstallTimeMillis(), otherState.getMinAspectRatio(),
1036                 otherState.getArchiveState());
1037     }
1038 
1039     WatchedArraySet<String> getEnabledComponents(int userId) {
1040         return readUserState(userId).getEnabledComponentsNoCopy();
1041     }
1042 
1043     WatchedArraySet<String> getDisabledComponents(int userId) {
1044         return readUserState(userId).getDisabledComponentsNoCopy();
1045     }
1046 
1047     /** Test only */
1048     void setEnabledComponents(WatchedArraySet<String> components, int userId) {
1049         modifyUserState(userId).setEnabledComponents(components);
1050         onChanged();
1051     }
1052 
1053     /** Test only */
1054     void setDisabledComponents(WatchedArraySet<String> components, int userId) {
1055         modifyUserState(userId).setDisabledComponents(components);
1056         onChanged();
1057     }
1058 
1059     void setEnabledComponentsCopy(WatchedArraySet<String> components, int userId) {
1060         modifyUserState(userId).setEnabledComponents(components != null
1061                 ? components.untrackedStorage() : null);
1062         onChanged();
1063     }
1064 
1065     void setDisabledComponentsCopy(WatchedArraySet<String> components, int userId) {
1066         modifyUserState(userId).setDisabledComponents(components != null
1067                 ? components.untrackedStorage() : null);
1068         onChanged();
1069     }
1070 
1071     PackageUserStateImpl modifyUserStateComponents(int userId, boolean disabled,
1072             boolean enabled) {
1073         PackageUserStateImpl state = modifyUserState(userId);
1074         boolean changed = false;
1075         if (disabled && state.getDisabledComponentsNoCopy() == null) {
1076             state.setDisabledComponents(new ArraySet<String>(1));
1077             changed = true;
1078         }
1079         if (enabled && state.getEnabledComponentsNoCopy() == null) {
1080             state.setEnabledComponents(new ArraySet<String>(1));
1081             changed = true;
1082         }
1083         if (changed) {
1084             onChanged();
1085         }
1086         return state;
1087     }
1088 
1089     void addDisabledComponent(String componentClassName, int userId) {
1090         modifyUserStateComponents(userId, true, false)
1091                 .getDisabledComponentsNoCopy().add(componentClassName);
1092         onChanged();
1093     }
1094 
1095     void addEnabledComponent(String componentClassName, int userId) {
1096         modifyUserStateComponents(userId, false, true)
1097                 .getEnabledComponentsNoCopy().add(componentClassName);
1098         onChanged();
1099     }
1100 
1101     boolean enableComponentLPw(String componentClassName, int userId) {
1102         PackageUserStateImpl state = modifyUserStateComponents(userId, false, true);
1103         boolean changed = state.getDisabledComponentsNoCopy() != null
1104                 ? state.getDisabledComponentsNoCopy().remove(componentClassName) : false;
1105         changed |= state.getEnabledComponentsNoCopy().add(componentClassName);
1106         if (changed) {
1107             onChanged();
1108         }
1109         return changed;
1110     }
1111 
1112     boolean disableComponentLPw(String componentClassName, int userId) {
1113         PackageUserStateImpl state = modifyUserStateComponents(userId, true, false);
1114         boolean changed = state.getEnabledComponentsNoCopy() != null
1115                 ? state.getEnabledComponentsNoCopy().remove(componentClassName) : false;
1116         changed |= state.getDisabledComponentsNoCopy().add(componentClassName);
1117         if (changed) {
1118             onChanged();
1119         }
1120         return changed;
1121     }
1122 
1123     boolean restoreComponentLPw(String componentClassName, int userId) {
1124         PackageUserStateImpl state = modifyUserStateComponents(userId, true, true);
1125         boolean changed = state.getDisabledComponentsNoCopy() != null
1126                 ? state.getDisabledComponentsNoCopy().remove(componentClassName) : false;
1127         changed |= state.getEnabledComponentsNoCopy() != null
1128                 ? state.getEnabledComponentsNoCopy().remove(componentClassName) : false;
1129         if (changed) {
1130             onChanged();
1131         }
1132         return changed;
1133     }
1134 
1135     void restoreComponentSettings(int userId) {
1136         PackageUserStateImpl state = modifyUserStateComponents(userId, true, true);
1137         WatchedArraySet<String> enabledComponents = state.getEnabledComponentsNoCopy();
1138         WatchedArraySet<String> disabledComponents = state.getDisabledComponentsNoCopy();
1139 
1140         boolean changed = false;
1141         for (int i = enabledComponents.size() - 1; i >= 0; i--) {
1142             if (!AndroidPackageUtils.hasComponentClassName(pkg, enabledComponents.valueAt(i))) {
1143                 enabledComponents.removeAt(i);
1144                 changed = true;
1145             }
1146         }
1147         for (int i = disabledComponents.size() - 1; i >= 0; i--) {
1148             if (!AndroidPackageUtils.hasComponentClassName(pkg, disabledComponents.valueAt(i))) {
1149                 disabledComponents.removeAt(i);
1150                 changed = true;
1151             }
1152         }
1153         if (changed) {
1154             onChanged();
1155         }
1156     }
1157 
1158     int getCurrentEnabledStateLPr(String componentName, int userId) {
1159         PackageUserStateInternal state = readUserState(userId);
1160         if (state.getEnabledComponentsNoCopy() != null
1161                 && state.getEnabledComponentsNoCopy().contains(componentName)) {
1162             return COMPONENT_ENABLED_STATE_ENABLED;
1163         } else if (state.getDisabledComponentsNoCopy() != null
1164                 && state.getDisabledComponentsNoCopy().contains(componentName)) {
1165             return COMPONENT_ENABLED_STATE_DISABLED;
1166         } else {
1167             return COMPONENT_ENABLED_STATE_DEFAULT;
1168         }
1169     }
1170 
1171     void removeUser(int userId) {
1172         mUserStates.delete(userId);
1173         onChanged();
1174     }
1175 
1176     public int[] getNotInstalledUserIds() {
1177         int count = 0;
1178         int userStateCount = mUserStates.size();
1179         for (int i = 0; i < userStateCount; i++) {
1180             if (!mUserStates.valueAt(i).isInstalled()) {
1181                 count++;
1182             }
1183         }
1184         if (count == 0) {
1185             return EmptyArray.INT;
1186         }
1187 
1188         int[] excludedUserIds = new int[count];
1189         int idx = 0;
1190         for (int i = 0; i < userStateCount; i++) {
1191             if (!mUserStates.valueAt(i).isInstalled()) {
1192                 excludedUserIds[idx++] = mUserStates.keyAt(i);
1193             }
1194         }
1195         return excludedUserIds;
1196     }
1197 
1198     /**
1199      * TODO (b/170263003) refactor to dump to permissiongr proto Dumps the permissions that are
1200      * granted to users for this package.
1201      */
1202     void writePackageUserPermissionsProto(ProtoOutputStream proto, long fieldId,
1203             List<UserInfo> users, LegacyPermissionDataProvider dataProvider) {
1204         Collection<LegacyPermissionState.PermissionState> runtimePermissionStates;
1205         for (UserInfo user : users) {
1206             final long permissionsToken = proto.start(PackageProto.USER_PERMISSIONS);
1207             proto.write(PackageProto.UserPermissionsProto.ID, user.id);
1208 
1209             runtimePermissionStates = dataProvider.getLegacyPermissionState(mAppId)
1210                     .getPermissionStates(user.id);
1211             for (LegacyPermissionState.PermissionState permission : runtimePermissionStates) {
1212                 if (permission.isGranted()) {
1213                     proto.write(PackageProto.UserPermissionsProto.GRANTED_PERMISSIONS,
1214                             permission.getName());
1215                 }
1216             }
1217             proto.end(permissionsToken);
1218         }
1219     }
1220 
1221     protected void writeUsersInfoToProto(ProtoOutputStream proto, long fieldId) {
1222         int count = mUserStates.size();
1223         for (int i = 0; i < count; i++) {
1224             final long userToken = proto.start(fieldId);
1225             final int userId = mUserStates.keyAt(i);
1226             final PackageUserStateInternal state = mUserStates.valueAt(i);
1227             proto.write(PackageProto.UserInfoProto.ID, userId);
1228             final int installType;
1229             if (state.isInstantApp()) {
1230                 installType = PackageProto.UserInfoProto.INSTANT_APP_INSTALL;
1231             } else if (state.isInstalled()) {
1232                 installType = PackageProto.UserInfoProto.FULL_APP_INSTALL;
1233             } else {
1234                 installType = PackageProto.UserInfoProto.NOT_INSTALLED_FOR_USER;
1235             }
1236             proto.write(PackageProto.UserInfoProto.INSTALL_TYPE, installType);
1237             proto.write(PackageProto.UserInfoProto.IS_HIDDEN, state.isHidden());
1238             proto.write(PackageProto.UserInfoProto.DISTRACTION_FLAGS, state.getDistractionFlags());
1239             proto.write(PackageProto.UserInfoProto.IS_SUSPENDED, state.isSuspended());
1240             if (state.isSuspended()) {
1241                 for (int j = 0; j < state.getSuspendParams().size(); j++) {
1242                     proto.write(PackageProto.UserInfoProto.SUSPENDING_PACKAGE,
1243                             state.getSuspendParams().keyAt(j).packageName);
1244                     if (crossUserSuspensionEnabledRo()) {
1245                         proto.write(PackageProto.UserInfoProto.SUSPENDING_USER,
1246                                 state.getSuspendParams().keyAt(j).userId);
1247                     }
1248                 }
1249             }
1250             proto.write(PackageProto.UserInfoProto.IS_STOPPED, state.isStopped());
1251             proto.write(PackageProto.UserInfoProto.IS_LAUNCHED, !state.isNotLaunched());
1252             proto.write(PackageProto.UserInfoProto.ENABLED_STATE, state.getEnabledState());
1253             proto.write(
1254                     PackageProto.UserInfoProto.LAST_DISABLED_APP_CALLER,
1255                     state.getLastDisableAppCaller());
1256             proto.write(PackageProto.UserInfoProto.FIRST_INSTALL_TIME_MS,
1257                     state.getFirstInstallTimeMillis());
1258             writeArchiveState(proto, state.getArchiveState());
1259             proto.end(userToken);
1260         }
1261     }
1262 
1263     private static void writeArchiveState(ProtoOutputStream proto, ArchiveState archiveState) {
1264         if (archiveState == null) {
1265             return;
1266         }
1267         long archiveStateToken = proto.start(PackageProto.UserInfoProto.ARCHIVE_STATE);
1268         for (ArchiveState.ArchiveActivityInfo activityInfo : archiveState.getActivityInfos()) {
1269             long activityInfoToken = proto.start(
1270                     PackageProto.UserInfoProto.ArchiveState.ACTIVITY_INFOS);
1271             proto.write(ArchiveActivityInfo.TITLE, activityInfo.getTitle());
1272             proto.write(
1273                     ArchiveActivityInfo.ORIGINAL_COMPONENT_NAME,
1274                     activityInfo.getOriginalComponentName().flattenToString());
1275             if (activityInfo.getIconBitmap() != null) {
1276                 proto.write(ArchiveActivityInfo.ICON_BITMAP_PATH,
1277                         activityInfo.getIconBitmap().toAbsolutePath().toString());
1278             }
1279             if (activityInfo.getMonochromeIconBitmap() != null) {
1280                 proto.write(ArchiveActivityInfo.MONOCHROME_ICON_BITMAP_PATH,
1281                         activityInfo.getMonochromeIconBitmap().toAbsolutePath().toString());
1282             }
1283             proto.end(activityInfoToken);
1284         }
1285 
1286         proto.write(PackageProto.UserInfoProto.ArchiveState.INSTALLER_TITLE,
1287                 archiveState.getInstallerTitle());
1288         proto.end(archiveStateToken);
1289     }
1290 
1291     /**
1292      * @see #mPath
1293      */
1294     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
1295     public PackageSetting setPath(@NonNull File path) {
1296         this.mPath = path;
1297         this.mPathString = path.toString();
1298         onChanged();
1299         return this;
1300     }
1301 
1302     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
1303     public PackageSetting addOldPath(@NonNull File path) {
1304         if (mOldPaths == null) {
1305             mOldPaths = new LinkedHashSet<>();
1306         }
1307         mOldPaths.add(path);
1308         onChanged();
1309         return this;
1310     }
1311 
1312     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
1313     public PackageSetting removeOldPath(@Nullable File path) {
1314         if (path == null || mOldPaths == null) {
1315             return this;
1316         }
1317         if (mOldPaths.remove(path)) {
1318             onChanged();
1319         }
1320         return this;
1321     }
1322 
1323     /**
1324      * @param userId the specific user to change the label/icon for
1325      * @see PackageUserStateImpl#overrideLabelAndIcon(ComponentName, String, Integer)
1326      */
1327     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
1328     public boolean overrideNonLocalizedLabelAndIcon(@NonNull ComponentName component,
1329             @Nullable String label, @Nullable Integer icon, @UserIdInt int userId) {
1330         boolean changed = modifyUserState(userId).overrideLabelAndIcon(component, label, icon);
1331         onChanged();
1332         return changed;
1333     }
1334 
1335     /**
1336      * @param userId the specific user to reset
1337      * @see PackageUserStateImpl#resetOverrideComponentLabelIcon()
1338      */
1339     public void resetOverrideComponentLabelIcon(@UserIdInt int userId) {
1340         modifyUserState(userId).resetOverrideComponentLabelIcon();
1341         onChanged();
1342     }
1343 
1344     /**
1345      * @param userId the specified user to get the theme setting from
1346      * @return the theme name previously persisted for the user or null if no splashscreen theme is
1347      * persisted.
1348      * @see android.window.SplashScreen#setSplashScreenTheme(int)
1349      */
1350     @Nullable
1351     public String getSplashScreenTheme(@UserIdInt int userId) {
1352         return readUserState(userId).getSplashScreenTheme();
1353     }
1354 
1355     public boolean isIncremental() {
1356         return IncrementalManager.isIncrementalPath(mPathString);
1357     }
1358     /**
1359      * @return True if package is still being loaded, false if the package is fully loaded.
1360      */
1361     public boolean isLoading() {
1362         return Math.abs(1.0f - mLoadingProgress) >= 0.00000001f;
1363     }
1364 
1365     public PackageSetting setLoadingProgress(float progress) {
1366         // To prevent race conditions, we don't allow progress to ever go down
1367         if (mLoadingProgress < progress) {
1368             mLoadingProgress = progress;
1369             onChanged();
1370         }
1371         return this;
1372     }
1373 
1374     public PackageSetting setLoadingCompletedTime(long loadingCompletedTime) {
1375         mLoadingCompletedTime = loadingCompletedTime;
1376         onChanged();
1377         return this;
1378     }
1379 
1380     /**
1381      * @param path to app metadata file
1382      */
1383     public PackageSetting setAppMetadataFilePath(String path) {
1384         mAppMetadataFilePath = path;
1385         onChanged();
1386         return this;
1387     }
1388 
1389     /**
1390      * @param source the source of the app metadata that is currently associated with
1391      */
1392     public PackageSetting setAppMetadataSource(int source) {
1393         mAppMetadataSource = source;
1394         onChanged();
1395         return this;
1396     }
1397 
1398     @NonNull
1399     @Override
1400     public long getVersionCode() {
1401         return versionCode;
1402     }
1403 
1404     /**
1405      * @see PackageState#getMimeGroups()
1406      */
1407     @Nullable
1408     @Override
1409     public Map<String, Set<String>> getMimeGroups() {
1410         return CollectionUtils.isEmpty(mimeGroups) ? Collections.emptyMap()
1411                 : Collections.unmodifiableMap(mimeGroups);
1412     }
1413 
1414     @NonNull
1415     @Override
1416     public String getPackageName() {
1417         return mName;
1418     }
1419 
1420     @Nullable
1421     @Override
1422     public AndroidPackage getAndroidPackage() {
1423         return getPkg();
1424     }
1425 
1426     @NonNull
1427     public SigningInfo getSigningInfo() {
1428         return new SigningInfo(signatures.mSigningDetails);
1429     }
1430 
1431     @NonNull
1432     @Override
1433     public String[] getUsesSdkLibraries() {
1434         return usesSdkLibraries == null ? EmptyArray.STRING : usesSdkLibraries;
1435     }
1436 
1437     @NonNull
1438     @Override
1439     public long[] getUsesSdkLibrariesVersionsMajor() {
1440         return usesSdkLibrariesVersionsMajor == null ? EmptyArray.LONG
1441                 : usesSdkLibrariesVersionsMajor;
1442     }
1443 
1444     @NonNull
1445     @Override
1446     public boolean[] getUsesSdkLibrariesOptional() {
1447         return usesSdkLibrariesOptional == null ? EmptyArray.BOOLEAN : usesSdkLibrariesOptional;
1448     }
1449 
1450     @NonNull
1451     @Override
1452     public String[] getUsesStaticLibraries() {
1453         return usesStaticLibraries == null ? EmptyArray.STRING : usesStaticLibraries;
1454     }
1455 
1456     @NonNull
1457     @Override
1458     public long[] getUsesStaticLibrariesVersions() {
1459         return usesStaticLibrariesVersions == null ? EmptyArray.LONG : usesStaticLibrariesVersions;
1460     }
1461 
1462     @NonNull
1463     @Override
1464     public List<SharedLibrary> getSharedLibraryDependencies() {
1465         return Collections.unmodifiableList(pkgState.getUsesLibraryInfos());
1466     }
1467 
1468     @NonNull
1469     public PackageSetting addUsesLibraryInfo(@NonNull SharedLibraryInfo value) {
1470         pkgState.addUsesLibraryInfo(new SharedLibraryWrapper(value));
1471         return this;
1472     }
1473 
1474     @NonNull
1475     @Override
1476     public List<String> getUsesLibraryFiles() {
1477         return Collections.unmodifiableList(pkgState.getUsesLibraryFiles());
1478     }
1479 
1480     @NonNull
1481     public PackageSetting addUsesLibraryFile(String value) {
1482         pkgState.addUsesLibraryFile(value);
1483         return this;
1484     }
1485 
1486     @Override
1487     public boolean isHiddenUntilInstalled() {
1488         return pkgState.isHiddenUntilInstalled();
1489     }
1490 
1491     @NonNull
1492     @Override
1493     public long[] getLastPackageUsageTime() {
1494         return pkgState.getLastPackageUsageTimeInMills();
1495     }
1496 
1497     @Override
1498     public boolean isUpdatedSystemApp() {
1499         return pkgState.isUpdatedSystemApp();
1500     }
1501 
1502     @Override
1503     public boolean isApkInUpdatedApex() {
1504         return pkgState.isApkInUpdatedApex();
1505     }
1506 
1507     @Nullable
1508     @Override
1509     public String getApexModuleName() {
1510         return pkgState.getApexModuleName();
1511     }
1512 
1513     public PackageSetting setDomainSetId(@NonNull UUID domainSetId) {
1514         mDomainSetId = domainSetId;
1515         onChanged();
1516         return this;
1517     }
1518 
1519     public PackageSetting setCategoryOverride(int categoryHint) {
1520         this.categoryOverride = categoryHint;
1521         onChanged();
1522         return this;
1523     }
1524 
1525     public PackageSetting setLegacyNativeLibraryPath(
1526             String legacyNativeLibraryPathString) {
1527         this.legacyNativeLibraryPath = legacyNativeLibraryPathString;
1528         onChanged();
1529         return this;
1530     }
1531 
1532     public PackageSetting setMimeGroups(@Nullable Map<String, Set<String>> mimeGroups) {
1533         if (mimeGroups != null) {
1534             copyMimeGroups(mimeGroups);
1535             onChanged();
1536         }
1537         return this;
1538     }
1539 
1540     public PackageSetting setUsesSdkLibraries(String[] usesSdkLibraries) {
1541         this.usesSdkLibraries = usesSdkLibraries;
1542         onChanged();
1543         return this;
1544     }
1545 
1546     public PackageSetting setUsesSdkLibrariesVersionsMajor(long[] usesSdkLibrariesVersions) {
1547         this.usesSdkLibrariesVersionsMajor = usesSdkLibrariesVersions;
1548         onChanged();
1549         return this;
1550     }
1551 
1552     public PackageSetting setUsesSdkLibrariesOptional(boolean[] usesSdkLibrariesOptional) {
1553         this.usesSdkLibrariesOptional = usesSdkLibrariesOptional;
1554         onChanged();
1555         return this;
1556     }
1557 
1558     public PackageSetting setUsesStaticLibraries(String[] usesStaticLibraries) {
1559         this.usesStaticLibraries = usesStaticLibraries;
1560         onChanged();
1561         return this;
1562     }
1563 
1564     public PackageSetting setUsesStaticLibrariesVersions(long[] usesStaticLibrariesVersions) {
1565         this.usesStaticLibrariesVersions = usesStaticLibrariesVersions;
1566         onChanged();
1567         return this;
1568     }
1569 
1570     public PackageSetting setApexModuleName(@Nullable String apexModuleName) {
1571         pkgState.setApexModuleName(apexModuleName);
1572         return this;
1573     }
1574 
1575     @NonNull
1576     @Override
1577     public PackageStateUnserialized getTransientState() {
1578         return pkgState;
1579     }
1580 
1581     @NonNull
1582     public SparseArray<? extends PackageUserStateInternal> getUserStates() {
1583         return mUserStates;
1584     }
1585 
1586     public PackageSetting addMimeTypes(String mimeGroup, Set<String> mimeTypes) {
1587         if (mimeGroups == null) {
1588             mimeGroups = new ArrayMap<>();
1589         }
1590 
1591         Set<String> existingMimeTypes = mimeGroups.get(mimeGroup);
1592         if (existingMimeTypes == null) {
1593             existingMimeTypes = new ArraySet<>();
1594             mimeGroups.put(mimeGroup, existingMimeTypes);
1595         }
1596         existingMimeTypes.addAll(mimeTypes);
1597         return this;
1598     }
1599 
1600     @NonNull
1601     @Override
1602     public PackageUserState getStateForUser(@NonNull UserHandle user) {
1603         PackageUserState userState = getUserStates().get(user.getIdentifier());
1604         return userState == null ? PackageUserState.DEFAULT : userState;
1605     }
1606 
1607     @Nullable
1608     public String getPrimaryCpuAbi() {
1609         if (TextUtils.isEmpty(mPrimaryCpuAbi) && pkg != null) {
1610             return AndroidPackageUtils.getRawPrimaryCpuAbi(pkg);
1611         }
1612 
1613         return mPrimaryCpuAbi;
1614     }
1615 
1616     @Nullable
1617     public String getSecondaryCpuAbi() {
1618         if (TextUtils.isEmpty(mSecondaryCpuAbi) && pkg != null) {
1619             return AndroidPackageUtils.getRawSecondaryCpuAbi(pkg);
1620         }
1621 
1622         return mSecondaryCpuAbi;
1623     }
1624 
1625     @Nullable
1626     @Override
1627     public String getSeInfo() {
1628         String overrideSeInfo = getTransientState().getOverrideSeInfo();
1629         if (!TextUtils.isEmpty(overrideSeInfo)) {
1630             return overrideSeInfo;
1631         }
1632 
1633         return getTransientState().getSeInfo();
1634     }
1635 
1636     @Nullable
1637     public String getPrimaryCpuAbiLegacy() {
1638         return mPrimaryCpuAbi;
1639     }
1640 
1641     @Nullable
1642     public String getSecondaryCpuAbiLegacy() {
1643         return mSecondaryCpuAbi;
1644     }
1645 
1646     @ApplicationInfo.HiddenApiEnforcementPolicy
1647     @Override
1648     public int getHiddenApiEnforcementPolicy() {
1649         return AndroidPackageUtils.getHiddenApiEnforcementPolicy(getAndroidPackage(), this);
1650     }
1651 
1652     @Override
1653     public boolean isApex() {
1654         // TODO(b/256637152):
1655         // TODO(b/243839669): Use a flag tracked directly in PackageSetting
1656         return getAndroidPackage() != null && getAndroidPackage().isApex();
1657     }
1658 
1659     @Override
1660     public boolean isForceQueryableOverride() {
1661         return getBoolean(Booleans.FORCE_QUERYABLE_OVERRIDE);
1662     }
1663 
1664     /**
1665      * @see PackageState#isUpdateAvailable()
1666      */
1667     @Override
1668     public boolean isUpdateAvailable() {
1669         return getBoolean(Booleans.UPDATE_AVAILABLE);
1670     }
1671 
1672     @Override
1673     public boolean isInstallPermissionsFixed() {
1674         return getBoolean(Booleans.INSTALL_PERMISSION_FIXED);
1675     }
1676 
1677     /**
1678      * @see PackageState#isDefaultToDeviceProtectedStorage()
1679      */
1680     @Override
1681     public boolean isDefaultToDeviceProtectedStorage() {
1682         return (getPrivateFlags() & PRIVATE_FLAG_DEFAULT_TO_DEVICE_PROTECTED_STORAGE) != 0;
1683     }
1684 
1685     @Override
1686     public boolean isPersistent() {
1687         return (getFlags() & ApplicationInfo.FLAG_PERSISTENT) != 0;
1688     }
1689 
1690     @Override
1691     public boolean isScannedAsStoppedSystemApp() {
1692         return getBoolean(Booleans.SCANNED_AS_STOPPED_SYSTEM_APP);
1693     }
1694 
1695 
1696 
1697     // Code below generated by codegen v1.0.23.
1698     //
1699     // DO NOT MODIFY!
1700     // CHECKSTYLE:OFF Generated code
1701     //
1702     // To regenerate run:
1703     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/PackageSetting.java
1704     //
1705     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
1706     //   Settings > Editor > Code Style > Formatter Control
1707     //@formatter:off
1708 
1709 
1710     /**
1711      * The path under which native libraries have been unpacked. This path is
1712      * always derived at runtime, and is only stored here for cleanup when a
1713      * package is uninstalled.
1714      */
1715     @DataClass.Generated.Member
1716     public @Nullable @Deprecated String getLegacyNativeLibraryPath() {
1717         return legacyNativeLibraryPath;
1718     }
1719 
1720     @DataClass.Generated.Member
1721     public @NonNull String getName() {
1722         return mName;
1723     }
1724 
1725     @DataClass.Generated.Member
1726     public @Nullable String getRealName() {
1727         return mRealName;
1728     }
1729 
1730     @DataClass.Generated.Member
1731     public int getAppId() {
1732         return mAppId;
1733     }
1734 
1735     /**
1736      * It is expected that all code that uses a {@link PackageSetting} understands this inner field
1737      * may be null. Note that this relationship only works one way. It should not be possible to
1738      * have an entry inside {@link PackageManagerService#mPackages} without a corresponding
1739      * {@link PackageSetting} inside {@link Settings#mPackages}.
1740      *
1741      * @see PackageState#getAndroidPackage()
1742      */
1743     @DataClass.Generated.Member
1744     public @Nullable AndroidPackageInternal getPkg() {
1745         return pkg;
1746     }
1747 
1748     /**
1749      * @see AndroidPackage#getPath()
1750      */
1751     @DataClass.Generated.Member
1752     public @NonNull File getPath() {
1753         return mPath;
1754     }
1755 
1756     @DataClass.Generated.Member
1757     public @NonNull String getPathString() {
1758         return mPathString;
1759     }
1760 
1761     @DataClass.Generated.Member
1762     public @Nullable LinkedHashSet<File> getOldPaths() {
1763         return mOldPaths;
1764     }
1765 
1766     @DataClass.Generated.Member
1767     public float getLoadingProgress() {
1768         return mLoadingProgress;
1769     }
1770 
1771     @DataClass.Generated.Member
1772     public long getLoadingCompletedTime() {
1773         return mLoadingCompletedTime;
1774     }
1775 
1776     @DataClass.Generated.Member
1777     public @Nullable String getCpuAbiOverride() {
1778         return mCpuAbiOverride;
1779     }
1780 
1781     @DataClass.Generated.Member
1782     public long getLastModifiedTime() {
1783         return mLastModifiedTime;
1784     }
1785 
1786     @DataClass.Generated.Member
1787     public long getLastUpdateTime() {
1788         return lastUpdateTime;
1789     }
1790 
1791     @DataClass.Generated.Member
1792     public @NonNull PackageSignatures getSignatures() {
1793         return signatures;
1794     }
1795 
1796     @DataClass.Generated.Member
1797     public @NonNull PackageKeySetData getKeySetData() {
1798         return keySetData;
1799     }
1800 
1801     @DataClass.Generated.Member
1802     public @NonNull InstallSource getInstallSource() {
1803         return installSource;
1804     }
1805 
1806     /**
1807      * @see PackageState#getVolumeUuid()
1808      */
1809     @DataClass.Generated.Member
1810     public @Nullable String getVolumeUuid() {
1811         return volumeUuid;
1812     }
1813 
1814     /**
1815      * @see PackageState#getCategoryOverride()
1816      */
1817     @DataClass.Generated.Member
1818     public int getCategoryOverride() {
1819         return categoryOverride;
1820     }
1821 
1822     @DataClass.Generated.Member
1823     public @NonNull PackageStateUnserialized getPkgState() {
1824         return pkgState;
1825     }
1826 
1827     @DataClass.Generated.Member
1828     public @NonNull UUID getDomainSetId() {
1829         return mDomainSetId;
1830     }
1831 
1832     @DataClass.Generated.Member
1833     public @Nullable String getAppMetadataFilePath() {
1834         return mAppMetadataFilePath;
1835     }
1836 
1837     @DataClass.Generated.Member
1838     public int getAppMetadataSource() {
1839         return mAppMetadataSource;
1840     }
1841 
1842     @DataClass.Generated.Member
1843     public int getTargetSdkVersion() {
1844         return mTargetSdkVersion;
1845     }
1846 
1847     @DataClass.Generated.Member
1848     public @Nullable byte[] getRestrictUpdateHash() {
1849         return mRestrictUpdateHash;
1850     }
1851 
1852     @DataClass.Generated(
1853             time = 1706698406378L,
1854             codegenVersion = "1.0.23",
1855             sourceFile = "frameworks/base/services/core/java/com/android/server/pm/PackageSetting.java",
1856             inputSignatures = "private  int mBooleans\nprivate  int mSharedUserAppId\nprivate @android.annotation.Nullable java.util.Map<java.lang.String,java.util.Set<java.lang.String>> mimeGroups\nprivate @android.annotation.Nullable java.lang.String[] usesSdkLibraries\nprivate @android.annotation.Nullable long[] usesSdkLibrariesVersionsMajor\nprivate @android.annotation.Nullable boolean[] usesSdkLibrariesOptional\nprivate @android.annotation.Nullable java.lang.String[] usesStaticLibraries\nprivate @android.annotation.Nullable long[] usesStaticLibrariesVersions\nprivate @android.annotation.Nullable @java.lang.Deprecated java.lang.String legacyNativeLibraryPath\nprivate @android.annotation.NonNull java.lang.String mName\nprivate @android.annotation.Nullable java.lang.String mRealName\nprivate  int mAppId\nprivate @android.annotation.Nullable com.android.internal.pm.parsing.pkg.AndroidPackageInternal pkg\nprivate @android.annotation.NonNull java.io.File mPath\nprivate @android.annotation.NonNull java.lang.String mPathString\nprivate @android.annotation.Nullable java.util.LinkedHashSet<java.io.File> mOldPaths\nprivate  float mLoadingProgress\nprivate  long mLoadingCompletedTime\nprivate @android.annotation.Nullable java.lang.String mPrimaryCpuAbi\nprivate @android.annotation.Nullable java.lang.String mSecondaryCpuAbi\nprivate @android.annotation.Nullable java.lang.String mCpuAbiOverride\nprivate  long mLastModifiedTime\nprivate  long lastUpdateTime\nprivate  long versionCode\nprivate @android.annotation.NonNull com.android.server.pm.PackageSignatures signatures\nprivate @android.annotation.NonNull com.android.server.pm.PackageKeySetData keySetData\nprivate final @android.annotation.NonNull android.util.SparseArray<com.android.server.pm.pkg.PackageUserStateImpl> mUserStates\nprivate @android.annotation.NonNull com.android.server.pm.InstallSource installSource\nprivate @android.annotation.Nullable java.lang.String volumeUuid\nprivate  int categoryOverride\nprivate final @android.annotation.NonNull com.android.server.pm.pkg.PackageStateUnserialized pkgState\nprivate @android.annotation.NonNull java.util.UUID mDomainSetId\nprivate @android.annotation.Nullable java.lang.String mAppMetadataFilePath\nprivate  int mAppMetadataSource\nprivate  int mTargetSdkVersion\nprivate @android.annotation.Nullable byte[] mRestrictUpdateHash\nprivate final @android.annotation.NonNull com.android.server.utils.SnapshotCache<com.android.server.pm.PackageSetting> mSnapshot\nprivate  void setBoolean(int,boolean)\nprivate  boolean getBoolean(int)\nprivate  com.android.server.utils.SnapshotCache<com.android.server.pm.PackageSetting> makeCache()\npublic  com.android.server.pm.PackageSetting snapshot()\npublic  void dumpDebug(android.util.proto.ProtoOutputStream,long,java.util.List<android.content.pm.UserInfo>,com.android.server.pm.permission.LegacyPermissionDataProvider)\npublic  com.android.server.pm.PackageSetting setAppId(int)\npublic  com.android.server.pm.PackageSetting setCpuAbiOverride(java.lang.String)\npublic  com.android.server.pm.PackageSetting setFirstInstallTimeFromReplaced(com.android.server.pm.pkg.PackageStateInternal,int[])\npublic  com.android.server.pm.PackageSetting setFirstInstallTime(long,int)\npublic  com.android.server.pm.PackageSetting setForceQueryableOverride(boolean)\npublic  com.android.server.pm.PackageSetting setInstallerPackage(java.lang.String,int)\npublic  com.android.server.pm.PackageSetting setUpdateOwnerPackage(java.lang.String)\npublic  com.android.server.pm.PackageSetting setInstallSource(com.android.server.pm.InstallSource)\n  com.android.server.pm.PackageSetting removeInstallerPackage(java.lang.String)\npublic  com.android.server.pm.PackageSetting setIsOrphaned(boolean)\npublic  com.android.server.pm.PackageSetting setKeySetData(com.android.server.pm.PackageKeySetData)\npublic  com.android.server.pm.PackageSetting setLastModifiedTime(long)\npublic  com.android.server.pm.PackageSetting setLastUpdateTime(long)\npublic  com.android.server.pm.PackageSetting setLongVersionCode(long)\npublic  boolean setMimeGroup(java.lang.String,android.util.ArraySet<java.lang.String>)\npublic  com.android.server.pm.PackageSetting setPkg(com.android.server.pm.pkg.AndroidPackage)\npublic  com.android.server.pm.PackageSetting setPkgStateLibraryFiles(java.util.Collection<java.lang.String>)\npublic  com.android.server.pm.PackageSetting setPrimaryCpuAbi(java.lang.String)\npublic  com.android.server.pm.PackageSetting setSecondaryCpuAbi(java.lang.String)\npublic  com.android.server.pm.PackageSetting setSignatures(com.android.server.pm.PackageSignatures)\npublic  com.android.server.pm.PackageSetting setVolumeUuid(java.lang.String)\npublic @java.lang.Override boolean isExternalStorage()\npublic  com.android.server.pm.PackageSetting setUpdateAvailable(boolean)\npublic  com.android.server.pm.PackageSetting setSharedUserAppId(int)\npublic  com.android.server.pm.PackageSetting setTargetSdkVersion(int)\npublic  com.android.server.pm.PackageSetting setRestrictUpdateHash(byte[])\npublic @java.lang.Override int getSharedUserAppId()\npublic @java.lang.Override boolean hasSharedUser()\npublic @java.lang.Override java.lang.String toString()\nprivate  void copyMimeGroups(java.util.Map<java.lang.String,java.util.Set<java.lang.String>>)\npublic  void updateFrom(com.android.server.pm.PackageSetting)\n  com.android.server.pm.PackageSetting updateMimeGroups(java.util.Set<java.lang.String>)\npublic @java.lang.Deprecated @java.lang.Override com.android.server.pm.permission.LegacyPermissionState getLegacyPermissionState()\npublic  com.android.server.pm.PackageSetting setInstallPermissionsFixed(boolean)\npublic  boolean isPrivileged()\npublic  boolean isOem()\npublic  boolean isVendor()\npublic  boolean isProduct()\npublic @java.lang.Override boolean isRequiredForSystemUser()\npublic  boolean isSystemExt()\npublic  boolean isOdm()\npublic  boolean isSystem()\npublic  boolean isRequestLegacyExternalStorage()\npublic  boolean isUserDataFragile()\npublic  android.content.pm.SigningDetails getSigningDetails()\npublic  com.android.server.pm.PackageSetting setSigningDetails(android.content.pm.SigningDetails)\npublic  void copyPackageSetting(com.android.server.pm.PackageSetting,boolean)\n @com.android.internal.annotations.VisibleForTesting com.android.server.pm.pkg.PackageUserStateImpl modifyUserState(int)\npublic  com.android.server.pm.pkg.PackageUserStateImpl getOrCreateUserState(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateInternal readUserState(int)\n  void setEnabled(int,int,java.lang.String)\n  int getEnabled(int)\n  void setInstalled(boolean,int)\n  void setArchiveState(com.android.server.pm.pkg.ArchiveState,int)\n  boolean getInstalled(int)\n  boolean isArchived(int)\n  int getInstallReason(int)\n  void setInstallReason(int,int)\n  int getUninstallReason(int)\n  void setUninstallReason(int,int)\n @android.annotation.NonNull android.content.pm.overlay.OverlayPaths getOverlayPaths(int)\n  boolean setOverlayPathsForLibrary(java.lang.String,android.content.pm.overlay.OverlayPaths,int)\n  boolean isInstalledOnAnyOtherUser(int[],int)\n  boolean hasDataOnAnyOtherUser(int[],int)\n  int[] queryInstalledUsers(int[],boolean)\n  int[] queryUsersInstalledOrHasData(int[])\n  long getCeDataInode(int)\n  long getDeDataInode(int)\n  void setCeDataInode(long,int)\n  void setDeDataInode(long,int)\n  boolean getStopped(int)\n  void setStopped(boolean,int)\npublic  com.android.server.pm.PackageSetting setScannedAsStoppedSystemApp(boolean)\n  boolean getNotLaunched(int)\n  void setNotLaunched(boolean,int)\n  boolean getHidden(int)\n  void setHidden(boolean,int)\n  int getDistractionFlags(int)\n  void setDistractionFlags(int,int)\npublic  boolean getInstantApp(int)\n  void setInstantApp(boolean,int)\n  boolean getVirtualPreload(int)\n  void setVirtualPreload(boolean,int)\n  void setUserState(int,long,long,int,boolean,boolean,boolean,boolean,int,android.util.ArrayMap<android.content.pm.UserPackage,com.android.server.pm.pkg.SuspendParams>,boolean,boolean,java.lang.String,android.util.ArraySet<java.lang.String>,android.util.ArraySet<java.lang.String>,int,int,java.lang.String,java.lang.String,long,int,com.android.server.pm.pkg.ArchiveState)\n  void setUserState(int,com.android.server.pm.pkg.PackageUserStateInternal)\n  com.android.server.utils.WatchedArraySet<java.lang.String> getEnabledComponents(int)\n  com.android.server.utils.WatchedArraySet<java.lang.String> getDisabledComponents(int)\n  void setEnabledComponents(com.android.server.utils.WatchedArraySet<java.lang.String>,int)\n  void setDisabledComponents(com.android.server.utils.WatchedArraySet<java.lang.String>,int)\n  void setEnabledComponentsCopy(com.android.server.utils.WatchedArraySet<java.lang.String>,int)\n  void setDisabledComponentsCopy(com.android.server.utils.WatchedArraySet<java.lang.String>,int)\n  com.android.server.pm.pkg.PackageUserStateImpl modifyUserStateComponents(int,boolean,boolean)\n  void addDisabledComponent(java.lang.String,int)\n  void addEnabledComponent(java.lang.String,int)\n  boolean enableComponentLPw(java.lang.String,int)\n  boolean disableComponentLPw(java.lang.String,int)\n  boolean restoreComponentLPw(java.lang.String,int)\n  void restoreComponentSettings(int)\n  int getCurrentEnabledStateLPr(java.lang.String,int)\n  void removeUser(int)\npublic  int[] getNotInstalledUserIds()\n  void writePackageUserPermissionsProto(android.util.proto.ProtoOutputStream,long,java.util.List<android.content.pm.UserInfo>,com.android.server.pm.permission.LegacyPermissionDataProvider)\nprotected  void writeUsersInfoToProto(android.util.proto.ProtoOutputStream,long)\nprivate static  void writeArchiveState(android.util.proto.ProtoOutputStream,com.android.server.pm.pkg.ArchiveState)\npublic @com.android.internal.annotations.VisibleForTesting com.android.server.pm.PackageSetting setPath(java.io.File)\npublic @com.android.internal.annotations.VisibleForTesting com.android.server.pm.PackageSetting addOldPath(java.io.File)\npublic @com.android.internal.annotations.VisibleForTesting com.android.server.pm.PackageSetting removeOldPath(java.io.File)\npublic @com.android.internal.annotations.VisibleForTesting boolean overrideNonLocalizedLabelAndIcon(android.content.ComponentName,java.lang.String,java.lang.Integer,int)\npublic  void resetOverrideComponentLabelIcon(int)\npublic @android.annotation.Nullable java.lang.String getSplashScreenTheme(int)\npublic  boolean isIncremental()\npublic  boolean isLoading()\npublic  com.android.server.pm.PackageSetting setLoadingProgress(float)\npublic  com.android.server.pm.PackageSetting setLoadingCompletedTime(long)\npublic  com.android.server.pm.PackageSetting setAppMetadataFilePath(java.lang.String)\npublic  com.android.server.pm.PackageSetting setAppMetadataSource(int)\npublic @android.annotation.NonNull @java.lang.Override long getVersionCode()\npublic @android.annotation.Nullable @java.lang.Override java.util.Map<java.lang.String,java.util.Set<java.lang.String>> getMimeGroups()\npublic @android.annotation.NonNull @java.lang.Override java.lang.String getPackageName()\npublic @android.annotation.Nullable @java.lang.Override com.android.server.pm.pkg.AndroidPackage getAndroidPackage()\npublic @android.annotation.NonNull android.content.pm.SigningInfo getSigningInfo()\npublic @android.annotation.NonNull @java.lang.Override java.lang.String[] getUsesSdkLibraries()\npublic @android.annotation.NonNull @java.lang.Override long[] getUsesSdkLibrariesVersionsMajor()\npublic @android.annotation.NonNull @java.lang.Override boolean[] getUsesSdkLibrariesOptional()\npublic @android.annotation.NonNull @java.lang.Override java.lang.String[] getUsesStaticLibraries()\npublic @android.annotation.NonNull @java.lang.Override long[] getUsesStaticLibrariesVersions()\npublic @android.annotation.NonNull @java.lang.Override java.util.List<com.android.server.pm.pkg.SharedLibrary> getSharedLibraryDependencies()\npublic @android.annotation.NonNull com.android.server.pm.PackageSetting addUsesLibraryInfo(android.content.pm.SharedLibraryInfo)\npublic @android.annotation.NonNull @java.lang.Override java.util.List<java.lang.String> getUsesLibraryFiles()\npublic @android.annotation.NonNull com.android.server.pm.PackageSetting addUsesLibraryFile(java.lang.String)\npublic @java.lang.Override boolean isHiddenUntilInstalled()\npublic @android.annotation.NonNull @java.lang.Override long[] getLastPackageUsageTime()\npublic @java.lang.Override boolean isUpdatedSystemApp()\npublic @java.lang.Override boolean isApkInUpdatedApex()\npublic @android.annotation.Nullable @java.lang.Override java.lang.String getApexModuleName()\npublic  com.android.server.pm.PackageSetting setDomainSetId(java.util.UUID)\npublic  com.android.server.pm.PackageSetting setCategoryOverride(int)\npublic  com.android.server.pm.PackageSetting setLegacyNativeLibraryPath(java.lang.String)\npublic  com.android.server.pm.PackageSetting setMimeGroups(java.util.Map<java.lang.String,java.util.Set<java.lang.String>>)\npublic  com.android.server.pm.PackageSetting setUsesSdkLibraries(java.lang.String[])\npublic  com.android.server.pm.PackageSetting setUsesSdkLibrariesVersionsMajor(long[])\npublic  com.android.server.pm.PackageSetting setUsesSdkLibrariesOptional(boolean[])\npublic  com.android.server.pm.PackageSetting setUsesStaticLibraries(java.lang.String[])\npublic  com.android.server.pm.PackageSetting setUsesStaticLibrariesVersions(long[])\npublic  com.android.server.pm.PackageSetting setApexModuleName(java.lang.String)\npublic @android.annotation.NonNull @java.lang.Override com.android.server.pm.pkg.PackageStateUnserialized getTransientState()\npublic @android.annotation.NonNull android.util.SparseArray<? extends PackageUserStateInternal> getUserStates()\npublic  com.android.server.pm.PackageSetting addMimeTypes(java.lang.String,java.util.Set<java.lang.String>)\npublic @android.annotation.NonNull @java.lang.Override com.android.server.pm.pkg.PackageUserState getStateForUser(android.os.UserHandle)\npublic @android.annotation.Nullable java.lang.String getPrimaryCpuAbi()\npublic @android.annotation.Nullable java.lang.String getSecondaryCpuAbi()\npublic @android.annotation.Nullable @java.lang.Override java.lang.String getSeInfo()\npublic @android.annotation.Nullable java.lang.String getPrimaryCpuAbiLegacy()\npublic @android.annotation.Nullable java.lang.String getSecondaryCpuAbiLegacy()\npublic @android.content.pm.ApplicationInfo.HiddenApiEnforcementPolicy @java.lang.Override int getHiddenApiEnforcementPolicy()\npublic @java.lang.Override boolean isApex()\npublic @java.lang.Override boolean isForceQueryableOverride()\npublic @java.lang.Override boolean isUpdateAvailable()\npublic @java.lang.Override boolean isInstallPermissionsFixed()\npublic @java.lang.Override boolean isDefaultToDeviceProtectedStorage()\npublic @java.lang.Override boolean isPersistent()\npublic @java.lang.Override boolean isScannedAsStoppedSystemApp()\nclass PackageSetting extends com.android.server.pm.SettingBase implements [com.android.server.pm.pkg.PackageStateInternal]\nprivate static final  int INSTALL_PERMISSION_FIXED\nprivate static final  int UPDATE_AVAILABLE\nprivate static final  int FORCE_QUERYABLE_OVERRIDE\nprivate static final  int SCANNED_AS_STOPPED_SYSTEM_APP\nclass Booleans extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genGetters=true, genConstructor=false, genSetters=false, genBuilder=false)")
1857     @Deprecated
1858     private void __metadata() {}
1859 
1860 
1861     //@formatter:on
1862     // End of generated code
1863 
1864 }
1865