Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 85feed4e authored by dev-12's avatar dev-12
Browse files

refactor: use long instead of int for package version.

upstream packages and AOSP everyone is switching to long due the limits of int.
parent 5603bd12
Loading
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -24,26 +24,26 @@ import android.content.pm.PackageManager
import androidx.core.content.pm.PackageInfoCompat

class NativeGsfVersionProvider(context: Context) {
    private var gsfVersionCode = 0
    private var gsfVersionCode = 0L
    private val packageManager = context.packageManager

    init {
        try {
            val gsfPkgInfo = packageManager.getPackageInfo(GOOGLE_SERVICES_PACKAGE_ID, 0)
            gsfVersionCode = PackageInfoCompat.getLongVersionCode(gsfPkgInfo).toInt()
            gsfVersionCode = PackageInfoCompat.getLongVersionCode(gsfPkgInfo)
        } catch (e: PackageManager.NameNotFoundException) {
            // com.google.android.gms not found
        }
    }

    fun getGsfVersionCode(defaultIfNotFound: Boolean): Int {
    fun getGsfVersionCode(defaultIfNotFound: Boolean): Long {
        return if (defaultIfNotFound && gsfVersionCode < GOOGLE_SERVICES_VERSION_CODE)
            GOOGLE_SERVICES_VERSION_CODE
        else
            gsfVersionCode
    }

    fun getVendingVersionCode(): Int {
    fun getVendingVersionCode(): Long {
        return GOOGLE_VENDING_VERSION_CODE
    }

@@ -53,8 +53,8 @@ class NativeGsfVersionProvider(context: Context) {

    companion object {
        private const val GOOGLE_SERVICES_PACKAGE_ID = "com.google.android.gms"
        private const val GOOGLE_SERVICES_VERSION_CODE = 203019037
        private const val GOOGLE_VENDING_VERSION_CODE = 82151710
        private const val GOOGLE_SERVICES_VERSION_CODE = 203019037L
        private const val GOOGLE_VENDING_VERSION_CODE = 82151710L
        private const val GOOGLE_VENDING_VERSION_STRING = "21.5.17-21 [0] [PR] 326734551"
    }
}