Skip to content

Commit

Permalink
Update getting package info
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Aug 12, 2024
1 parent 8554692 commit dc7b419
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.pm.PackageInfo
import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.net.Uri
import android.util.Log
import androidx.compose.runtime.Stable
Expand Down
9 changes: 3 additions & 6 deletions app/src/main/java/app/revanced/manager/util/PM.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.content.pm.PackageInstaller
import android.content.pm.PackageManager
import android.content.pm.PackageManager.MATCH_UNINSTALLED_PACKAGES
import android.content.pm.PackageManager.NameNotFoundException
import androidx.core.content.pm.PackageInfoCompat
import android.os.Build
import android.os.Parcelable
import androidx.compose.runtime.Immutable
Expand Down Expand Up @@ -115,12 +116,8 @@ class PM(

fun PackageInfo.label() = this.applicationInfo.loadLabel(app.packageManager).toString()

fun getVersionCode(packageInfo: PackageInfo): Int {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
packageInfo.longVersionCode.toInt()
} else {
packageInfo.versionCode
}
fun getVersionCode(packageInfo: PackageInfo): Long {
return PackageInfoCompat.getLongVersionCode(packageInfo)
}

suspend fun installApp(apks: List<File>) = withContext(Dispatchers.IO) {
Expand Down

0 comments on commit dc7b419

Please sign in to comment.