mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-01 02:25:40 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77fbc3abb4 |
No files matched your search
@@ -27,6 +27,7 @@ import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import java.util.TimeZone
|
||||
|
||||
object DeviceReport {
|
||||
private const val TAG = "DeviceReport"
|
||||
@@ -36,6 +37,10 @@ object DeviceReport {
|
||||
.map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") }
|
||||
.filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" }
|
||||
|
||||
internal fun buildDate(millis: Long): String? = millis.takeIf { it > 0 }?.let {
|
||||
SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }.format(Date(it))
|
||||
}
|
||||
|
||||
fun write(context: Context, target: File, mode: String) {
|
||||
try {
|
||||
target.writeText(build(context, mode))
|
||||
@@ -129,6 +134,7 @@ object DeviceReport {
|
||||
k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
|
||||
k("Security patch", Build.VERSION.SECURITY_PATCH)
|
||||
k("Build", Build.DISPLAY)
|
||||
k("Build date", buildDate(Build.TIME))
|
||||
k("Fingerprint", Build.FINGERPRINT)
|
||||
k("Kernel", System.getProperty("os.version"))
|
||||
k("ABIs", Build.SUPPORTED_ABIS.joinToString(", "))
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class DeviceReportBuildDateTest {
|
||||
@Test fun theFirmwareBuildTimeIsShownInUtc() {
|
||||
assertEquals("2024-11-08 17:47 UTC", DeviceReport.buildDate(1_731_088_027_000L))
|
||||
}
|
||||
|
||||
@Test fun anUnsetBuildTimeIsUnknown() {
|
||||
assertNull(DeviceReport.buildDate(0L))
|
||||
assertNull(DeviceReport.buildDate(-1L))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user