anadroid.application package
Submodules
anadroid.application.AbstractApplication module
- class anadroid.application.AbstractApplication.AbstractApplication(package_name, version='0.0')[source]
Bases:
ABC
Abstract base class representing a mobile application and defining an interface to interact with the application on the device.
- package_name
The package name of the app.
- Type:
str
- version
The version number of the app (default is ‘0.0’).
- Type:
str
- on_fg
A flag indicating whether the app is in the foreground.
- Type:
bool
- get_app_id()[source]
Get the unique app identifier.
- Returns:
The app identifier in the format ‘<package_name>_<version>’.
- Return type:
str
anadroid.application.AndroidProject module
- class anadroid.application.AndroidProject.AndroidProject(projname, projdir, results_dir='anadroid_results', clean_instrumentations=False)[source]
Bases:
Project
Class that abstracts Android Projects.
- projname
Project name.
- Type:
str
- projir
Project directory.
- Type:
str
- results_dir
Directory where to store project’s results.
- Type:
str
- root_build_file
Project-level gradle file.
- Type:
str
- main_manif_file
Project manifest file.
- Type:
str
- tests_manif_file
Manifest of the test project.
- add_apk(apk_path, build_type)[source]
Adds an APK path of the specified build type to the known list of APKs for the project.
- Parameters:
apk_path (str) – Path to APK.
build_type (BUILD_TYPE) – APK build type (test, release, custom).
- create_inner_folder(name='libs')[source]
Creates a folder inside the project.
- Parameters:
name (str) – Name of the folder to be created.
- Returns:
Path of the created folder.
- Return type:
path (str)
- get_apks(build_type=BUILD_TYPE.DEBUG)[source]
Get APKs of a specific build type.
- Parameters:
build_type (BUILD_TYPE) – Build type.
- Returns:
List of APK paths.
- Return type:
apk_list (
list
ofstr
)
- get_build_files()[source]
Returns build.gradle files of the project.
- Returns:
List of file paths.
- Return type:
files_list (
list
ofstr
)
- get_gradle_plugin()[source]
Returns the gradle plugin version.
Parses gradle plugin version from the root build file.
- Returns:
Gradle plugin version.
- Return type:
gradle_plugin_version (str)
- get_gradle_settings()[source]
Returns settings.gradle file.
- Returns:
Path of the settings.gradle file.
- Return type:
file_path (str)
- get_main_manif_file()[source]
Returns project’s main manifest file.
- Returns:
Path of the main manifest file.
- Return type:
file_path (str)
- get_proj_json()[source]
Get a dictionary containing project information.
- Returns:
A dictionary containing project details.
- Return type:
dict
- get_root_build_file()[source]
Returns project-level build.gradle file.
Assumes that it is the one with the shortest path. Gets the list of the build.gradle file paths and returns the shortest one.
- Returns:
Path of gradle file.
- Return type:
file_path (str)
- get_test_apks()[source]
Returns test APKs.
- Returns:
List of test APK paths.
- Return type:
apk_list (
list
ofstr
)
- has_gradle_wrapper()[source]
Determine if the project is ready to be built with gradle wrapper.
- Returns:
True if gradlew file is found in project’s sources, False otherwise.
- Return type:
bool
- save_proj_json(path)[source]
Save the project information to a JSON file.
- Parameters:
path (str) – Path where the JSON file will be saved.
- set_version(build_type)[source]
Set the project version based on the specified build type.
- Parameters:
build_type (BUILD_TYPE) – Build type.
- class anadroid.application.AndroidProject.BUILD_FLAVOR(value)[source]
Bases:
Enum
An enumeration.
- CUSTOM = 'Custom'
- DEMO = 'Demo'
- FULL = 'full'
- NONE = 'None'
- class anadroid.application.AndroidProject.BUILD_TYPE(value)[source]
Bases:
Enum
An enumeration.
- CUSTOM = 'Custom'
- DEBUG = 'Debug'
- RELEASE = 'Release'
- class anadroid.application.AndroidProject.Project(projname, projdir, results_dir='anadroid_results')[source]
Bases:
object
Class that abstracts software projects.
- projname
Project name.
- Type:
str
- projir
Project directory.
- Type:
str
- results_dir
Directory where to store project’s results.
- Type:
str
anadroid.application.Application module
- class anadroid.application.Application.App(device, proj, package_name, apk_path, local_res_dir, app_name='app', version=None)[source]
Bases:
AbstractApplication
Main class that abstracts an Android App.
- proj
Respective Android project.
- Type:
- package_name
Package name of the app.
- Type:
str
- local_res_dir
Local results directory.
- Type:
str
- app_name
Name of the app.
- Type:
str
- version
App version.
- Type:
- clean_cache()[source]
Cleans the app cache.
Cleans the app cache on the device using the package manager.
- get_app_json()[source]
Get a JSON representation of the app.
- Returns:
JSON representation of the app.
- Return type:
dict
- get_permissions_json()[source]
Get the permissions JSON file.
- Returns:
Path to the permissions JSON file or None if it doesn’t exist.
- Return type:
str
- init_local_test_(testing_framework, inst_type)[source]
Initializes a directory for a current test being run with the specified testing framework and instrumented with the specified instrumentation type.
- Parameters:
testing_framework (TESTING_FRAMEWORK) – Testing framework enumeration.
inst_type (INSTRUMENTATION_TYPE) – Instrumentation type enumeration.
- set_immersive_mode()[source]
Sets immersive mode for this app if the Android version < 11.
This feature is only available for devices running Android 10 or lower.
- anadroid.application.Application.get_prefix(testing_framework, inst_type)[source]
Gets an adequate prefix for a folder, given the testing framework and instrumentation type.
- Parameters:
testing_framework (TESTING_FRAMEWORK) – Testing framework enumeration.
inst_type (INSTRUMENTATION_TYPE) – Instrumentation type enumeration.
- Returns:
Prefix for the folder.
- Return type:
prefix (str)
anadroid.application.Dependency module
- class anadroid.application.Dependency.BuildDependency(name, dep_type=DependencyType.REMOTE, version=None, bin_type=None)[source]
Bases:
object
Represents an app build dependency referred in build files.
- name
Dependency name.
- Type:
str
- dep_type
Type of dependency.
- Type:
- version
Dependency version.
- Type:
str
- bin_type
Binary type, used when it is a local dependency, such as an .aar.
- Type:
str
anadroid.application.ProjectModule module
- class anadroid.application.ProjectModule.MODULE_TYPE(value)[source]
Bases:
Enum
Project Module types.
- APP = 'App'
- LIBRARY = 'Library'
- class anadroid.application.ProjectModule.ProjectModule(name, mod_dir)[source]
Bases:
object
Represents an Android Project Module.
- mod_name
Module name.
- Type:
str
- mod_dir
Module directory.
- Type:
str
- build_file
Path to the build.gradle file of the module.
- Type:
str
- module_type
Type of the module (LIBRARY or APP).
- Type:
- manifest
Path to the AndroidManifest.xml file of the module.
- Type:
str
- dependencies
Set of module dependencies.
- Type:
set
- gen_apks
Generated APKs within the module.
- Type:
dict
- gen_aars
Generated AARs within the module.
- Type:
dict