The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
| 17 | package android.test.mock; |
| 18 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.content.ComponentName; |
| 20 | import android.content.Intent; |
| 21 | import android.content.IntentFilter; |
Suchi Amalapurapu | 1ccac75 | 2009-06-12 10:09:58 -0700 | [diff] [blame] | 22 | import android.content.IntentSender; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.content.pm.ActivityInfo; |
| 24 | import android.content.pm.ApplicationInfo; |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 25 | import android.content.pm.FeatureInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.pm.IPackageDeleteObserver; |
| 27 | import android.content.pm.IPackageDataObserver; |
| 28 | import android.content.pm.IPackageInstallObserver; |
| 29 | import android.content.pm.IPackageStatsObserver; |
| 30 | import android.content.pm.InstrumentationInfo; |
| 31 | import android.content.pm.PackageInfo; |
| 32 | import android.content.pm.PackageManager; |
Suchi Amalapurapu | 117818e | 2010-02-09 03:45:40 -0800 | [diff] [blame] | 33 | import android.content.pm.PackageParser; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.content.pm.PermissionGroupInfo; |
| 35 | import android.content.pm.PermissionInfo; |
| 36 | import android.content.pm.ProviderInfo; |
| 37 | import android.content.pm.ResolveInfo; |
| 38 | import android.content.pm.ServiceInfo; |
| 39 | import android.content.pm.PackageManager.NameNotFoundException; |
| 40 | import android.content.res.Resources; |
| 41 | import android.content.res.XmlResourceParser; |
| 42 | import android.graphics.drawable.Drawable; |
| 43 | import android.net.Uri; |
| 44 | import android.os.RemoteException; |
| 45 | |
| 46 | import 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 | */ |
| 53 | public 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 |
Dianne Hackborn | 4709693 | 2010-02-11 15:57:09 -0800 | [diff] [blame] | 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 |
Mihai Preda | eae850c | 2009-05-13 10:13:48 +0200 | [diff] [blame] | 72 | public Intent getLaunchIntentForPackage(String packageName) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | throw new UnsupportedOperationException(); |
| 74 | } |
Mihai Preda | eae850c | 2009-05-13 10:13:48 +0200 | [diff] [blame] | 75 | |
| 76 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 |
Dianne Hackborn | 766cbfe | 2009-08-12 18:33:39 -0700 | [diff] [blame] | 154 | public int checkSignatures(int uid1, int uid2) { |
| 155 | throw new UnsupportedOperationException(); |
| 156 | } |
| 157 | |
| 158 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Dianne Hackborn | ade3eca | 2009-05-11 18:54:45 -0700 | [diff] [blame] | 303 | /** |
| 304 | * @hide - to match hiding in superclass |
| 305 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 306 | @Override |
| 307 | public void installPackage(Uri packageURI, IPackageInstallObserver observer, |
Jacek Surazski | 65e1317 | 2009-04-28 15:26:38 +0200 | [diff] [blame] | 308 | int flags, String installerPackageName) { |
| 309 | throw new UnsupportedOperationException(); |
| 310 | } |
| 311 | |
| 312 | @Override |
| 313 | public String getInstallerPackageName(String packageName) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | |
| 344 | /** |
| 345 | * @hide - to match hiding in superclass |
| 346 | */ |
| 347 | @Override |
Suchi Amalapurapu | bc806f6 | 2009-06-17 15:18:19 -0700 | [diff] [blame] | 348 | public void freeStorage( |
Suchi Amalapurapu | 1ccac75 | 2009-06-12 10:09:58 -0700 | [diff] [blame] | 349 | long idealStorageSize, IntentSender pi) { |
| 350 | throw new UnsupportedOperationException(); |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * @hide - to match hiding in superclass |
| 355 | */ |
| 356 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Satish Sampath | 8dbe612 | 2009-06-02 23:35:54 +0100 | [diff] [blame] | 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 |
Dianne Hackborn | 4923734 | 2009-08-27 20:08:01 -0700 | [diff] [blame] | 439 | public FeatureInfo[] getSystemAvailableFeatures() { |
| 440 | throw new UnsupportedOperationException(); |
| 441 | } |
| 442 | |
| 443 | @Override |
Dianne Hackborn | 039c68e | 2009-09-26 16:39:23 -0700 | [diff] [blame] | 444 | public boolean hasSystemFeature(String name) { |
| 445 | throw new UnsupportedOperationException(); |
| 446 | } |
| 447 | |
| 448 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 449 | public boolean isSafeMode() { |
| 450 | throw new UnsupportedOperationException(); |
| 451 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | } |