破烂乌龟 (#184)

* 同步blockmiui上游
显示编译时间
优化命名,简化方法等

* 同步blockmiui上游
显示编译时间
优化命名,简化方法等
This commit is contained in:
xiao_wine
2022-08-11 01:08:21 +08:00
committed by GitHub
parent bc04edade1
commit efa375ba0c
18 changed files with 598 additions and 1487 deletions

View File

@@ -14,6 +14,7 @@ android {
targetSdk = 33 targetSdk = 33
versionCode = 68 versionCode = 68
versionName = "1.6.7" versionName = "1.6.7"
buildConfigField("String", "BUILD_TIME", "\"${System.currentTimeMillis()}\"")
} }
buildTypes { buildTypes {

View File

@@ -16,6 +16,10 @@
android:launchMode="singleTop"> android:launchMode="singleTop">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<action android:name="miui.cn.fkj233.xposed.statusbarlyric.SettingsFragment"/>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" /> <category android:name="de.robv.android.xposed.category.MODULE_SETTINGS" />
</intent-filter> </intent-filter>
</activity> </activity>

View File

@@ -15,7 +15,7 @@ object Updater : AppRegister() {
hasEnable("remove_ota_validate") { hasEnable("remove_ota_validate") {
Array(26) { "com.android.updater.common.utils.${'a' + it}" } Array(26) { "com.android.updater.common.utils.${'a' + it}" }
.mapNotNull { loadClassOrNull(it) } .mapNotNull { loadClassOrNull(it) }
.firstOrNull() { it.declaredFields.size >= 9 && it.declaredMethods.size > 60 } .firstOrNull { it.declaredFields.size >= 9 && it.declaredMethods.size > 60 }
?.findMethod { name == "T" && returnType == Boolean::class.java } ?.findMethod { name == "T" && returnType == Boolean::class.java }
?.hookReturnConstant(false) ?.hookReturnConstant(false)
} }

View File

@@ -20,6 +20,7 @@ import java.security.cert.Certificate;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import de.robv.android.xposed.IXposedHookLoadPackage; import de.robv.android.xposed.IXposedHookLoadPackage;
@@ -133,7 +134,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I
if(prefs.getBoolean("UsePreSig", false)) { if(prefs.getBoolean("UsePreSig", false)) {
PackageManager PM = AndroidAppHelper.currentApplication().getPackageManager(); PackageManager PM = AndroidAppHelper.currentApplication().getPackageManager();
if(PM == null){ if(PM == null){
XposedBridge.log("E: " + BuildConfig.APPLICATION_ID + " Cannot get the Package Manager... Are you using MiUI?"); XposedBridge.log("E: ${}" + BuildConfig.APPLICATION_ID + " Cannot get the Package Manager... Are you using MiUI?");
}else { }else {
PackageInfo pI = PM.getPackageArchiveInfo((String) methodHookParam.args[0], 0); PackageInfo pI = PM.getPackageArchiveInfo((String) methodHookParam.args[0], 0);
PackageInfo InstpI = PM.getPackageInfo(pI.packageName, PackageManager.GET_SIGNATURES); PackageInfo InstpI = PM.getPackageInfo(pI.packageName, PackageManager.GET_SIGNATURES);
@@ -147,11 +148,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I
lastSigs = (Signature[]) XposedHelpers.callStaticMethod(ASV, "convertToSignatures", (Object) lastCerts); lastSigs = (Signature[]) XposedHelpers.callStaticMethod(ASV, "convertToSignatures", (Object) lastCerts);
} }
} }
if (lastSigs != null) { signingDetailsArgs[0] = Objects.requireNonNullElseGet(lastSigs, () -> new Signature[]{new Signature(SIGNATURE)});
signingDetailsArgs[0] = lastSigs;
} else {
signingDetailsArgs[0] = new Signature[]{new Signature(SIGNATURE)};
}
Object newInstance = findConstructorExact.newInstance(signingDetailsArgs); Object newInstance = findConstructorExact.newInstance(signingDetailsArgs);
//修复 java.lang.ClassCastException: Cannot cast android.content.pm.PackageParser$SigningDetails to android.util.apk.ApkSignatureVerifier$SigningDetailsWithDigests //修复 java.lang.ClassCastException: Cannot cast android.content.pm.PackageParser$SigningDetails to android.util.apk.ApkSignatureVerifier$SigningDetailsWithDigests
@@ -159,7 +156,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I
if (signingDetailsWithDigests != null) { if (signingDetailsWithDigests != null) {
Constructor<?> signingDetailsWithDigestsConstructorExact = XposedHelpers.findConstructorExact(signingDetailsWithDigests, signingDetails, Map.class); Constructor<?> signingDetailsWithDigestsConstructorExact = XposedHelpers.findConstructorExact(signingDetailsWithDigests, signingDetails, Map.class);
signingDetailsWithDigestsConstructorExact.setAccessible(true); signingDetailsWithDigestsConstructorExact.setAccessible(true);
newInstance = signingDetailsWithDigestsConstructorExact.newInstance(new Object[]{newInstance, null}); newInstance = signingDetailsWithDigestsConstructorExact.newInstance(newInstance, null);
} }
Throwable cause = throwable.getCause(); Throwable cause = throwable.getCause();
@@ -211,7 +208,7 @@ public class CorePatch extends XposedHelper implements IXposedHookLoadPackage, I
Class<?> pPClass = findClass("com.android.server.pm.parsing.pkg.ParsedPackage", loadPackageParam.classLoader); Class<?> pPClass = findClass("com.android.server.pm.parsing.pkg.ParsedPackage", loadPackageParam.classLoader);
XposedHelpers.findAndHookMethod(pmClass, "doesSignatureMatchForPermissions", String.class, pPClass, int.class, new XC_MethodHook() { XposedHelpers.findAndHookMethod(pmClass, "doesSignatureMatchForPermissions", String.class, pPClass, int.class, new XC_MethodHook() {
@Override @Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable { protected void afterHookedMethod(MethodHookParam param) {
//If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate. //If we decide to crack this then at least make sure they are same apks, avoid another one that tries to impersonate.
if (param.getResult().equals(false)) { if (param.getResult().equals(false)) {
String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName"); String pPname = (String) XposedHelpers.callMethod(param.args[1], "getPackageName");

View File

@@ -9,38 +9,26 @@ import de.robv.android.xposed.XposedHelpers
object ShowNotificationImportance : HookRegister() { object ShowNotificationImportance : HookRegister() {
override fun init() { override fun init() {
findMethod("com.android.settings.notification.ChannelNotificationSettings"){ findMethod("com.android.settings.notification.ChannelNotificationSettings") {
name == "removeDefaultPrefs" name == "removeDefaultPrefs"
}.hookBefore { }.hookBefore {
if (!XSPUtils.getBoolean("show_notification_importance", false)) return@hookBefore if (!XSPUtils.getBoolean("show_notification_importance", false)) return@hookBefore
val importance = val importance = it.thisObject.invokeMethodAuto("findPreference", "importance") ?: return@hookBefore
it.thisObject.invokeMethodAuto("findPreference", "importance") ?: return@hookBefore
val mChannel = it.thisObject.getObject("mChannel") as NotificationChannel val mChannel = it.thisObject.getObject("mChannel") as NotificationChannel
val index = importance.invokeMethodAutoAs<Int>( val index = importance.invokeMethodAutoAs<Int>("findSpinnerIndexOfValue", mChannel.importance.toString())!!
"findSpinnerIndexOfValue",
mChannel.importance.toString()
) as Int
if (index < 0) return@hookBefore if (index < 0) return@hookBefore
importance.invokeMethodAuto("setValueIndex", index) importance.invokeMethodAuto("setValueIndex", index)
XposedHelpers.setAdditionalInstanceField( XposedHelpers.setAdditionalInstanceField(importance, "channelNotificationSettings", it.thisObject)
importance,
"channelNotificationSettings",
it.thisObject
)
it.result = null it.result = null
} }
findMethod("androidx.preference.Preference"){ findMethod("androidx.preference.Preference") {
name == "callChangeListener" && parameterTypes[0] == Any::class.java name == "callChangeListener" && parameterTypes[0] == Any::class.java
}.hookAfter { }.hookAfter {
val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField( val channelNotificationSettings = XposedHelpers.getAdditionalInstanceField(it.thisObject, "channelNotificationSettings") ?: return@hookAfter
it.thisObject,
"channelNotificationSettings"
) ?: return@hookAfter
val mChannel = channelNotificationSettings.getObject("mChannel") as NotificationChannel val mChannel = channelNotificationSettings.getObject("mChannel") as NotificationChannel
mChannel.invokeMethodAuto("setImportance", (it.args[0] as String).toInt()) mChannel.invokeMethodAuto("setImportance", (it.args[0] as String).toInt())
val mBackend = val mBackend = channelNotificationSettings.getObjectOrNull("mBackend") ?: return@hookAfter
channelNotificationSettings.getObjectOrNull("mBackend") ?: return@hookAfter
val mPkg = channelNotificationSettings.getObjectAs<String>("mPkg") val mPkg = channelNotificationSettings.getObjectAs<String>("mPkg")
val mUid = channelNotificationSettings.getObjectAs<Int>("mUid") val mUid = channelNotificationSettings.getObjectAs<Int>("mUid")
mBackend.invokeMethodAuto("updateChannel", mPkg, mUid, mChannel) mBackend.invokeMethodAuto("updateChannel", mPkg, mUid, mChannel)

View File

@@ -33,13 +33,13 @@ object ControlCenterWeather : HookRegister() {
!SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM") !SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM")
) { ) {
//获取原组件 //获取原组件
val big_time_ID = val bigTimeId =
context.resources.getIdentifier("big_time", "id", context.packageName) context.resources.getIdentifier("big_time", "id", context.packageName)
val big_time: TextView = viewGroup.findViewById(big_time_ID) val big_time: TextView = viewGroup.findViewById(bigTimeId)
val date_time_ID = val dateTimeId =
context.resources.getIdentifier("date_time", "id", context.packageName) context.resources.getIdentifier("date_time", "id", context.packageName)
val date_time: TextView = viewGroup.findViewById(date_time_ID) val dateTime: TextView = viewGroup.findViewById(dateTimeId)
//创建新布局 //创建新布局
val mConstraintLayoutLp = LinearLayout.LayoutParams( val mConstraintLayoutLp = LinearLayout.LayoutParams(
@@ -62,18 +62,18 @@ object ControlCenterWeather : HookRegister() {
//从原布局中删除组件 //从原布局中删除组件
(big_time.parent as ViewGroup).removeView(big_time) (big_time.parent as ViewGroup).removeView(big_time)
(date_time.parent as ViewGroup).removeView(date_time) (dateTime.parent as ViewGroup).removeView(dateTime)
//添加组件至新布局 //添加组件至新布局
mConstraintLayout!!.addView(big_time) mConstraintLayout!!.addView(big_time)
mConstraintLayout!!.addView(date_time) mConstraintLayout!!.addView(dateTime)
//组件属性 //组件属性
val date_time_LP = ConstraintLayout.LayoutParams( val dateTimeLp = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT ConstraintLayout.LayoutParams.WRAP_CONTENT
).also { ).also {
it.startToEnd = big_time_ID it.startToEnd = bigTimeId
it.bottomToBottom = 0 it.bottomToBottom = 0
it.marginStart = context.resources.getDimensionPixelSize( it.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier( context.resources.getIdentifier(
@@ -84,7 +84,7 @@ object ControlCenterWeather : HookRegister() {
) )
it.bottomMargin = dp2px(context, 5f) it.bottomMargin = dp2px(context, 5f)
} }
date_time.layoutParams = date_time_LP dateTime.layoutParams = dateTimeLp
//创建天气组件 //创建天气组件
@@ -100,12 +100,12 @@ object ControlCenterWeather : HookRegister() {
} }
mConstraintLayout!!.addView(mWeatherView) mConstraintLayout!!.addView(mWeatherView)
val mWeatherView_LP = ConstraintLayout.LayoutParams( val mweatherviewLp = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT ConstraintLayout.LayoutParams.WRAP_CONTENT
).also { ).also {
it.startToEnd = big_time_ID it.startToEnd = bigTimeId
it.bottomToTop = date_time_ID it.bottomToTop = dateTimeId
it.marginStart = context.resources.getDimensionPixelSize( it.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier( context.resources.getIdentifier(
"notification_panel_time_date_space", "notification_panel_time_date_space",
@@ -115,7 +115,7 @@ object ControlCenterWeather : HookRegister() {
) )
} }
(mWeatherView as WeatherView).layoutParams = mWeatherView_LP (mWeatherView as WeatherView).layoutParams = mweatherviewLp
} else { } else {
val layoutParam = val layoutParam =

View File

@@ -35,10 +35,8 @@ object DoubleLineNetworkSpeed : HookRegister() {
val none = InitFields.moduleRes.getString(R.string.none) val none = InitFields.moduleRes.getString(R.string.none)
if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) { if (XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) != none) {
upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none) upIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.firstOrNull().toString()
?.firstOrNull().toString() downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)?.lastOrNull().toString()
downIcon = XSPUtils.getString("status_bar_network_speed_dual_row_icon", none)
?.lastOrNull().toString()
} }
findConstructor("com.android.systemui.statusbar.views.NetworkSpeedView") { findConstructor("com.android.systemui.statusbar.views.NetworkSpeedView") {
@@ -62,16 +60,12 @@ object DoubleLineNetworkSpeed : HookRegister() {
name == "formatSpeed" && parameterCount == 2 name == "formatSpeed" && parameterCount == 2
}.hookBefore { }.hookBefore {
if (getDualAlign == 0) { if (getDualAlign == 0) {
it.result = it.result = "$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n${downIcon} ${
"$upIcon ${getTotalUpSpeed(it.args[0] as Context)}\n${downIcon} ${
getTotalDownloadSpeed(it.args[0] as Context) getTotalDownloadSpeed(it.args[0] as Context)
}" }"
} else { } else {
it.result = it.result = "${getTotalUpSpeed(it.args[0] as Context)} ${upIcon}\n${
"${getTotalUpSpeed(it.args[0] as Context)} ${upIcon}\n${ getTotalDownloadSpeed(it.args[0] as Context)
getTotalDownloadSpeed(
it.args[0] as Context
)
} $downIcon" } $downIcon"
} }
} }
@@ -85,30 +79,15 @@ object DoubleLineNetworkSpeed : HookRegister() {
val nowTimeStampTotalUp = System.currentTimeMillis() val nowTimeStampTotalUp = System.currentTimeMillis()
//计算上传速度 //计算上传速度
val bytes = val bytes = (currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat()
(currentTotalTxBytes - mLastTotalUp) * 1000 / (nowTimeStampTotalUp - lastTimeStampTotalUp).toFloat()
val unit: String val unit: String
if (bytes >= 1048576) { if (bytes >= 1048576) {
totalUpSpeed = totalUpSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat()
DecimalFormat("0.0").format(bytes / 1048576).toFloat() unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName))
unit = context.resources.getString(
context.resources.getIdentifier(
"megabyte_per_second",
"string",
context.packageName
)
)
} else { } else {
totalUpSpeed = totalUpSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat()
DecimalFormat("0.0").format(bytes / 1024).toFloat() unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName))
unit = context.resources.getString(
context.resources.getIdentifier(
"kilobyte_per_second",
"string",
context.packageName
)
)
} }
//保存当前的流量总和和上次的时间戳 //保存当前的流量总和和上次的时间戳
@@ -116,9 +95,9 @@ object DoubleLineNetworkSpeed : HookRegister() {
lastTimeStampTotalUp = nowTimeStampTotalUp lastTimeStampTotalUp = nowTimeStampTotalUp
return if (totalUpSpeed >= 100) { return if (totalUpSpeed >= 100) {
"" + totalUpSpeed.toInt() + unit "${totalUpSpeed.toInt()}$unit"
} else { } else {
"" + totalUpSpeed + unit "${totalUpSpeed}$unit"
} }
} }
@@ -129,40 +108,25 @@ object DoubleLineNetworkSpeed : HookRegister() {
val nowTimeStampTotalDown = System.currentTimeMillis() val nowTimeStampTotalDown = System.currentTimeMillis()
//计算下行速度 //计算下行速度
val bytes = val bytes = (currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat()
(currentTotalRxBytes - mLastTotalDown) * 1000 / (nowTimeStampTotalDown - lastTimeStampTotalDown).toFloat()
val unit: String val unit: String
if (bytes >= 1048576) { if (bytes >= 1048576) {
totalDownSpeed = totalDownSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat()
DecimalFormat("0.0").format(bytes / 1048576).toFloat() unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second", "string", context.packageName))
unit = context.resources.getString(
context.resources.getIdentifier(
"megabyte_per_second",
"string",
context.packageName
)
)
} else { } else {
totalDownSpeed = totalDownSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat()
DecimalFormat("0.0").format(bytes / 1024).toFloat() unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second", "string", context.packageName))
unit = context.resources.getString(
context.resources.getIdentifier(
"kilobyte_per_second",
"string",
context.packageName
)
)
} }
//保存当前的流量总和和上次的时间戳 //保存当前的流量总和和上次的时间戳
mLastTotalDown = currentTotalRxBytes mLastTotalDown = currentTotalRxBytes
lastTimeStampTotalDown = nowTimeStampTotalDown lastTimeStampTotalDown = nowTimeStampTotalDown
return if (totalDownSpeed >= 100) { return if (totalDownSpeed >= 100) {
"" + totalDownSpeed.toInt() + unit "${totalDownSpeed.toInt()}$unit"
} else { } else {
"" + totalDownSpeed + unit "${totalDownSpeed}$unit"
} }
} }

View File

@@ -62,14 +62,8 @@ object LockScreenClockDisplaySeconds : HookRegister() {
val textV = it.thisObject.getObjectAs<TextView>("mTimeText") val textV = it.thisObject.getObjectAs<TextView>("mTimeText")
val c: Context = textV.context val c: Context = textV.context
Log.d( Log.d("lock_screen_clock_display_seconds", "updateTime: ${it.thisObject.javaClass.simpleName}")
"lock_screen_clock_display_seconds", val is24 = Settings.System.getString(c.contentResolver, Settings.System.TIME_12_24) == "24"
"updateTime: " + it.thisObject.javaClass.simpleName
)
val is24 = Settings.System.getString(
c.contentResolver,
Settings.System.TIME_12_24
) == "24"
nowTime = Calendar.getInstance().time nowTime = Calendar.getInstance().time

View File

@@ -1,6 +1,9 @@
package com.lt2333.simplicitytools.hook.app.systemui package com.lt2333.simplicitytools.hook.app.systemui
import android.annotation.SuppressLint
import android.app.AndroidAppHelper
import android.content.Context
import android.os.BatteryManager
import android.widget.TextView import android.widget.TextView
import com.github.kyuubiran.ezxhelper.init.InitFields import com.github.kyuubiran.ezxhelper.init.InitFields
import com.github.kyuubiran.ezxhelper.utils.findMethod import com.github.kyuubiran.ezxhelper.utils.findMethod
@@ -11,8 +14,7 @@ import com.lt2333.simplicitytools.util.hasEnable
import com.lt2333.simplicitytools.util.xposed.base.HookRegister import com.lt2333.simplicitytools.util.xposed.base.HookRegister
import java.io.BufferedReader import java.io.BufferedReader
import java.io.FileReader import java.io.FileReader
import java.lang.reflect.Method import kotlin.math.abs
import kotlin.math.roundToInt
object LockScreenCurrent : HookRegister() { object LockScreenCurrent : HookRegister() {
@@ -20,43 +22,22 @@ object LockScreenCurrent : HookRegister() {
findMethod("com.android.keyguard.charge.ChargeUtils") { findMethod("com.android.keyguard.charge.ChargeUtils") {
name == "getChargingHintText" && parameterCount == 3 name == "getChargingHintText" && parameterCount == 3
}.hookAfter { }.hookAfter {
it.result = getCurrent() + "\n" + it.result it.result = "${getCurrent()}\n${it.result}"
} }
findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") { findMethod("com.android.systemui.statusbar.phone.KeyguardBottomAreaView") {
name == "onFinishInflate" name == "onFinishInflate"
}.hookAfter { }.hookAfter {
(it.thisObject.getObject( (it.thisObject.getObject("mIndicationText") as TextView).isSingleLine = false
"mIndicationText"
) as TextView).isSingleLine = false
} }
} }
/**
* 原始代码来自 CSDN
* https://blog.csdn.net/zhangyongfeiyong/article/details/53641809
*/
@SuppressLint("PrivateApi")
private fun getCurrent(): String { private fun getCurrent(): String {
var result = "" val batteryManager = AndroidAppHelper.currentApplication().getSystemService(Context.BATTERY_SERVICE) as BatteryManager
try { val current = abs(batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW) / 1000)
val systemProperties = Class.forName("android.os.SystemProperties") return "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
val get = systemProperties.getDeclaredMethod("get", String::class.java) as Method
val platName = get.invoke(null, "ro.hardware") as String
if (platName.startsWith("mt") || platName.startsWith("MT")) {
val filePath =
"/sys/class/power_supply/battery/device/FG_Battery_CurrentConsumption"
val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt()
result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
} else if (platName.startsWith("qcom")) {
val filePath = "/sys/class/power_supply/battery/current_now"
val current = (-getMeanCurrentVal(filePath, 5, 0) / 1000.0f).roundToInt()
result = "${InitFields.moduleRes.getString(R.string.current_current)} ${current}mA"
}
} catch (e: Exception) {
e.printStackTrace()
}
return result
} }
/** /**

View File

@@ -29,17 +29,17 @@ object NotificationWeather : HookRegister() {
val context = viewGroup.context val context = viewGroup.context
// MIUI编译时间大于 2022-03-12 00:00:00 且为内测版 // MIUI编译时间大于 2022-03-12 00:00:00 且为内测版
if (SystemProperties[context, "ro.build.date.utc"]!!.toInt() >= 1647014400 && if (SystemProperties[context, "ro.build.date.utc"].toInt() >= 1647014400 &&
!SystemProperties[context, "ro.build.version.incremental"]!!.endsWith("XM") !SystemProperties[context, "ro.build.version.incremental"].endsWith("XM")
) { ) {
//获取原组件 //获取原组件
val big_time_ID = val bigTimeId =
context.resources.getIdentifier("big_time", "id", context.packageName) context.resources.getIdentifier("big_time", "id", context.packageName)
val big_time: TextView = viewGroup.findViewById(big_time_ID) val bigTime: TextView = viewGroup.findViewById(bigTimeId)
val date_time_ID = val dateTimeId =
context.resources.getIdentifier("date_time", "id", context.packageName) context.resources.getIdentifier("date_time", "id", context.packageName)
val date_time: TextView = viewGroup.findViewById(date_time_ID) val dateTime: TextView = viewGroup.findViewById(dateTimeId)
//创建新布局 //创建新布局
val mConstraintLayoutLp = LinearLayout.LayoutParams( val mConstraintLayoutLp = LinearLayout.LayoutParams(
@@ -58,25 +58,25 @@ object NotificationWeather : HookRegister() {
mConstraintLayout = mConstraintLayout =
ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp } ConstraintLayout(context).also { it.layoutParams = mConstraintLayoutLp }
(big_time.parent as ViewGroup).addView(mConstraintLayout, 0) (bigTime.parent as ViewGroup).addView(mConstraintLayout, 0)
//从原布局中删除组件 //从原布局中删除组件
(big_time.parent as ViewGroup).removeView(big_time) (bigTime.parent as ViewGroup).removeView(bigTime)
(date_time.parent as ViewGroup).removeView(date_time) (dateTime.parent as ViewGroup).removeView(dateTime)
//添加组件至新布局 //添加组件至新布局
mConstraintLayout!!.addView(big_time) mConstraintLayout!!.addView(bigTime)
mConstraintLayout!!.addView(date_time) mConstraintLayout!!.addView(dateTime)
//组件属性 //组件属性
val date_time_LP = ConstraintLayout.LayoutParams( val dateTimeLp = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT ConstraintLayout.LayoutParams.WRAP_CONTENT
).also { ).also {
it.startToEnd = big_time_ID it.startToEnd = bigTimeId
it.bottomToBottom = 0 it.bottomToBottom = 0
it.marginStart = context.resources.getDimensionPixelSize( it.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier( context.resources.getIdentifier(
@@ -87,7 +87,7 @@ object NotificationWeather : HookRegister() {
) )
it.bottomMargin = dp2px(context, 5f) it.bottomMargin = dp2px(context, 5f)
} }
date_time.layoutParams = date_time_LP dateTime.layoutParams = dateTimeLp
//创建天气组件 //创建天气组件
@@ -103,12 +103,12 @@ object NotificationWeather : HookRegister() {
} }
mConstraintLayout!!.addView(mWeatherView) mConstraintLayout!!.addView(mWeatherView)
val mWeatherView_LP = ConstraintLayout.LayoutParams( val mweatherviewLp = ConstraintLayout.LayoutParams(
ConstraintLayout.LayoutParams.WRAP_CONTENT, ConstraintLayout.LayoutParams.WRAP_CONTENT,
ConstraintLayout.LayoutParams.WRAP_CONTENT ConstraintLayout.LayoutParams.WRAP_CONTENT
).also { ).also {
it.startToEnd = big_time_ID it.startToEnd = bigTimeId
it.bottomToTop = date_time_ID it.bottomToTop = dateTimeId
it.marginStart = context.resources.getDimensionPixelSize( it.marginStart = context.resources.getDimensionPixelSize(
context.resources.getIdentifier( context.resources.getIdentifier(
"notification_panel_time_date_space", "notification_panel_time_date_space",
@@ -118,7 +118,7 @@ object NotificationWeather : HookRegister() {
) )
} }
(mWeatherView as WeatherView).layoutParams = mWeatherView_LP (mWeatherView as WeatherView).layoutParams = mweatherviewLp
} else { } else {
val layoutParam = val layoutParam =

View File

@@ -118,12 +118,12 @@ object StatusBarLayout : HookRegister() {
mConstraintLayout.addView(notificationIconAreaInner) mConstraintLayout.addView(notificationIconAreaInner)
val fullscreen_notification_icon_area_lp = LinearLayout.LayoutParams( val fullscreenNotificationIconAreaLp = LinearLayout.LayoutParams(
ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT,
ConstraintLayout.LayoutParams.MATCH_PARENT ConstraintLayout.LayoutParams.MATCH_PARENT
) )
notificationIconAreaInner.layoutParams = fullscreen_notification_icon_area_lp notificationIconAreaInner.layoutParams = fullscreenNotificationIconAreaLp
//增加一个左对齐布局 //增加一个左对齐布局
mLeftLayout = LinearLayout(context) mLeftLayout = LinearLayout(context)
@@ -404,16 +404,16 @@ object StatusBarLayout : HookRegister() {
}.hookAfter { }.hookAfter {
val miuiPhoneStatusBarView = it.thisObject.getObjectAs<ViewGroup>("mStatusBar") val miuiPhoneStatusBarView = it.thisObject.getObjectAs<ViewGroup>("mStatusBar")
val res = miuiPhoneStatusBarView.resources val res = miuiPhoneStatusBarView.resources
val status_bar_ID = val statusBarId =
res.getIdentifier("status_bar", "id", "com.android.systemui") res.getIdentifier("status_bar", "id", "com.android.systemui")
val status_bar = miuiPhoneStatusBarView.findViewById<ViewGroup>(status_bar_ID) val statusBar1 = miuiPhoneStatusBarView.findViewById<ViewGroup>(statusBarId)
//非锁屏下整个状态栏布局 //非锁屏下整个状态栏布局
val keyguardMgr = val keyguardMgr =
status_bar.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager statusBar1.context.getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
if (keyguardMgr.isKeyguardLocked) { if (keyguardMgr.isKeyguardLocked) {
status_bar!!.visibility = View.GONE statusBar1!!.visibility = View.GONE
} else { } else {
status_bar!!.visibility = View.VISIBLE statusBar1!!.visibility = View.VISIBLE
} }
} }
} }

View File

@@ -4,7 +4,7 @@ import android.service.quicksettings.Tile
import android.service.quicksettings.TileService import android.service.quicksettings.TileService
class AllowScreenshots : TileService() { class AllowScreenshots : TileService() {
val key = "disable_flag_secure" private val key = "disable_flag_secure"
override fun onClick() { override fun onClick() {
super.onClick() super.onClick()

View File

@@ -5,7 +5,7 @@ import android.service.quicksettings.TileService
class LockMaxFpsTile : TileService() { class LockMaxFpsTile : TileService() {
val key = "lock_max_fps" private val key = "lock_max_fps"
override fun onClick() { override fun onClick() {
super.onClick() super.onClick()

View File

@@ -5,7 +5,7 @@ import android.content.Context
object SystemProperties { object SystemProperties {
@SuppressLint("PrivateApi") @SuppressLint("PrivateApi")
operator fun get(context: Context, key: String?): String? { operator fun get(context: Context, key: String?): String {
var ret = "" var ret = ""
try { try {
val cl = context.classLoader val cl = context.classLoader

View File

@@ -5,7 +5,6 @@ import com.github.kyuubiran.ezxhelper.utils.Log.logexIfThrow
import com.lt2333.simplicitytools.util.xposed.base.AppRegister import com.lt2333.simplicitytools.util.xposed.base.AppRegister
import de.robv.android.xposed.IXposedHookLoadPackage import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.IXposedHookZygoteInit import de.robv.android.xposed.IXposedHookZygoteInit
import de.robv.android.xposed.XposedBridge
import de.robv.android.xposed.callbacks.XC_LoadPackage import de.robv.android.xposed.callbacks.XC_LoadPackage
abstract class EasyXposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit { abstract class EasyXposedInit : IXposedHookLoadPackage, IXposedHookZygoteInit {

View File

@@ -14,7 +14,7 @@ import android.widget.TextView
class WeatherView(context: Context?, private val showCity: Boolean) : TextView(context) { class WeatherView(context: Context?, private val showCity: Boolean) : TextView(context) {
private val mContext: Context private val mContext: Context
private val WEATHER_URI = Uri.parse("content://weather/weather") private val weatherUri = Uri.parse("content://weather/weather")
private val mHandler: Handler private val mHandler: Handler
private val mWeatherObserver: ContentObserver? private val mWeatherObserver: ContentObserver?
private val mWeatherRunnable: WeatherRunnable private val mWeatherRunnable: WeatherRunnable
@@ -30,7 +30,7 @@ class WeatherView(context: Context?, private val showCity: Boolean) : TextView(c
mWeatherObserver = WeatherContentObserver(mHandler) mWeatherObserver = WeatherContentObserver(mHandler)
mContext = context!! mContext = context!!
mWeatherRunnable = WeatherRunnable() mWeatherRunnable = WeatherRunnable()
context.contentResolver.registerContentObserver(WEATHER_URI, true, mWeatherObserver) context.contentResolver.registerContentObserver(weatherUri, true, mWeatherObserver)
updateWeatherInfo() updateWeatherInfo()
} }
@@ -44,19 +44,13 @@ class WeatherView(context: Context?, private val showCity: Boolean) : TextView(c
override fun run() { override fun run() {
var str = "" var str = ""
try { try {
val query = mContext.contentResolver.query(WEATHER_URI, null, null, null, null) val query = mContext.contentResolver.query(weatherUri, null, null, null, null)
if (query != null) { if (query != null) {
if (query.moveToFirst()) { if (query.moveToFirst()) {
if (showCity) { str = if (showCity) {
str = query.getString(query.getColumnIndexOrThrow("city_name")) + " " + query.getString(query.getColumnIndexOrThrow("description")) + " " + query.getString(query.getColumnIndexOrThrow("temperature"))
query.getString(query.getColumnIndexOrThrow("city_name")) + " " + query.getString(
query.getColumnIndexOrThrow("description")
) + " " + query.getString(query.getColumnIndexOrThrow("temperature"))
} else { } else {
str = query.getString(query.getColumnIndexOrThrow("description")) + " " + query.getString(query.getColumnIndexOrThrow("temperature"))
query.getString(
query.getColumnIndexOrThrow("description")
) + " " + query.getString(query.getColumnIndexOrThrow("temperature"))
} }
} }
query.close() query.close()