AppInstaller: Make lint happy about version check for shizuku

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-02-08 12:49:22 +01:00
parent 5ceb339b35
commit 473d59ad78
3 changed files with 9 additions and 13 deletions

View File

@@ -25,6 +25,8 @@ import android.content.Intent
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import androidx.annotation.RequiresApi
import com.aurora.extensions.isOAndAbove
import com.aurora.extensions.isPAndAbove
import com.aurora.store.BuildConfig
@@ -78,6 +80,7 @@ class AppInstaller @Inject constructor(@ApplicationContext private val context:
PackageUtil.isInstalled(context, AMInstaller.AM_DEBUG_PACKAGE_NAME)
}
@RequiresApi(Build.VERSION_CODES.O)
fun hasShizukuOrSui(context: Context): Boolean {
return PackageUtil.isInstalled(
context,

View File

@@ -28,7 +28,6 @@ import com.aurora.extensions.isMiuiOptimizationDisabled
import com.aurora.extensions.isOAndAbove
import com.aurora.extensions.showDialog
import com.aurora.store.R
import com.aurora.store.data.installer.AppInstaller
import com.aurora.store.data.installer.AppInstaller.Companion.hasAppManager
import com.aurora.store.data.installer.AppInstaller.Companion.hasRootAccess
import com.aurora.store.data.installer.AppInstaller.Companion.hasShizukuOrSui
@@ -85,7 +84,7 @@ class InstallerFragment : BaseFragment(R.layout.fragment_onboarding_installer) {
installerId = Preferences.getInteger(requireContext(), PREFERENCE_INSTALLER_ID)
if (hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && hasShizukuOrSui(requireContext())) {
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
Shizuku.addBinderDeadListener(shizukuDeadListener)
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
@@ -121,7 +120,7 @@ class InstallerFragment : BaseFragment(R.layout.fragment_onboarding_installer) {
}
override fun onDestroy() {
if (hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && hasShizukuOrSui(requireContext())) {
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
Shizuku.removeBinderDeadListener(shizukuDeadListener)
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)
@@ -163,7 +162,7 @@ class InstallerFragment : BaseFragment(R.layout.fragment_onboarding_installer) {
}
}
5 -> {
if (hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && hasShizukuOrSui(requireContext())) {
if (shizukuAlive && hasShizukuPerm()) {
this.installerId = installerId
save(PREFERENCE_INSTALLER_ID, installerId)

View File

@@ -36,7 +36,6 @@ import com.aurora.store.R
import com.aurora.store.data.installer.AMInstaller
import com.aurora.store.data.installer.AppInstaller
import com.aurora.store.data.installer.ServiceInstaller
import com.aurora.store.data.installer.ShizukuInstaller
import com.aurora.store.util.CommonUtil
import com.aurora.store.util.Log
import com.aurora.store.util.PackageUtil
@@ -97,7 +96,7 @@ class InstallationPreference : PreferenceFragmentCompat() {
setNavigationOnClickListener { findNavController().navigateUp() }
}
if (AppInstaller.hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
Shizuku.addBinderDeadListener(shizukuDeadListener)
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
@@ -158,7 +157,7 @@ class InstallationPreference : PreferenceFragmentCompat() {
false
}
} else if (selectedId == 5) {
if (AppInstaller.hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
if (shizukuAlive && AppInstaller.hasShizukuPerm()) {
save(Preferences.PREFERENCE_INSTALLER_ID, selectedId)
true
@@ -188,7 +187,7 @@ class InstallationPreference : PreferenceFragmentCompat() {
}
override fun onDestroy() {
if (AppInstaller.hasShizukuOrSui(requireContext()) && isOAndAbove()) {
if (isOAndAbove() && AppInstaller.hasShizukuOrSui(requireContext())) {
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
Shizuku.removeBinderDeadListener(shizukuDeadListener)
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)
@@ -225,9 +224,4 @@ class InstallationPreference : PreferenceFragmentCompat() {
AMInstaller.AM_DEBUG_PACKAGE_NAME
)
}
private fun checkShizukuAvailability(): Boolean {
return (PackageUtil.isInstalled(requireContext(), ShizukuInstaller.SHIZUKU_PACKAGE_NAME) || Sui.isSui()) &&
shizukuAlive && Shizuku.checkSelfPermission() == PackageManager.PERMISSION_GRANTED
}
}