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 |
| 142 | public String[] getPackagesForUid(int uid) { |
| 143 | throw new UnsupportedOperationException(); |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public String getNameForUid(int uid) { |
| 148 | throw new UnsupportedOperationException(); |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * @hide - to match hiding in superclass |
| 153 | */ |
| 154 | @Override |
| 155 | public int getUidForSharedUser(String sharedUserName) { |
| 156 | throw new UnsupportedOperationException(); |
| 157 | } |
| 158 | |
| 159 | @Override |
| 160 | public List<ApplicationInfo> getInstalledApplications(int flags) { |
| 161 | throw new UnsupportedOperationException(); |
| 162 | } |
| 163 | |
| 164 | @Override |
| 165 | public ResolveInfo resolveActivity(Intent intent, int flags) { |
| 166 | throw new UnsupportedOperationException(); |
| 167 | } |
| 168 | |
| 169 | @Override |
| 170 | public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) { |
| 171 | throw new UnsupportedOperationException(); |
| 172 | } |
| 173 | |
| 174 | @Override |
| 175 | public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, |
| 176 | Intent[] specifics, Intent intent, int flags) { |
| 177 | throw new UnsupportedOperationException(); |
| 178 | } |
| 179 | |
| 180 | @Override |
| 181 | public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) { |
| 182 | throw new UnsupportedOperationException(); |
| 183 | } |
| 184 | |
| 185 | @Override |
| 186 | public ResolveInfo resolveService(Intent intent, int flags) { |
| 187 | throw new UnsupportedOperationException(); |
| 188 | } |
| 189 | |
| 190 | @Override |
| 191 | public List<ResolveInfo> queryIntentServices(Intent intent, int flags) { |
| 192 | throw new UnsupportedOperationException(); |
| 193 | } |
| 194 | |
| 195 | @Override |
| 196 | public ProviderInfo resolveContentProvider(String name, int flags) { |
| 197 | throw new UnsupportedOperationException(); |
| 198 | } |
| 199 | |
| 200 | @Override |
| 201 | public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) { |
| 202 | throw new UnsupportedOperationException(); |
| 203 | } |
| 204 | |
| 205 | @Override |
| 206 | public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags) |
| 207 | throws NameNotFoundException { |
| 208 | throw new UnsupportedOperationException(); |
| 209 | } |
| 210 | |
| 211 | @Override |
| 212 | public List<InstrumentationInfo> queryInstrumentation( |
| 213 | String targetPackage, int flags) { |
| 214 | throw new UnsupportedOperationException(); |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) { |
| 219 | throw new UnsupportedOperationException(); |
| 220 | } |
| 221 | |
| 222 | @Override |
| 223 | public Drawable getActivityIcon(ComponentName activityName) |
| 224 | throws NameNotFoundException { |
| 225 | throw new UnsupportedOperationException(); |
| 226 | } |
| 227 | |
| 228 | @Override |
| 229 | public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { |
| 230 | throw new UnsupportedOperationException(); |
| 231 | } |
| 232 | |
| 233 | @Override |
| 234 | public Drawable getDefaultActivityIcon() { |
| 235 | throw new UnsupportedOperationException(); |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public Drawable getApplicationIcon(ApplicationInfo info) { |
| 240 | throw new UnsupportedOperationException(); |
| 241 | } |
| 242 | |
| 243 | @Override |
| 244 | public Drawable getApplicationIcon(String packageName) throws NameNotFoundException { |
| 245 | throw new UnsupportedOperationException(); |
| 246 | } |
| 247 | |
| 248 | @Override |
| 249 | public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) { |
| 250 | throw new UnsupportedOperationException(); |
| 251 | } |
| 252 | |
| 253 | @Override |
| 254 | public XmlResourceParser getXml(String packageName, int resid, |
| 255 | ApplicationInfo appInfo) { |
| 256 | throw new UnsupportedOperationException(); |
| 257 | } |
| 258 | |
| 259 | @Override |
| 260 | public CharSequence getApplicationLabel(ApplicationInfo info) { |
| 261 | throw new UnsupportedOperationException(); |
| 262 | } |
| 263 | |
| 264 | @Override |
| 265 | public Resources getResourcesForActivity(ComponentName activityName) |
| 266 | throws NameNotFoundException { |
| 267 | throw new UnsupportedOperationException(); |
| 268 | } |
| 269 | |
| 270 | @Override |
| 271 | public Resources getResourcesForApplication(ApplicationInfo app) { |
| 272 | throw new UnsupportedOperationException(); |
| 273 | } |
| 274 | |
| 275 | @Override |
| 276 | public Resources getResourcesForApplication(String appPackageName) |
| 277 | throws NameNotFoundException { |
| 278 | throw new UnsupportedOperationException(); |
| 279 | } |
| 280 | |
| 281 | @Override |
| 282 | public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { |
| 283 | throw new UnsupportedOperationException(); |
| 284 | } |
| 285 | |
Dianne Hackborn | ade3eca | 2009-05-11 18:54:45 -0700 | [diff] [blame] | 286 | /** |
| 287 | * @hide - to match hiding in superclass |
| 288 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 289 | @Override |
| 290 | public void installPackage(Uri packageURI, IPackageInstallObserver observer, |
Jacek Surazski | c64322c | 2009-04-28 15:26:38 +0200 | [diff] [blame] | 291 | int flags, String installerPackageName) { |
| 292 | throw new UnsupportedOperationException(); |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * @hide - to match hiding in superclass |
| 297 | */ |
| 298 | @Override |
| 299 | public String getInstallerPackageName(String packageName) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | throw new UnsupportedOperationException(); |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * @hide - to match hiding in superclass |
| 305 | */ |
| 306 | @Override |
| 307 | public void clearApplicationUserData( |
| 308 | String packageName, IPackageDataObserver observer) { |
| 309 | throw new UnsupportedOperationException(); |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * @hide - to match hiding in superclass |
| 314 | */ |
| 315 | @Override |
| 316 | public void deleteApplicationCacheFiles( |
| 317 | String packageName, IPackageDataObserver observer) { |
| 318 | throw new UnsupportedOperationException(); |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * @hide - to match hiding in superclass |
| 323 | */ |
| 324 | @Override |
| 325 | public void freeStorageAndNotify( |
| 326 | long idealStorageSize, IPackageDataObserver observer) { |
| 327 | throw new UnsupportedOperationException(); |
| 328 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 329 | |
| 330 | /** |
| 331 | * @hide - to match hiding in superclass |
| 332 | */ |
| 333 | @Override |
Suchi Amalapurapu | bc806f6 | 2009-06-17 15:18:19 -0700 | [diff] [blame^] | 334 | public void freeStorage( |
Suchi Amalapurapu | 1ccac75 | 2009-06-12 10:09:58 -0700 | [diff] [blame] | 335 | long idealStorageSize, IntentSender pi) { |
| 336 | throw new UnsupportedOperationException(); |
| 337 | } |
| 338 | |
| 339 | /** |
| 340 | * @hide - to match hiding in superclass |
| 341 | */ |
| 342 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 343 | public void deletePackage( |
| 344 | String packageName, IPackageDeleteObserver observer, int flags) { |
| 345 | throw new UnsupportedOperationException(); |
| 346 | } |
| 347 | |
| 348 | @Override |
| 349 | public void addPackageToPreferred(String packageName) { |
| 350 | throw new UnsupportedOperationException(); |
| 351 | } |
| 352 | |
| 353 | @Override |
| 354 | public void removePackageFromPreferred(String packageName) { |
| 355 | throw new UnsupportedOperationException(); |
| 356 | } |
| 357 | |
| 358 | @Override |
| 359 | public List<PackageInfo> getPreferredPackages(int flags) { |
| 360 | throw new UnsupportedOperationException(); |
| 361 | } |
| 362 | |
| 363 | @Override |
| 364 | public void setComponentEnabledSetting(ComponentName componentName, |
| 365 | int newState, int flags) { |
| 366 | throw new UnsupportedOperationException(); |
| 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public int getComponentEnabledSetting(ComponentName componentName) { |
| 371 | throw new UnsupportedOperationException(); |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public void setApplicationEnabledSetting(String packageName, int newState, int flags) { |
| 376 | throw new UnsupportedOperationException(); |
| 377 | } |
| 378 | |
| 379 | @Override |
| 380 | public int getApplicationEnabledSetting(String packageName) { |
| 381 | throw new UnsupportedOperationException(); |
| 382 | } |
| 383 | |
| 384 | @Override |
| 385 | public void addPreferredActivity(IntentFilter filter, |
| 386 | int match, ComponentName[] set, ComponentName activity) { |
| 387 | throw new UnsupportedOperationException(); |
| 388 | } |
| 389 | |
Satish Sampath | 8dbe612 | 2009-06-02 23:35:54 +0100 | [diff] [blame] | 390 | /** |
| 391 | * @hide - to match hiding in superclass |
| 392 | */ |
| 393 | @Override |
| 394 | public void replacePreferredActivity(IntentFilter filter, |
| 395 | int match, ComponentName[] set, ComponentName activity) { |
| 396 | throw new UnsupportedOperationException(); |
| 397 | } |
| 398 | |
| 399 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 400 | @Override |
| 401 | public void clearPackagePreferredActivities(String packageName) { |
| 402 | throw new UnsupportedOperationException(); |
| 403 | } |
| 404 | |
| 405 | /** |
| 406 | * @hide - to match hiding in superclass |
| 407 | */ |
| 408 | @Override |
| 409 | public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { |
| 410 | throw new UnsupportedOperationException(); |
| 411 | } |
| 412 | |
| 413 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | public int getPreferredActivities(List<IntentFilter> outFilters, |
| 415 | List<ComponentName> outActivities, String packageName) { |
| 416 | throw new UnsupportedOperationException(); |
| 417 | } |
| 418 | |
| 419 | @Override |
| 420 | public String[] getSystemSharedLibraryNames() { |
| 421 | throw new UnsupportedOperationException(); |
| 422 | } |
| 423 | |
| 424 | @Override |
| 425 | public boolean isSafeMode() { |
| 426 | throw new UnsupportedOperationException(); |
| 427 | } |
| 428 | } |