manager: Fix template escape
This commit is contained in:
@@ -143,7 +143,7 @@ fun installModule(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Parcelize
|
@Parcelize
|
||||||
sealed class LkmSelection: Parcelable {
|
sealed class LkmSelection : Parcelable {
|
||||||
data class LkmUri(val uri: Uri) : LkmSelection()
|
data class LkmUri(val uri: Uri) : LkmSelection()
|
||||||
data class KmiString(val value: String) : LkmSelection()
|
data class KmiString(val value: String) : LkmSelection()
|
||||||
data object KmiNone : LkmSelection()
|
data object KmiNone : LkmSelection()
|
||||||
@@ -340,7 +340,9 @@ fun getAppProfileTemplate(id: String): String {
|
|||||||
|
|
||||||
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
fun setAppProfileTemplate(id: String, template: String): Boolean {
|
||||||
val shell = getRootShell()
|
val shell = getRootShell()
|
||||||
return shell.newJob().add("${getKsuDaemonPath()} profile set-template '${id}' '${template}'")
|
val escapedTemplate = template.replace("\"", "\\\"")
|
||||||
|
val cmd = """${getKsuDaemonPath()} profile set-template "$id" "$escapedTemplate'""""
|
||||||
|
return shell.newJob().add(cmd)
|
||||||
.to(ArrayList(), null).exec().isSuccess
|
.to(ArrayList(), null).exec().isSuccess
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import org.json.JSONArray
|
|||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import java.text.Collator
|
import java.text.Collator
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author weishu
|
* @author weishu
|
||||||
@@ -136,7 +138,13 @@ class TemplateViewModel : ViewModel() {
|
|||||||
|
|
||||||
private fun fetchRemoteTemplates() {
|
private fun fetchRemoteTemplates() {
|
||||||
runCatching {
|
runCatching {
|
||||||
OkHttpClient().newCall(
|
val client: OkHttpClient = OkHttpClient.Builder()
|
||||||
|
.connectTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.writeTimeout(5, TimeUnit.SECONDS)
|
||||||
|
.readTimeout(10, TimeUnit.SECONDS)
|
||||||
|
.build()
|
||||||
|
|
||||||
|
client.newCall(
|
||||||
Request.Builder().url(TEMPLATE_INDEX_URL).build()
|
Request.Builder().url(TEMPLATE_INDEX_URL).build()
|
||||||
).execute().use { response ->
|
).execute().use { response ->
|
||||||
if (!response.isSuccessful) {
|
if (!response.isSuccessful) {
|
||||||
@@ -146,7 +154,8 @@ private fun fetchRemoteTemplates() {
|
|||||||
Log.i(TAG, "fetchRemoteTemplates: $remoteTemplateIds")
|
Log.i(TAG, "fetchRemoteTemplates: $remoteTemplateIds")
|
||||||
0.until(remoteTemplateIds.length()).forEach { i ->
|
0.until(remoteTemplateIds.length()).forEach { i ->
|
||||||
val id = remoteTemplateIds.getString(i)
|
val id = remoteTemplateIds.getString(i)
|
||||||
val templateJson = OkHttpClient().newCall(
|
Log.i(TAG, "fetch template: $id")
|
||||||
|
val templateJson = client.newCall(
|
||||||
Request.Builder().url(TEMPLATE_URL.format(id)).build()
|
Request.Builder().url(TEMPLATE_URL.format(id)).build()
|
||||||
).runCatching {
|
).runCatching {
|
||||||
execute().use { response ->
|
execute().use { response ->
|
||||||
|
|||||||
Reference in New Issue
Block a user