-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SERVER_API: io.github.iamr0s:Dhizuku-SERVER_API SERVER_API source: https://github.com/iamr0s/Dhizuku-API
- Loading branch information
Showing
107 changed files
with
1,796 additions
and
3,210 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Submodule api
deleted from
b17a8c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
app/src/main/aidl/com/rosan/dhizuku/aidl/IDhizukuUserService.aidl
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
app/src/main/aidl/com/rosan/dhizuku/aidl/IDhizukuUserServiceManager.aidl
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/com/rosan/dhizuku/data/common/model/exception/DhizukuNotWorkException.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.rosan.dhizuku.data.common.model.exception | ||
|
||
class DhizukuNotWorkException : RuntimeException { | ||
constructor() : super() | ||
|
||
constructor(message: String?) : super(message) | ||
|
||
constructor(cause: Throwable?) : super(cause) | ||
|
||
constructor(message: String?, cause: Throwable?) : super(message, cause) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
app/src/main/java/com/rosan/dhizuku/data/common/util/DeviceOwnerUtil.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/rosan/dhizuku/data/common/util/DhizukuUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.rosan.dhizuku.data.common.util | ||
|
||
import android.content.pm.PackageManager | ||
import com.rosan.dhizuku.api.Dhizuku | ||
import com.rosan.dhizuku.api.DhizukuRequestPermissionListener | ||
import com.rosan.dhizuku.data.common.model.exception.DhizukuNotWorkException | ||
import kotlinx.coroutines.channels.awaitClose | ||
import kotlinx.coroutines.flow.callbackFlow | ||
import kotlinx.coroutines.flow.catch | ||
import kotlinx.coroutines.flow.first | ||
|
||
private suspend fun blockingRequestDhizukuPermission() = callbackFlow { | ||
Dhizuku.requestPermission(object : DhizukuRequestPermissionListener() { | ||
override fun onRequestPermission(grantResult: Int) { | ||
if (grantResult == PackageManager.PERMISSION_GRANTED) trySend(Unit) | ||
else close(DhizukuNotWorkException("dhizuku permission denied")) | ||
} | ||
}) | ||
awaitClose() | ||
}.catch { | ||
throw if (it !is DhizukuNotWorkException) DhizukuNotWorkException(cause = it) | ||
else it | ||
}.first() | ||
|
||
suspend fun <T> requireDhizukuPermissionGranted(action: suspend () -> T): T { | ||
if (!Dhizuku.init()) throw DhizukuNotWorkException("dhizuku isn't activated") | ||
if (!Dhizuku.isPermissionGranted()) | ||
blockingRequestDhizukuPermission() | ||
return action() | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/java/com/rosan/dhizuku/data/common/util/IntUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.rosan.dhizuku.data.common.util | ||
|
||
fun Int.has(flag: Int) = this and flag != 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.