Skip to content

Commit

Permalink
Add boot time
Browse files Browse the repository at this point in the history
  • Loading branch information
alexal1 committed Oct 22, 2024
1 parent d3ef5e3 commit 08ae7a8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/src/main/java/com/nomixcloner/app/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.net.ConnectivityManager
import android.net.SSLCertificateSocketFactory
import android.os.Build
import android.os.Bundle
import android.os.SystemClock
import android.provider.Settings
import android.telephony.TelephonyManager
import android.util.Log
Expand Down Expand Up @@ -61,6 +62,9 @@ import java.net.ProxySelector
import java.net.URI
import java.net.URL
import java.security.MessageDigest
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import java.util.concurrent.atomic.AtomicBoolean
import java.util.regex.Matcher
import java.util.regex.Pattern
Expand Down Expand Up @@ -406,6 +410,14 @@ class MainActivity : ComponentActivity() {
val defaultUserAgent = remember { mutableStateOf(WebSettings.getDefaultUserAgent(context)) }
var showWebView by remember { mutableStateOf(false) }

// Calculate boot times
val currentTimeMillis = System.currentTimeMillis()
val elapsedRealtimeMillis = SystemClock.elapsedRealtime()
val elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos()

val bootTimeElapsed = Date(currentTimeMillis - elapsedRealtimeMillis)
val bootTimeElapsedNanos = Date(currentTimeMillis - (elapsedRealtimeNanos / 1_000_000))

Box {
Column(
modifier = Modifier
Expand All @@ -419,6 +431,8 @@ class MainActivity : ComponentActivity() {
Text("COPY JSON TO CLIPBOARD")
}
Text("\nHardware data: $hardwareData\n")
Text("Boot time (elapsedRealtime): ${formatDate(bootTimeElapsed)}")
Text("Boot time (elapsedRealtimeNanos): ${formatDate(bootTimeElapsedNanos)}\n")
Text("Package name: $packageName\n")
Text("Signature: $signature\n")
Text("Google Advertising ID: $googleAdId\n")
Expand Down Expand Up @@ -566,6 +580,11 @@ class MainActivity : ComponentActivity() {
}
}

private fun formatDate(date: Date): String {
val sdf = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.getDefault())
return sdf.format(date)
}

@Preview(showBackground = true)
@Composable
fun DeviceInfoPreview() {
Expand Down

0 comments on commit 08ae7a8

Please sign in to comment.