fixup! Fix AuroraOSS/AuroraStore#981 allow Sui without Shizuku app

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2023-12-18 15:40:12 +05:30
parent db609d9e81
commit 8f518d026a
3 changed files with 14 additions and 9 deletions

View File

@@ -80,12 +80,11 @@ open class AppInstaller private constructor(var context: Context) {
PackageUtil.isInstalled(context, AMInstaller.AM_DEBUG_PACKAGE_NAME)
}
fun hasShizuku(context: Context): Boolean {
return PackageUtil.isInstalled(context, ShizukuInstaller.SHIZUKU_PACKAGE_NAME)
}
fun hasShizukuOrSui(context: Context): Boolean {
return hasShizuku(context) || Sui.isSui()
return PackageUtil.isInstalled(
context,
ShizukuInstaller.SHIZUKU_PACKAGE_NAME
) || Sui.isSui()
}
fun hasShizukuPerm(): Boolean {

View File

@@ -28,9 +28,9 @@ 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.hasShizuku
import com.aurora.store.data.installer.AppInstaller.Companion.hasShizukuOrSui
import com.aurora.store.data.installer.AppInstaller.Companion.hasShizukuPerm
import com.aurora.store.data.model.Installer
@@ -85,6 +85,12 @@ class InstallerFragment : BaseFragment(R.layout.fragment_onboarding_installer) {
installerId = Preferences.getInteger(requireContext(), PREFERENCE_INSTALLER_ID)
if (hasShizukuOrSui(requireContext()) && isOAndAbove()) {
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
Shizuku.addBinderDeadListener(shizukuDeadListener)
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
}
// RecyclerView
binding.epoxyRecycler.withModels {
setFilterDuplicates(true)
@@ -115,7 +121,7 @@ class InstallerFragment : BaseFragment(R.layout.fragment_onboarding_installer) {
}
override fun onDestroy() {
if (hasShizuku(requireContext()) && isOAndAbove()) {
if (hasShizukuOrSui(requireContext()) && isOAndAbove()) {
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
Shizuku.removeBinderDeadListener(shizukuDeadListener)
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)

View File

@@ -97,7 +97,7 @@ class InstallationPreference : PreferenceFragmentCompat() {
setNavigationOnClickListener { findNavController().navigateUp() }
}
if (AppInstaller.hasShizuku(requireContext()) && isOAndAbove()) {
if (AppInstaller.hasShizukuOrSui(requireContext()) && isOAndAbove()) {
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
Shizuku.addBinderDeadListener(shizukuDeadListener)
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
@@ -188,7 +188,7 @@ class InstallationPreference : PreferenceFragmentCompat() {
}
override fun onDestroy() {
if (AppInstaller.hasShizuku(requireContext()) && isOAndAbove()) {
if (AppInstaller.hasShizukuOrSui(requireContext()) && isOAndAbove()) {
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
Shizuku.removeBinderDeadListener(shizukuDeadListener)
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)