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