installer: Put more details into installerinfo
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.Intent
|
||||
import android.util.Log
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.room.download.Download
|
||||
import com.aurora.store.util.PackageUtil.isSharedLibraryInstalled
|
||||
@@ -25,14 +26,16 @@ class AMInstaller @Inject constructor(
|
||||
const val AM_PACKAGE_NAME = "io.github.muntashirakon.AppManager"
|
||||
const val AM_DEBUG_PACKAGE_NAME = "io.github.muntashirakon.AppManager.debug"
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 4,
|
||||
title = context.getString(R.string.pref_install_mode_am),
|
||||
subtitle = context.getString(R.string.am_installer_subtitle),
|
||||
description = context.getString(R.string.am_installer_desc)
|
||||
installer = Installer.AM,
|
||||
packageNames = listOf(AM_PACKAGE_NAME, AM_DEBUG_PACKAGE_NAME),
|
||||
installerPackageNames = listOf(AM_PACKAGE_NAME, AM_DEBUG_PACKAGE_NAME),
|
||||
title = R.string.pref_install_mode_am,
|
||||
subtitle = R.string.am_installer_subtitle,
|
||||
description = R.string.am_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = AMInstaller::class.java.simpleName
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.core.content.pm.PackageInfoCompat
|
||||
import com.aurora.extensions.getUpdateOwnerPackageNameCompat
|
||||
import com.aurora.extensions.isOAndAbove
|
||||
@@ -68,28 +67,14 @@ class AppInstaller @Inject constructor(
|
||||
}
|
||||
|
||||
fun getAvailableInstallersInfo(context: Context): List<InstallerInfo> {
|
||||
val installers = mutableListOf(
|
||||
SessionInstaller.getInstallerInfo(context),
|
||||
NativeInstaller.getInstallerInfo(context)
|
||||
return listOfNotNull(
|
||||
SessionInstaller.installerInfo,
|
||||
NativeInstaller.installerInfo,
|
||||
if (hasRootAccess()) RootInstaller.installerInfo else null,
|
||||
if (hasAuroraService(context)) ServiceInstaller.installerInfo else null,
|
||||
if (hasAppManager(context)) AMInstaller.installerInfo else null,
|
||||
if (hasShizukuOrSui(context)) ShizukuInstaller.installerInfo else null
|
||||
)
|
||||
|
||||
if (hasRootAccess()) {
|
||||
installers.add(RootInstaller.getInstallerInfo(context))
|
||||
}
|
||||
|
||||
if (hasAuroraService(context)) {
|
||||
installers.add(ServiceInstaller.getInstallerInfo(context))
|
||||
}
|
||||
|
||||
if (hasAppManager(context)) {
|
||||
installers.add(AMInstaller.getInstallerInfo(context))
|
||||
}
|
||||
|
||||
if (isOAndAbove && hasShizukuOrSui(context)) {
|
||||
installers.add(ShizukuInstaller.getInstallerInfo(context))
|
||||
}
|
||||
|
||||
return installers
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,12 +131,11 @@ class AppInstaller @Inject constructor(
|
||||
PackageUtil.isInstalled(context, AMInstaller.AM_DEBUG_PACKAGE_NAME)
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
fun hasShizukuOrSui(context: Context): Boolean {
|
||||
return PackageUtil.isInstalled(
|
||||
return isOAndAbove && (PackageUtil.isInstalled(
|
||||
context,
|
||||
ShizukuInstaller.SHIZUKU_PACKAGE_NAME
|
||||
) || Sui.isSui()
|
||||
) || Sui.isSui())
|
||||
}
|
||||
|
||||
fun hasShizukuPerm(): Boolean {
|
||||
@@ -185,7 +169,7 @@ class AppInstaller @Inject constructor(
|
||||
Installer.SERVICE -> if (hasAuroraService(context)) serviceInstaller else defaultInstaller
|
||||
Installer.AM -> if (hasAppManager(context)) amInstaller else defaultInstaller
|
||||
Installer.SHIZUKU -> {
|
||||
if (isOAndAbove && hasShizukuOrSui(context) && hasShizukuPerm()) {
|
||||
if (hasShizukuOrSui(context) && hasShizukuPerm()) {
|
||||
shizukuInstaller
|
||||
} else {
|
||||
defaultInstaller
|
||||
|
||||
@@ -27,6 +27,8 @@ import android.util.Log
|
||||
import com.aurora.extensions.runOnUiThread
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.BuildType
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.room.download.Download
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
@@ -42,14 +44,16 @@ class NativeInstaller @Inject constructor(
|
||||
|
||||
companion object {
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 1,
|
||||
title = context.getString(R.string.pref_install_mode_native),
|
||||
subtitle = context.getString(R.string.native_installer_subtitle),
|
||||
description = context.getString(R.string.native_installer_desc)
|
||||
installer = Installer.NATIVE,
|
||||
packageNames = BuildType.PACKAGE_NAMES,
|
||||
installerPackageNames = BuildType.PACKAGE_NAMES,
|
||||
title = R.string.pref_install_mode_native,
|
||||
subtitle = R.string.native_installer_subtitle,
|
||||
description = R.string.native_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = NativeInstaller::class.java.simpleName
|
||||
|
||||
@@ -25,6 +25,8 @@ import com.aurora.store.AuroraApp
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.event.InstallerEvent
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.BuildType
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.room.download.Download
|
||||
import com.aurora.store.util.PackageUtil.isSharedLibraryInstalled
|
||||
@@ -40,15 +42,18 @@ class RootInstaller @Inject constructor(
|
||||
) : InstallerBase(context) {
|
||||
|
||||
companion object {
|
||||
const val PLAY_PACKAGE_NAME = "com.android.vending"
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 2,
|
||||
title = context.getString(R.string.pref_install_mode_root),
|
||||
subtitle = context.getString(R.string.root_installer_subtitle),
|
||||
description = context.getString(R.string.root_installer_desc)
|
||||
installer = Installer.ROOT,
|
||||
packageNames = BuildType.PACKAGE_NAMES,
|
||||
installerPackageNames = listOf(PLAY_PACKAGE_NAME),
|
||||
title = R.string.pref_install_mode_root,
|
||||
subtitle = R.string.root_installer_subtitle,
|
||||
description = R.string.root_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = RootInstaller::class.java.simpleName
|
||||
@@ -83,7 +88,7 @@ class RootInstaller @Inject constructor(
|
||||
totalSize += file.length().toInt()
|
||||
|
||||
val result: Shell.Result =
|
||||
Shell.cmd("pm install-create -i com.android.vending --user 0 -r -S $totalSize")
|
||||
Shell.cmd("pm install-create -i $PLAY_PACKAGE_NAME --user 0 -r -S $totalSize")
|
||||
.exec()
|
||||
|
||||
val response = result.out
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.aurora.store.BuildConfig
|
||||
import com.aurora.store.R
|
||||
import com.aurora.store.data.event.InstallerEvent
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.room.download.Download
|
||||
import com.aurora.store.util.PackageUtil
|
||||
@@ -62,14 +63,16 @@ class ServiceInstaller @Inject constructor(
|
||||
const val PRIVILEGED_EXTENSION_PACKAGE_NAME = "com.aurora.services"
|
||||
const val PRIVILEGED_EXTENSION_SERVICE_INTENT = "com.aurora.services.IPrivilegedService"
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 3,
|
||||
title = context.getString(R.string.pref_install_mode_services),
|
||||
subtitle = context.getString(R.string.services_installer_subtitle),
|
||||
description = context.getString(R.string.services_installer_desc)
|
||||
installer = Installer.SERVICE,
|
||||
packageNames = listOf(PRIVILEGED_EXTENSION_PACKAGE_NAME),
|
||||
installerPackageNames = listOf(PRIVILEGED_EXTENSION_PACKAGE_NAME),
|
||||
title = R.string.pref_install_mode_services,
|
||||
subtitle = R.string.services_installer_subtitle,
|
||||
description = R.string.services_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = ServiceInstaller::class.java.simpleName
|
||||
|
||||
@@ -45,6 +45,8 @@ import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_DISPLAY_NAME
|
||||
import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_PACKAGE_NAME
|
||||
import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_VERSION_CODE
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.BuildType
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.model.SessionInfo
|
||||
import com.aurora.store.data.receiver.InstallerStatusReceiver
|
||||
@@ -113,14 +115,16 @@ class SessionInstaller @Inject constructor(
|
||||
|
||||
companion object {
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 0,
|
||||
title = context.getString(R.string.pref_install_mode_session),
|
||||
subtitle = context.getString(R.string.session_installer_subtitle),
|
||||
description = context.getString(R.string.session_installer_desc)
|
||||
installer = Installer.SESSION,
|
||||
packageNames = BuildType.PACKAGE_NAMES,
|
||||
installerPackageNames = BuildType.PACKAGE_NAMES,
|
||||
title = R.string.pref_install_mode_session,
|
||||
subtitle = R.string.session_installer_subtitle,
|
||||
description = R.string.session_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_DISPLAY_NAME
|
||||
import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_PACKAGE_NAME
|
||||
import com.aurora.store.data.installer.AppInstaller.Companion.EXTRA_VERSION_CODE
|
||||
import com.aurora.store.data.installer.base.InstallerBase
|
||||
import com.aurora.store.data.model.Installer
|
||||
import com.aurora.store.data.model.InstallerInfo
|
||||
import com.aurora.store.data.receiver.InstallerStatusReceiver
|
||||
import com.aurora.store.data.room.download.Download
|
||||
@@ -62,15 +63,18 @@ class ShizukuInstaller @Inject constructor(
|
||||
|
||||
companion object {
|
||||
const val SHIZUKU_PACKAGE_NAME = "moe.shizuku.privileged.api"
|
||||
const val PLAY_PACKAGE_NAME = "com.android.vending"
|
||||
|
||||
fun getInstallerInfo(context: Context): InstallerInfo {
|
||||
return InstallerInfo(
|
||||
val installerInfo: InstallerInfo
|
||||
get() = InstallerInfo(
|
||||
id = 5,
|
||||
title = context.getString(R.string.pref_install_mode_shizuku),
|
||||
subtitle = context.getString(R.string.shizuku_installer_subtitle),
|
||||
description = context.getString(R.string.shizuku_installer_desc)
|
||||
installer = Installer.SHIZUKU,
|
||||
packageNames = listOf(SHIZUKU_PACKAGE_NAME),
|
||||
installerPackageNames = listOf(PLAY_PACKAGE_NAME),
|
||||
title = R.string.pref_install_mode_shizuku,
|
||||
subtitle = R.string.shizuku_installer_subtitle,
|
||||
description = R.string.shizuku_installer_desc
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val TAG = ShizukuInstaller::class.java.simpleName
|
||||
@@ -90,11 +94,11 @@ class ShizukuInstaller @Inject constructor(
|
||||
private val packageInstaller: PackageInstaller? by lazy {
|
||||
if (isSAndAbove) {
|
||||
Refine.unsafeCast<PackageInstaller>(
|
||||
PackageInstallerHidden(iPackageInstaller, "com.android.vending", null, 0)
|
||||
PackageInstallerHidden(iPackageInstaller, PLAY_PACKAGE_NAME, null, 0)
|
||||
)
|
||||
} else if (isOAndAbove) {
|
||||
Refine.unsafeCast<PackageInstaller>(
|
||||
PackageInstallerHidden(iPackageInstaller, "com.android.vending", 0)
|
||||
PackageInstallerHidden(iPackageInstaller, PLAY_PACKAGE_NAME, 0)
|
||||
)
|
||||
} else null
|
||||
}
|
||||
|
||||
@@ -1,7 +1,32 @@
|
||||
package com.aurora.store.data.model
|
||||
|
||||
enum class BuildType {
|
||||
RELEASE,
|
||||
NIGHTLY,
|
||||
DEBUG
|
||||
import com.aurora.store.BuildConfig
|
||||
|
||||
/**
|
||||
* Class representing build types for Aurora Store
|
||||
*/
|
||||
enum class BuildType(val packageName: String) {
|
||||
RELEASE("com.aurora.store"),
|
||||
NIGHTLY("com.aurora.store.nightly"),
|
||||
DEBUG("com.aurora.store.debug");
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* Returns current build type
|
||||
*/
|
||||
@Suppress("KotlinConstantConditions")
|
||||
val CURRENT: BuildType
|
||||
get() = when (BuildConfig.BUILD_TYPE) {
|
||||
"release" -> RELEASE
|
||||
"nightly" -> NIGHTLY
|
||||
else -> DEBUG
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns package names for all possible build types
|
||||
*/
|
||||
val PACKAGE_NAMES: List<String>
|
||||
get() = BuildType.entries.map { it.packageName }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.aurora.store.data.model
|
||||
|
||||
/**
|
||||
* Supported installers for Aurora Store
|
||||
*/
|
||||
enum class Installer {
|
||||
SESSION,
|
||||
NATIVE,
|
||||
|
||||
@@ -19,11 +19,19 @@
|
||||
|
||||
package com.aurora.store.data.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
/**
|
||||
* Class holding information on a supported installer
|
||||
*/
|
||||
data class InstallerInfo(
|
||||
var id: Int,
|
||||
var title: String,
|
||||
var subtitle: String,
|
||||
var description: String
|
||||
val id: Int,
|
||||
val installer: Installer,
|
||||
val packageNames: List<String>,
|
||||
val installerPackageNames: List<String>,
|
||||
@StringRes val title: Int,
|
||||
@StringRes val subtitle: Int,
|
||||
@StringRes val description: Int
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return when (other) {
|
||||
|
||||
@@ -61,16 +61,9 @@ class UpdateWorker @AssistedInject constructor(
|
||||
|
||||
private val notificationID = 100
|
||||
|
||||
@Suppress("KotlinConstantConditions")
|
||||
private val buildType = when (BuildConfig.BUILD_TYPE) {
|
||||
"release" -> BuildType.RELEASE
|
||||
"nightly" -> BuildType.NIGHTLY
|
||||
else -> BuildType.DEBUG
|
||||
}
|
||||
|
||||
private val canSelfUpdate = !CertUtil.isFDroidApp(appContext, BuildConfig.APPLICATION_ID) &&
|
||||
!CertUtil.isAppGalleryApp(appContext, BuildConfig.APPLICATION_ID) &&
|
||||
buildType != BuildType.DEBUG
|
||||
BuildType.CURRENT != BuildType.DEBUG
|
||||
|
||||
private val isAuroraOnlyFilterEnabled: Boolean
|
||||
get() = Preferences.getBoolean(appContext, Preferences.PREFERENCE_FILTER_AURORA_ONLY, false)
|
||||
@@ -182,7 +175,7 @@ class UpdateWorker @AssistedInject constructor(
|
||||
*/
|
||||
private suspend fun getSelfUpdate(): App? {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val updateUrl = when (buildType) {
|
||||
val updateUrl = when (BuildType.CURRENT) {
|
||||
BuildType.RELEASE -> Constants.UPDATE_URL_STABLE
|
||||
BuildType.NIGHTLY -> Constants.UPDATE_URL_NIGHTLY
|
||||
else -> {
|
||||
@@ -198,7 +191,7 @@ class UpdateWorker @AssistedInject constructor(
|
||||
SelfUpdate::class.java
|
||||
)
|
||||
|
||||
val isUpdate = when (buildType) {
|
||||
val isUpdate = when (BuildType.CURRENT) {
|
||||
BuildType.NIGHTLY,
|
||||
BuildType.RELEASE -> selfUpdate.versionCode > BuildConfig.VERSION_CODE
|
||||
else -> false
|
||||
|
||||
@@ -42,9 +42,9 @@ class InstallerView @JvmOverloads constructor(
|
||||
|
||||
@ModelProp
|
||||
fun installer(installer: InstallerInfo) {
|
||||
binding.line1.text = installer.title
|
||||
binding.line2.text = installer.subtitle
|
||||
binding.line3.text = installer.description
|
||||
binding.line1.text = context.getString(installer.title)
|
||||
binding.line2.text = context.getString(installer.subtitle)
|
||||
binding.line3.text = context.getString(installer.description)
|
||||
}
|
||||
|
||||
@ModelProp
|
||||
|
||||
@@ -79,7 +79,7 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
||||
|
||||
installerId = Preferences.getInteger(requireContext(), PREFERENCE_INSTALLER_ID)
|
||||
|
||||
if (isOAndAbove && AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||
if (AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||
Shizuku.addBinderReceivedListenerSticky(shizukuAliveListener)
|
||||
Shizuku.addBinderDeadListener(shizukuDeadListener)
|
||||
Shizuku.addRequestPermissionResultListener(shizukuResultListener)
|
||||
@@ -108,7 +108,7 @@ class InstallerFragment : BaseFragment<FragmentInstallerBinding>() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if (isOAndAbove && AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||
if (AppInstaller.hasShizukuOrSui(requireContext())) {
|
||||
Shizuku.removeBinderReceivedListener(shizukuAliveListener)
|
||||
Shizuku.removeBinderDeadListener(shizukuDeadListener)
|
||||
Shizuku.removeRequestPermissionResultListener(shizukuResultListener)
|
||||
|
||||
Reference in New Issue
Block a user