Skip to content

Commit

Permalink
Forgot to use application scope (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEblan authored Dec 15, 2024
1 parent 753e959 commit fa2bcbc
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
7 changes: 0 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,4 @@

</application>

<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,26 @@
*/
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,
) : BroadcastReceiverController {
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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal fun ShizukuScreen(
Scaffold(
topBar = {
ShizukuTopAppBar(
title = "Shizuku",
title = stringResource(R.string.shizuku),
onNavigationIconClick = onNavigationIconClick,
)
},
Expand All @@ -216,7 +216,7 @@ internal fun ShizukuScreen(
modifier = modifier.fillMaxSize(),
active = shizukuStatus == ShizukuStatus.CanWriteSecureSettings,
onClick = {
onEvent(ShizukuEvent.CheckShizukuShizuku)
onEvent(ShizukuEvent.CheckShizukuPermission)
},
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ShizukuViewModel @Inject constructor(private val shizukuWrapper: ShizukuWr

fun onEvent(event: ShizukuEvent) {
when (event) {
ShizukuEvent.CheckShizukuShizuku -> {
ShizukuEvent.CheckShizukuPermission -> {
shizukuWrapper.checkShizukuPermission()
}

Expand Down
1 change: 1 addition & 0 deletions feature/shizuku/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@
<string name="something_went_wrong_with_the_request">Something went wrong with the request</string>
<string name="please_check_if_shizuku_is_properly_running">Please check if Shizuku is properly running</string>
<string name="shizuku_dead_binder">Shizuku dead binder</string>
<string name="shizuku">Shizuku</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class AndroidUsageStatsForegroundServiceManager @Inject constructor(@Application

_isBound = false

_isActive.tryEmit(context.stopService(usageStatsServiceIntent).not())
context.stopService(usageStatsServiceIntent)

_isActive.tryEmit(false)
}
}
8 changes: 7 additions & 1 deletion framework/package-manager/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
~ limitations under the License.
~
-->
<manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<queries>
<intent>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent>
</queries>
</manifest>

0 comments on commit fa2bcbc

Please sign in to comment.