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