mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 21:17:37 +00:00
More MagidkDB fixes
This commit is contained in:
parent
3123cc1059
commit
cec017b7bf
@ -75,7 +75,11 @@ open class Insert : MagiskQueryBuilder {
|
|||||||
|
|
||||||
private val keys get() = _values.keys.joinToString(",")
|
private val keys get() = _values.keys.joinToString(",")
|
||||||
private val values get() = _values.values.joinToString(",") {
|
private val values get() = _values.values.joinToString(",") {
|
||||||
if (it is String) "\"$it\"" else it.toString()
|
when (it) {
|
||||||
|
is Boolean -> if (it) "1" else "0"
|
||||||
|
is Number -> it.toString()
|
||||||
|
else -> "\"$it\""
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private var _values: Map<String, Any> = mapOf()
|
private var _values: Map<String, Any> = mapOf()
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ fun Map<String, String>.toLog(): MagiskLog {
|
|||||||
|
|
||||||
fun Long.toDate() = Date(this)
|
fun Long.toDate() = Date(this)
|
||||||
|
|
||||||
|
|
||||||
fun MagiskLog.toMap() = mapOf(
|
fun MagiskLog.toMap() = mapOf(
|
||||||
"from_uid" to fromUid,
|
"from_uid" to fromUid,
|
||||||
"to_uid" to toUid,
|
"to_uid" to toUid,
|
||||||
@ -47,8 +46,8 @@ fun MagiskLog.toMap() = mapOf(
|
|||||||
"app_name" to appName,
|
"app_name" to appName,
|
||||||
"command" to command,
|
"command" to command,
|
||||||
"action" to action,
|
"action" to action,
|
||||||
"time" to date
|
"time" to date.time
|
||||||
).mapValues { it.toString() }
|
)
|
||||||
|
|
||||||
fun MagiskPolicy.toLog(
|
fun MagiskPolicy.toLog(
|
||||||
toUid: Int,
|
toUid: Int,
|
||||||
|
@ -24,42 +24,14 @@ data class MagiskPolicy(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Throws(PackageManager.NameNotFoundException::class)
|
|
||||||
fun ContentValues.toPolicy(pm: PackageManager): MagiskPolicy {
|
|
||||||
val uid = getAsInteger("uid")
|
|
||||||
val packageName = getAsString("package_name")
|
|
||||||
val info = pm.getApplicationInfo(packageName, 0)
|
|
||||||
if (info.uid != uid)
|
|
||||||
throw PackageManager.NameNotFoundException()
|
|
||||||
return MagiskPolicy(
|
|
||||||
uid = uid,
|
|
||||||
packageName = packageName,
|
|
||||||
policy = getAsInteger("policy"),
|
|
||||||
until = getAsInteger("until").toLong(),
|
|
||||||
logging = getAsInteger("logging") != 0,
|
|
||||||
notification = getAsInteger("notification") != 0,
|
|
||||||
applicationInfo = info,
|
|
||||||
appName = info.loadLabel(pm).toString()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
fun MagiskPolicy.toContentValues() = ContentValues().apply {
|
|
||||||
put("uid", uid)
|
|
||||||
put("uid", uid)
|
|
||||||
put("package_name", packageName)
|
|
||||||
put("policy", policy)
|
|
||||||
put("until", until)
|
|
||||||
put("logging", if (logging) 1 else 0)
|
|
||||||
put("notification", if (notification) 1 else 0)
|
|
||||||
}*/
|
|
||||||
|
|
||||||
fun MagiskPolicy.toMap() = mapOf(
|
fun MagiskPolicy.toMap() = mapOf(
|
||||||
"uid" to uid,
|
"uid" to uid,
|
||||||
"package_name" to packageName,
|
"package_name" to packageName,
|
||||||
"policy" to policy,
|
"policy" to policy,
|
||||||
"until" to until,
|
"until" to until,
|
||||||
"logging" to if (logging) 1 else 0,
|
"logging" to logging,
|
||||||
"notification" to if (notification) 1 else 0
|
"notification" to notification
|
||||||
).mapValues { it.value.toString() }
|
)
|
||||||
|
|
||||||
@Throws(PackageManager.NameNotFoundException::class)
|
@Throws(PackageManager.NameNotFoundException::class)
|
||||||
fun Map<String, String>.toPolicy(pm: PackageManager): MagiskPolicy {
|
fun Map<String, String>.toPolicy(pm: PackageManager): MagiskPolicy {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user