mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
add miui auto legacy mode
This commit is contained in:
parent
92cdb882f7
commit
c433df0f29
1 changed files with 36 additions and 0 deletions
|
@ -22,6 +22,10 @@ import okio.BufferedSink
|
||||||
import okio.buffer
|
import okio.buffer
|
||||||
import okio.sink
|
import okio.sink
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import android.text.TextUtils
|
||||||
|
import java.io.BufferedReader
|
||||||
|
import java.io.IOException
|
||||||
|
import java.io.InputStreamReader
|
||||||
|
|
||||||
|
|
||||||
class InAppUpdater {
|
class InAppUpdater {
|
||||||
|
@ -294,6 +298,12 @@ class InAppUpdater {
|
||||||
setPositiveButton(R.string.update) { _, _ ->
|
setPositiveButton(R.string.update) { _, _ ->
|
||||||
showToast(context, R.string.download_started, Toast.LENGTH_LONG)
|
showToast(context, R.string.download_started, Toast.LENGTH_LONG)
|
||||||
|
|
||||||
|
// Check if the setting hasn't been changed
|
||||||
|
if (settingsManager.getInt(getString(R.string.apk_installer_key), -1) == -1) {
|
||||||
|
if (isMiUi()) // Set to legacy if using miui
|
||||||
|
settingsManager.edit().putInt(getString(R.string.apk_installer_key), 1).apply()
|
||||||
|
}
|
||||||
|
|
||||||
val currentInstaller =
|
val currentInstaller =
|
||||||
settingsManager.getInt(
|
settingsManager.getInt(
|
||||||
getString(R.string.apk_installer_key),
|
getString(R.string.apk_installer_key),
|
||||||
|
@ -348,4 +358,30 @@ class InAppUpdater {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isMiUi(): Boolean {
|
||||||
|
return !TextUtils.isEmpty(getSystemProperty("ro.miui.ui.version.name"))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSystemProperty(propName: String): String? {
|
||||||
|
var line: String? = null
|
||||||
|
var input: BufferedReader? = null
|
||||||
|
try {
|
||||||
|
val p = Runtime.getRuntime().exec("getprop $propName")
|
||||||
|
input = BufferedReader(InputStreamReader(p.inputStream), 1024)
|
||||||
|
line = input.readLine()
|
||||||
|
input.close()
|
||||||
|
} catch (ex: IOException) {
|
||||||
|
return null
|
||||||
|
} finally {
|
||||||
|
if (input != null) {
|
||||||
|
try {
|
||||||
|
input.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return line
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue