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 { } else {
true true
} }
val writeExternalStorage = val writeExternalStorage =
if (!isRAndAbove()) isExternalStorageAccessible(requireContext()) else true if (!isRAndAbove()) isExternalStorageAccessible(requireContext()) else true
val postNotifications = if (isTAndAbove()) ActivityCompat.checkSelfPermission( val postNotifications = if (isTAndAbove()) ActivityCompat.checkSelfPermission(
requireContext(), requireContext(),
Manifest.permission.POST_NOTIFICATIONS Manifest.permission.POST_NOTIFICATIONS
) == PackageManager.PERMISSION_GRANTED else true ) == PackageManager.PERMISSION_GRANTED else true
val storageManager = if (isRAndAbove()) Environment.isExternalStorageManager() else true val storageManager = if (isRAndAbove()) Environment.isExternalStorageManager() else true
val canInstallPackages = if (isOAndAbove()) {
requireContext().packageManager.canRequestPackageInstalls()
} else {
true
}
setFilterDuplicates(true) setFilterDuplicates(true)
installerList.forEach { installerList.forEach {
@@ -164,7 +162,7 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
when (it.id) { when (it.id) {
0 -> writeExternalStorage 0 -> writeExternalStorage
1 -> storageManager 1 -> storageManager
2 -> canInstallPackages 2 -> canInstallPackages()
3 -> postNotifications 3 -> postNotifications
4 -> dozeDisabled 4 -> dozeDisabled
else -> false 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() { private fun requestDozePermission() {
if (isMAndAbove()) { if (isMAndAbove()) {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply { val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
@@ -194,7 +200,11 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
} }
private fun checkStorageAccessPermission() { 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() { private fun checkPostNotificationsPermission() {
@@ -205,9 +215,13 @@ class PermissionsFragment : BaseFragment<FragmentOnboardingPermissionsBinding>()
private fun requestStorageManagerPermission() { private fun requestStorageManagerPermission() {
if (isRAndAbove()) { if (isRAndAbove()) {
startForStorageManagerResult.launch( if (canInstallPackages()) {
PackageUtil.getStorageManagerIntent() 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_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_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_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_spoof_applied">Device spoof applied.</string>
<string name="toast_purchase_blocked">"App purchases not available on Anonymous accounts."</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> <string name="toast_manual_unavailable">"The version code you are requesting is unavailable."</string>