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

Commit 9499074d authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Merge branch 'implement-arch_apk_install' into 'master'

Implement arch apk install

See merge request e/apps/apps!3
parents 62dc0ece 07c6c9ef
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -10,8 +10,8 @@ android {
        applicationId "foundation.e.apps"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 3
        versionName "1.1.0"
        versionCode 4
        versionName "1.1.1"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
+5 −2
Original line number Diff line number Diff line
@@ -602,7 +602,10 @@ class ApplicationActivity :

    override fun onDestroy() {
        super.onDestroy()
        if (::application.isInitialized) {
            application.removeListener(this)
            application.decrementUses()
            applicationManagerServiceConnection.unbindService(this)
        }
    }
}
+23 −5
Original line number Diff line number Diff line
@@ -120,18 +120,36 @@ class Application(val packageName: String, private val applicationManager: Appli
    fun download(context: Context) {
        val error = assertFullData(context)
        if (error == null) {
            if (isAPKArchCompatible()) {
                downloader = Downloader(info, fullData!!, this)
                stateManager.notifyDownloading(downloader!!)
                downloader!!.download(context)
                synchronized(blocker) {
                    blocker.wait()
                }
            } else {
                stateManager.notifyError(Error.APK_INCOMPATIBLE)
                onDownloadComplete(context, DownloadManager.STATUS_FAILED)
            }
        } else {
            stateManager.notifyError(error)
            onDownloadComplete(context, DownloadManager.STATUS_FAILED)
        }
    }

    private fun isAPKArchCompatible(): Boolean {
        val apkArchitecture: String? = fullData!!.getLastVersion()?.apkArchitecture
        return if (apkArchitecture != null) {
            if (apkArchitecture == "universal") {
                true
            } else {
                android.os.Build.SUPPORTED_ABIS.toList().contains(apkArchitecture)
            }
        } else {
            false
        }
    }

    override fun onDownloadComplete(context: Context, status: Int) {
        if (status == DownloadManager.STATUS_SUCCESSFUL) {
            install(context)
+2 −1
Original line number Diff line number Diff line
@@ -31,4 +31,5 @@ class Version(val downloadFlag: String?,
              val updateName: String,
              val privacyRating: Int?,
              val exodusPermissions: ArrayList<String>?,
              val exodusTrackers: ArrayList<String>?)
 No newline at end of file
              val exodusTrackers: ArrayList<String>?,
              val apkArchitecture: String)
 No newline at end of file
+2 −1
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ constructor(
                    name,
                    result["exodus_score"] as Int?,
                    getPermissions(result["exodus_perms"] as ArrayList<String>?),
                    getTrackers(result["exodus_trackers"] as ArrayList<LinkedHashMap<String, String>>?))
                    getTrackers(result["exodus_trackers"] as ArrayList<LinkedHashMap<String, String>>?),
                    result["architecture"] as String)
        }
    }

Loading