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.pkg;
18 
19 import android.annotation.CurrentTimeMillisLong;
20 import android.annotation.IntDef;
21 import android.annotation.NonNull;
22 import android.annotation.Nullable;
23 import android.content.ComponentName;
24 import android.content.pm.PackageManager;
25 import android.content.pm.UserPackage;
26 import android.content.pm.overlay.OverlayPaths;
27 import android.text.TextUtils;
28 import android.util.ArrayMap;
29 import android.util.ArraySet;
30 import android.util.Pair;
31 
32 import com.android.internal.annotations.VisibleForTesting;
33 import com.android.internal.util.ArrayUtils;
34 import com.android.internal.util.CollectionUtils;
35 import com.android.internal.util.DataClass;
36 import com.android.server.utils.Snappable;
37 import com.android.server.utils.SnapshotCache;
38 import com.android.server.utils.Watchable;
39 import com.android.server.utils.WatchableImpl;
40 import com.android.server.utils.WatchedArrayMap;
41 import com.android.server.utils.WatchedArraySet;
42 
43 import java.util.Collections;
44 import java.util.Map;
45 import java.util.Objects;
46 
47 /** @hide */
48 @DataClass(genConstructor = false, genBuilder = false, genEqualsHashCode = true)
49 @DataClass.Suppress({"mOverlayPathsLock", "mOverlayPaths", "mSharedLibraryOverlayPathsLock",
50         "mSharedLibraryOverlayPaths", "setOverlayPaths", "setCachedOverlayPaths", "getWatchable",
51         "getBooleans"
52 })
53 public class PackageUserStateImpl extends WatchableImpl implements PackageUserStateInternal,
54         Snappable {
55     // Use a bitset to store boolean data to save memory
56     private static class Booleans {
57         @IntDef({
58                 INSTALLED,
59                 STOPPED,
60                 NOT_LAUNCHED,
61                 HIDDEN,
62                 INSTANT_APP,
63                 VIRTUAL_PRELOADED,
64         })
65         public @interface Flags {
66         }
67         private static final int INSTALLED = 1;
68         private static final int STOPPED = 1 << 1;
69         private static final int NOT_LAUNCHED = 1 << 2;
70         // Is the app restricted by owner / admin
71         private static final int HIDDEN = 1 << 3;
72         private static final int INSTANT_APP = 1 << 4;
73         private static final int VIRTUAL_PRELOADED = 1 << 5;
74     }
75     private int mBooleans;
76 
setBoolean(@ooleans.Flags int flag, boolean value)77     private void setBoolean(@Booleans.Flags int flag, boolean value) {
78         if (value) {
79             mBooleans |= flag;
80         } else {
81             mBooleans &= ~flag;
82         }
83     }
84 
getBoolean(@ooleans.Flags int flag)85     private boolean getBoolean(@Booleans.Flags int flag) {
86         return (mBooleans & flag) != 0;
87     }
88 
89     @Nullable
90     protected WatchedArraySet<String> mDisabledComponentsWatched;
91     @Nullable
92     protected WatchedArraySet<String> mEnabledComponentsWatched;
93 
94     private long mCeDataInode;
95     private long mDeDataInode;
96     private int mDistractionFlags;
97     @PackageManager.EnabledState
98     private int mEnabledState = PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
99     @PackageManager.InstallReason
100     private int mInstallReason = PackageManager.INSTALL_REASON_UNKNOWN;
101     @PackageManager.UninstallReason
102     private int mUninstallReason = PackageManager.UNINSTALL_REASON_UNKNOWN;
103     @Nullable
104     private String mHarmfulAppWarning;
105     @Nullable
106     private String mLastDisableAppCaller;
107 
108     @Nullable
109     private OverlayPaths mOverlayPaths;
110 
111     // Lib name to overlay paths
112     @Nullable
113     protected WatchedArrayMap<String, OverlayPaths> mSharedLibraryOverlayPaths;
114 
115     @Nullable
116     private String mSplashScreenTheme;
117 
118     @PackageManager.UserMinAspectRatio
119     private int mMinAspectRatio = PackageManager.USER_MIN_ASPECT_RATIO_UNSET;
120 
121     /**
122      * Suspending package to suspend params
123      */
124     @Nullable
125     private WatchedArrayMap<UserPackage, SuspendParams> mSuspendParams;
126 
127     @Nullable
128     private WatchedArrayMap<ComponentName, Pair<String, Integer>> mComponentLabelIconOverrideMap;
129 
130     private @CurrentTimeMillisLong long mFirstInstallTimeMillis;
131 
132     // TODO(b/239050028): Remove, enforce notifying parent through PMS commit method
133     @Nullable
134     private Watchable mWatchable;
135 
136     @Nullable
137     private ArchiveState mArchiveState;
138 
139     @NonNull
140     final SnapshotCache<PackageUserStateImpl> mSnapshot;
141 
makeCache()142     private SnapshotCache<PackageUserStateImpl> makeCache() {
143         return new SnapshotCache<PackageUserStateImpl>(this, this) {
144             @Override
145             public PackageUserStateImpl createSnapshot() {
146                 return new PackageUserStateImpl(mWatchable, mSource);
147             }};
148     }
149 
150     /**
151      * Only used for tests
152      */
153     public PackageUserStateImpl() {
154         super();
155         mWatchable = null;
156         mSnapshot = makeCache();
157         setBoolean(Booleans.INSTALLED, true);
158     }
159 
160     public PackageUserStateImpl(@NonNull Watchable watchable) {
161         mWatchable = watchable;
162         mSnapshot = makeCache();
163         setBoolean(Booleans.INSTALLED, true);
164     }
165 
166     public PackageUserStateImpl(@NonNull Watchable watchable, PackageUserStateImpl other) {
167         mWatchable = watchable;
168         mBooleans = other.mBooleans;
169         mDisabledComponentsWatched = other.mDisabledComponentsWatched == null
170                 ? null : other.mDisabledComponentsWatched.snapshot();
171         mEnabledComponentsWatched =  other.mEnabledComponentsWatched == null
172                 ? null : other.mEnabledComponentsWatched.snapshot();
173         mOverlayPaths = other.mOverlayPaths;
174         mSharedLibraryOverlayPaths = other.mSharedLibraryOverlayPaths == null
175                 ? null : other.mSharedLibraryOverlayPaths.snapshot();
176         mCeDataInode = other.mCeDataInode;
177         mDeDataInode = other.mDeDataInode;
178         mDistractionFlags = other.mDistractionFlags;
179         mEnabledState = other.mEnabledState;
180         mInstallReason = other.mInstallReason;
181         mUninstallReason = other.mUninstallReason;
182         mHarmfulAppWarning = other.mHarmfulAppWarning;
183         mLastDisableAppCaller = other.mLastDisableAppCaller;
184         mSplashScreenTheme = other.mSplashScreenTheme;
185         mMinAspectRatio = other.mMinAspectRatio;
186         mSuspendParams = other.mSuspendParams == null ? null : other.mSuspendParams.snapshot();
187         mComponentLabelIconOverrideMap = other.mComponentLabelIconOverrideMap == null
188                 ? null : other.mComponentLabelIconOverrideMap.snapshot();
189         mFirstInstallTimeMillis = other.mFirstInstallTimeMillis;
190         mArchiveState = other.mArchiveState;
191         mSnapshot = new SnapshotCache.Sealed<>();
192     }
193 
194     private void onChanged() {
195         if (mWatchable != null) {
196             mWatchable.dispatchChange(mWatchable);
197         }
198         dispatchChange(this);
199     }
200 
201     @NonNull
202     @Override
203     public PackageUserStateImpl snapshot() {
204         return mSnapshot.snapshot();
205     }
206 
207     /**
208      * Sets the path of overlays currently enabled for this package and user combination.
209      *
210      * @return true if the path contents differ than what they were previously
211      */
212     @Nullable
213     public boolean setOverlayPaths(@Nullable OverlayPaths paths) {
214         if (Objects.equals(paths, mOverlayPaths)) {
215             return false;
216         }
217         if ((mOverlayPaths == null && paths.isEmpty())
218                 || (paths == null && mOverlayPaths.isEmpty())) {
219             return false;
220         }
221         mOverlayPaths = paths;
222         onChanged();
223         return true;
224     }
225 
226     /**
227      * Sets the path of overlays currently enabled for a library that this package uses.
228      *
229      * @return true if the path contents for the library differ than what they were previously
230      */
231     public boolean setSharedLibraryOverlayPaths(@NonNull String library,
232             @Nullable OverlayPaths paths) {
233         if (mSharedLibraryOverlayPaths == null) {
234             mSharedLibraryOverlayPaths = new WatchedArrayMap<>();
235             mSharedLibraryOverlayPaths.registerObserver(mSnapshot);
236         }
237         final OverlayPaths currentPaths = mSharedLibraryOverlayPaths.get(library);
238         if (Objects.equals(paths, currentPaths)) {
239             return false;
240         }
241         if (paths == null || paths.isEmpty()) {
242             boolean returnValue = mSharedLibraryOverlayPaths.remove(library) != null;
243             onChanged();
244             return returnValue;
245         } else {
246             mSharedLibraryOverlayPaths.put(library, paths);
247             onChanged();
248             return true;
249         }
250     }
251 
252     @Nullable
253     @Override
254     public WatchedArraySet<String> getDisabledComponentsNoCopy() {
255         return mDisabledComponentsWatched;
256     }
257 
258     @Nullable
259     @Override
260     public WatchedArraySet<String> getEnabledComponentsNoCopy() {
261         return mEnabledComponentsWatched;
262     }
263 
264     @NonNull
265     @Override
266     public ArraySet<String> getDisabledComponents() {
267         return mDisabledComponentsWatched == null
268                 ? new ArraySet<>() : mDisabledComponentsWatched.untrackedStorage();
269     }
270 
271     @NonNull
272     @Override
273     public ArraySet<String> getEnabledComponents() {
274         return mEnabledComponentsWatched == null
275                 ? new ArraySet<>() : mEnabledComponentsWatched.untrackedStorage();
276     }
277 
278 
279     @Override
280     public boolean isComponentEnabled(String componentName) {
281         return mEnabledComponentsWatched != null
282                 && mEnabledComponentsWatched.contains(componentName);
283     }
284 
285     @Override
286     public boolean isComponentDisabled(String componentName) {
287         return mDisabledComponentsWatched != null
288                 && mDisabledComponentsWatched.contains(componentName);
289     }
290 
291     @Override
292     public OverlayPaths getAllOverlayPaths() {
293         if (mOverlayPaths == null && mSharedLibraryOverlayPaths == null) {
294             return null;
295         }
296         final OverlayPaths.Builder newPaths = new OverlayPaths.Builder();
297         newPaths.addAll(mOverlayPaths);
298         if (mSharedLibraryOverlayPaths != null) {
299             for (final OverlayPaths libOverlayPaths : mSharedLibraryOverlayPaths.values()) {
300                 newPaths.addAll(libOverlayPaths);
301             }
302         }
303         return newPaths.build();
304     }
305 
306     /**
307      * Overrides the non-localized label and icon of a component.
308      *
309      * @return true if the label or icon was changed.
310      */
311     @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
312     public boolean overrideLabelAndIcon(@NonNull ComponentName component,
313             @Nullable String nonLocalizedLabel, @Nullable Integer icon) {
314         String existingLabel = null;
315         Integer existingIcon = null;
316 
317         if (mComponentLabelIconOverrideMap != null) {
318             Pair<String, Integer> pair = mComponentLabelIconOverrideMap.get(component);
319             if (pair != null) {
320                 existingLabel = pair.first;
321                 existingIcon = pair.second;
322             }
323         }
324 
325         boolean changed = !TextUtils.equals(existingLabel, nonLocalizedLabel)
326                 || !Objects.equals(existingIcon, icon);
327 
328         if (changed) {
329             if (nonLocalizedLabel == null && icon == null) {
330                 mComponentLabelIconOverrideMap.remove(component);
331                 if (mComponentLabelIconOverrideMap.isEmpty()) {
332                     mComponentLabelIconOverrideMap = null;
333                 }
334             } else {
335                 if (mComponentLabelIconOverrideMap == null) {
336                     mComponentLabelIconOverrideMap = new WatchedArrayMap<>(1);
337                     mComponentLabelIconOverrideMap.registerObserver(mSnapshot);
338                 }
339 
340                 mComponentLabelIconOverrideMap.put(component, Pair.create(nonLocalizedLabel, icon));
341             }
342             onChanged();
343         }
344 
345         return changed;
346     }
347 
348     /**
349      * Clears all values previously set by {@link #overrideLabelAndIcon(ComponentName, String,
350      * Integer)}.
351      * <p>
352      * This is done when the package is updated as the components and resource IDs may have
353      * changed.
354      */
355     public void resetOverrideComponentLabelIcon() {
356         mComponentLabelIconOverrideMap = null;
357     }
358 
359     @Nullable
360     public Pair<String, Integer> getOverrideLabelIconForComponent(ComponentName componentName) {
361         if (ArrayUtils.isEmpty(mComponentLabelIconOverrideMap)) {
362             return null;
363         }
364 
365         return mComponentLabelIconOverrideMap.get(componentName);
366     }
367 
368     @Override
369     public boolean isSuspended() {
370         return !CollectionUtils.isEmpty(mSuspendParams);
371     }
372 
373     /**
374      * Adds or updates suspension params by the given package.
375      */
376     public PackageUserStateImpl putSuspendParams(@NonNull UserPackage suspendingPackage,
377             @Nullable SuspendParams suspendParams) {
378         if (mSuspendParams == null) {
379             mSuspendParams = new WatchedArrayMap<>();
380             mSuspendParams.registerObserver(mSnapshot);
381         }
382         if (!mSuspendParams.containsKey(suspendingPackage)
383                 || !Objects.equals(mSuspendParams.get(suspendingPackage), suspendParams)) {
384             mSuspendParams.put(suspendingPackage, suspendParams);
385             onChanged();
386         }
387 
388         return this;
389     }
390 
391     /**
392      * Removes suspension by the given package.
393      */
394     public PackageUserStateImpl removeSuspension(@NonNull UserPackage suspendingPackage) {
395         if (mSuspendParams != null) {
396             mSuspendParams.remove(suspendingPackage);
397             onChanged();
398         }
399         return this;
400     }
401 
402     public @NonNull PackageUserStateImpl setDisabledComponents(@Nullable ArraySet<String> value) {
403         if (mDisabledComponentsWatched == null) {
404             mDisabledComponentsWatched = new WatchedArraySet<>();
405             mDisabledComponentsWatched.registerObserver(mSnapshot);
406         }
407         mDisabledComponentsWatched.clear();
408         if (value != null) {
409             mDisabledComponentsWatched.addAll(value);
410         }
411         onChanged();
412         return this;
413     }
414 
415     public @NonNull PackageUserStateImpl setEnabledComponents(@Nullable ArraySet<String> value) {
416         if (mEnabledComponentsWatched == null) {
417             mEnabledComponentsWatched = new WatchedArraySet<>();
418             mEnabledComponentsWatched.registerObserver(mSnapshot);
419         }
420         mEnabledComponentsWatched.clear();
421         if (value != null) {
422             mEnabledComponentsWatched.addAll(value);
423         }
424         onChanged();
425         return this;
426     }
427 
428     public @NonNull PackageUserStateImpl setEnabledComponents(
429             @Nullable WatchedArraySet<String> value) {
430         mEnabledComponentsWatched = value;
431         if (mEnabledComponentsWatched != null) {
432             mEnabledComponentsWatched.registerObserver(mSnapshot);
433         }
434         onChanged();
435         return this;
436     }
437 
438     public @NonNull PackageUserStateImpl setDisabledComponents(
439             @Nullable WatchedArraySet<String> value) {
440         mDisabledComponentsWatched = value;
441         if (mDisabledComponentsWatched != null) {
442             mDisabledComponentsWatched.registerObserver(mSnapshot);
443         }
444         onChanged();
445         return this;
446     }
447 
448     public @NonNull PackageUserStateImpl setCeDataInode(long value) {
449         mCeDataInode = value;
450         onChanged();
451         return this;
452     }
453 
454     public @NonNull PackageUserStateImpl setDeDataInode(long value) {
455         mDeDataInode = value;
456         onChanged();
457         return this;
458     }
459 
460     public @NonNull PackageUserStateImpl setInstalled(boolean value) {
461         setBoolean(Booleans.INSTALLED, value);
462         onChanged();
463         return this;
464     }
465 
466     public @NonNull PackageUserStateImpl setStopped(boolean value) {
467         setBoolean(Booleans.STOPPED, value);
468         onChanged();
469         return this;
470     }
471 
472     public @NonNull PackageUserStateImpl setNotLaunched(boolean value) {
473         setBoolean(Booleans.NOT_LAUNCHED, value);
474         onChanged();
475         return this;
476     }
477 
478     public @NonNull PackageUserStateImpl setHidden(boolean value) {
479         setBoolean(Booleans.HIDDEN, value);
480         onChanged();
481         return this;
482     }
483 
484     public @NonNull PackageUserStateImpl setDistractionFlags(int value) {
485         mDistractionFlags = value;
486         onChanged();
487         return this;
488     }
489 
490     public @NonNull PackageUserStateImpl setInstantApp(boolean value) {
491         setBoolean(Booleans.INSTANT_APP, value);
492         onChanged();
493         return this;
494     }
495 
496     public @NonNull PackageUserStateImpl setVirtualPreload(boolean value) {
497         setBoolean(Booleans.VIRTUAL_PRELOADED, value);
498         onChanged();
499         return this;
500     }
501 
502     public @NonNull PackageUserStateImpl setEnabledState(int value) {
503         mEnabledState = value;
504         onChanged();
505         return this;
506     }
507 
508     public @NonNull PackageUserStateImpl setInstallReason(@PackageManager.InstallReason int value) {
509         mInstallReason = value;
510         com.android.internal.util.AnnotationValidations.validate(
511                 PackageManager.InstallReason.class, null, mInstallReason);
512         onChanged();
513         return this;
514     }
515 
516     public @NonNull PackageUserStateImpl setUninstallReason(
517             @PackageManager.UninstallReason int value) {
518         mUninstallReason = value;
519         com.android.internal.util.AnnotationValidations.validate(
520                 PackageManager.UninstallReason.class, null, mUninstallReason);
521         onChanged();
522         return this;
523     }
524 
525     public @NonNull PackageUserStateImpl setHarmfulAppWarning(@NonNull String value) {
526         mHarmfulAppWarning = value;
527         onChanged();
528         return this;
529     }
530 
531     public @NonNull PackageUserStateImpl setLastDisableAppCaller(@NonNull String value) {
532         mLastDisableAppCaller = value;
533         onChanged();
534         return this;
535     }
536 
537     public @NonNull PackageUserStateImpl setSharedLibraryOverlayPaths(
538             @NonNull ArrayMap<String, OverlayPaths> value) {
539         if (value == null) {
540             return this;
541         }
542         if (mSharedLibraryOverlayPaths == null) {
543             mSharedLibraryOverlayPaths = new WatchedArrayMap<>();
544             registerObserver(mSnapshot);
545         }
546         mSharedLibraryOverlayPaths.clear();
547         mSharedLibraryOverlayPaths.putAll(value);
548         onChanged();
549         return this;
550     }
551 
552     public @NonNull PackageUserStateImpl setSplashScreenTheme(@NonNull String value) {
553         mSplashScreenTheme = value;
554         onChanged();
555         return this;
556     }
557 
558     /**
559      * Sets user min aspect ratio override value
560      * @see PackageManager.UserMinAspectRatio
561      */
562     public @NonNull PackageUserStateImpl setMinAspectRatio(
563             @PackageManager.UserMinAspectRatio int value) {
564         mMinAspectRatio = value;
565         com.android.internal.util.AnnotationValidations.validate(
566                 PackageManager.UserMinAspectRatio.class, null, mMinAspectRatio);
567         onChanged();
568         return this;
569     }
570 
571     /**
572      * Suspending package to suspend params
573      */
574     public @NonNull PackageUserStateImpl setSuspendParams(
575             @NonNull ArrayMap<UserPackage, SuspendParams> value) {
576         if (value == null) {
577             return this;
578         }
579         if (mSuspendParams == null) {
580             mSuspendParams = new WatchedArrayMap<>();
581             registerObserver(mSnapshot);
582         }
583         mSuspendParams.clear();
584         mSuspendParams.putAll(value);
585         onChanged();
586         return this;
587     }
588 
589     public @NonNull PackageUserStateImpl setComponentLabelIconOverrideMap(
590             @NonNull ArrayMap<ComponentName, Pair<String, Integer>> value) {
591         if (value == null) {
592             return this;
593         }
594         if (mComponentLabelIconOverrideMap == null) {
595             mComponentLabelIconOverrideMap = new WatchedArrayMap<>();
596             registerObserver(mSnapshot);
597         }
598         mComponentLabelIconOverrideMap.clear();
599         mComponentLabelIconOverrideMap.putAll(value);
600         onChanged();
601         return this;
602     }
603 
604     public @NonNull PackageUserStateImpl setFirstInstallTimeMillis(long value) {
605         mFirstInstallTimeMillis = value;
606         onChanged();
607         return this;
608     }
609 
610     /**
611      * Sets the value for {@link #getArchiveState()}.
612      */
613     @NonNull
614     public PackageUserStateImpl setArchiveState(@NonNull ArchiveState archiveState) {
615         mArchiveState = archiveState;
616         onChanged();
617         return this;
618     }
619 
620     @NonNull
621     @Override
622     public Map<String, OverlayPaths> getSharedLibraryOverlayPaths() {
623         return mSharedLibraryOverlayPaths == null
624                 ? Collections.emptyMap() : mSharedLibraryOverlayPaths;
625     }
626 
627     @NonNull
628     public PackageUserStateImpl setWatchable(@NonNull Watchable watchable) {
629         mWatchable = watchable;
630         return this;
631     }
632 
633     private boolean watchableEquals(Watchable other) {
634         // Ignore the Watchable for equality
635         return true;
636     }
637 
638     private int watchableHashCode() {
639         // Ignore the Watchable for equality
640         return 0;
641     }
642 
643     private boolean snapshotEquals(SnapshotCache<PackageUserStateImpl> other) {
644         // Ignore the SnapshotCache for equality
645         return true;
646     }
647 
648     private int snapshotHashCode() {
649         // Ignore the SnapshotCache for equality
650         return 0;
651     }
652 
653 
654     @Override
655     public boolean isInstalled() {
656         return getBoolean(Booleans.INSTALLED);
657     }
658 
659     @Override
660     public boolean isStopped() {
661         return getBoolean(Booleans.STOPPED);
662     }
663 
664     @Override
665     public boolean isNotLaunched() {
666         return getBoolean(Booleans.NOT_LAUNCHED);
667     }
668 
669     @Override
670     public boolean isHidden() {
671         return getBoolean(Booleans.HIDDEN);
672     }
673 
674     @Override
675     public boolean isInstantApp() {
676         return getBoolean(Booleans.INSTANT_APP);
677     }
678 
679     @Override
680     public boolean isVirtualPreload() {
681         return getBoolean(Booleans.VIRTUAL_PRELOADED);
682     }
683 
684     @Override
685     public boolean isQuarantined() {
686         if (!isSuspended()) {
687             return false;
688         }
689         final var suspendParams = mSuspendParams;
690         for (int i = 0, size = suspendParams.size(); i < size; i++) {
691             final SuspendParams params = suspendParams.valueAt(i);
692             if (params.isQuarantined()) {
693                 return true;
694             }
695         }
696         return false;
697     }
698 
699     @Override
700     public boolean dataExists() {
701         return getCeDataInode() > 0 || getDeDataInode() > 0;
702     }
703 
704 
705 
706     // Code below generated by codegen v1.0.23.
707     //
708     // DO NOT MODIFY!
709     // CHECKSTYLE:OFF Generated code
710     //
711     // To regenerate run:
712     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/services/core/java/com/android/server/pm/pkg/PackageUserStateImpl.java
713     //
714     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
715     //   Settings > Editor > Code Style > Formatter Control
716     //@formatter:off
717 
718 
719     @DataClass.Generated.Member
720     public @Nullable WatchedArraySet<String> getDisabledComponentsWatched() {
721         return mDisabledComponentsWatched;
722     }
723 
724     @DataClass.Generated.Member
725     public @Nullable WatchedArraySet<String> getEnabledComponentsWatched() {
726         return mEnabledComponentsWatched;
727     }
728 
729     @DataClass.Generated.Member
730     public long getCeDataInode() {
731         return mCeDataInode;
732     }
733 
734     @DataClass.Generated.Member
735     public long getDeDataInode() {
736         return mDeDataInode;
737     }
738 
739     @DataClass.Generated.Member
740     public int getDistractionFlags() {
741         return mDistractionFlags;
742     }
743 
744     @DataClass.Generated.Member
745     public @PackageManager.EnabledState int getEnabledState() {
746         return mEnabledState;
747     }
748 
749     @DataClass.Generated.Member
750     public @PackageManager.InstallReason int getInstallReason() {
751         return mInstallReason;
752     }
753 
754     @DataClass.Generated.Member
755     public @PackageManager.UninstallReason int getUninstallReason() {
756         return mUninstallReason;
757     }
758 
759     @DataClass.Generated.Member
760     public @Nullable String getHarmfulAppWarning() {
761         return mHarmfulAppWarning;
762     }
763 
764     @DataClass.Generated.Member
765     public @Nullable String getLastDisableAppCaller() {
766         return mLastDisableAppCaller;
767     }
768 
769     @DataClass.Generated.Member
770     public @Nullable OverlayPaths getOverlayPaths() {
771         return mOverlayPaths;
772     }
773 
774     @DataClass.Generated.Member
775     public @Nullable String getSplashScreenTheme() {
776         return mSplashScreenTheme;
777     }
778 
779     @DataClass.Generated.Member
780     public @PackageManager.UserMinAspectRatio int getMinAspectRatio() {
781         return mMinAspectRatio;
782     }
783 
784     /**
785      * Suspending package to suspend params
786      */
787     @DataClass.Generated.Member
788     public @Nullable WatchedArrayMap<UserPackage,SuspendParams> getSuspendParams() {
789         return mSuspendParams;
790     }
791 
792     @DataClass.Generated.Member
793     public @Nullable WatchedArrayMap<ComponentName,Pair<String,Integer>> getComponentLabelIconOverrideMap() {
794         return mComponentLabelIconOverrideMap;
795     }
796 
797     @DataClass.Generated.Member
798     public @CurrentTimeMillisLong long getFirstInstallTimeMillis() {
799         return mFirstInstallTimeMillis;
800     }
801 
802     @DataClass.Generated.Member
803     public @Nullable ArchiveState getArchiveState() {
804         return mArchiveState;
805     }
806 
807     @DataClass.Generated.Member
808     public @NonNull SnapshotCache<PackageUserStateImpl> getSnapshot() {
809         return mSnapshot;
810     }
811 
812     @DataClass.Generated.Member
813     public @NonNull PackageUserStateImpl setBooleans( int value) {
814         mBooleans = value;
815         return this;
816     }
817 
818     @DataClass.Generated.Member
819     public @NonNull PackageUserStateImpl setDisabledComponentsWatched(@NonNull WatchedArraySet<String> value) {
820         mDisabledComponentsWatched = value;
821         return this;
822     }
823 
824     @DataClass.Generated.Member
825     public @NonNull PackageUserStateImpl setEnabledComponentsWatched(@NonNull WatchedArraySet<String> value) {
826         mEnabledComponentsWatched = value;
827         return this;
828     }
829 
830     @DataClass.Generated.Member
831     public @NonNull PackageUserStateImpl setSharedLibraryOverlayPaths(@NonNull WatchedArrayMap<String,OverlayPaths> value) {
832         mSharedLibraryOverlayPaths = value;
833         return this;
834     }
835 
836     /**
837      * Suspending package to suspend params
838      */
839     @DataClass.Generated.Member
840     public @NonNull PackageUserStateImpl setSuspendParams(@NonNull WatchedArrayMap<UserPackage,SuspendParams> value) {
841         mSuspendParams = value;
842         return this;
843     }
844 
845     @DataClass.Generated.Member
846     public @NonNull PackageUserStateImpl setComponentLabelIconOverrideMap(@NonNull WatchedArrayMap<ComponentName,Pair<String,Integer>> value) {
847         mComponentLabelIconOverrideMap = value;
848         return this;
849     }
850 
851     @Override
852     @DataClass.Generated.Member
853     public boolean equals(@Nullable Object o) {
854         // You can override field equality logic by defining either of the methods like:
855         // boolean fieldNameEquals(PackageUserStateImpl other) { ... }
856         // boolean fieldNameEquals(FieldType otherValue) { ... }
857 
858         if (this == o) return true;
859         if (o == null || getClass() != o.getClass()) return false;
860         @SuppressWarnings("unchecked")
861         PackageUserStateImpl that = (PackageUserStateImpl) o;
862         //noinspection PointlessBooleanExpression
863         return true
864                 && mBooleans == that.mBooleans
865                 && Objects.equals(mDisabledComponentsWatched, that.mDisabledComponentsWatched)
866                 && Objects.equals(mEnabledComponentsWatched, that.mEnabledComponentsWatched)
867                 && mCeDataInode == that.mCeDataInode
868                 && mDeDataInode == that.mDeDataInode
869                 && mDistractionFlags == that.mDistractionFlags
870                 && mEnabledState == that.mEnabledState
871                 && mInstallReason == that.mInstallReason
872                 && mUninstallReason == that.mUninstallReason
873                 && Objects.equals(mHarmfulAppWarning, that.mHarmfulAppWarning)
874                 && Objects.equals(mLastDisableAppCaller, that.mLastDisableAppCaller)
875                 && Objects.equals(mOverlayPaths, that.mOverlayPaths)
876                 && Objects.equals(mSharedLibraryOverlayPaths, that.mSharedLibraryOverlayPaths)
877                 && Objects.equals(mSplashScreenTheme, that.mSplashScreenTheme)
878                 && mMinAspectRatio == that.mMinAspectRatio
879                 && Objects.equals(mSuspendParams, that.mSuspendParams)
880                 && Objects.equals(mComponentLabelIconOverrideMap, that.mComponentLabelIconOverrideMap)
881                 && mFirstInstallTimeMillis == that.mFirstInstallTimeMillis
882                 && watchableEquals(that.mWatchable)
883                 && Objects.equals(mArchiveState, that.mArchiveState)
884                 && snapshotEquals(that.mSnapshot);
885     }
886 
887     @Override
888     @DataClass.Generated.Member
889     public int hashCode() {
890         // You can override field hashCode logic by defining methods like:
891         // int fieldNameHashCode() { ... }
892 
893         int _hash = 1;
894         _hash = 31 * _hash + mBooleans;
895         _hash = 31 * _hash + Objects.hashCode(mDisabledComponentsWatched);
896         _hash = 31 * _hash + Objects.hashCode(mEnabledComponentsWatched);
897         _hash = 31 * _hash + Long.hashCode(mCeDataInode);
898         _hash = 31 * _hash + Long.hashCode(mDeDataInode);
899         _hash = 31 * _hash + mDistractionFlags;
900         _hash = 31 * _hash + mEnabledState;
901         _hash = 31 * _hash + mInstallReason;
902         _hash = 31 * _hash + mUninstallReason;
903         _hash = 31 * _hash + Objects.hashCode(mHarmfulAppWarning);
904         _hash = 31 * _hash + Objects.hashCode(mLastDisableAppCaller);
905         _hash = 31 * _hash + Objects.hashCode(mOverlayPaths);
906         _hash = 31 * _hash + Objects.hashCode(mSharedLibraryOverlayPaths);
907         _hash = 31 * _hash + Objects.hashCode(mSplashScreenTheme);
908         _hash = 31 * _hash + mMinAspectRatio;
909         _hash = 31 * _hash + Objects.hashCode(mSuspendParams);
910         _hash = 31 * _hash + Objects.hashCode(mComponentLabelIconOverrideMap);
911         _hash = 31 * _hash + Long.hashCode(mFirstInstallTimeMillis);
912         _hash = 31 * _hash + watchableHashCode();
913         _hash = 31 * _hash + Objects.hashCode(mArchiveState);
914         _hash = 31 * _hash + snapshotHashCode();
915         return _hash;
916     }
917 
918     @DataClass.Generated(
919             time = 1701864813354L,
920             codegenVersion = "1.0.23",
921             sourceFile = "frameworks/base/services/core/java/com/android/server/pm/pkg/PackageUserStateImpl.java",
922             inputSignatures = "private  int mBooleans\nprotected @android.annotation.Nullable com.android.server.utils.WatchedArraySet<java.lang.String> mDisabledComponentsWatched\nprotected @android.annotation.Nullable com.android.server.utils.WatchedArraySet<java.lang.String> mEnabledComponentsWatched\nprivate  long mCeDataInode\nprivate  long mDeDataInode\nprivate  int mDistractionFlags\nprivate @android.content.pm.PackageManager.EnabledState int mEnabledState\nprivate @android.content.pm.PackageManager.InstallReason int mInstallReason\nprivate @android.content.pm.PackageManager.UninstallReason int mUninstallReason\nprivate @android.annotation.Nullable java.lang.String mHarmfulAppWarning\nprivate @android.annotation.Nullable java.lang.String mLastDisableAppCaller\nprivate @android.annotation.Nullable android.content.pm.overlay.OverlayPaths mOverlayPaths\nprotected @android.annotation.Nullable com.android.server.utils.WatchedArrayMap<java.lang.String,android.content.pm.overlay.OverlayPaths> mSharedLibraryOverlayPaths\nprivate @android.annotation.Nullable java.lang.String mSplashScreenTheme\nprivate @android.content.pm.PackageManager.UserMinAspectRatio int mMinAspectRatio\nprivate @android.annotation.Nullable com.android.server.utils.WatchedArrayMap<android.content.pm.UserPackage,com.android.server.pm.pkg.SuspendParams> mSuspendParams\nprivate @android.annotation.Nullable com.android.server.utils.WatchedArrayMap<android.content.ComponentName,android.util.Pair<java.lang.String,java.lang.Integer>> mComponentLabelIconOverrideMap\nprivate @android.annotation.CurrentTimeMillisLong long mFirstInstallTimeMillis\nprivate @android.annotation.Nullable com.android.server.utils.Watchable mWatchable\nprivate @android.annotation.Nullable com.android.server.pm.pkg.ArchiveState mArchiveState\nfinal @android.annotation.NonNull com.android.server.utils.SnapshotCache<com.android.server.pm.pkg.PackageUserStateImpl> mSnapshot\nprivate  void setBoolean(int,boolean)\nprivate  boolean getBoolean(int)\nprivate  com.android.server.utils.SnapshotCache<com.android.server.pm.pkg.PackageUserStateImpl> makeCache()\nprivate  void onChanged()\npublic @android.annotation.NonNull @java.lang.Override com.android.server.pm.pkg.PackageUserStateImpl snapshot()\npublic @android.annotation.Nullable boolean setOverlayPaths(android.content.pm.overlay.OverlayPaths)\npublic  boolean setSharedLibraryOverlayPaths(java.lang.String,android.content.pm.overlay.OverlayPaths)\npublic @android.annotation.Nullable @java.lang.Override com.android.server.utils.WatchedArraySet<java.lang.String> getDisabledComponentsNoCopy()\npublic @android.annotation.Nullable @java.lang.Override com.android.server.utils.WatchedArraySet<java.lang.String> getEnabledComponentsNoCopy()\npublic @android.annotation.NonNull @java.lang.Override android.util.ArraySet<java.lang.String> getDisabledComponents()\npublic @android.annotation.NonNull @java.lang.Override android.util.ArraySet<java.lang.String> getEnabledComponents()\npublic @java.lang.Override boolean isComponentEnabled(java.lang.String)\npublic @java.lang.Override boolean isComponentDisabled(java.lang.String)\npublic @java.lang.Override android.content.pm.overlay.OverlayPaths getAllOverlayPaths()\npublic @com.android.internal.annotations.VisibleForTesting boolean overrideLabelAndIcon(android.content.ComponentName,java.lang.String,java.lang.Integer)\npublic  void resetOverrideComponentLabelIcon()\npublic @android.annotation.Nullable android.util.Pair<java.lang.String,java.lang.Integer> getOverrideLabelIconForComponent(android.content.ComponentName)\npublic @java.lang.Override boolean isSuspended()\npublic  com.android.server.pm.pkg.PackageUserStateImpl putSuspendParams(android.content.pm.UserPackage,com.android.server.pm.pkg.SuspendParams)\npublic  com.android.server.pm.pkg.PackageUserStateImpl removeSuspension(android.content.pm.UserPackage)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setDisabledComponents(android.util.ArraySet<java.lang.String>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setEnabledComponents(android.util.ArraySet<java.lang.String>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setEnabledComponents(com.android.server.utils.WatchedArraySet<java.lang.String>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setDisabledComponents(com.android.server.utils.WatchedArraySet<java.lang.String>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setCeDataInode(long)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setDeDataInode(long)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setInstalled(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setStopped(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setNotLaunched(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setHidden(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setDistractionFlags(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setInstantApp(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setVirtualPreload(boolean)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setEnabledState(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setInstallReason(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setUninstallReason(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setHarmfulAppWarning(java.lang.String)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setLastDisableAppCaller(java.lang.String)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setSharedLibraryOverlayPaths(android.util.ArrayMap<java.lang.String,android.content.pm.overlay.OverlayPaths>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setSplashScreenTheme(java.lang.String)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setMinAspectRatio(int)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setSuspendParams(android.util.ArrayMap<android.content.pm.UserPackage,com.android.server.pm.pkg.SuspendParams>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setComponentLabelIconOverrideMap(android.util.ArrayMap<android.content.ComponentName,android.util.Pair<java.lang.String,java.lang.Integer>>)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setFirstInstallTimeMillis(long)\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setArchiveState(com.android.server.pm.pkg.ArchiveState)\npublic @android.annotation.NonNull @java.lang.Override java.util.Map<java.lang.String,android.content.pm.overlay.OverlayPaths> getSharedLibraryOverlayPaths()\npublic @android.annotation.NonNull com.android.server.pm.pkg.PackageUserStateImpl setWatchable(com.android.server.utils.Watchable)\nprivate  boolean watchableEquals(com.android.server.utils.Watchable)\nprivate  int watchableHashCode()\nprivate  boolean snapshotEquals(com.android.server.utils.SnapshotCache<com.android.server.pm.pkg.PackageUserStateImpl>)\nprivate  int snapshotHashCode()\npublic @java.lang.Override boolean isInstalled()\npublic @java.lang.Override boolean isStopped()\npublic @java.lang.Override boolean isNotLaunched()\npublic @java.lang.Override boolean isHidden()\npublic @java.lang.Override boolean isInstantApp()\npublic @java.lang.Override boolean isVirtualPreload()\npublic @java.lang.Override boolean isQuarantined()\npublic @java.lang.Override boolean dataExists()\nclass PackageUserStateImpl extends com.android.server.utils.WatchableImpl implements [com.android.server.pm.pkg.PackageUserStateInternal, com.android.server.utils.Snappable]\nprivate static final  int INSTALLED\nprivate static final  int STOPPED\nprivate static final  int NOT_LAUNCHED\nprivate static final  int HIDDEN\nprivate static final  int INSTANT_APP\nprivate static final  int VIRTUAL_PRELOADED\nclass Booleans extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=false, genEqualsHashCode=true)")
923     @Deprecated
924     private void __metadata() {}
925 
926 
927     //@formatter:on
928     // End of generated code
929 
930 }
931