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