Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
fix shizuku/dhizuku authorizer
Browse files Browse the repository at this point in the history
  • Loading branch information
iamr0s committed Jun 2, 2023
1 parent 22d1160 commit 25a23d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/com/rosan/installer/App.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.rosan.installer

import android.app.Application
import com.rosan.dhizuku.api.Dhizuku
import com.rosan.installer.di.init.appModules
import org.koin.android.ext.koin.androidContext
import org.koin.android.ext.koin.androidLogger
import org.koin.core.context.startKoin
import rikka.sui.Sui

class App : Application() {
override fun onCreate() {
Expand All @@ -20,7 +18,5 @@ class App : Application() {
// use modules
modules(appModules)
}
Sui.init(BuildConfig.APPLICATION_ID)
Dhizuku.init()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.first

suspend fun <T> requireDhizukuPermissionGranted(action: suspend () -> T): T {
callbackFlow {
Dhizuku.init()
if (Dhizuku.isPermissionGranted()) send(Unit)
else {
Dhizuku.requestPermission(object : DhizukuRequestPermissionListener() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package com.rosan.installer.data.recycle.util

import android.content.pm.PackageManager
import com.rosan.installer.BuildConfig
import com.rosan.installer.data.recycle.model.exception.ShizukuNotWorkException
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.callbackFlow
import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.first
import rikka.shizuku.Shizuku
import rikka.sui.Sui

suspend fun <T> requireShizukuPermissionGranted(action: suspend () -> T): T {
callbackFlow {
Sui.init(BuildConfig.APPLICATION_ID)
if (Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED) {
send(Unit)
awaitClose()
Expand Down

0 comments on commit 25a23d1

Please sign in to comment.