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 | |
| 19 | import android.app.PendingIntent; |
| 20 | import android.content.ComponentName; |
| 21 | import android.content.Intent; |
| 22 | import android.content.IntentFilter; |
| 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 |
| 60 | public Intent getLaunchIntentForPackage(String packageName) |
| 61 | throws NameNotFoundException { |
| 62 | throw new UnsupportedOperationException(); |
| 63 | } |
| 64 | |
| 65 | @Override |
| 66 | public int[] getPackageGids(String packageName) throws NameNotFoundException { |
| 67 | throw new UnsupportedOperationException(); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public PermissionInfo getPermissionInfo(String name, int flags) |
| 72 | throws NameNotFoundException { |
| 73 | throw new UnsupportedOperationException(); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public List<PermissionInfo> queryPermissionsByGroup(String group, int flags) |
| 78 | throws NameNotFoundException { |
| 79 | throw new UnsupportedOperationException(); |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public PermissionGroupInfo getPermissionGroupInfo(String name, |
| 84 | int flags) throws NameNotFoundException { |
| 85 | throw new UnsupportedOperationException(); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public List<PermissionGroupInfo> getAllPermissionGroups(int flags) { |
| 90 | throw new UnsupportedOperationException(); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public ApplicationInfo getApplicationInfo(String packageName, int flags) |
| 95 | throws NameNotFoundException { |
| 96 | throw new UnsupportedOperationException(); |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public ActivityInfo getActivityInfo(ComponentName className, int flags) |
| 101 | throws NameNotFoundException { |
| 102 | throw new UnsupportedOperationException(); |
| 103 | } |
| 104 | |
| 105 | @Override |
| 106 | public ActivityInfo getReceiverInfo(ComponentName className, int flags) |
| 107 | throws NameNotFoundException { |
| 108 | throw new UnsupportedOperationException(); |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public ServiceInfo getServiceInfo(ComponentName className, int flags) |
| 113 | throws NameNotFoundException { |
| 114 | throw new UnsupportedOperationException(); |
| 115 | } |
| 116 | |
| 117 | @Override |
| 118 | public List<PackageInfo> getInstalledPackages(int flags) { |
| 119 | throw new UnsupportedOperationException(); |
| 120 | } |
| 121 | |
| 122 | @Override |
| 123 | public int checkPermission(String permName, String pkgName) { |
| 124 | throw new UnsupportedOperationException(); |
| 125 | } |
| 126 | |
| 127 | @Override |
| 128 | public boolean addPermission(PermissionInfo info) { |
| 129 | throw new UnsupportedOperationException(); |
| 130 | } |
| 131 | |
| 132 | @Override |
| 133 | public void removePermission(String name) { |
| 134 | throw new UnsupportedOperationException(); |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | public int checkSignatures(String pkg1, String pkg2) { |
| 139 | throw new UnsupportedOperationException(); |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public String[] getPackagesForUid(int uid) { |
| 144 | throw new UnsupportedOperationException(); |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | public String getNameForUid(int uid) { |
| 149 | throw new UnsupportedOperationException(); |
| 150 | } |
| 151 | |
| 152 | /** |
| 153 | * @hide - to match hiding in superclass |
| 154 | */ |
| 155 | @Override |
| 156 | public int getUidForSharedUser(String sharedUserName) { |
| 157 | throw new UnsupportedOperationException(); |
| 158 | } |
| 159 | |
| 160 | @Override |
| 161 | public List<ApplicationInfo> getInstalledApplications(int flags) { |
| 162 | throw new UnsupportedOperationException(); |
| 163 | } |
| 164 | |
| 165 | @Override |
| 166 | public ResolveInfo resolveActivity(Intent intent, int flags) { |
| 167 | throw new UnsupportedOperationException(); |
| 168 | } |
| 169 | |
| 170 | @Override |
| 171 | public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) { |
| 172 | throw new UnsupportedOperationException(); |
| 173 | } |
| 174 | |
| 175 | @Override |
| 176 | public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller, |
| 177 | Intent[] specifics, Intent intent, int flags) { |
| 178 | throw new UnsupportedOperationException(); |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public List<ResolveInfo> queryBroadcastReceivers(Intent intent, int flags) { |
| 183 | throw new UnsupportedOperationException(); |
| 184 | } |
| 185 | |
| 186 | @Override |
| 187 | public ResolveInfo resolveService(Intent intent, int flags) { |
| 188 | throw new UnsupportedOperationException(); |
| 189 | } |
| 190 | |
| 191 | @Override |
| 192 | public List<ResolveInfo> queryIntentServices(Intent intent, int flags) { |
| 193 | throw new UnsupportedOperationException(); |
| 194 | } |
| 195 | |
| 196 | @Override |
| 197 | public ProviderInfo resolveContentProvider(String name, int flags) { |
| 198 | throw new UnsupportedOperationException(); |
| 199 | } |
| 200 | |
| 201 | @Override |
| 202 | public List<ProviderInfo> queryContentProviders(String processName, int uid, int flags) { |
| 203 | throw new UnsupportedOperationException(); |
| 204 | } |
| 205 | |
| 206 | @Override |
| 207 | public InstrumentationInfo getInstrumentationInfo(ComponentName className, int flags) |
| 208 | throws NameNotFoundException { |
| 209 | throw new UnsupportedOperationException(); |
| 210 | } |
| 211 | |
| 212 | @Override |
| 213 | public List<InstrumentationInfo> queryInstrumentation( |
| 214 | String targetPackage, int flags) { |
| 215 | throw new UnsupportedOperationException(); |
| 216 | } |
| 217 | |
| 218 | @Override |
| 219 | public Drawable getDrawable(String packageName, int resid, ApplicationInfo appInfo) { |
| 220 | throw new UnsupportedOperationException(); |
| 221 | } |
| 222 | |
| 223 | @Override |
| 224 | public Drawable getActivityIcon(ComponentName activityName) |
| 225 | throws NameNotFoundException { |
| 226 | throw new UnsupportedOperationException(); |
| 227 | } |
| 228 | |
| 229 | @Override |
| 230 | public Drawable getActivityIcon(Intent intent) throws NameNotFoundException { |
| 231 | throw new UnsupportedOperationException(); |
| 232 | } |
| 233 | |
| 234 | @Override |
| 235 | public Drawable getDefaultActivityIcon() { |
| 236 | throw new UnsupportedOperationException(); |
| 237 | } |
| 238 | |
| 239 | @Override |
| 240 | public Drawable getApplicationIcon(ApplicationInfo info) { |
| 241 | throw new UnsupportedOperationException(); |
| 242 | } |
| 243 | |
| 244 | @Override |
| 245 | public Drawable getApplicationIcon(String packageName) throws NameNotFoundException { |
| 246 | throw new UnsupportedOperationException(); |
| 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public CharSequence getText(String packageName, int resid, ApplicationInfo appInfo) { |
| 251 | throw new UnsupportedOperationException(); |
| 252 | } |
| 253 | |
| 254 | @Override |
| 255 | public XmlResourceParser getXml(String packageName, int resid, |
| 256 | ApplicationInfo appInfo) { |
| 257 | throw new UnsupportedOperationException(); |
| 258 | } |
| 259 | |
| 260 | @Override |
| 261 | public CharSequence getApplicationLabel(ApplicationInfo info) { |
| 262 | throw new UnsupportedOperationException(); |
| 263 | } |
| 264 | |
| 265 | @Override |
| 266 | public Resources getResourcesForActivity(ComponentName activityName) |
| 267 | throws NameNotFoundException { |
| 268 | throw new UnsupportedOperationException(); |
| 269 | } |
| 270 | |
| 271 | @Override |
| 272 | public Resources getResourcesForApplication(ApplicationInfo app) { |
| 273 | throw new UnsupportedOperationException(); |
| 274 | } |
| 275 | |
| 276 | @Override |
| 277 | public Resources getResourcesForApplication(String appPackageName) |
| 278 | throws NameNotFoundException { |
| 279 | throw new UnsupportedOperationException(); |
| 280 | } |
| 281 | |
| 282 | @Override |
| 283 | public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { |
| 284 | throw new UnsupportedOperationException(); |
| 285 | } |
| 286 | |
| 287 | @Override |
| 288 | public void installPackage(Uri packageURI, IPackageInstallObserver observer, |
| 289 | int flags) { |
| 290 | throw new UnsupportedOperationException(); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * @hide - to match hiding in superclass |
| 295 | */ |
| 296 | @Override |
| 297 | public void clearApplicationUserData( |
| 298 | String packageName, IPackageDataObserver observer) { |
| 299 | throw new UnsupportedOperationException(); |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * @hide - to match hiding in superclass |
| 304 | */ |
| 305 | @Override |
| 306 | public void deleteApplicationCacheFiles( |
| 307 | String packageName, IPackageDataObserver observer) { |
| 308 | throw new UnsupportedOperationException(); |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * @hide - to match hiding in superclass |
| 313 | */ |
| 314 | @Override |
| 315 | public void freeStorageAndNotify( |
| 316 | long idealStorageSize, IPackageDataObserver observer) { |
| 317 | throw new UnsupportedOperationException(); |
| 318 | } |
| 319 | |
| 320 | /** |
| 321 | * @hide - to match hiding in superclass |
| 322 | */ |
| 323 | @Override |
| 324 | public void freeStorage( |
| 325 | long idealStorageSize, PendingIntent onFinishedIntent) { |
| 326 | throw new UnsupportedOperationException(); |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * @hide - to match hiding in superclass |
| 331 | */ |
| 332 | @Override |
| 333 | public void deletePackage( |
| 334 | String packageName, IPackageDeleteObserver observer, int flags) { |
| 335 | throw new UnsupportedOperationException(); |
| 336 | } |
| 337 | |
| 338 | @Override |
| 339 | public void addPackageToPreferred(String packageName) { |
| 340 | throw new UnsupportedOperationException(); |
| 341 | } |
| 342 | |
| 343 | @Override |
| 344 | public void removePackageFromPreferred(String packageName) { |
| 345 | throw new UnsupportedOperationException(); |
| 346 | } |
| 347 | |
| 348 | @Override |
| 349 | public List<PackageInfo> getPreferredPackages(int flags) { |
| 350 | throw new UnsupportedOperationException(); |
| 351 | } |
| 352 | |
| 353 | @Override |
| 354 | public void setComponentEnabledSetting(ComponentName componentName, |
| 355 | int newState, int flags) { |
| 356 | throw new UnsupportedOperationException(); |
| 357 | } |
| 358 | |
| 359 | @Override |
| 360 | public int getComponentEnabledSetting(ComponentName componentName) { |
| 361 | throw new UnsupportedOperationException(); |
| 362 | } |
| 363 | |
| 364 | @Override |
| 365 | public void setApplicationEnabledSetting(String packageName, int newState, int flags) { |
| 366 | throw new UnsupportedOperationException(); |
| 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public int getApplicationEnabledSetting(String packageName) { |
| 371 | throw new UnsupportedOperationException(); |
| 372 | } |
| 373 | |
| 374 | @Override |
| 375 | public void addPreferredActivity(IntentFilter filter, |
| 376 | int match, ComponentName[] set, ComponentName activity) { |
| 377 | throw new UnsupportedOperationException(); |
| 378 | } |
| 379 | |
| 380 | @Override |
| 381 | public void clearPackagePreferredActivities(String packageName) { |
| 382 | throw new UnsupportedOperationException(); |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * @hide - to match hiding in superclass |
| 387 | */ |
| 388 | @Override |
| 389 | public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { |
| 390 | throw new UnsupportedOperationException(); |
| 391 | } |
| 392 | |
| 393 | @Override |
| 394 | public void installPackage(Uri packageURI) { |
| 395 | throw new UnsupportedOperationException(); |
| 396 | } |
| 397 | |
| 398 | @Override |
| 399 | public int getPreferredActivities(List<IntentFilter> outFilters, |
| 400 | List<ComponentName> outActivities, String packageName) { |
| 401 | throw new UnsupportedOperationException(); |
| 402 | } |
| 403 | |
| 404 | @Override |
| 405 | public String[] getSystemSharedLibraryNames() { |
| 406 | throw new UnsupportedOperationException(); |
| 407 | } |
| 408 | |
| 409 | @Override |
| 410 | public boolean isSafeMode() { |
| 411 | throw new UnsupportedOperationException(); |
| 412 | } |
| 413 | } |