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:
Enum
Logging levels for the application.
- DEBUG = 'DEBUG'
- INFO = 'INFO'
- WARNING = 'WARNING'
- ERROR = 'ERROR'
- CRITICAL = 'CRITICAL'
- class TrigDroid_Infrastructure.interfaces.TestResult(value)[source]
Bases:
Enum
Result of test execution.
- SUCCESS = 'SUCCESS'
- FAILURE = 'FAILURE'
- SKIPPED = 'SKIPPED'
- class TrigDroid_Infrastructure.interfaces.DeviceConnectionState(value)[source]
Bases:
Enum
Android device connection states.
- CONNECTED = 'CONNECTED'
- DISCONNECTED = 'DISCONNECTED'
- UNAUTHORIZED = 'UNAUTHORIZED'
- class TrigDroid_Infrastructure.interfaces.ILogger(*args, **kwargs)[source]
Bases:
Protocol
Logger interface for dependency inversion.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IConfigurationProvider(*args, **kwargs)[source]
Bases:
Protocol
Configuration provider interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IConfigurationValidator(*args, **kwargs)[source]
Bases:
Protocol
Configuration validation interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IAndroidDevice(*args, **kwargs)[source]
Bases:
Protocol
Android device interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.ICommandResult(*args, **kwargs)[source]
Bases:
Protocol
Command execution result interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.ITestRunner(*args, **kwargs)[source]
Bases:
Protocol
Test 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:
Protocol
Test execution context interface.
- property device: IAndroidDevice
- property config: IConfigurationProvider
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IFridaHookProvider(*args, **kwargs)[source]
Bases:
Protocol
Frida hook provider interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IChangelogWriter(*args, **kwargs)[source]
Bases:
Protocol
Changelog writer interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.IApplicationOrchestrator(*args, **kwargs)[source]
Bases:
Protocol
Main application orchestrator interface.
- __init__(*args, **kwargs)
- class TrigDroid_Infrastructure.interfaces.TestRunnerBase(logger)[source]
Bases:
ABC
Base 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.
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:
object
Simple 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:
object
Service 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:
ABC
Base 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:
ICommandResult
Implementation of command result interface.
- class TrigDroid_Infrastructure.infrastructure.android.AndroidDevice(logger, device_id=None)[source]
Bases:
IAndroidDevice
,Injectable
Android 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:
object
Manager 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:
Exception
Configuration-related errors.
- class TrigDroid_Infrastructure.infrastructure.configuration.CommandLineConfigProvider(parser=None)[source]
Bases:
IConfigurationProvider
Configuration 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:
IConfigurationProvider
Configuration provider for YAML files.
- Parameters:
config_path (str | None)
- class TrigDroid_Infrastructure.infrastructure.configuration.CompositeConfigurationProvider(providers)[source]
Bases:
IConfigurationProvider
Configuration 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
,Injectable
Validates configuration values according to rules.
- Parameters:
logger (ILogger)
- class TrigDroid_Infrastructure.infrastructure.configuration.ConfigurationManager(config_provider, validator, logger)[source]
Bases:
Injectable
High-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:
object
Builder 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:
Formatter
Custom 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.Template
formatting in your format string.Changed in version 3.2: Added the
style
parameter.- 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:
ILogger
Standard 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:
ILogger
Logger wrapper that applies include/exclude filters.
- Parameters:
- class TrigDroid_Infrastructure.infrastructure.logging.NullLogger(*args, **kwargs)[source]
Bases:
ILogger
Null object pattern logger for testing.
- class TrigDroid_Infrastructure.infrastructure.logging.LoggerFactory[source]
Bases:
object
Factory 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
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:
Enum
Supported sensor types.
- ACCELEROMETER = 'accelerometer'
- GYROSCOPE = 'gyroscope'
- LIGHT = 'light'
- PRESSURE = 'pressure'
- MAGNETOMETER = 'magnetometer'
- class TrigDroid_Infrastructure.test_runners.sensor_test_runner.SensorTestRunner(logger)[source]
Bases:
TestRunnerBase
Test 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:
TestRunnerBase
Test 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:
object
Manages 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:
ITestContext
Implementation 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.