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

Commit c424246b authored by Romain Hunault's avatar Romain Hunault 💻
Browse files

Detect Release Type from build Tags

parent 56126beb
Loading
Loading
Loading
Loading
Loading
+1 −12
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@
package foundation.e.apps.api

import android.content.Context
import android.os.Build
import android.util.Log
import com.google.gson.Gson
import com.google.gson.JsonParser
import foundation.e.apps.application.model.Application
@@ -42,16 +40,8 @@ class GitlabDataRequest {
        val releaseList: List<ReleaseData> = Gson().fromJson(element.toString(),
                Array<ReleaseData>::class.java).toList()
        urlConnection.disconnect()
        var buildTag = Build.TAGS.split("-").toTypedArray();


        Log.e("build tags", Build.TAGS);
        Log.e("build type", Build.TYPE);
        Log.e("build display", Build.DISPLAY);
        Log.e("build fingerprint", Build.FINGERPRINT);
        Log.e("build version release", Build.VERSION.RELEASE);

        val osReleaseType = buildTag[0];
        val osReleaseType = OsInfo().getOSReleaseType()
        var releaseUrl = ""

        releaseList[0].assets.links.forEach {
@@ -60,7 +50,6 @@ class GitlabDataRequest {
            }
        }


        callback.invoke(null, GitlabDataResult(SystemAppDataSource.createDataSource(Constants.MICROG_ID.toString(),
                releaseList[0].tag_name, Constants.MICROG_ICON_URI, releaseUrl)))

+22 −0
Original line number Diff line number Diff line
package foundation.e.apps.utils

import android.os.Build
import android.util.Log

class OsInfo() {

    fun getOSReleaseType(): String {
        val buildTags = Build.TAGS.split(",").toTypedArray()
        var osReleaseType = ""
        buildTags.forEach {
            if (it.contains("release-")) {
                osReleaseType = it.substringAfter("release-")
            }
        }

        Log.i("foundation.e.apps", "Release Type: $osReleaseType")

        return osReleaseType
    }

}
 No newline at end of file