Add filter to list & update apps installed by Aurora Store only
- Improves fdroid filter - Remove all apps that have no launch intent:
This commit is contained in:
@@ -61,6 +61,10 @@ fun isTAndAbove(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
|
||||
}
|
||||
|
||||
fun isUAndAbove(): Boolean {
|
||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE
|
||||
}
|
||||
|
||||
fun isMIUI(): Boolean {
|
||||
return getSystemProperty("ro.miui.ui.version.name").isNotEmpty()
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ class NativeInstaller(context: Context) : InstallerBase(context) {
|
||||
}
|
||||
|
||||
intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true)
|
||||
intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, "com.android.vending")
|
||||
intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, context.packageName)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.aurora.extensions.isNAndAbove
|
||||
import com.aurora.extensions.isOAndAbove
|
||||
import com.aurora.extensions.isSAndAbove
|
||||
import com.aurora.extensions.isTAndAbove
|
||||
import com.aurora.extensions.isUAndAbove
|
||||
import com.aurora.store.util.Log
|
||||
|
||||
|
||||
@@ -54,6 +55,9 @@ class SessionInstaller(context: Context) : SessionInstallerBase(context) {
|
||||
if (isTAndAbove()) {
|
||||
setPackageSource(PACKAGE_SOURCE_STORE)
|
||||
}
|
||||
if (isUAndAbove()) {
|
||||
setInstallerPackageName(context.packageName)
|
||||
}
|
||||
}
|
||||
|
||||
val sessionId = packageInstaller.createSession(sessionParams)
|
||||
|
||||
@@ -143,7 +143,18 @@ object PackageUtil {
|
||||
val flags: Int = PackageManager.GET_META_DATA
|
||||
var packageInfoList: List<PackageInfo> = packageManager.getInstalledPackages(flags)
|
||||
|
||||
val isFdroidFilterEnabled = Preferences.getBoolean(
|
||||
val isGoogleFilterEnabled = Preferences.getBoolean(
|
||||
context,
|
||||
Preferences.PREFERENCE_FILTER_GOOGLE
|
||||
)
|
||||
|
||||
val isAuroraOnlyUpdateEnabled = Preferences.getBoolean(
|
||||
context,
|
||||
Preferences.PREFERENCE_FILTER_AURORA_ONLY,
|
||||
false
|
||||
)
|
||||
|
||||
val isFDroidFilterEnabled = Preferences.getBoolean(
|
||||
context,
|
||||
Preferences.PREFERENCE_FILTER_FDROID
|
||||
)
|
||||
@@ -154,18 +165,54 @@ object PackageUtil {
|
||||
)
|
||||
|
||||
packageInfoList = packageInfoList.filter {
|
||||
it.packageName != null && it.applicationInfo != null
|
||||
it.packageName != null
|
||||
&& it.applicationInfo != null
|
||||
&& packageManager.getLaunchIntentForPackage(it.packageName) != null
|
||||
}
|
||||
|
||||
/*Filter google apps*/
|
||||
if (isGoogleFilterEnabled) {
|
||||
packageInfoList = packageInfoList
|
||||
.filter {
|
||||
!listOf(
|
||||
"com.chrome.beta",
|
||||
"com.chrome.canary",
|
||||
"com.chrome.dev",
|
||||
"com.android.chrome",
|
||||
"com.niksoftware.snapseed",
|
||||
"com.google.toontastic",
|
||||
).contains(it.packageName)
|
||||
}.filter {
|
||||
it.packageName?.contains("com.google") == false
|
||||
}
|
||||
}
|
||||
|
||||
/*Select only Aurora STore installed apps*/
|
||||
if (isAuroraOnlyUpdateEnabled) {
|
||||
packageInfoList = packageInfoList
|
||||
.filter {
|
||||
val packageInstaller = packageManager.getInstallerPackageName(it.packageName)
|
||||
listOf(
|
||||
"com.aurora.store",
|
||||
"com.aurora.store.nightly",
|
||||
"com.aurora.services"
|
||||
).contains(packageInstaller)
|
||||
}
|
||||
}
|
||||
|
||||
if (!isExtendedUpdateEnabled) {
|
||||
packageInfoList = packageInfoList.filter { it.applicationInfo.enabled }
|
||||
}
|
||||
|
||||
if (isFdroidFilterEnabled) {
|
||||
/*Filter F-Droid apps*/
|
||||
if (isFDroidFilterEnabled) {
|
||||
packageInfoList = packageInfoList
|
||||
.filter {
|
||||
val packageInstaller = packageManager.getInstallerPackageName(it.packageName)
|
||||
packageInstaller != "org.fdroid.fdroid.privileged"
|
||||
!listOf(
|
||||
"org.fdroid.fdroid",
|
||||
"org.fdroid.fdroid.privileged"
|
||||
).contains(packageInstaller)
|
||||
}.filter {
|
||||
!CertUtil.isFDroidApp(context, it.packageName)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ object Preferences {
|
||||
const val PREFERENCE_FILTER_GOOGLE = "PREFERENCE_FILTER_GOOGLE"
|
||||
const val PREFERENCE_FILTER_FDROID = "PREFERENCE_FILTER_FDROID"
|
||||
const val PREFERENCE_FILTER_SEARCH = "PREFERENCE_FILTER_SEARCH"
|
||||
const val PREFERENCE_FILTER_AURORA_ONLY = "PREFERENCE_FILTER_AURORA_ONLY"
|
||||
|
||||
const val PREFERENCE_AUTO_INSTALL = "PREFERENCE_AUTO_INSTALL"
|
||||
const val PREFERENCE_AUTO_DELETE = "PREFERENCE_AUTO_DELETE"
|
||||
@@ -107,8 +108,8 @@ object Preferences {
|
||||
return getPrefs(context).getLong(key, 0L)
|
||||
}
|
||||
|
||||
fun getBoolean(context: Context, key: String): Boolean {
|
||||
return getPrefs(context).getBoolean(key, false)
|
||||
fun getBoolean(context: Context, key: String, default: Boolean = false): Boolean {
|
||||
return getPrefs(context).getBoolean(key, default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ class InstalledAppsFragment : BaseFragment() {
|
||||
)
|
||||
|
||||
VM = ViewModelProvider(requireActivity())[InstalledViewModel::class.java]
|
||||
VM.observe()
|
||||
|
||||
return B.root
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_DIRECTORY
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_WIFI_ONLY
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_AURORA_ONLY
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
|
||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_SEARCH
|
||||
@@ -151,6 +152,7 @@ class OnboardingFragment : Fragment(R.layout.fragment_onboarding) {
|
||||
|
||||
private fun loadDefaultPreferences() {
|
||||
/*Filters*/
|
||||
save(PREFERENCE_FILTER_AURORA_ONLY, false)
|
||||
save(PREFERENCE_FILTER_FDROID, true)
|
||||
save(PREFERENCE_FILTER_GOOGLE, false)
|
||||
save(PREFERENCE_FILTER_SEARCH, true)
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.aurora.store.data.network.HttpClient
|
||||
import com.aurora.store.data.providers.AuthProvider
|
||||
import com.aurora.store.data.providers.BlacklistProvider
|
||||
import com.aurora.store.util.PackageUtil
|
||||
import com.aurora.store.util.Preferences
|
||||
import com.aurora.store.viewmodel.BaseAndroidViewModel
|
||||
|
||||
abstract class BaseAppsViewModel(application: Application) : BaseAndroidViewModel(application) {
|
||||
@@ -50,41 +49,18 @@ abstract class BaseAppsViewModel(application: Application) : BaseAndroidViewMode
|
||||
|
||||
fun getFilteredApps(): List<App> {
|
||||
val blackList = blacklistProvider.getBlackList()
|
||||
val gapps = getGApps()
|
||||
|
||||
val isGoogleFilterEnabled = Preferences.getBoolean(
|
||||
getApplication(),
|
||||
Preferences.PREFERENCE_FILTER_GOOGLE
|
||||
)
|
||||
|
||||
packageInfoMap.clear()
|
||||
packageInfoMap = PackageUtil.getPackageInfoMap(getApplication())
|
||||
|
||||
packageInfoMap.keys.let { packages ->
|
||||
/*Filter black list*/
|
||||
var filtersPackages = packages
|
||||
val filtersPackages = packages
|
||||
.filter { !blackList.contains(it) }
|
||||
|
||||
/*Filter google apps*/
|
||||
if (isGoogleFilterEnabled)
|
||||
filtersPackages = filtersPackages
|
||||
.filter { !it.startsWith("com.google") }
|
||||
.filter { !gapps.contains(it) }
|
||||
|
||||
return appDetailsHelper
|
||||
.getAppByPackageName(filtersPackages)
|
||||
.filter { it.displayName.isNotEmpty() }
|
||||
}
|
||||
}
|
||||
|
||||
open fun getGApps(): Set<String> {
|
||||
val gapps: MutableSet<String> = HashSet()
|
||||
gapps.add("com.chrome.beta")
|
||||
gapps.add("com.chrome.canary")
|
||||
gapps.add("com.chrome.dev")
|
||||
gapps.add("com.android.chrome")
|
||||
gapps.add("com.niksoftware.snapseed")
|
||||
gapps.add("com.google.toontastic")
|
||||
return gapps
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ class InstalledViewModel(application: Application) : BaseAppsViewModel(applicati
|
||||
EventBus.getDefault().register(this)
|
||||
|
||||
requestState = RequestState.Init
|
||||
observe()
|
||||
}
|
||||
|
||||
override fun observe() {
|
||||
|
||||
Reference in New Issue
Block a user