exception test 4

This commit is contained in:
X1nto 2020-07-01 19:10:34 +04:00
parent a9da78ff71
commit 6595effa07
5 changed files with 34 additions and 37 deletions

View File

@ -12,6 +12,8 @@
# public *;
#}
-keep class com.vanced.manager.core.App
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

View File

@ -4,7 +4,6 @@ import android.app.Service
import android.content.Context
import android.content.Intent
import android.os.IBinder
import android.widget.Toast
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import com.dezlum.codelabs.getjson.GetJson
import com.downloader.Error
@ -18,6 +17,7 @@ import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.NotificationHelper
import com.vanced.manager.utils.NotificationHelper.cancelNotif
import com.vanced.manager.utils.NotificationHelper.createBasicNotif
import java.util.concurrent.ExecutionException
class MicrogDownloadService: Service() {
@ -31,14 +31,14 @@ class MicrogDownloadService: Service() {
val prefs = getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val apkUrl =
if(GetJson().isConnected(this))
try {
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json").get("url").asString
} catch (e: Exception) {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/microg.json").get("url").asString
}
else
try {
GetJson().AsJSONObject("https://vanced.app/api/v1/microg.json").get("url").asString
} catch (e: ExecutionException) {
""
} catch (e: InterruptedException) {
""
}
val channel = 420
PRDownloader.download(apkUrl, filesDir.path, "microg.apk")

View File

@ -22,17 +22,13 @@ import com.vanced.manager.utils.InternetTools.getFileNameFromUrl
import com.vanced.manager.utils.NotificationHelper.cancelNotif
import com.vanced.manager.utils.NotificationHelper.createBasicNotif
import com.vanced.manager.utils.NotificationHelper.displayDownloadNotif
import java.lang.IllegalStateException
import java.util.concurrent.ExecutionException
class VancedDownloadService: Service() {
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
try {
downloadSplits()
} catch (e: Exception) {
Toast.makeText(this, "Unable to download Vanced", Toast.LENGTH_SHORT).show()
}
downloadSplits()
stopSelf()
return START_NOT_STICKY
}
@ -42,14 +38,14 @@ class VancedDownloadService: Service() {
) {
val baseUrl = PreferenceManager.getDefaultSharedPreferences(this).getString("install_url", baseUrl)
val vancedVer =
if(GetJson().isConnected(this))
try {
GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json").get("vanced").asString
} catch (e: Exception) {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/vanced.json").get("vanced").asString
}
else
try {
GetJson().AsJSONObject("https://vanced.app/api/v1/vanced.json").get("url").asString
} catch (e: ExecutionException) {
""
} catch (e: InterruptedException) {
""
}
val prefs = getSharedPreferences("installPrefs", Context.MODE_PRIVATE)
val variant = PreferenceManager.getDefaultSharedPreferences(this).getString("vanced_variant", "nonroot")
val lang = prefs?.getString("lang", "en")

View File

@ -25,30 +25,29 @@ object InternetTools {
fun displayJsonString(json: String, obj: String, context: Context): String {
val installUrl = PreferenceManager.getDefaultSharedPreferences(context).getString("install_url", baseUrl)
return if (GetJson().isConnected(context)) {
return try {
GetJson().AsJSONObject("$installUrl/$json").get(obj).asString
} catch (e: Exception) {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/$json").get(obj).asString
}
} else {
return try {
GetJson().AsJSONObject("$installUrl/$json").get(obj).asString
} catch (e: ExecutionException) {
context.getString(R.string.unavailable)
} catch (e: InterruptedException) {
context.getString(R.string.unavailable)
}
}
fun displayJsonInt(json: String, obj: String, context: Context): Int {
val installUrl = PreferenceManager.getDefaultSharedPreferences(context).getString("install_url", baseUrl)
return if (GetJson().isConnected(context)) {
return try {
GetJson().AsJSONObject("$installUrl/$json").get(obj).asInt
} catch (e: Exception) {
GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/$json").get(obj).asInt
}
} else 0
return try {
GetJson().AsJSONObject("$installUrl/$json").get(obj).asInt
} catch (e: ExecutionException) {
0
} catch (e: InterruptedException) {
0
}
}
fun isUpdateAvailable(): Boolean {
val checkUrl = GetJson().AsJSONObject("https://vanced.app/api/v1/manager.json")
val checkUrl = GetJson().AsJSONObject("https://x1nto.github.io/VancedFiles/manager.json")
val remoteVersion = checkUrl.get("versionCode").asInt
return remoteVersion > BuildConfig.VERSION_CODE

View File

@ -11,7 +11,7 @@ object MiuiHelper {
fun isMiuiOptimisationsDisabled(): Boolean {
return if (isMiui())
getSystemProps("persist.sys.miui_optimization") == "0"
getSystemProps("persist.sys.miui_optimization").equals("0")
else
true
}