From 801ade5859c66e529b781e1ca66d5f0845a566d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=8C=E5=A0=86=E5=B0=8F=E9=80=8F=E6=98=8E?= Date: Mon, 21 Mar 2022 15:41:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=8C=E6=8E=92=E7=BD=91?= =?UTF-8?q?=E9=80=9F=EF=BC=8C=E4=BD=BF=E7=94=A8=E4=B8=BB=E9=A2=98=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hook/app/systemui/DoubleLineNetworkSpeed.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt index a1e94ce5..d6fabb87 100644 --- a/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt +++ b/app/src/main/java/com/lt2333/simplicitytools/hook/app/systemui/DoubleLineNetworkSpeed.kt @@ -63,17 +63,17 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage { ) { if (getDualAlign == 0) { it.result = - "${upIcon} ${getTotalUpSpeed()}\n${downIcon} ${getTotalDownloadSpeed()}" + "${upIcon} ${getTotalUpSpeed(it.args[0]as Context)}\n${downIcon} ${getTotalDownloadSpeed(it.args[0]as Context)}" } else { it.result = - "${getTotalUpSpeed()} ${upIcon}\n${getTotalDownloadSpeed()} ${downIcon}" + "${getTotalUpSpeed(it.args[0]as Context)} ${upIcon}\n${getTotalDownloadSpeed(it.args[0]as Context)} ${downIcon}" } } } } //获取总的上行速度 - fun getTotalUpSpeed(): String { + fun getTotalUpSpeed(context: Context): String { var totalUpSpeed = 0F val currentTotalTxBytes = TrafficStats.getTotalTxBytes() @@ -87,11 +87,11 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage { if (bytes >= 1048576) { totalUpSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat() - unit = "MB/s" + unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second","string",context.packageName)) } else { totalUpSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat() - unit = "KB/s" + unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second","string",context.packageName)) } //保存当前的流量总和和上次的时间戳 @@ -106,7 +106,7 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage { } //获取总的下行速度 - fun getTotalDownloadSpeed(): String { + fun getTotalDownloadSpeed(context: Context): String { var totalDownSpeed = 0F val currentTotalRxBytes = TrafficStats.getTotalRxBytes() val nowTimeStampTotalDown = System.currentTimeMillis() @@ -120,11 +120,11 @@ class DoubleLineNetworkSpeed : IXposedHookLoadPackage { if (bytes >= 1048576) { totalDownSpeed = DecimalFormat("0.0").format(bytes / 1048576).toFloat() - unit = "MB/s" + unit = context.resources.getString(context.resources.getIdentifier("kilobyte_per_second","string",context.packageName)) } else { totalDownSpeed = DecimalFormat("0.0").format(bytes / 1024).toFloat() - unit = "KB/s" + unit = context.resources.getString(context.resources.getIdentifier("megabyte_per_second","string",context.packageName)) } //保存当前的流量总和和上次的时间戳 mLastTotalDown = currentTotalRxBytes