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