Merge pull request #169

* 修复 隐藏网速单位 & 随便精简了下代码

* Update SettingsActivity.kt
This commit is contained in:
YuKongA
2022-05-25 22:04:41 +08:00
committed by GitHub
parent cef006ced2
commit 90466bb3fb
70 changed files with 435 additions and 531 deletions

View File

@@ -1,21 +1,23 @@
package com.lt2333.simplicitytools.util
import android.annotation.SuppressLint
import android.content.Context
object SystemProperties {
@SuppressLint("PrivateApi")
operator fun get(context: Context, key: String?): String? {
var ret = ""
try {
val cl = context.classLoader
val SystemProperties = cl.loadClass("android.os.SystemProperties")
val systemProperties = cl.loadClass("android.os.SystemProperties")
//参数类型
val paramTypes: Array<Class<*>?> = arrayOfNulls(1)
paramTypes[0] = String::class.java
val get = SystemProperties.getMethod("get", *paramTypes)
val get = systemProperties.getMethod("get", *paramTypes)
//参数
val params = arrayOfNulls<Any>(1)
params[0] = key
ret = get.invoke(SystemProperties, *params) as String
ret = get.invoke(systemProperties, *params) as String
} catch (iAE: IllegalArgumentException) {
throw iAE
} catch (e: Exception) {
@@ -23,4 +25,5 @@ object SystemProperties {
}
return ret
}
}