Draft: refactor: break down AppInstallProcessor into collaborator classes
Description
This MR refactors AppInstallProcessor into smaller, tightly scoped, unit-testable components while preserving current behaviour and keeping the public API (mostly) unchanged.
Please review the MR commit by commit to understand how the refactoring evolved. Otherwise, you can review the changes at once; for your aid in the review process, a diagram, and a guide have been added in the Technical details section.
Technical details
Before refactor
Before the refactor, AppInstallProcessor was effectively the central class for almost all install-related responsibilities.
classDiagram
class AppInstallProcessor_PreRefactor {
+initAppInstall(...)
+enqueueFusedDownload(...)
+canEnqueue(...)
+validateAgeLimit(...)
+awaitInvokeAgeLimitEvent(...)
+updateDownloadUrls(...)
+processInstall(...)
+checkDownloadingState(...)
+startAppInstallationProcess(...)
+handleFusedDownloadStatus(...)
+checkUpdateWork(...)
+showNotificationOnUpdateEnded(...)
}
class EventBus
class StorageComputer
class ParentalControlAuthenticator
class UpdatesDao
class UpdatesNotifier
class AppInstallComponents
class ApplicationRepository
class AppLoungeDataStore
class StorageNotificationManager
class DownloadManagerUtils
class AppManager
class ValidateAppAgeLimitUseCase
AppInstallProcessor_PreRefactor --> AppInstallComponents
AppInstallProcessor_PreRefactor --> ApplicationRepository
AppInstallProcessor_PreRefactor --> AppLoungeDataStore
AppInstallProcessor_PreRefactor --> StorageNotificationManager
AppInstallProcessor_PreRefactor --> DownloadManagerUtils
AppInstallProcessor_PreRefactor --> AppManager
AppInstallProcessor_PreRefactor --> ValidateAppAgeLimitUseCase
AppInstallProcessor_PreRefactor --> EventBus
AppInstallProcessor_PreRefactor --> StorageComputer
AppInstallProcessor_PreRefactor --> ParentalControlAuthenticator
AppInstallProcessor_PreRefactor --> UpdatesDao
AppInstallProcessor_PreRefactor --> UpdatesNotifier
After refactor
The refactor improves the codebase in these ways:
- smaller classes with tighter responsibilities
- more focused unit tests
- better organization of classes based on their role
This diagram gives a reviewer-friendly starting point for the install/update flow under:
- app/src/main/java/foundation/e/apps/data/install/core/
- app/src/main/java/foundation/e/apps/data/install/wrapper/
classDiagram
direction LR
class AppInstallationFacade
class InstallationRequest
class InstallationEnqueuer
class PreEnqueueChecker
class DownloadUrlRefresher
class AgeLimitGate
class DevicePreconditions
class InstallationProcessor
class InstallationCompletionHandler
class AppEventDispatcher
class NetworkStatusChecker
class ParentalControlAuthGateway
class StorageSpaceChecker
class UpdatesTracker
class UpdatesNotificationSender
AppInstallationFacade --> InstallationRequest : builds install request
AppInstallationFacade --> InstallationEnqueuer : starts enqueue path
AppInstallationFacade --> InstallationProcessor : starts processing path
InstallationEnqueuer --> PreEnqueueChecker : runs checks
PreEnqueueChecker --> DownloadUrlRefresher
PreEnqueueChecker --> AgeLimitGate
PreEnqueueChecker --> DevicePreconditions
AgeLimitGate --> ParentalControlAuthGateway
AgeLimitGate --> AppEventDispatcher
DevicePreconditions --> NetworkStatusChecker
DevicePreconditions --> StorageSpaceChecker
DevicePreconditions --> AppEventDispatcher
InstallationProcessor --> AppEventDispatcher : status events
InstallationProcessor --> InstallationCompletionHandler : finishes update flow
InstallationCompletionHandler --> UpdatesTracker
InstallationCompletionHandler --> UpdatesNotificationSender
Reading guide
- Start at AppInstallationFacade.
- Follow the enqueue side first: InstallationRequest -> InstallationEnqueuer -> PreEnqueueChecker.
- PreEnqueueChecker fans out into the three main checks: URL refresh, age-limit check, and device checks.
- The wrapper classes shown are the main system-facing collaborators used during checks and completion.
- Then review the runtime side: InstallationProcessor -> InstallationCompletionHandler.
Tests
Issues
https://gitlab.e.foundation/e/os/backlog/-/issues/4177
https://gitlab.e.foundation/e/os/backlog/-/issues/4165