This repository has been archived by the owner on Nov 8, 2023. It is now read-only.
/
PackageManager.java
11594 lines (10649 loc) · 474 KB
/
PackageManager.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2006 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.content.pm;
import android.Manifest;
import android.annotation.CallbackExecutor;
import android.annotation.CheckResult;
import android.annotation.DrawableRes;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.LongDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.StringRes;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.annotation.UserIdInt;
import android.annotation.WorkerThread;
import android.annotation.XmlRes;
import android.app.ActivityManager;
import android.app.ActivityThread;
import android.app.AppDetailsActivity;
import android.app.PackageDeleteObserver;
import android.app.PackageInstallObserver;
import android.app.PropertyInvalidatedCache;
import android.app.admin.DevicePolicyManager;
import android.app.usage.StorageStatsManager;
import android.companion.virtual.VirtualDeviceManager;
import android.compat.annotation.ChangeId;
import android.compat.annotation.EnabledSince;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.IntentSender;
import android.content.pm.PackageInstaller.SessionParams;
import android.content.pm.dex.ArtManager;
import android.content.pm.pkg.FrameworkPackageUserState;
import android.content.pm.verify.domain.DomainVerificationManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.graphics.Rect;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.wifi.WifiManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.IRemoteCallback;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
import android.os.RemoteException;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.incremental.IncrementalManager;
import android.os.storage.StorageManager;
import android.os.storage.VolumeInfo;
import android.permission.PermissionManager;
import android.telephony.TelephonyManager;
import android.telephony.UiccCardInfo;
import android.telephony.gba.GbaService;
import android.telephony.ims.ImsService;
import android.telephony.ims.ProvisioningManager;
import android.telephony.ims.RcsUceAdapter;
import android.telephony.ims.SipDelegateManager;
import android.util.AndroidException;
import android.util.Log;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DataClass;
import dalvik.system.VMRuntime;
import java.io.File;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.cert.Certificate;
import java.security.cert.CertificateEncodingException;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* Class for retrieving various kinds of information related to the application
* packages that are currently installed on the device.
*
* You can find this class through {@link Context#getPackageManager}.
*
* <p class="note"><strong>Note: </strong>If your app targets Android 11 (API level 30) or
* higher, the methods in this class each return a filtered list of apps. Learn more about how to
* <a href="/training/basics/intents/package-visibility">manage package visibility</a>.
* </p>
*/
public abstract class PackageManager {
private static final String TAG = "PackageManager";
/** {@hide} */
public static final boolean APPLY_DEFAULT_TO_DEVICE_PROTECTED_STORAGE = true;
/** {@hide} */
public static final boolean ENABLE_SHARED_UID_MIGRATION = true;
/**
* This exception is thrown when a given package, application, or component
* name cannot be found.
*/
public static class NameNotFoundException extends AndroidException {
public NameNotFoundException() {
}
public NameNotFoundException(String name) {
super(name);
}
}
/**
* <application> level {@link android.content.pm.PackageManager.Property} tag specifying
* the XML resource ID containing an application's media capabilities XML file
*
* For example:
* <application>
* <property android:name="android.media.PROPERTY_MEDIA_CAPABILITIES"
* android:resource="@xml/media_capabilities">
* <application>
*/
public static final String PROPERTY_MEDIA_CAPABILITIES =
"android.media.PROPERTY_MEDIA_CAPABILITIES";
/**
* <application> level {@link android.content.pm.PackageManager.Property} tag
* specifying the XML resource ID containing the declaration of the self-certified network
* capabilities used by the application.
*
* <p> Starting from Android 14, usage of some network capabilities in
* {@link android.net.ConnectivityManager#requestNetwork} require the application to
* declare its usage of that particular capability in this resource. Only some capabilities
* require a declaration. Please look up the specific capability you want to use in
* {@link android.net.NetworkCapabilities} to see if it needs declaration in this property.
*
* For example:
* <application>
* <property android:name="android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES"
* android:resource="@xml/self_certified_network_capabilities">
* <application>
*
* <p> The detail format of self_certified_network_capabilities.xml is described in
* {@link android.net.NetworkRequest}
*/
public static final String PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES =
"android.net.PROPERTY_SELF_CERTIFIED_NETWORK_CAPABILITIES";
/**
* Application level property that an app can specify to opt-out from having private data
* directories both on the internal and external storages.
*
* <p>Changing the value of this property during app update is not supported, and such updates
* will be rejected.
*
* <p>This should only be set by platform apps that know what they are doing.
*
* @hide
*/
public static final String PROPERTY_NO_APP_DATA_STORAGE =
"android.internal.PROPERTY_NO_APP_DATA_STORAGE";
/**
* <service> level {@link android.content.pm.PackageManager.Property} tag specifying
* the actual use case of the service if it's foreground service with the type
* {@link ServiceInfo#FOREGROUND_SERVICE_TYPE_SPECIAL_USE}.
*
* <p>
* For example:
* <service>
* <property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
* android:value="foo"/>
* </service>
*/
public static final String PROPERTY_SPECIAL_USE_FGS_SUBTYPE =
"android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE";
/**
* Application level {@link android.content.pm.PackageManager.Property PackageManager
* .Property} for an app to inform the system that the app can be opted-in or opted-out
* from the compatibility treatment that rotates camera output by 90 degrees on landscape
* sensors on devices known to have compatibility issues.
*
* <p>The treatment is disabled by default but device manufacturers can enable the treatment
* using their discretion to improve camera compatibility. With this property set to
* {@code false}, the rotation will not be applied. A value of {@code true}
* will ensure that rotation is applied, provided it is enabled for the device. In most cases,
* if rotation is the desired behavior this property need not be set. However, if your app
* experiences stretching or incorrect rotation on these devices, explicitly setting this to
* {@code true} may resolve that behavior. Apps should set this to {@code false} if there
* is confidence that the app handles
* {@link android.hardware.camera2.CameraCharacteristics#SENSOR_ORIENTATION} correctly.
* See <a href="https://developer.android.com/training/camera2/camera-preview"> the
* documentation for best practice.</a>
*
* <p><b>Syntax:</b>
* <pre>
* <application>
* <property
* android:name="android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT"
* android:value="true|false"/>
* </application>
* </pre>
*/
public static final String PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT =
"android.camera.PROPERTY_COMPAT_OVERRIDE_LANDSCAPE_TO_PORTRAIT";
/**
* Application level {@link android.content.pm.PackageManager.Property PackageManager
* .Property} for a privileged system installer to define a list of up to 500 packages that
* should not have their updates owned by any installer. The list must be provided via a default
* XML resource with the following format:
*
* <pre>
* <deny-ownership>PACKAGE_NAME</deny-ownership>
* <deny-ownership>PACKAGE_NAME</deny-ownership>
* </pre>
*
* <b>NOTE:</b> Installers that provide this property will not granted update ownership for any
* packages that they request update ownership of.
* @hide
*/
public static final String PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST =
"android.app.PROPERTY_LEGACY_UPDATE_OWNERSHIP_DENYLIST";
/**
* A property value set within the manifest.
* <p>
* The value of a property will only have a single type, as defined by
* the property itself.
*/
public static final class Property implements Parcelable {
private static final int TYPE_BOOLEAN = 1;
private static final int TYPE_FLOAT = 2;
private static final int TYPE_INTEGER = 3;
private static final int TYPE_RESOURCE = 4;
private static final int TYPE_STRING = 5;
private final String mName;
private final int mType;
private final String mClassName;
private final String mPackageName;
private boolean mBooleanValue;
private float mFloatValue;
private int mIntegerValue;
private String mStringValue;
/** @hide */
@VisibleForTesting
public Property(@NonNull String name, int type,
@NonNull String packageName, @Nullable String className) {
if (type < TYPE_BOOLEAN || type > TYPE_STRING) {
throw new IllegalArgumentException("Invalid type");
}
this.mName = Objects.requireNonNull(name);
this.mType = type;
this.mPackageName = Objects.requireNonNull(packageName);
this.mClassName = className;
}
/** @hide */
public Property(@NonNull String name, boolean value,
String packageName, String className) {
this(name, TYPE_BOOLEAN, packageName, className);
mBooleanValue = value;
}
/** @hide */
public Property(@NonNull String name, float value,
String packageName, String className) {
this(name, TYPE_FLOAT, packageName, className);
mFloatValue = value;
}
/** @hide */
public Property(@NonNull String name, int value, boolean isResource,
String packageName, String className) {
this(name, isResource ? TYPE_RESOURCE : TYPE_INTEGER, packageName, className);
mIntegerValue = value;
}
/** @hide */
public Property(@NonNull String name, String value,
String packageName, String className) {
this(name, TYPE_STRING, packageName, className);
mStringValue = value;
}
/** @hide */
@VisibleForTesting
public int getType() {
return mType;
}
/**
* Returns the name of the property.
*/
@NonNull public String getName() {
return mName;
}
/**
* Returns the name of the package where this this property was defined.
*/
@NonNull public String getPackageName() {
return mPackageName;
}
/**
* Returns the classname of the component where this property was defined.
* <p>If the property was defined within and <application> tag, returns
* {@code null}
*/
@Nullable public String getClassName() {
return mClassName;
}
/**
* Returns the boolean value set for the property.
* <p>If the property is not of a boolean type, returns {@code false}.
*/
public boolean getBoolean() {
return mBooleanValue;
}
/**
* Returns {@code true} if the property is a boolean type. Otherwise {@code false}.
*/
public boolean isBoolean() {
return mType == TYPE_BOOLEAN;
}
/**
* Returns the float value set for the property.
* <p>If the property is not of a float type, returns {@code 0.0}.
*/
public float getFloat() {
return mFloatValue;
}
/**
* Returns {@code true} if the property is a float type. Otherwise {@code false}.
*/
public boolean isFloat() {
return mType == TYPE_FLOAT;
}
/**
* Returns the integer value set for the property.
* <p>If the property is not of an integer type, returns {@code 0}.
*/
public int getInteger() {
return mType == TYPE_INTEGER ? mIntegerValue : 0;
}
/**
* Returns {@code true} if the property is an integer type. Otherwise {@code false}.
*/
public boolean isInteger() {
return mType == TYPE_INTEGER;
}
/**
* Returns the a resource id set for the property.
* <p>If the property is not of a resource id type, returns {@code 0}.
*/
public int getResourceId() {
return mType == TYPE_RESOURCE ? mIntegerValue : 0;
}
/**
* Returns {@code true} if the property is a resource id type. Otherwise {@code false}.
*/
public boolean isResourceId() {
return mType == TYPE_RESOURCE;
}
/**
* Returns the a String value set for the property.
* <p>If the property is not a String type, returns {@code null}.
*/
@Nullable public String getString() {
return mStringValue;
}
/**
* Returns {@code true} if the property is a String type. Otherwise {@code false}.
*/
public boolean isString() {
return mType == TYPE_STRING;
}
/**
* Adds a mapping from the given key to this property's value in the provided
* {@link android.os.Bundle}. If the provided {@link android.os.Bundle} is
* {@code null}, creates a new {@link android.os.Bundle}.
* @hide
*/
public Bundle toBundle(Bundle outBundle) {
final Bundle b = outBundle == null || outBundle == Bundle.EMPTY
? new Bundle() : outBundle;
if (mType == TYPE_BOOLEAN) {
b.putBoolean(mName, mBooleanValue);
} else if (mType == TYPE_FLOAT) {
b.putFloat(mName, mFloatValue);
} else if (mType == TYPE_INTEGER) {
b.putInt(mName, mIntegerValue);
} else if (mType == TYPE_RESOURCE) {
b.putInt(mName, mIntegerValue);
} else if (mType == TYPE_STRING) {
b.putString(mName, mStringValue);
}
return b;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeString(mName);
dest.writeInt(mType);
dest.writeString(mPackageName);
dest.writeString(mClassName);
if (mType == TYPE_BOOLEAN) {
dest.writeBoolean(mBooleanValue);
} else if (mType == TYPE_FLOAT) {
dest.writeFloat(mFloatValue);
} else if (mType == TYPE_INTEGER) {
dest.writeInt(mIntegerValue);
} else if (mType == TYPE_RESOURCE) {
dest.writeInt(mIntegerValue);
} else if (mType == TYPE_STRING) {
dest.writeString(mStringValue);
}
}
@NonNull
public static final Creator<Property> CREATOR = new Creator<Property>() {
@Override
public Property createFromParcel(@NonNull Parcel source) {
final String name = source.readString();
final int type = source.readInt();
final String packageName = source.readString();
final String className = source.readString();
if (type == TYPE_BOOLEAN) {
return new Property(name, source.readBoolean(), packageName, className);
} else if (type == TYPE_FLOAT) {
return new Property(name, source.readFloat(), packageName, className);
} else if (type == TYPE_INTEGER) {
return new Property(name, source.readInt(), false, packageName, className);
} else if (type == TYPE_RESOURCE) {
return new Property(name, source.readInt(), true, packageName, className);
} else if (type == TYPE_STRING) {
return new Property(name, source.readString(), packageName, className);
}
return null;
}
@Override
public Property[] newArray(int size) {
return new Property[size];
}
};
}
/**
* The class containing the enabled setting of a package component.
* <p>
* This is used by the {@link #setComponentEnabledSettings(List)} to support the batch updates
* of the enabled settings of components.
*
* @see #setComponentEnabledSettings(List)
*/
@DataClass(genConstructor = false)
public static final class ComponentEnabledSetting implements Parcelable {
/**
* The package name of the application to enable the setting.
*/
private final @Nullable String mPackageName;
/**
* The component name of the application to enable the setting.
*/
private final @Nullable ComponentName mComponentName;
/**
* The new enabled state
*/
private final @EnabledState int mEnabledState;
/**
* The optional behavior flag
*/
private final @EnabledFlags int mEnabledFlags;
/**
* Create an instance of the ComponentEnabledSetting for the component level's enabled
* setting update.
*
* @param componentName The component name to update the enabled setting.
* @param newState The new enabled state.
* @param flags The optional behavior flags.
*/
public ComponentEnabledSetting(@NonNull ComponentName componentName,
@EnabledState int newState, @EnabledFlags int flags) {
mPackageName = null;
mComponentName = Objects.requireNonNull(componentName);
mEnabledState = newState;
mEnabledFlags = flags;
}
/**
* Create an instance of the ComponentEnabledSetting for the application level's enabled
* setting update.
*
* @param packageName The package name to update the enabled setting.
* @param newState The new enabled state.
* @param flags The optional behavior flags.
* @hide
*/
public ComponentEnabledSetting(@NonNull String packageName,
@EnabledState int newState, @EnabledFlags int flags) {
mPackageName = Objects.requireNonNull(packageName);
mComponentName = null;
mEnabledState = newState;
mEnabledFlags = flags;
}
/**
* Returns the package name of the setting.
*
* @return the package name.
* @hide
*/
public @NonNull String getPackageName() {
if (isComponent()) {
return mComponentName.getPackageName();
}
return mPackageName;
}
/**
* Returns the component class name of the setting.
*
* @return the class name.
* @hide
*/
public @Nullable String getClassName() {
if (isComponent()) {
return mComponentName.getClassName();
}
return null;
}
/**
* Whether or not this is for the component level's enabled setting update.
*
* @return {@code true} if it's the component level enabled setting update.
* @hide
*/
public boolean isComponent() {
return mComponentName != null;
}
// Code below generated by codegen v1.0.23.
//
// DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code
//
// To regenerate run:
// $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/pm/PackageManager.java
//
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
// Settings > Editor > Code Style > Formatter Control
//@formatter:off
/**
* The component name of the application to enable the setting.
*/
@DataClass.Generated.Member
public @Nullable ComponentName getComponentName() {
return mComponentName;
}
/**
* The new enabled state
*/
@DataClass.Generated.Member
public @EnabledState int getEnabledState() {
return mEnabledState;
}
/**
* The optional behavior flag
*/
@DataClass.Generated.Member
public @EnabledFlags int getEnabledFlags() {
return mEnabledFlags;
}
@Override
@DataClass.Generated.Member
public void writeToParcel(@NonNull Parcel dest, int flags) {
// You can override field parcelling by defining methods like:
// void parcelFieldName(Parcel dest, int flags) { ... }
byte flg = 0;
if (mPackageName != null) flg |= 0x1;
if (mComponentName != null) flg |= 0x2;
dest.writeByte(flg);
if (mPackageName != null) dest.writeString(mPackageName);
if (mComponentName != null) dest.writeTypedObject(mComponentName, flags);
dest.writeInt(mEnabledState);
dest.writeInt(mEnabledFlags);
}
@Override
@DataClass.Generated.Member
public int describeContents() { return 0; }
/** @hide */
@SuppressWarnings({"unchecked", "RedundantCast"})
@DataClass.Generated.Member
/* package-private */ ComponentEnabledSetting(@NonNull Parcel in) {
// You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... }
byte flg = in.readByte();
String packageName = (flg & 0x1) == 0 ? null : in.readString();
ComponentName componentName = (flg & 0x2) == 0 ? null : (ComponentName) in.readTypedObject(ComponentName.CREATOR);
int enabledState = in.readInt();
int enabledFlags = in.readInt();
this.mPackageName = packageName;
this.mComponentName = componentName;
this.mEnabledState = enabledState;
com.android.internal.util.AnnotationValidations.validate(
EnabledState.class, null, mEnabledState);
this.mEnabledFlags = enabledFlags;
com.android.internal.util.AnnotationValidations.validate(
EnabledFlags.class, null, mEnabledFlags);
// onConstructed(); // You can define this method to get a callback
}
@DataClass.Generated.Member
public static final @NonNull Parcelable.Creator<ComponentEnabledSetting> CREATOR
= new Parcelable.Creator<ComponentEnabledSetting>() {
@Override
public ComponentEnabledSetting[] newArray(int size) {
return new ComponentEnabledSetting[size];
}
@Override
public ComponentEnabledSetting createFromParcel(@NonNull Parcel in) {
return new ComponentEnabledSetting(in);
}
};
@DataClass.Generated(
time = 1628668290863L,
codegenVersion = "1.0.23",
sourceFile = "frameworks/base/core/java/android/content/pm/PackageManager.java",
inputSignatures = "private final @android.annotation.Nullable java.lang.String mPackageName\nprivate final @android.annotation.Nullable android.content.ComponentName mComponentName\nprivate final @android.content.pm.PackageManager.EnabledState int mEnabledState\nprivate final @android.content.pm.PackageManager.EnabledFlags int mEnabledFlags\npublic @android.annotation.NonNull java.lang.String getPackageName()\npublic @android.annotation.Nullable java.lang.String getClassName()\npublic boolean isComponent()\nclass ComponentEnabledSetting extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false)")
@Deprecated
private void __metadata() {}
//@formatter:on
// End of generated code
}
/**
* Listener for changes in permissions granted to a UID.
*
* @hide
*/
@SystemApi
public interface OnPermissionsChangedListener {
/**
* Called when the permissions for a UID change for the default device.
*
* @param uid The UID with a change.
* @see Context#DEVICE_ID_DEFAULT
*/
void onPermissionsChanged(int uid);
/**
* Called when the permissions for a UID change for a device, including virtual devices.
*
* @param uid The UID of permission change event.
* @param persistentDeviceId The persistent device ID of permission change event.
*
* @see VirtualDeviceManager.VirtualDevice#getPersistentDeviceId()
* @see VirtualDeviceManager#PERSISTENT_DEVICE_ID_DEFAULT
*/
@FlaggedApi(android.permission.flags.Flags.FLAG_DEVICE_AWARE_PERMISSION_APIS_ENABLED)
default void onPermissionsChanged(int uid, @NonNull String persistentDeviceId) {
Objects.requireNonNull(persistentDeviceId);
if (Objects.equals(persistentDeviceId,
VirtualDeviceManager.PERSISTENT_DEVICE_ID_DEFAULT)) {
onPermissionsChanged(uid);
}
}
}
/** @hide */
public static final int TYPE_UNKNOWN = 0;
/** @hide */
public static final int TYPE_ACTIVITY = 1;
/** @hide */
public static final int TYPE_RECEIVER = 2;
/** @hide */
public static final int TYPE_SERVICE = 3;
/** @hide */
public static final int TYPE_PROVIDER = 4;
/** @hide */
public static final int TYPE_APPLICATION = 5;
/** @hide */
@IntDef(prefix = { "TYPE_" }, value = {
TYPE_UNKNOWN,
TYPE_ACTIVITY,
TYPE_RECEIVER,
TYPE_SERVICE,
TYPE_PROVIDER,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ComponentType {}
/** @hide */
@IntDef(prefix = { "TYPE_" }, value = {
TYPE_UNKNOWN,
TYPE_ACTIVITY,
TYPE_RECEIVER,
TYPE_SERVICE,
TYPE_PROVIDER,
TYPE_APPLICATION,
})
@Retention(RetentionPolicy.SOURCE)
public @interface PropertyLocation {}
/**
* As a guiding principle:
* <p>
* {@code GET_} flags are used to request additional data that may have been
* elided to save wire space.
* <p>
* {@code MATCH_} flags are used to include components or packages that
* would have otherwise been omitted from a result set by current system
* state.
*/
/** @hide */
@LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_ACTIVITIES,
GET_CONFIGURATIONS,
GET_GIDS,
GET_INSTRUMENTATION,
GET_INTENT_FILTERS,
GET_META_DATA,
GET_PERMISSIONS,
GET_PROVIDERS,
GET_RECEIVERS,
GET_SERVICES,
GET_SHARED_LIBRARY_FILES,
GET_SIGNATURES,
GET_SIGNING_CERTIFICATES,
GET_URI_PERMISSION_PATTERNS,
MATCH_UNINSTALLED_PACKAGES,
MATCH_DISABLED_COMPONENTS,
MATCH_DISABLED_UNTIL_USED_COMPONENTS,
MATCH_SYSTEM_ONLY,
MATCH_FACTORY_ONLY,
MATCH_ANY_USER,
MATCH_DEBUG_TRIAGED_MISSING,
MATCH_INSTANT,
MATCH_APEX,
MATCH_ARCHIVED_PACKAGES,
GET_DISABLED_COMPONENTS,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
GET_ATTRIBUTIONS_LONG,
})
@Retention(RetentionPolicy.SOURCE)
public @interface PackageInfoFlagsBits {}
/** @hide */
@LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
GET_SHARED_LIBRARY_FILES,
MATCH_UNINSTALLED_PACKAGES,
MATCH_SYSTEM_ONLY,
MATCH_DEBUG_TRIAGED_MISSING,
MATCH_DISABLED_COMPONENTS,
MATCH_DISABLED_UNTIL_USED_COMPONENTS,
MATCH_INSTANT,
MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
MATCH_APEX,
MATCH_ARCHIVED_PACKAGES,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ApplicationInfoFlagsBits {}
/** @hide */
@LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
GET_SHARED_LIBRARY_FILES,
MATCH_ALL,
MATCH_DEBUG_TRIAGED_MISSING,
MATCH_DEFAULT_ONLY,
MATCH_DISABLED_COMPONENTS,
MATCH_DISABLED_UNTIL_USED_COMPONENTS,
MATCH_DIRECT_BOOT_AUTO,
MATCH_DIRECT_BOOT_AWARE,
MATCH_DIRECT_BOOT_UNAWARE,
MATCH_SYSTEM_ONLY,
MATCH_UNINSTALLED_PACKAGES,
MATCH_INSTANT,
MATCH_STATIC_SHARED_AND_SDK_LIBRARIES,
GET_DISABLED_COMPONENTS,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
MATCH_QUARANTINED_COMPONENTS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ComponentInfoFlagsBits {}
/** @hide */
@LongDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
GET_RESOLVED_FILTER,
GET_SHARED_LIBRARY_FILES,
MATCH_ALL,
MATCH_DEBUG_TRIAGED_MISSING,
MATCH_DISABLED_COMPONENTS,
MATCH_DISABLED_UNTIL_USED_COMPONENTS,
MATCH_DEFAULT_ONLY,
MATCH_DIRECT_BOOT_AUTO,
MATCH_DIRECT_BOOT_AWARE,
MATCH_DIRECT_BOOT_UNAWARE,
MATCH_SYSTEM_ONLY,
MATCH_UNINSTALLED_PACKAGES,
MATCH_INSTANT,
GET_DISABLED_COMPONENTS,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
MATCH_CLONE_PROFILE,
MATCH_QUARANTINED_COMPONENTS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ResolveInfoFlagsBits {}
/** @hide */
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
MATCH_ALL,
})
@Retention(RetentionPolicy.SOURCE)
public @interface InstalledModulesFlags {}
/** @hide */
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
})
@Retention(RetentionPolicy.SOURCE)
public @interface PermissionInfoFlags {}
/** @hide */
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
})
@Retention(RetentionPolicy.SOURCE)
public @interface PermissionGroupInfoFlags {}
/** @hide */
@IntDef(flag = true, prefix = { "GET_", "MATCH_" }, value = {
GET_META_DATA,
})
@Retention(RetentionPolicy.SOURCE)
public @interface InstrumentationInfoFlags {}
//-------------------------------------------------------------------------
// Beginning of GET_ and MATCH_ flags
//-------------------------------------------------------------------------
/**
* {@link PackageInfo} flag: return information about
* activities in the package in {@link PackageInfo#activities}.
*/
public static final int GET_ACTIVITIES = 0x00000001;
/**
* {@link PackageInfo} flag: return information about
* intent receivers in the package in
* {@link PackageInfo#receivers}.
*/
public static final int GET_RECEIVERS = 0x00000002;
/**
* {@link PackageInfo} flag: return information about
* services in the package in {@link PackageInfo#services}.
*/
public static final int GET_SERVICES = 0x00000004;
/**
* {@link PackageInfo} flag: return information about
* content providers in the package in
* {@link PackageInfo#providers}.
*/
public static final int GET_PROVIDERS = 0x00000008;
/**
* {@link PackageInfo} flag: return information about
* instrumentation in the package in
* {@link PackageInfo#instrumentation}.
*/
public static final int GET_INSTRUMENTATION = 0x00000010;
/**
* {@link PackageInfo} flag: return information about the
* intent filters supported by the activity.
*
* @deprecated The platform does not support getting {@link IntentFilter}s for the package.
*/
@Deprecated
public static final int GET_INTENT_FILTERS = 0x00000020;
/**
* {@link PackageInfo} flag: return information about the
* signatures included in the package.
*
* @deprecated use {@code GET_SIGNING_CERTIFICATES} instead
*/
@Deprecated
public static final int GET_SIGNATURES = 0x00000040;
/**
* {@link ResolveInfo} flag: return the IntentFilter that
* was matched for a particular ResolveInfo in
* {@link ResolveInfo#filter}.
*/
public static final int GET_RESOLVED_FILTER = 0x00000040;
/**
* {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData}
* data {@link android.os.Bundle}s that are associated with a component.
* This applies for any API returning a ComponentInfo subclass.
*/
public static final int GET_META_DATA = 0x00000080;
/**
* {@link PackageInfo} flag: return the
* {@link PackageInfo#gids group ids} that are associated with an
* application.
* This applies for any API returning a PackageInfo class, either
* directly or nested inside of another.
*/
public static final int GET_GIDS = 0x00000100;
/**