Skip to content

Commit 9d9ffcb

Browse files
committed
修正浮点匹配/小版本号值计算错误的问题
1 parent 4b45380 commit 9d9ffcb

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

  • library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/utils/api

library/libhook/src/main/java/com/sevtinge/hyperceiler/libhook/utils/api/DeviceHelper.kt

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -233,17 +233,16 @@ object DeviceHelper {
233233
}
234234
}
235235

236-
@SuppressLint("DefaultLocale")
237236
fun getDisplayVersion(): String {
238237
val version = smallVersion
239238
val major = version.roundToInt()
240239
val decimal = version - major
241240

242241
return if (decimal < 0.001f) {
243-
String.format("%d.0", major)
242+
String.format(Locale.ROOT, "%d.0", major)
244243
} else {
245244
val patch = (decimal * 1000).roundToInt()
246-
String.format("%d.0.%d", major, patch)
245+
String.format(Locale.ROOT, "%d.0.%d", major, patch)
247246
}
248247
}
249248

@@ -263,7 +262,7 @@ object DeviceHelper {
263262
// VersionInfo(37, 3.0f, 3.3f, SUPPORT_PARTIAL),
264263

265264
// 未适配
266-
VersionInfo(36, 2.0f, 2.23f, SUPPORT_NOT)
265+
VersionInfo(36, 2.0f, 2.2f, SUPPORT_NOT)
267266
)
268267
}
269268

@@ -297,10 +296,10 @@ object DeviceHelper {
297296

298297
@JvmStatic
299298
fun getXmsVersion(): String = runCatching {
300-
getProp("persist.sys.xms.version")
301-
}.recoverCatching {
302-
getProp("ro.mi.xms.version.incremental")
303-
}.getOrElse { "null" }
299+
getProp("persist.sys.xms.version")
300+
}.recoverCatching {
301+
getProp("ro.mi.xms.version.incremental")
302+
}.getOrElse { "null" }
304303

305304
@JvmStatic
306305
fun getRomAuthor(): String = getProp("ro.rom.author") + getProp("ro.romid")
@@ -320,10 +319,11 @@ object DeviceHelper {
320319
@JvmStatic
321320
fun getHyperOSVersion(): Float = hyperOSSDK
322321

323-
@SuppressLint("DefaultLocale")
324322
@JvmStatic
325-
fun getSmallVersion(): Float =
326-
String.format("%.1f", hyperOSSDK + smallVersion * 0.001f).toFloatOrNull() ?: -1f
323+
fun getSmallVersion(): Float {
324+
val tenth = smallVersion / 100
325+
return hyperOSSDK + (tenth * 0.1f)
326+
}
327327

328328
@JvmStatic
329329
fun isSupportTelephony(context: Context): Boolean =
@@ -380,7 +380,6 @@ object DeviceHelper {
380380
}
381381
}
382382

383-
@SuppressLint("DefaultLocale")
384383
@JvmStatic
385384
fun getVersionListText(status: Int): String {
386385
return getVersionsByStatus(status).joinToString("\n") { info ->

0 commit comments

Comments
 (0)