mirror of
https://github.com/whyorean/AuroraStore.git
synced 2026-06-16 03:31:02 -04:00
Add a safeguard to ESM/ESA access prompt
This commit is contained in:
@@ -124,11 +124,15 @@ object PackageUtil {
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.R)
|
||||
fun getStorageManagerIntent(): Intent {
|
||||
return Intent(
|
||||
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
|
||||
Uri.parse("package:${BuildConfig.APPLICATION_ID}")
|
||||
)
|
||||
fun getStorageManagerIntent(safe: Boolean = false): Intent {
|
||||
return if (safe) {
|
||||
Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION)
|
||||
} else {
|
||||
Intent(
|
||||
Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION,
|
||||
Uri.parse("package:${BuildConfig.APPLICATION_ID}")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Throws(Exception::class)
|
||||
|
||||
@@ -562,9 +562,11 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
||||
if (PathUtil.needsStorageManagerPerm(app.fileList)) {
|
||||
if (isRAndAbove()) {
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
startForStorageManagerResult.launch(
|
||||
PackageUtil.getStorageManagerIntent()
|
||||
)
|
||||
try {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent())
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent(true))
|
||||
}
|
||||
} else {
|
||||
viewModel.download(app)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
package com.aurora.store.view.ui.onboarding
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
@@ -216,9 +217,11 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
|
||||
private fun requestStorageManagerPermission() {
|
||||
if (isRAndAbove()) {
|
||||
if (canInstallPackages()) {
|
||||
startForStorageManagerResult.launch(
|
||||
PackageUtil.getStorageManagerIntent()
|
||||
)
|
||||
try {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent())
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent(true))
|
||||
}
|
||||
} else {
|
||||
toast(R.string.toast_permission_installer_required)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
package com.aurora.store.view.ui.updates
|
||||
|
||||
import android.Manifest
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
import android.os.Environment
|
||||
@@ -205,9 +206,11 @@ class UpdatesFragment : BaseFragment<FragmentUpdatesBinding>() {
|
||||
if (PathUtil.needsStorageManagerPerm(update.fileList)) {
|
||||
if (isRAndAbove()) {
|
||||
if (!Environment.isExternalStorageManager()) {
|
||||
startForStorageManagerResult.launch(
|
||||
PackageUtil.getStorageManagerIntent()
|
||||
)
|
||||
try {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent())
|
||||
} catch (_: ActivityNotFoundException) {
|
||||
startForStorageManagerResult.launch(PackageUtil.getStorageManagerIntent(true))
|
||||
}
|
||||
} else {
|
||||
viewModel.download(update)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user