Infrastructure Layer
The TrigDroid infrastructure layer provides the core services and abstractions.
Interfaces
Core abstractions and protocol definitions.
Core interfaces for TrigDroid following SOLID principles.
This module defines the core abstractions that enable dependency inversion and make the system more maintainable and testable.
- class TrigDroid_Infrastructure.interfaces.LogLevel(value)[source]
Bases:
EnumLogging levels for the application.
- DEBUG = 'DEBUG'
- INFO = 'INFO'
- WARNING = 'WARNING'
- ERROR = 'ERROR'
- CRITICAL = 'CRITICAL'
- class TrigDroid_Infrastructure.interfaces.TestResult(value)[source]
Bases:
EnumResult of test execution.
- SUCCESS = 'SUCCESS'
- FAILURE = 'FAILURE'
- SKIPPED = 'SKIPPED'
- class TrigDroid_Infrastructure.interfaces.DeviceConnectionState(value)[source]
Bases:
EnumAndroid device connection states.
- CONNECTED = 'CONNECTED'
- DISCONNECTED = 'DISCONNECTED'
- UNAUTHORIZED = 'UNAUTHORIZED'
- class TrigDroid_Infrastructure.interfaces.ILogger(*args, **kwargs)[source]
Bases:
ProtocolLogger interface for dependency inversion.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IConfigurationProvider(*args, **kwargs)[source]
Bases:
ProtocolConfiguration provider interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IConfigurationValidator(*args, **kwargs)[source]
Bases:
ProtocolConfiguration validation interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IAndroidDevice(*args, **kwargs)[source]
Bases:
ProtocolAndroid device interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.ICommandResult(*args, **kwargs)[source]
Bases:
ProtocolCommand execution result interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.ITestRunner(*args, **kwargs)[source]
Bases:
ProtocolTest runner interface for different test types.
- execute(context)[source]
- Parameters:
context (ITestContext)
- Return type:
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.ITestContext(*args, **kwargs)[source]
Bases:
ProtocolTest execution context interface.
- property device: IAndroidDevice
- property config: IConfigurationProvider
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IFridaHookProvider(*args, **kwargs)[source]
Bases:
ProtocolFrida hook provider interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IChangelogWriter(*args, **kwargs)[source]
Bases:
ProtocolChangelog writer interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IApplicationOrchestrator(*args, **kwargs)[source]
Bases:
ProtocolMain application orchestrator interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.TestRunnerBase(logger)[source]
Bases:
ABCBase class for test runners implementing common functionality.
- Parameters:
logger (ILogger)
- execute(context)[source]
Execute the test with proper error handling.
- Parameters:
context (ITestContext)
- Return type:
Application Layer
Main application orchestration and workflow coordination.
Application orchestrator following SOLID principles.
This module coordinates the entire TrigDroid testing flow with proper separation of concerns and dependency inversion.
- class TrigDroid_Infrastructure.application.orchestrator.TestPhase(value)[source]
Bases:
EnumTest execution phases.
- SETUP = 'setup'
- EXECUTION = 'execution'
- TEARDOWN = 'teardown'
- class TrigDroid_Infrastructure.application.orchestrator.ApplicationOrchestrator(logger, config, device, test_runners, changelog_writer)[source]
Bases:
IApplicationOrchestrator,InjectableMain application orchestrator that coordinates the testing flow.
- Parameters:
logger (ILogger)
config (IConfigurationProvider)
device (IAndroidDevice)
test_runners (List[ITestRunner])
changelog_writer (IChangelogWriter)
- __init__(logger, config, device, test_runners, changelog_writer)[source]
- Parameters:
logger (ILogger)
config (IConfigurationProvider)
device (IAndroidDevice)
test_runners (List[ITestRunner])
changelog_writer (IChangelogWriter)
- class TrigDroid_Infrastructure.application.orchestrator.OrchestratorBuilder[source]
Bases:
objectBuilder for creating application orchestrator with dependencies.
- with_config(config)[source]
Set the configuration provider.
- Parameters:
config (IConfigurationProvider)
- Return type:
- with_device(device)[source]
Set the Android device.
- Parameters:
device (IAndroidDevice)
- Return type:
- add_test_runner(runner)[source]
Add a test runner.
- Parameters:
runner (ITestRunner)
- Return type:
- with_changelog_writer(writer)[source]
Set the changelog writer.
- Parameters:
writer (IChangelogWriter)
- Return type:
Infrastructure Services
Core infrastructure services including dependency injection, logging, and configuration.
Dependency Injection
Dependency Injection Container for TrigDroid.
This module implements a simple but effective dependency injection container that follows the Dependency Inversion Principle and enables loose coupling between components.
- class TrigDroid_Infrastructure.infrastructure.dependency_injection.DIContainer[source]
Bases:
objectSimple dependency injection container.
- register_singleton(interface, implementation, name=None)[source]
Register a singleton service.
- Parameters:
- Return type:
- register_transient(interface, implementation, name=None)[source]
Register a transient service (new instance every time).
- Parameters:
- Return type:
- register_instance(interface, instance, name=None)[source]
Register a specific instance.
- Parameters:
- Return type:
- class TrigDroid_Infrastructure.infrastructure.dependency_injection.ServiceLocator[source]
Bases:
objectService locator pattern implementation.
- classmethod set_container(container)[source]
Set the global container.
- Parameters:
container (DIContainer)
- Return type:
None
- class TrigDroid_Infrastructure.infrastructure.dependency_injection.Injectable[source]
Bases:
ABCBase class for injectable services.
- set_container(container)[source]
Set the DI container for this service.
- Parameters:
container (DIContainer)
- Return type:
None
- TrigDroid_Infrastructure.infrastructure.dependency_injection.configure_container()[source]
Configure the dependency injection container with TrigDroid services.
- Return type:
Android Integration
Android device abstraction following SOLID principles.
This module provides a clean abstraction over ADB operations that can be easily tested and extended.
- class TrigDroid_Infrastructure.infrastructure.android.CommandResult(return_code, stdout, stderr)[source]
Bases:
ICommandResultImplementation of command result interface.
- class TrigDroid_Infrastructure.infrastructure.android.AndroidDevice(logger, device_id=None)[source]
Bases:
IAndroidDevice,InjectableAndroid device implementation using ADB.
- set_current_package(package_name)[source]
Set the current test package.
- Parameters:
package_name (str)
- Return type:
None
- class TrigDroid_Infrastructure.infrastructure.android.DeviceManager(logger)[source]
Bases:
objectManager for discovering and connecting to Android devices.
- Parameters:
logger (ILogger)
- connect_to_device(device_id=None)[source]
Connect to a specific device or auto-select if only one available.
- Parameters:
device_id (str | None)
- Return type:
AndroidDevice | None
Configuration Management
Configuration system refactored to follow SOLID principles.
This module provides a clean separation between configuration sources, validation, and consumption following the Single Responsibility Principle.
- exception TrigDroid_Infrastructure.infrastructure.configuration.ConfigurationError[source]
Bases:
ExceptionConfiguration-related errors.
- class TrigDroid_Infrastructure.infrastructure.configuration.CommandLineConfigProvider(parser=None)[source]
Bases:
IConfigurationProviderConfiguration provider for command line arguments.
- Parameters:
parser (ArgumentParser | None)
- __init__(parser=None)[source]
- Parameters:
parser (ArgumentParser | None)
- class TrigDroid_Infrastructure.infrastructure.configuration.YamlConfigProvider(config_path=None)[source]
Bases:
IConfigurationProviderConfiguration provider for YAML files.
- Parameters:
config_path (str | None)
- class TrigDroid_Infrastructure.infrastructure.configuration.CompositeConfigurationProvider(providers)[source]
Bases:
IConfigurationProviderConfiguration provider that merges multiple sources.
- Parameters:
providers (List[IConfigurationProvider])
- __init__(providers)[source]
- Parameters:
providers (List[IConfigurationProvider])
- class TrigDroid_Infrastructure.infrastructure.configuration.ConfigurationValidator(logger)[source]
Bases:
IConfigurationValidator,InjectableValidates configuration values according to rules.
- Parameters:
logger (ILogger)
- class TrigDroid_Infrastructure.infrastructure.configuration.ConfigurationManager(config_provider, validator, logger)[source]
Bases:
InjectableHigh-level configuration manager that coordinates providers and validation.
- Parameters:
config_provider (IConfigurationProvider)
validator (IConfigurationValidator)
logger (ILogger)
- __init__(config_provider, validator, logger)[source]
- Parameters:
config_provider (IConfigurationProvider)
validator (IConfigurationValidator)
logger (ILogger)
- class TrigDroid_Infrastructure.infrastructure.configuration.ConfigurationBuilder[source]
Bases:
objectBuilder pattern for creating configuration managers.
- add_command_line_provider(parser=None)[source]
Add command line configuration provider.
- Parameters:
parser (ArgumentParser | None)
- Return type:
- add_yaml_provider(config_path=None)[source]
Add YAML configuration provider.
- Parameters:
config_path (str | None)
- Return type:
- set_validator(validator)[source]
Set the configuration validator.
- Parameters:
validator (IConfigurationValidator)
- Return type:
Logging Infrastructure
Logging infrastructure following SOLID principles.
This module provides a clean logging abstraction that can be easily extended and tested.
- class TrigDroid_Infrastructure.infrastructure.logging.LogFormatter(extended_format=False)[source]
Bases:
FormatterCustom formatter for TrigDroid logs.
- Parameters:
extended_format (bool)
- __init__(extended_format=False)[source]
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.
Use a style parameter of ‘%’, ‘{’ or ‘$’ to specify that you want to use one of %-formatting,
str.format()({}) formatting orstring.Templateformatting in your format string.Changed in version 3.2: Added the
styleparameter.- Parameters:
extended_format (bool)
- class TrigDroid_Infrastructure.infrastructure.logging.StandardLogger(name='TrigDroid', level=LogLevel.INFO, log_file=None, suppress_console=False, extended_format=False)[source]
Bases:
ILoggerStandard logger implementation using Python’s logging module.
- Parameters:
- __init__(name='TrigDroid', level=LogLevel.INFO, log_file=None, suppress_console=False, extended_format=False)[source]
- class TrigDroid_Infrastructure.infrastructure.logging.FilteredLogger(base_logger, include_patterns=None, exclude_patterns=None)[source]
Bases:
ILoggerLogger wrapper that applies include/exclude filters.
- Parameters:
- class TrigDroid_Infrastructure.infrastructure.logging.NullLogger(*args, **kwargs)[source]
Bases:
ILoggerNull object pattern logger for testing.
- class TrigDroid_Infrastructure.infrastructure.logging.LoggerFactory[source]
Bases:
objectFactory for creating different types of loggers.
- static create_standard_logger(name='TrigDroid', level=LogLevel.INFO, log_file=None, suppress_console=False, extended_format=False)[source]
Create a standard logger.
- static create_filtered_logger(base_logger, include_patterns=None, exclude_patterns=None)[source]
Create a filtered logger.
Test Runners
Pluggable test execution engines for different testing scenarios.
Base Test Runner
TrigDroid Infrastructure Test Runners.
This module exports the test runner implementations.
- class TrigDroid_Infrastructure.test_runners.TestContext(device, config, logger, package_name)[source]
Bases:
ITestContextImplementation of test execution context.
- Parameters:
device (IAndroidDevice)
config (IConfigurationProvider)
logger (ILogger)
package_name (str)
- __init__(device, config, logger, package_name)[source]
- Parameters:
device (IAndroidDevice)
config (IConfigurationProvider)
logger (ILogger)
package_name (str)
- property device: IAndroidDevice
Get the Android device instance.
- property config: IConfigurationProvider
Get the configuration provider.
- class TrigDroid_Infrastructure.test_runners.FridaTestRunner(logger, hook_provider)[source]
Bases:
TestRunnerBaseTest runner for Frida-based instrumentation.
- Parameters:
logger (ILogger)
hook_provider (IFridaHookProvider)
- SUPPORTED_TESTS = ['frida_hooks', 'runtime_instrumentation', 'api_hooking', 'environment_spoofing']
- __init__(logger, hook_provider)[source]
- Parameters:
logger (ILogger)
hook_provider (IFridaHookProvider)
- is_frida_needed(context)[source]
Check if Frida is needed for the current configuration.
- Parameters:
context (ITestContext)
- Return type:
- class TrigDroid_Infrastructure.test_runners.SensorTestRunner(logger)[source]
Bases:
TestRunnerBaseTest runner for sensor-based operations.
- Parameters:
logger (ILogger)
- SUPPORTED_TESTS = ['sensor_rotation', 'sensor_initial_values', 'sensor_power_manipulation', 'sensor_availability']
Sensor Test Runner
Sensor test runner implementation.
This module handles sensor-related test operations including accelerometer, gyroscope, light, and pressure sensor manipulations.
- class TrigDroid_Infrastructure.test_runners.sensor_test_runner.SensorType(value)[source]
Bases:
EnumSupported sensor types.
- ACCELEROMETER = 'accelerometer'
- GYROSCOPE = 'gyroscope'
- LIGHT = 'light'
- PRESSURE = 'pressure'
- MAGNETOMETER = 'magnetometer'
- class TrigDroid_Infrastructure.test_runners.sensor_test_runner.SensorTestRunner(logger)[source]
Bases:
TestRunnerBaseTest runner for sensor-based operations.
- Parameters:
logger (ILogger)
- SUPPORTED_TESTS = ['sensor_rotation', 'sensor_initial_values', 'sensor_power_manipulation', 'sensor_availability']
Frida Test Runner
Frida test runner implementation.
This module handles Frida-based instrumentation and hooking operations for runtime environment manipulation.
- class TrigDroid_Infrastructure.test_runners.frida_test_runner.FridaTestRunner(logger, hook_provider)[source]
Bases:
TestRunnerBaseTest runner for Frida-based instrumentation.
- Parameters:
logger (ILogger)
hook_provider (IFridaHookProvider)
- SUPPORTED_TESTS = ['frida_hooks', 'runtime_instrumentation', 'api_hooking', 'environment_spoofing']
- __init__(logger, hook_provider)[source]
- Parameters:
logger (ILogger)
hook_provider (IFridaHookProvider)
- is_frida_needed(context)[source]
Check if Frida is needed for the current configuration.
- Parameters:
context (ITestContext)
- Return type:
- class TrigDroid_Infrastructure.test_runners.frida_test_runner.FridaServerManager(logger)[source]
Bases:
objectManages Frida server lifecycle on Android devices.
- Parameters:
logger (ILogger)
Test Context
Test context implementation for TrigDroid.
This module provides the test execution context that contains all necessary dependencies for test runners.
- class TrigDroid_Infrastructure.test_runners.test_context.TestContext(device, config, logger, package_name)[source]
Bases:
ITestContextImplementation of test execution context.
- Parameters:
device (IAndroidDevice)
config (IConfigurationProvider)
logger (ILogger)
package_name (str)
- __init__(device, config, logger, package_name)[source]
- Parameters:
device (IAndroidDevice)
config (IConfigurationProvider)
logger (ILogger)
package_name (str)
- property device: IAndroidDevice
Get the Android device instance.
- property config: IConfigurationProvider
Get the configuration provider.