From fa2bcbc13789f208e4818ca389a5e48ae703013c Mon Sep 17 00:00:00 2001 From: Jack Eblan <141921460+JackEblan@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:10:49 +0800 Subject: [PATCH] Forgot to use application scope (#257) --- app/src/main/AndroidManifest.xml | 7 ------- .../DefaultBroadcastReceiverController.kt | 8 +++----- .../com/android/geto/feature/shizuku/ShizukuEvent.kt | 2 +- .../com/android/geto/feature/shizuku/ShizukuScreen.kt | 4 ++-- .../com/android/geto/feature/shizuku/ShizukuViewModel.kt | 2 +- feature/shizuku/src/main/res/values/strings.xml | 1 + .../AndroidUsageStatsForegroundServiceManager.kt | 4 +++- framework/package-manager/src/main/AndroidManifest.xml | 8 +++++++- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2f46055b7..c10b06d75 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -41,11 +41,4 @@ - - - - - - - \ No newline at end of file diff --git a/broadcast-receiver/src/main/kotlin/com/android/geto/broadcastreceiver/DefaultBroadcastReceiverController.kt b/broadcast-receiver/src/main/kotlin/com/android/geto/broadcastreceiver/DefaultBroadcastReceiverController.kt index 66687e15b..b5198f28c 100644 --- a/broadcast-receiver/src/main/kotlin/com/android/geto/broadcastreceiver/DefaultBroadcastReceiverController.kt +++ b/broadcast-receiver/src/main/kotlin/com/android/geto/broadcastreceiver/DefaultBroadcastReceiverController.kt @@ -17,20 +17,18 @@ */ package com.android.geto.broadcastreceiver -import com.android.geto.core.common.Dispatcher -import com.android.geto.core.common.GetoDispatchers.IO +import com.android.geto.core.common.di.ApplicationScope import com.android.geto.core.domain.broadcastreceiver.BroadcastReceiverController import com.android.geto.core.domain.foregroundservice.UsageStatsForegroundServiceManager import com.android.geto.core.domain.framework.NotificationManagerWrapper import com.android.geto.core.domain.model.AppSettingsResult import com.android.geto.core.domain.usecase.RevertAppSettingsUseCase -import kotlinx.coroutines.CoroutineDispatcher import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import javax.inject.Inject internal class DefaultBroadcastReceiverController @Inject constructor( - @Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher, + @ApplicationScope private val appScope: CoroutineScope, private val revertAppSettingsUseCase: RevertAppSettingsUseCase, private val notificationManagerWrapper: NotificationManagerWrapper, private val usageStatsForegroundServiceManager: UsageStatsForegroundServiceManager, @@ -38,7 +36,7 @@ internal class DefaultBroadcastReceiverController @Inject constructor( override fun revertSettings(packageName: String?, notificationId: Int?) { if (packageName == null || notificationId == null) return - CoroutineScope(ioDispatcher).launch { + appScope.launch { if (revertAppSettingsUseCase(packageName = packageName) == AppSettingsResult.Success) { notificationManagerWrapper.cancel(notificationId) } diff --git a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuEvent.kt b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuEvent.kt index d6ac81b35..bf7e42f26 100644 --- a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuEvent.kt +++ b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuEvent.kt @@ -18,7 +18,7 @@ package com.android.geto.feature.shizuku sealed interface ShizukuEvent { - data object CheckShizukuShizuku : ShizukuEvent + data object CheckShizukuPermission : ShizukuEvent data object OnCreate : ShizukuEvent diff --git a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuScreen.kt b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuScreen.kt index dc53e3ef2..fddba8cc3 100644 --- a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuScreen.kt +++ b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuScreen.kt @@ -195,7 +195,7 @@ internal fun ShizukuScreen( Scaffold( topBar = { ShizukuTopAppBar( - title = "Shizuku", + title = stringResource(R.string.shizuku), onNavigationIconClick = onNavigationIconClick, ) }, @@ -216,7 +216,7 @@ internal fun ShizukuScreen( modifier = modifier.fillMaxSize(), active = shizukuStatus == ShizukuStatus.CanWriteSecureSettings, onClick = { - onEvent(ShizukuEvent.CheckShizukuShizuku) + onEvent(ShizukuEvent.CheckShizukuPermission) }, ) } diff --git a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuViewModel.kt b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuViewModel.kt index 886849cb3..e0f3ec3d5 100644 --- a/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuViewModel.kt +++ b/feature/shizuku/src/main/kotlin/com/android/geto/feature/shizuku/ShizukuViewModel.kt @@ -37,7 +37,7 @@ class ShizukuViewModel @Inject constructor(private val shizukuWrapper: ShizukuWr fun onEvent(event: ShizukuEvent) { when (event) { - ShizukuEvent.CheckShizukuShizuku -> { + ShizukuEvent.CheckShizukuPermission -> { shizukuWrapper.checkShizukuPermission() } diff --git a/feature/shizuku/src/main/res/values/strings.xml b/feature/shizuku/src/main/res/values/strings.xml index 74e241b18..9c74361f0 100644 --- a/feature/shizuku/src/main/res/values/strings.xml +++ b/feature/shizuku/src/main/res/values/strings.xml @@ -26,4 +26,5 @@ Something went wrong with the request Please check if Shizuku is properly running Shizuku dead binder + Shizuku \ No newline at end of file diff --git a/foreground-service/src/main/kotlin/com/android/geto/foregroundservice/AndroidUsageStatsForegroundServiceManager.kt b/foreground-service/src/main/kotlin/com/android/geto/foregroundservice/AndroidUsageStatsForegroundServiceManager.kt index c0e0a0d17..8b83a581d 100644 --- a/foreground-service/src/main/kotlin/com/android/geto/foregroundservice/AndroidUsageStatsForegroundServiceManager.kt +++ b/foreground-service/src/main/kotlin/com/android/geto/foregroundservice/AndroidUsageStatsForegroundServiceManager.kt @@ -80,6 +80,8 @@ class AndroidUsageStatsForegroundServiceManager @Inject constructor(@Application _isBound = false - _isActive.tryEmit(context.stopService(usageStatsServiceIntent).not()) + context.stopService(usageStatsServiceIntent) + + _isActive.tryEmit(false) } } diff --git a/framework/package-manager/src/main/AndroidManifest.xml b/framework/package-manager/src/main/AndroidManifest.xml index 57f8df3ef..e6eb478d0 100644 --- a/framework/package-manager/src/main/AndroidManifest.xml +++ b/framework/package-manager/src/main/AndroidManifest.xml @@ -15,6 +15,12 @@ ~ limitations under the License. ~ --> - + + + + + + + \ No newline at end of file