BlacklistViewModel: Filter packages which are not apps

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
Aayush Gupta
2024-06-17 18:54:46 +05:30
parent 0fdef34baf
commit 05d9f279c9
2 changed files with 19 additions and 5 deletions

View File

@@ -0,0 +1,17 @@
package com.aurora.extensions
import android.content.pm.PackageInfo
import android.os.Process
fun PackageInfo.isApp(): Boolean {
if (this.applicationInfo == null) return false
return when {
isQAndAbove() -> {
Process.isApplicationUid(this.applicationInfo.uid) &&
!this.applicationInfo.isResourceOverlay && !this.isApex
}
isNAndAbove() -> Process.isApplicationUid(this.applicationInfo.uid)
else -> this.packageName != null && this.versionName != null
}
}