Skip to content

Commit

Permalink
fix: checkSelfPermission & setInstallReason
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Dec 29, 2023
1 parent 6ebe166 commit 21ad002
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.Manifest
import android.content.pm.PackageManager
import androidx.activity.result.contract.ActivityResultContract
import androidx.activity.result.contract.ActivityResultContracts
import androidx.core.content.ContextCompat
import app.revanced.manager.util.RequestManageStorageContract

class Filesystem(private val app: Application) {
Expand All @@ -32,5 +33,5 @@ class Filesystem(private val app: Application) {
return contract to storagePermissionName
}

fun hasStoragePermission() = if (usesManagePermission()) Environment.isExternalStorageManager() else app.checkSelfPermission(storagePermissionName) == PackageManager.PERMISSION_GRANTED
fun hasStoragePermission() = if (usesManagePermission()) Environment.isExternalStorageManager() else ContextCompat.checkSelfPermission(app, storagePermissionName) == PackageManager.PERMISSION_GRANTED
}
4 changes: 3 additions & 1 deletion app/src/main/java/app/revanced/manager/util/PM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ class PM(
get() = PackageInstaller.SessionParams(
PackageInstaller.SessionParams.MODE_FULL_INSTALL
).apply {
setInstallReason(PackageManager.INSTALL_REASON_USER)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
setInstallReason(PackageManager.INSTALL_REASON_USER)
}
}

private val Context.installIntentSender
Expand Down

0 comments on commit 21ad002

Please sign in to comment.