2 * Copyright (C) 2008 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package android.test.mock;
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.app.PackageInstallObserver;
22 import android.content.ComponentName;
23 import android.content.Intent;
24 import android.content.IntentFilter;
25 import android.content.IntentSender;
26 import android.content.pm.ActivityInfo;
27 import android.content.pm.ApplicationInfo;
28 import android.content.pm.EphemeralApplicationInfo;
29 import android.content.pm.FeatureInfo;
30 import android.content.pm.IPackageDataObserver;
31 import android.content.pm.IPackageDeleteObserver;
32 import android.content.pm.IPackageInstallObserver;
33 import android.content.pm.IPackageStatsObserver;
34 import android.content.pm.InstrumentationInfo;
35 import android.content.pm.IntentFilterVerificationInfo;
36 import android.content.pm.KeySet;
37 import android.content.pm.PackageInfo;
38 import android.content.pm.PackageInstaller;
39 import android.content.pm.PackageItemInfo;
40 import android.content.pm.PackageManager;
41 import android.content.pm.PermissionGroupInfo;
42 import android.content.pm.PermissionInfo;
43 import android.content.pm.ProviderInfo;
44 import android.content.pm.ResolveInfo;
45 import android.content.pm.ServiceInfo;
46 import android.content.pm.VerifierDeviceIdentity;
47 import android.content.res.Resources;
48 import android.content.res.XmlResourceParser;
49 import android.graphics.Rect;
50 import android.graphics.drawable.Drawable;
51 import android.net.Uri;
52 import android.os.Handler;
53 import android.os.UserHandle;
54 import android.os.storage.VolumeInfo;
56 import java.util.List;
59 * A mock {@link android.content.pm.PackageManager} class. All methods are non-functional and throw
60 * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
63 * @deprecated Use a mocking framework like <a href="https://github.com/mockito/mockito">Mockito</a>.
64 * New tests should be written using the
65 * <a href="{@docRoot}tools/testing-support-library/index.html">Android Testing Support Library</a>.
68 public class MockPackageManager extends PackageManager {
71 public PackageInfo getPackageInfo(String packageName, int flags) throws NameNotFoundException {
72 throw new UnsupportedOperationException();
77 public PackageInfo getPackageInfoAsUser(String packageName, int flags, int userId)
78 throws NameNotFoundException {
79 throw new UnsupportedOperationException();
83 public String[] currentToCanonicalPackageNames(String[] names) {
84 throw new UnsupportedOperationException();
88 public String[] canonicalToCurrentPackageNames(String[] names) {
89 throw new UnsupportedOperationException();
93 public Intent getLaunchIntentForPackage(String packageName) {
94 throw new UnsupportedOperationException();
98 public Intent getLeanbackLaunchIntentForPackage(String packageName) {
99 throw new UnsupportedOperationException();
103 public int[] getPackageGids(String packageName) throws NameNotFoundException {
104 throw new UnsupportedOperationException();
108 public int[] getPackageGids(String packageName, int flags) throws NameNotFoundException {
109 throw new UnsupportedOperationException();
113 public int getPackageUid(String packageName, int flags) throws NameNotFoundException {
114 throw new UnsupportedOperationException();
119 public int getPackageUidAsUser(String packageName, int flags, int userHandle)
120 throws NameNotFoundException {
121 throw new UnsupportedOperationException();
126 public int getPackageUidAsUser(String packageName, int userHandle)
127 throws NameNotFoundException {
128 throw new UnsupportedOperationException();
132 public PermissionInfo getPermissionInfo(String name, int flags)
133 throws NameNotFoundException {
134 throw new UnsupportedOperationException();
138 public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
139 throws NameNotFoundException {
140 throw new UnsupportedOperationException();
145 public boolean isPermissionReviewModeEnabled() {
150 public PermissionGroupInfo getPermissionGroupInfo(String name,
151 int flags) throws NameNotFoundException {
152 throw new UnsupportedOperationException();
156 public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
157 throw new UnsupportedOperationException();
161 public ApplicationInfo getApplicationInfo(String packageName, int flags)
162 throws NameNotFoundException {
163 throw new UnsupportedOperationException();
168 public ApplicationInfo getApplicationInfoAsUser(String packageName, int flags, int userId)
169 throws NameNotFoundException {
170 throw new UnsupportedOperationException();
174 public ActivityInfo getActivityInfo(ComponentName className, int flags)
175 throws NameNotFoundException {
176 throw new UnsupportedOperationException();
180 public ActivityInfo getReceiverInfo(ComponentName className, int flags)
181 throws NameNotFoundException {
182 throw new UnsupportedOperationException();
186 public ServiceInfo getServiceInfo(ComponentName className, int flags)
187 throws NameNotFoundException {
188 throw new UnsupportedOperationException();
192 public ProviderInfo getProviderInfo(ComponentName className, int flags)
193 throws NameNotFoundException {
194 throw new UnsupportedOperationException();
198 public List<PackageInfo> getInstalledPackages(int flags) {
199 throw new UnsupportedOperationException();
203 public List<PackageInfo> getPackagesHoldingPermissions(String[] permissions,
205 throw new UnsupportedOperationException();
210 public List<PackageInfo> getInstalledPackagesAsUser(int flags, int userId) {
211 throw new UnsupportedOperationException();
215 public int checkPermission(String permName, String pkgName) {
216 throw new UnsupportedOperationException();
220 public boolean isPermissionRevokedByPolicy(String permName, String pkgName) {
221 throw new UnsupportedOperationException();
226 public String getPermissionControllerPackageName() {
227 throw new UnsupportedOperationException();
231 public boolean addPermission(PermissionInfo info) {
232 throw new UnsupportedOperationException();
236 public boolean addPermissionAsync(PermissionInfo info) {
237 throw new UnsupportedOperationException();
241 public void removePermission(String name) {
242 throw new UnsupportedOperationException();
247 public void grantRuntimePermission(String packageName, String permissionName,
249 throw new UnsupportedOperationException();
254 public void revokeRuntimePermission(String packageName, String permissionName,
256 throw new UnsupportedOperationException();
261 public int getPermissionFlags(String permissionName, String packageName, UserHandle user) {
262 throw new UnsupportedOperationException();
267 public void updatePermissionFlags(String permissionName, String packageName,
268 int flagMask, int flagValues, UserHandle user) {
269 throw new UnsupportedOperationException();
274 public boolean shouldShowRequestPermissionRationale(String permission) {
275 throw new UnsupportedOperationException();
280 public void addOnPermissionsChangeListener(OnPermissionsChangedListener listener) {
281 throw new UnsupportedOperationException();
286 public void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener) {
287 throw new UnsupportedOperationException();
291 public int checkSignatures(String pkg1, String pkg2) {
292 throw new UnsupportedOperationException();
296 public int checkSignatures(int uid1, int uid2) {
297 throw new UnsupportedOperationException();
301 public String[] getPackagesForUid(int uid) {
302 throw new UnsupportedOperationException();
306 public String getNameForUid(int uid) {
307 throw new UnsupportedOperationException();
311 * @hide - to match hiding in superclass
314 public int getUidForSharedUser(String sharedUserName) {
315 throw new UnsupportedOperationException();
319 public List<ApplicationInfo> getInstalledApplications(int flags) {
320 throw new UnsupportedOperationException();
325 public List<EphemeralApplicationInfo> getEphemeralApplications() {
326 throw new UnsupportedOperationException();
331 public Drawable getEphemeralApplicationIcon(String packageName) {
332 throw new UnsupportedOperationException();
337 public byte[] getEphemeralCookie() {
343 public boolean isEphemeralApplication() {
349 public int getEphemeralCookieMaxSizeBytes() {
355 public boolean setEphemeralCookie(@NonNull byte[] cookie) {
360 public ResolveInfo resolveActivity(Intent intent, int flags) {
361 throw new UnsupportedOperationException();
366 public ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId) {
367 throw new UnsupportedOperationException();
371 public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
372 throw new UnsupportedOperationException();
377 public List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent,
378 int flags, int userId) {
379 throw new UnsupportedOperationException();
383 public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller,
384 Intent[] specifics, Intent intent, int flags) {
385 throw new UnsupportedOperationException();
389 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) {
390 throw new UnsupportedOperationException();
395 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, int flags, int userId) {
396 throw new UnsupportedOperationException();
400 public ResolveInfo resolveService(Intent intent, int flags) {
401 throw new UnsupportedOperationException();
405 public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
406 throw new UnsupportedOperationException();
411 public List<ResolveInfo> queryIntentServicesAsUser(Intent intent, int flags, int userId) {
412 throw new UnsupportedOperationException();
417 public List<ResolveInfo> queryIntentContentProvidersAsUser(
418 Intent intent, int flags, int userId) {
419 throw new UnsupportedOperationException();
423 public List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags) {
424 throw new UnsupportedOperationException();
428 public ProviderInfo resolveContentProvider(String name, int flags) {
429 throw new UnsupportedOperationException();
434 public ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId) {
435 throw new UnsupportedOperationException();
439 public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
440 throw new UnsupportedOperationException();
444 public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags)
445 throws NameNotFoundException {
446 throw new UnsupportedOperationException();
450 public List<InstrumentationInfo> queryInstrumentation(
451 String targetPackage, int flags) {
452 throw new UnsupportedOperationException();
456 public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
457 throw new UnsupportedOperationException();
461 public Drawable getActivityIcon(ComponentName activityName)
462 throws NameNotFoundException {
463 throw new UnsupportedOperationException();
467 public Drawable getActivityIcon(Intent intent) throws NameNotFoundException {
468 throw new UnsupportedOperationException();
472 public Drawable getDefaultActivityIcon() {
473 throw new UnsupportedOperationException();
477 public Drawable getActivityBanner(ComponentName activityName)
478 throws NameNotFoundException {
479 throw new UnsupportedOperationException();
483 public Drawable getActivityBanner(Intent intent) throws NameNotFoundException {
484 throw new UnsupportedOperationException();
488 public Drawable getApplicationBanner(ApplicationInfo info) {
489 throw new UnsupportedOperationException();
493 public Drawable getApplicationBanner(String packageName) throws NameNotFoundException {
494 throw new UnsupportedOperationException();
498 public Drawable getApplicationIcon(ApplicationInfo info) {
499 throw new UnsupportedOperationException();
503 public Drawable getApplicationIcon(String packageName) throws NameNotFoundException {
504 throw new UnsupportedOperationException();
508 public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException {
509 throw new UnsupportedOperationException();
513 public Drawable getActivityLogo(Intent intent) throws NameNotFoundException {
514 throw new UnsupportedOperationException();
518 public Drawable getApplicationLogo(ApplicationInfo info) {
519 throw new UnsupportedOperationException();
523 public Drawable getApplicationLogo(String packageName) throws NameNotFoundException {
524 throw new UnsupportedOperationException();
529 public Drawable getManagedUserBadgedDrawable(Drawable drawable, Rect badgeLocation,
531 throw new UnsupportedOperationException();
536 public Drawable getUserBadgedIcon(Drawable icon, UserHandle user) {
537 throw new UnsupportedOperationException();
541 public Drawable getUserBadgedDrawableForDensity(Drawable drawable, UserHandle user,
544 throw new UnsupportedOperationException();
549 public Drawable getUserBadgeForDensity(UserHandle user, int density) {
550 throw new UnsupportedOperationException();
555 public Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density) {
556 throw new UnsupportedOperationException();
560 public CharSequence getUserBadgedLabel(CharSequence label, UserHandle user) {
561 throw new UnsupportedOperationException();
565 public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
566 throw new UnsupportedOperationException();
570 public XmlResourceParser getXml(String packageName, int resid,
571 ApplicationInfo appInfo) {
572 throw new UnsupportedOperationException();
576 public CharSequence getApplicationLabel(ApplicationInfo info) {
577 throw new UnsupportedOperationException();
581 public Resources getResourcesForActivity(ComponentName activityName)
582 throws NameNotFoundException {
583 throw new UnsupportedOperationException();
587 public Resources getResourcesForApplication(ApplicationInfo app) {
588 throw new UnsupportedOperationException();
592 public Resources getResourcesForApplication(String appPackageName)
593 throws NameNotFoundException {
594 throw new UnsupportedOperationException();
599 public Resources getResourcesForApplicationAsUser(String appPackageName, int userId) {
600 throw new UnsupportedOperationException();
604 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
605 throw new UnsupportedOperationException();
609 * @hide - to match hiding in superclass
612 public void installPackage(Uri packageURI, IPackageInstallObserver observer,
613 int flags, String installerPackageName) {
614 throw new UnsupportedOperationException();
618 public void setInstallerPackageName(String targetPackage,
619 String installerPackageName) {
620 throw new UnsupportedOperationException();
624 public String getInstallerPackageName(String packageName) {
625 throw new UnsupportedOperationException();
630 public int getMoveStatus(int moveId) {
631 throw new UnsupportedOperationException();
636 public void registerMoveCallback(MoveCallback callback, Handler handler) {
637 throw new UnsupportedOperationException();
642 public void unregisterMoveCallback(MoveCallback callback) {
643 throw new UnsupportedOperationException();
648 public int movePackage(String packageName, VolumeInfo vol) {
649 throw new UnsupportedOperationException();
654 public VolumeInfo getPackageCurrentVolume(ApplicationInfo app) {
655 throw new UnsupportedOperationException();
660 public List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app) {
661 throw new UnsupportedOperationException();
666 public int movePrimaryStorage(VolumeInfo vol) {
667 throw new UnsupportedOperationException();
672 public VolumeInfo getPrimaryStorageCurrentVolume() {
673 throw new UnsupportedOperationException();
678 public List<VolumeInfo> getPrimaryStorageCandidateVolumes() {
679 throw new UnsupportedOperationException();
683 * @hide - to match hiding in superclass
686 public void clearApplicationUserData(
687 String packageName, IPackageDataObserver observer) {
688 throw new UnsupportedOperationException();
692 * @hide - to match hiding in superclass
695 public void deleteApplicationCacheFiles(
696 String packageName, IPackageDataObserver observer) {
697 throw new UnsupportedOperationException();
701 * @hide - to match hiding in superclass
704 public void deleteApplicationCacheFilesAsUser(String packageName, int userId,
705 IPackageDataObserver observer) {
706 throw new UnsupportedOperationException();
711 public void freeStorageAndNotify(String volumeUuid, long idealStorageSize,
712 IPackageDataObserver observer) {
713 throw new UnsupportedOperationException();
718 public void freeStorage(String volumeUuid, long idealStorageSize, IntentSender pi) {
719 throw new UnsupportedOperationException();
723 * @hide - to match hiding in superclass
726 public void deletePackage(
727 String packageName, IPackageDeleteObserver observer, int flags) {
728 throw new UnsupportedOperationException();
732 * @hide - to match hiding in superclass
735 public void deletePackageAsUser(
736 String packageName, IPackageDeleteObserver observer, int flags, int userId) {
737 throw new UnsupportedOperationException();
741 public void addPackageToPreferred(String packageName) {
742 throw new UnsupportedOperationException();
746 public void removePackageFromPreferred(String packageName) {
747 throw new UnsupportedOperationException();
751 public List<PackageInfo> getPreferredPackages(int flags) {
752 throw new UnsupportedOperationException();
756 public void setComponentEnabledSetting(ComponentName componentName,
757 int newState, int flags) {
758 throw new UnsupportedOperationException();
762 public int getComponentEnabledSetting(ComponentName componentName) {
763 throw new UnsupportedOperationException();
767 public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
768 throw new UnsupportedOperationException();
772 public int getApplicationEnabledSetting(String packageName) {
773 throw new UnsupportedOperationException();
778 public void flushPackageRestrictionsAsUser(int userId) {
779 throw new UnsupportedOperationException();
783 public void addPreferredActivity(IntentFilter filter,
784 int match, ComponentName[] set, ComponentName activity) {
785 throw new UnsupportedOperationException();
789 * @hide - to match hiding in superclass
792 public void replacePreferredActivity(IntentFilter filter,
793 int match, ComponentName[] set, ComponentName activity) {
794 throw new UnsupportedOperationException();
799 public void clearPackagePreferredActivities(String packageName) {
800 throw new UnsupportedOperationException();
804 * @hide - to match hiding in superclass
807 public void getPackageSizeInfoAsUser(String packageName, int userHandle,
808 IPackageStatsObserver observer) {
809 throw new UnsupportedOperationException();
813 public int getPreferredActivities(List<IntentFilter> outFilters,
814 List<ComponentName> outActivities, String packageName) {
815 throw new UnsupportedOperationException();
818 /** @hide - hidden in superclass */
820 public ComponentName getHomeActivities(List<ResolveInfo> outActivities) {
821 throw new UnsupportedOperationException();
825 public String[] getSystemSharedLibraryNames() {
826 throw new UnsupportedOperationException();
831 public @NonNull String getServicesSystemSharedLibraryPackageName() {
832 throw new UnsupportedOperationException();
837 public @NonNull String getSharedSystemSharedLibraryPackageName() {
838 throw new UnsupportedOperationException();
842 public FeatureInfo[] getSystemAvailableFeatures() {
843 throw new UnsupportedOperationException();
847 public boolean hasSystemFeature(String name) {
848 throw new UnsupportedOperationException();
852 public boolean hasSystemFeature(String name, int version) {
853 throw new UnsupportedOperationException();
857 public boolean isSafeMode() {
858 throw new UnsupportedOperationException();
863 public KeySet getKeySetByAlias(String packageName, String alias) {
864 throw new UnsupportedOperationException();
869 public KeySet getSigningKeySet(String packageName) {
870 throw new UnsupportedOperationException();
875 public boolean isSignedBy(String packageName, KeySet ks) {
876 throw new UnsupportedOperationException();
881 public boolean isSignedByExactly(String packageName, KeySet ks) {
882 throw new UnsupportedOperationException();
887 public String[] setPackagesSuspendedAsUser(String[] packageNames, boolean hidden, int userId) {
888 throw new UnsupportedOperationException();
893 public boolean isPackageSuspendedForUser(String packageName, int userId) {
894 throw new UnsupportedOperationException();
901 public boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden,
910 public boolean getApplicationHiddenSettingAsUser(String packageName, UserHandle user) {
918 public int installExistingPackage(String packageName) throws NameNotFoundException {
919 throw new UnsupportedOperationException();
926 public int installExistingPackageAsUser(String packageName, int userId)
927 throws NameNotFoundException {
928 throw new UnsupportedOperationException();
932 public void verifyPendingInstall(int id, int verificationCode) {
933 throw new UnsupportedOperationException();
937 public void extendVerificationTimeout(int id, int verificationCodeAtTimeout,
938 long millisecondsToDelay) {
939 throw new UnsupportedOperationException();
946 public void verifyIntentFilter(int id, int verificationCode, List<String> outFailedDomains) {
947 throw new UnsupportedOperationException();
954 public int getIntentVerificationStatusAsUser(String packageName, int userId) {
955 throw new UnsupportedOperationException();
962 public boolean updateIntentVerificationStatusAsUser(String packageName, int status, int userId) {
963 throw new UnsupportedOperationException();
970 public List<IntentFilterVerificationInfo> getIntentFilterVerifications(String packageName) {
971 throw new UnsupportedOperationException();
975 public List<IntentFilter> getAllIntentFilters(String packageName) {
976 throw new UnsupportedOperationException();
981 public String getDefaultBrowserPackageName(int userId) {
982 throw new UnsupportedOperationException();
987 public String getDefaultBrowserPackageNameAsUser(int userId) {
988 throw new UnsupportedOperationException();
993 public boolean setDefaultBrowserPackageName(String packageName, int userId) {
994 throw new UnsupportedOperationException();
999 public boolean setDefaultBrowserPackageNameAsUser(String packageName, int userId) {
1000 throw new UnsupportedOperationException();
1007 public VerifierDeviceIdentity getVerifierDeviceIdentity() {
1008 throw new UnsupportedOperationException();
1015 public boolean isUpgrade() {
1016 throw new UnsupportedOperationException();
1023 public void installPackage(Uri packageURI, PackageInstallObserver observer,
1024 int flags, String installerPackageName) {
1025 throw new UnsupportedOperationException();
1032 public void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, int targetUserId,
1034 throw new UnsupportedOperationException();
1041 public void clearCrossProfileIntentFilters(int sourceUserId) {
1042 throw new UnsupportedOperationException();
1046 public PackageInstaller getPackageInstaller() {
1047 throw new UnsupportedOperationException();
1052 public boolean isPackageAvailable(String packageName) {
1053 throw new UnsupportedOperationException();
1059 public Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
1060 throw new UnsupportedOperationException();
1066 public Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo) {
1067 throw new UnsupportedOperationException();