Revert "Revert "PackageInfo: Filter out more core AOSP system apps""

This reverts commit 769511ae66.

* It was assumed that the logic was incorrect but it was fine
This commit is contained in:
Aayush Gupta
2025-02-10 11:41:28 +07:00
parent 66e6bdb38f
commit 2014073c91

View File

@@ -1,14 +1,23 @@
package com.aurora.extensions
import android.content.pm.ApplicationInfo
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Build
import android.os.Process
import androidx.core.content.pm.PackageInfoCompat
fun PackageInfo.isValidApp(packageManager: PackageManager): Boolean {
if (this.applicationInfo == null || this.packageName.isEmpty()) return false
// Most core AOSP system apps use their package name as label
if (this.applicationInfo!!.loadLabel(packageManager).startsWith(this.packageName)) return false
// Filter out core AOSP system apps
if (this.applicationInfo!!.flags and ApplicationInfo.FLAG_SYSTEM != 0) {
if (this.packageName.endsWith(".resources")) return false
if (this.applicationInfo!!.loadLabel(packageManager).startsWith(this.packageName)) return false
if (this.versionName?.endsWith("system image") == true) return false
if (this.versionName?.endsWith("-initial") == true) return false
if (this.versionName == Build.VERSION.RELEASE && PackageInfoCompat.getLongVersionCode(this) == Build.VERSION.SDK_INT.toLong()) return false
}
return when {
isQAndAbove -> {