Package org.robolectric.manifest
Class AndroidManifest
- java.lang.Object
-
- org.robolectric.manifest.AndroidManifest
-
- All Implemented Interfaces:
org.robolectric.pluginapi.UsesSdk
public class AndroidManifest extends java.lang.Object implements org.robolectric.pluginapi.UsesSdkA wrapper for an Android App Manifest, which represents information about one's App to an Android system.- See Also:
- Android App Manifest
-
-
Constructor Summary
Constructors Constructor Description AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory)Creates a Robolectric configuration using specified locations.AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, java.lang.String overridePackageName)Creates a Robolectric configuration using specified values.AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, java.util.List<AndroidManifest> libraryManifests, java.lang.String overridePackageName)Creates a Robolectric configuration using specified values.AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, java.util.List<AndroidManifest> libraryManifests, java.lang.String overridePackageName, java.nio.file.Path apkFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(java.lang.Object o)ActivityDatagetActivityData(java.lang.String activityClassName)java.util.Map<java.lang.String,ActivityData>getActivityDatas()java.lang.StringgetActivityLabel(java.lang.String activityClassName)java.util.List<AndroidManifest>getAllManifests()Returns all transitively reachable manifests, including this one, in order and without duplicates.java.nio.file.PathgetAndroidManifestFile()java.nio.file.PathgetApkFile()java.util.Map<java.lang.String,java.lang.String>getApplicationAttributes()java.util.Map<java.lang.String,java.lang.Object>getApplicationMetaData()java.lang.StringgetApplicationName()java.nio.file.PathgetAssetsDirectory()BroadcastReceiverDatagetBroadcastReceiver(java.lang.String className)Returns data for the broadcast receiver with the provided name from this manifest.java.util.List<BroadcastReceiverData>getBroadcastReceivers()java.util.List<ContentProviderData>getContentProviders()java.util.List<ResourcePath>getIncludedResourcePaths()java.lang.StringgetLabelRef()java.util.List<AndroidManifest>getLibraryManifests()java.lang.IntegergetMaxSdkVersion()intgetMinSdkVersion()Returns the minimum Android SDK version that this package expects to be runnable on, as specified in the manifest.java.lang.StringgetPackageName()java.util.Map<java.lang.String,PermissionGroupItemData>getPermissionGroups()java.util.Map<java.lang.String,PermissionItemData>getPermissions()java.lang.StringgetProcessName()java.lang.ClassgetRClass()java.lang.StringgetRClassName()java.nio.file.PathgetResDirectory()ResourcePathgetResourcePath()ServiceDatagetServiceData(java.lang.String serviceClassName)java.util.List<ServiceData>getServices()intgetTargetSdkVersion()Returns the Android SDK version that this package prefers to be run on, as specified in the manifest.java.lang.StringgetThemeRef()java.lang.StringgetThemeRef(java.lang.String activityClassName)java.util.List<java.lang.String>getUsedPermissions()intgetVersionCode()java.lang.StringgetVersionName()inthashCode()voidinitMetaData(ResourceTable resourceTable)Allows ShadowPackageManager to provide a resource index for initialising the resource attributes in all the metadata elementsbooleansupportsBinaryResourcesMode()Deprecated.Do not use.booleansupportsLegacyResourcesMode()Deprecated.Do not use.
-
-
-
Constructor Detail
-
AndroidManifest
public AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory)Creates a Robolectric configuration using specified locations.- Parameters:
androidManifestFile- Location of the AndroidManifest.xml file.resDirectory- Location of the res directory.assetsDirectory- Location of the assets directory.
-
AndroidManifest
public AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, java.lang.String overridePackageName)Creates a Robolectric configuration using specified values.- Parameters:
androidManifestFile- Location of the AndroidManifest.xml file.resDirectory- Location of the res directory.assetsDirectory- Location of the assets directory.overridePackageName- Application package name.
-
AndroidManifest
public AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, @Nonnull java.util.List<AndroidManifest> libraryManifests, java.lang.String overridePackageName)Creates a Robolectric configuration using specified values.- Parameters:
androidManifestFile- Location of the AndroidManifest.xml file.resDirectory- Location of the res directory.assetsDirectory- Location of the assets directory.libraryManifests- List of dependency library manifests.overridePackageName- Application package name.
-
AndroidManifest
public AndroidManifest(java.nio.file.Path androidManifestFile, java.nio.file.Path resDirectory, java.nio.file.Path assetsDirectory, @Nonnull java.util.List<AndroidManifest> libraryManifests, java.lang.String overridePackageName, java.nio.file.Path apkFile)
-
-
Method Detail
-
getThemeRef
public java.lang.String getThemeRef(java.lang.String activityClassName)
-
getRClassName
public java.lang.String getRClassName() throws java.lang.Exception- Throws:
java.lang.Exception
-
getRClass
public java.lang.Class getRClass()
-
initMetaData
public void initMetaData(ResourceTable resourceTable) throws RoboNotFoundException
Allows ShadowPackageManager to provide a resource index for initialising the resource attributes in all the metadata elements- Parameters:
resourceTable- used for getting resource IDs from string identifiers- Throws:
RoboNotFoundException
-
getApplicationName
public java.lang.String getApplicationName()
-
getActivityLabel
public java.lang.String getActivityLabel(java.lang.String activityClassName)
-
getPackageName
public java.lang.String getPackageName()
-
getVersionCode
public int getVersionCode()
-
getVersionName
public java.lang.String getVersionName()
-
getLabelRef
public java.lang.String getLabelRef()
-
getMinSdkVersion
public int getMinSdkVersion()
Returns the minimum Android SDK version that this package expects to be runnable on, as specified in the manifest.Note that if
targetSdkVersionisn't set, this value changes the behavior of some Android code (notablyandroid.content.SharedPreferences) to emulate old bugs.- Specified by:
getMinSdkVersionin interfaceorg.robolectric.pluginapi.UsesSdk- Returns:
- the minimum SDK version, or Jelly Bean (16) by default
-
getTargetSdkVersion
public int getTargetSdkVersion()
Returns the Android SDK version that this package prefers to be run on, as specified in the manifest.Note that this value changes the behavior of some Android code (notably
android.content.SharedPreferences) to emulate old bugs.- Specified by:
getTargetSdkVersionin interfaceorg.robolectric.pluginapi.UsesSdk- Returns:
- the minimum SDK version, or Jelly Bean (16) by default
-
getMaxSdkVersion
public java.lang.Integer getMaxSdkVersion()
- Specified by:
getMaxSdkVersionin interfaceorg.robolectric.pluginapi.UsesSdk
-
getApplicationAttributes
public java.util.Map<java.lang.String,java.lang.String> getApplicationAttributes()
-
getProcessName
public java.lang.String getProcessName()
-
getApplicationMetaData
public java.util.Map<java.lang.String,java.lang.Object> getApplicationMetaData()
-
getResourcePath
public ResourcePath getResourcePath()
-
getIncludedResourcePaths
public java.util.List<ResourcePath> getIncludedResourcePaths()
-
getContentProviders
public java.util.List<ContentProviderData> getContentProviders()
-
getLibraryManifests
public java.util.List<AndroidManifest> getLibraryManifests()
-
getAllManifests
public java.util.List<AndroidManifest> getAllManifests()
Returns all transitively reachable manifests, including this one, in order and without duplicates.
-
getResDirectory
public java.nio.file.Path getResDirectory()
-
getAssetsDirectory
public java.nio.file.Path getAssetsDirectory()
-
getAndroidManifestFile
public java.nio.file.Path getAndroidManifestFile()
-
getBroadcastReceivers
public java.util.List<BroadcastReceiverData> getBroadcastReceivers()
-
getServices
public java.util.List<ServiceData> getServices()
-
getServiceData
public ServiceData getServiceData(java.lang.String serviceClassName)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getActivityData
public ActivityData getActivityData(java.lang.String activityClassName)
-
getThemeRef
public java.lang.String getThemeRef()
-
getActivityDatas
public java.util.Map<java.lang.String,ActivityData> getActivityDatas()
-
getUsedPermissions
public java.util.List<java.lang.String> getUsedPermissions()
-
getPermissions
public java.util.Map<java.lang.String,PermissionItemData> getPermissions()
-
getPermissionGroups
public java.util.Map<java.lang.String,PermissionGroupItemData> getPermissionGroups()
-
getBroadcastReceiver
@Nullable public BroadcastReceiverData getBroadcastReceiver(java.lang.String className)
Returns data for the broadcast receiver with the provided name from this manifest. If no receiver with the class name can be found, returns null.- Parameters:
className- the fully resolved class name of the receiver- Returns:
- data for the receiver or null if it cannot be found
-
getApkFile
public java.nio.file.Path getApkFile()
-
supportsLegacyResourcesMode
@Deprecated public boolean supportsLegacyResourcesMode()
Deprecated.Do not use.
-
supportsBinaryResourcesMode
@Deprecated public boolean supportsBinaryResourcesMode()
Deprecated.Do not use.
-
-