MockPackageManager.java revision 5d40fe9c6846ba765072e50ed1254293cb9195e4
1/*
2 * Copyright (C) 2008 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
17package android.test.mock;
18
19import android.content.ComponentName;
20import android.content.Intent;
21import android.content.IntentFilter;
22import android.content.IntentSender;
23import android.content.pm.ActivityInfo;
24import android.content.pm.ApplicationInfo;
25import android.content.pm.FeatureInfo;
26import android.content.pm.IPackageDeleteObserver;
27import android.content.pm.IPackageDataObserver;
28import android.content.pm.IPackageInstallObserver;
29import android.content.pm.IPackageMoveObserver;
30import android.content.pm.IPackageStatsObserver;
31import android.content.pm.InstrumentationInfo;
32import android.content.pm.PackageInfo;
33import android.content.pm.PackageManager;
34import android.content.pm.PackageParser;
35import android.content.pm.PermissionGroupInfo;
36import android.content.pm.PermissionInfo;
37import android.content.pm.ProviderInfo;
38import android.content.pm.ResolveInfo;
39import android.content.pm.ServiceInfo;
40import android.content.pm.PackageManager.NameNotFoundException;
41import android.content.res.Resources;
42import android.content.res.XmlResourceParser;
43import android.graphics.drawable.Drawable;
44import android.net.Uri;
45import android.os.RemoteException;
46
47import java.util.List;
48
49/**
50 * A mock {@link android.content.pm.PackageManager} class.  All methods are non-functional and throw
51 * {@link java.lang.UnsupportedOperationException}. Override it to provide the operations that you
52 * need.
53 */
54public class MockPackageManager extends PackageManager {
55
56    @Override
57    public PackageInfo getPackageInfo(String packageName, int flags)
58    throws NameNotFoundException {
59        throw new UnsupportedOperationException();
60    }
61
62    @Override
63    public String[] currentToCanonicalPackageNames(String[] names) {
64        throw new UnsupportedOperationException();
65    }
66
67    @Override
68    public String[] canonicalToCurrentPackageNames(String[] names) {
69        throw new UnsupportedOperationException();
70    }
71
72    @Override
73    public Intent getLaunchIntentForPackage(String packageName) {
74        throw new UnsupportedOperationException();
75    }
76
77    @Override
78    public int[] getPackageGids(String packageName) throws NameNotFoundException {
79        throw new UnsupportedOperationException();
80    }
81
82    @Override
83    public PermissionInfo getPermissionInfo(String name, int flags)
84    throws NameNotFoundException {
85        throw new UnsupportedOperationException();
86    }
87
88    @Override
89    public List<PermissionInfo> queryPermissionsByGroup(String group, int flags)
90            throws NameNotFoundException {
91        throw new UnsupportedOperationException();
92    }
93
94    @Override
95    public PermissionGroupInfo getPermissionGroupInfo(String name,
96            int flags) throws NameNotFoundException {
97        throw new UnsupportedOperationException();
98    }
99
100    @Override
101    public List<PermissionGroupInfo> getAllPermissionGroups(int flags) {
102        throw new UnsupportedOperationException();
103    }
104
105    @Override
106    public ApplicationInfo getApplicationInfo(String packageName, int flags)
107    throws NameNotFoundException {
108        throw new UnsupportedOperationException();
109    }
110
111    @Override
112    public ActivityInfo getActivityInfo(ComponentName className, int flags)
113    throws NameNotFoundException {
114        throw new UnsupportedOperationException();
115    }
116
117    @Override
118    public ActivityInfo getReceiverInfo(ComponentName className, int flags)
119    throws NameNotFoundException {
120        throw new UnsupportedOperationException();
121    }
122
123    @Override
124    public ServiceInfo getServiceInfo(ComponentName className, int flags)
125    throws NameNotFoundException {
126        throw new UnsupportedOperationException();
127    }
128
129    @Override
130    public ProviderInfo getProviderInfo(ComponentName className, int flags)
131    throws NameNotFoundException {
132        throw new UnsupportedOperationException();
133    }
134
135    @Override
136    public List<PackageInfo> getInstalledPackages(int flags) {
137        throw new UnsupportedOperationException();
138    }
139
140    @Override
141    public int checkPermission(String permName, String pkgName) {
142        throw new UnsupportedOperationException();
143    }
144
145    @Override
146    public boolean addPermission(PermissionInfo info) {
147        throw new UnsupportedOperationException();
148    }
149
150    @Override
151    public boolean addPermissionAsync(PermissionInfo info) {
152        throw new UnsupportedOperationException();
153    }
154
155    @Override
156    public void removePermission(String name) {
157        throw new UnsupportedOperationException();
158    }
159
160    @Override
161    public int checkSignatures(String pkg1, String pkg2) {
162        throw new UnsupportedOperationException();
163    }
164
165    @Override
166    public int checkSignatures(int uid1, int uid2) {
167        throw new UnsupportedOperationException();
168    }
169
170    @Override
171    public String[] getPackagesForUid(int uid) {
172        throw new UnsupportedOperationException();
173    }
174
175    @Override
176    public String getNameForUid(int uid) {
177        throw new UnsupportedOperationException();
178    }
179
180    /**
181     * @hide - to match hiding in superclass
182     */
183    @Override
184    public int getUidForSharedUser(String sharedUserName) {
185        throw new UnsupportedOperationException();
186    }
187
188    @Override
189    public List<ApplicationInfo> getInstalledApplications(int flags) {
190        throw new UnsupportedOperationException();
191    }
192
193    @Override
194    public ResolveInfo resolveActivity(Intent intent, int flags) {
195        throw new UnsupportedOperationException();
196    }
197
198    @Override
199    public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
200        throw new UnsupportedOperationException();
201    }
202
203    @Override
204    public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller,
205            Intent[] specifics, Intent intent, int flags) {
206        throw new UnsupportedOperationException();
207    }
208
209    @Override
210    public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) {
211        throw new UnsupportedOperationException();
212    }
213
214    @Override
215    public ResolveInfo resolveService(Intent intent, int flags) {
216        throw new UnsupportedOperationException();
217    }
218
219    @Override
220    public List<ResolveInfo> queryIntentServices(Intent intent, int flags) {
221        throw new UnsupportedOperationException();
222    }
223
224    @Override
225    public ProviderInfo resolveContentProvider(String name, int flags) {
226        throw new UnsupportedOperationException();
227    }
228
229    @Override
230    public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) {
231        throw new UnsupportedOperationException();
232    }
233
234    @Override
235    public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags)
236    throws NameNotFoundException {
237        throw new UnsupportedOperationException();
238    }
239
240    @Override
241    public List<InstrumentationInfo> queryInstrumentation(
242            String targetPackage, int flags) {
243        throw new UnsupportedOperationException();
244    }
245
246    @Override
247    public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) {
248        throw new UnsupportedOperationException();
249    }
250
251    @Override
252    public Drawable getActivityIcon(ComponentName activityName)
253    throws NameNotFoundException {
254        throw new UnsupportedOperationException();
255    }
256
257    @Override
258    public Drawable getActivityIcon(Intent intent) throws NameNotFoundException {
259        throw new UnsupportedOperationException();
260    }
261
262    @Override
263    public Drawable getDefaultActivityIcon() {
264        throw new UnsupportedOperationException();
265    }
266
267    @Override
268    public Drawable getApplicationIcon(ApplicationInfo info) {
269        throw new UnsupportedOperationException();
270    }
271
272    @Override
273    public Drawable getApplicationIcon(String packageName) throws NameNotFoundException {
274        throw new UnsupportedOperationException();
275    }
276
277    @Override
278    public Drawable getActivityLogo(ComponentName activityName) throws NameNotFoundException {
279        throw new UnsupportedOperationException();
280    }
281
282    @Override
283    public Drawable getActivityLogo(Intent intent) throws NameNotFoundException {
284        throw new UnsupportedOperationException();
285    }
286
287    @Override
288    public Drawable getApplicationLogo(ApplicationInfo info) {
289        throw new UnsupportedOperationException();
290    }
291
292    @Override
293    public Drawable getApplicationLogo(String packageName) throws NameNotFoundException {
294        throw new UnsupportedOperationException();
295    }
296
297    @Override
298    public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) {
299        throw new UnsupportedOperationException();
300    }
301
302    @Override
303    public XmlResourceParser getXml(String packageName, int resid,
304            ApplicationInfo appInfo) {
305        throw new UnsupportedOperationException();
306    }
307
308    @Override
309    public CharSequence getApplicationLabel(ApplicationInfo info) {
310        throw new UnsupportedOperationException();
311    }
312
313    @Override
314    public Resources getResourcesForActivity(ComponentName activityName)
315    throws NameNotFoundException {
316        throw new UnsupportedOperationException();
317    }
318
319    @Override
320    public Resources getResourcesForApplication(ApplicationInfo app) {
321        throw new UnsupportedOperationException();
322    }
323
324    @Override
325    public Resources getResourcesForApplication(String appPackageName)
326    throws NameNotFoundException {
327        throw new UnsupportedOperationException();
328    }
329
330    @Override
331    public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) {
332        throw new UnsupportedOperationException();
333    }
334
335    /**
336     * @hide - to match hiding in superclass
337     */
338    @Override
339    public void installPackage(Uri packageURI, IPackageInstallObserver observer,
340            int flags, String installerPackageName) {
341        throw new UnsupportedOperationException();
342    }
343
344    @Override
345    public void setInstallerPackageName(String targetPackage,
346            String installerPackageName) {
347        throw new UnsupportedOperationException();
348    }
349
350    /**
351     * @hide - to match hiding in superclass
352     */
353    @Override
354    public void movePackage(String packageName, IPackageMoveObserver observer, int flags) {
355        throw new UnsupportedOperationException();
356    }
357
358    @Override
359    public String getInstallerPackageName(String packageName) {
360        throw new UnsupportedOperationException();
361    }
362
363    /**
364     * @hide - to match hiding in superclass
365     */
366    @Override
367    public void clearApplicationUserData(
368            String packageName, IPackageDataObserver observer) {
369        throw new UnsupportedOperationException();
370    }
371
372    /**
373     * @hide - to match hiding in superclass
374     */
375    @Override
376    public void deleteApplicationCacheFiles(
377            String packageName, IPackageDataObserver observer) {
378        throw new UnsupportedOperationException();
379    }
380
381    /**
382     * @hide - to match hiding in superclass
383     */
384    @Override
385    public void freeStorageAndNotify(
386            long idealStorageSize, IPackageDataObserver observer) {
387        throw new UnsupportedOperationException();
388    }
389
390    /**
391     * @hide - to match hiding in superclass
392     */
393    @Override
394    public void freeStorage(
395            long idealStorageSize, IntentSender pi) {
396        throw new UnsupportedOperationException();
397    }
398
399    /**
400     * @hide - to match hiding in superclass
401     */
402    @Override
403    public void deletePackage(
404            String packageName, IPackageDeleteObserver observer, int flags) {
405        throw new UnsupportedOperationException();
406    }
407
408    @Override
409    public void addPackageToPreferred(String packageName) {
410        throw new UnsupportedOperationException();
411    }
412
413    @Override
414    public void removePackageFromPreferred(String packageName) {
415        throw new UnsupportedOperationException();
416    }
417
418    @Override
419    public List<PackageInfo> getPreferredPackages(int flags) {
420        throw new UnsupportedOperationException();
421    }
422
423    @Override
424    public void setComponentEnabledSetting(ComponentName componentName,
425            int newState, int flags) {
426        throw new UnsupportedOperationException();
427    }
428
429    @Override
430    public int getComponentEnabledSetting(ComponentName componentName) {
431        throw new UnsupportedOperationException();
432    }
433
434    @Override
435    public void setApplicationEnabledSetting(String packageName, int newState, int flags) {
436        throw new UnsupportedOperationException();
437    }
438
439    @Override
440    public int getApplicationEnabledSetting(String packageName) {
441        throw new UnsupportedOperationException();
442    }
443
444    @Override
445    public void addPreferredActivity(IntentFilter filter,
446            int match, ComponentName[] set, ComponentName activity) {
447        throw new UnsupportedOperationException();
448    }
449
450    /**
451     * @hide - to match hiding in superclass
452     */
453    @Override
454    public void replacePreferredActivity(IntentFilter filter,
455            int match, ComponentName[] set, ComponentName activity) {
456        throw new UnsupportedOperationException();
457    }
458
459
460    @Override
461    public void clearPackagePreferredActivities(String packageName) {
462        throw new UnsupportedOperationException();
463    }
464
465    /**
466     * @hide - to match hiding in superclass
467     */
468    @Override
469    public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) {
470        throw new UnsupportedOperationException();
471    }
472
473    @Override
474    public int getPreferredActivities(List<IntentFilter> outFilters,
475            List<ComponentName> outActivities, String packageName) {
476        throw new UnsupportedOperationException();
477    }
478
479    @Override
480    public String[] getSystemSharedLibraryNames() {
481        throw new UnsupportedOperationException();
482    }
483
484    @Override
485    public FeatureInfo[] getSystemAvailableFeatures() {
486        throw new UnsupportedOperationException();
487    }
488
489    @Override
490    public boolean hasSystemFeature(String name) {
491        throw new UnsupportedOperationException();
492    }
493
494    @Override
495    public boolean isSafeMode() {
496        throw new UnsupportedOperationException();
497    }
498
499    public void setPackageObbPath(String packageName, String path) {
500        throw new UnsupportedOperationException();
501    }
502
503    @Override
504    public void setPackageObbPaths(String packageName, String[] paths) {
505        throw new UnsupportedOperationException();
506    }
507
508    @Override
509    public String[] getPackageObbPaths(String packageName) {
510        throw new UnsupportedOperationException();
511    }
512}
513