Skip to content

Removed usage stats service as it is too unstable#361

Merged
JackEblan merged 7 commits into
masterfrom
try-refactor
May 25, 2026
Merged

Removed usage stats service as it is too unstable#361
JackEblan merged 7 commits into
masterfrom
try-refactor

Conversation

@JackEblan

Copy link
Copy Markdown
Owner

No description provided.

JackEblan added 7 commits May 25, 2026 11:20
This change introduces synchronous data retrieval methods to the AppSettings repository and DAO, refactors build-logic convention plugins, and updates the service feature's permission handling.

- **Data Layer**: Added non-`Flow` returning methods to `AppSettingsDao` and `AppSettingsRepository`. Existing `Flow` methods were renamed to include a `Flow` suffix (e.g., `getAppSettingsFlowByPackageName`) for clarity.
- **Use Cases**: Refactored `ApplyAppSettingsUseCase` and `AddAppSettingUseCase` to use direct repository calls instead of `Flow.first()`, wrapping operations in `withContext(defaultDispatcher)`.
- **Build Logic**: Consolidated Compose configuration by updating `configureCompose` to accept a `CommonExtension` parameter. Simplified `AndroidApplicationConventionPlugin` and `AndroidLibraryComposeConventionPlugin` to use this unified helper.
- **Service Feature**: Updated `ServiceViewModel` to check for usage stats permissions via `UsageStatsManagerWrapper` before updating the foreground service. Added the `domain:framework` dependency to `feature:service`.
- **ProGuard**: Refactored `proguard-rules.pro` to keep `domain.model` package names and enum members while removing unnecessary library-specific warnings.
- **Refactoring**: Migrated `DefaultAppSettingsRepository` mapping logic to extension functions and improved the use of named parameters.
This change migrates all domain-related modules to pure Kotlin JVM libraries, removing dependencies on the Android Gradle plugin where not required. It also cleans up unused logic related to usage statistics and foreground service management.

- Migrated `domain:common`, `domain:framework`, `domain:model`, `domain:repository`, and `domain:use-case` to use the `jvmLibrary` plugin.
- Removed Android-specific configurations, including namespaces and consumer ProGuard rules, from domain modules.
- Deleted usage stats and foreground service coordination logic: `ForegroundServiceAppSettingsUseCase`, `UsageStatsManagerWrapper`, and associated models.
- Updated `AppSettingsRepository` and `AppSettingsDao` to use `suspend` functions for fetching settings by package name.
- Removed unused `appSettings` property and `getAppSettingEntities()` query from the repository and DAO.
- Cleaned up unused imports in `ApplyAppSettingsUseCase` and `AddAppSettingUseCase`.
- Refined annotation usage for `CoroutineDispatcher` in `RevertAppSettingsUseCase`.
- Deleted `AppSettingsDaoTest.kt` and `MigrationTest.kt` from the `data:room` module.
- Updated `.idea/androidTestResultsUserPreferences.xml` with new device test metadata.
- Added `testInstrumentationRunner` to `defaultConfig` in `data:room/build.gradle.kts`.
This change adds the core, runner, rules, and JUnit KTX extension libraries to `androidTestImplementation` in `app/build.gradle.kts`.
@JackEblan JackEblan merged commit 3407f47 into master May 25, 2026
2 checks passed
@JackEblan JackEblan deleted the try-refactor branch May 25, 2026 04:32
@KyleBroflowski

Copy link
Copy Markdown

It was a shame to remove usage stats service. Though some of the behaviours was weird, it was possible to live it it. Keeping it as an optional or advanced user feature would have been great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants