Do not allow ESA & ESM prompt without Installer Permission

- This avoids OBB dir permission bakchodi!
This commit is contained in:
Rahul Patel
2024-07-25 00:45:47 +05:30
parent a76266c212
commit 6a01825a4f
2 changed files with 25 additions and 10 deletions

View File

@@ -141,18 +141,16 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
} else {
true
}
val writeExternalStorage =
if (!isRAndAbove()) isExternalStorageAccessible(requireContext()) else true
val postNotifications = if (isTAndAbove()) ActivityCompat.checkSelfPermission(
requireContext(),
Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED else true
val storageManager = if (isRAndAbove()) Environment.isExternalStorageManager() else true
val canInstallPackages = if (isOAndAbove()) {
requireContext().packageManager.canRequestPackageInstalls()
} else {
true
}
setFilterDuplicates(true)
installerList.forEach {
@@ -164,7 +162,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
when (it.id) {
0 -> writeExternalStorage
1 -> storageManager
2 -> canInstallPackages
2 -> canInstallPackages()
3 -> postNotifications
4 -> dozeDisabled
else -> false
@@ -184,6 +182,14 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
}
}
private fun canInstallPackages(): Boolean {
if (isOAndAbove()) {
return requireContext().packageManager.canRequestPackageInstalls()
} else {
return true
}
}
private fun requestDozePermission() {
if (isMAndAbove()) {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
@@ -194,7 +200,11 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
}
private fun checkStorageAccessPermission() {
startForPermissions.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
if (canInstallPackages()) {
startForPermissions.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE)
} else {
toast(R.string.toast_permission_installer_required)
}
}
private fun checkPostNotificationsPermission() {
@@ -205,9 +215,13 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
private fun requestStorageManagerPermission() {
if (isRAndAbove()) {
startForStorageManagerResult.launch(
PackageUtil.getStorageManagerIntent()
)
if (canInstallPackages()) {
startForStorageManagerResult.launch(
PackageUtil.getStorageManagerIntent()
)
} else {
toast(R.string.toast_permission_installer_required)
}
}
}

View File

@@ -308,6 +308,7 @@
<string name="toast_clipboard_copied">"Copied to clipboard"</string>
<string name="toast_developer_setting_failed">Turn on developer settings from the device settings to open them.</string>
<string name="toast_permission_granted">"Permission granted"</string>
<string name="toast_permission_installer_required">"You need to grant Installer Permission first"</string>
<string name="toast_spoof_applied">Device spoof applied.</string>
<string name="toast_purchase_blocked">"App purchases not available on Anonymous accounts."</string>
<string name="toast_manual_unavailable">"The version code you are requesting is unavailable."</string>