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

Merge branch 'implement-arch_apk_install' into 'master'

Implement arch apk install

See merge request !3
parents 62dc0ece 07c6c9ef
Pipeline #12474 passed with stage
in 3 minutes and 23 seconds
......@@ -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 {
......
......@@ -602,7 +602,10 @@ class ApplicationActivity :
override fun onDestroy() {
super.onDestroy()
application.decrementUses()
applicationManagerServiceConnection.unbindService(this)
if (::application.isInitialized) {
application.removeListener(this)
application.decrementUses()
applicationManagerServiceConnection.unbindService(this)
}
}
}
......@@ -120,11 +120,16 @@ class Application(val packageName: String, private val applicationManager: Appli
fun download(context: Context) {
val error = assertFullData(context)
if (error == null) {
downloader = Downloader(info, fullData!!, this)
stateManager.notifyDownloading(downloader!!)
downloader!!.download(context)
synchronized(blocker) {
blocker.wait()
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)
......@@ -132,6 +137,19 @@ class Application(val packageName: String, private val applicationManager: Appli
}
}
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)
......
......@@ -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
......@@ -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)
}
}
......
......@@ -32,7 +32,8 @@ enum class Error(val description: Int) {
INSTALL_FAILED(R.string.error_install_failed),
INVALID_PACKAGE_NAME(R.string.error_invalid_package_name),
PACKAGE_ALREADY_EXISTS(R.string.error_package_already_exists),
NO_ERROR(R.string.error_no_error);
NO_ERROR(R.string.error_no_error),
APK_INCOMPATIBLE(R.string.error_apk_incompatible);
companion object {
fun findError(e: Exception): Error {
......
......@@ -133,4 +133,5 @@
<string name="error_invalid_package_name">Unable to submit request. Please enter a valid package name.</string>
<string name="error_package_already_exists">This app is already available or has been requested.</string>
<string name="error_no_error">No error.</string>
<string name="error_apk_incompatible">This app is incompatible with your device.</string>
</resources>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment