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