diff --git a/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/benchmark/BenchmarkActivity.kt b/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/benchmark/BenchmarkActivity.kt index 9682789cb8b..2f30dacf724 100644 --- a/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/benchmark/BenchmarkActivity.kt +++ b/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/benchmark/BenchmarkActivity.kt @@ -2,10 +2,12 @@ package org.maplibre.android.testapp.activity.benchmark import android.annotation.SuppressLint import android.app.Activity +import android.content.Context import android.os.Build import android.os.Bundle import android.os.Environment import android.os.Handler +import android.os.PowerManager import android.view.View import android.view.WindowManager import androidx.appcompat.app.AppCompatActivity @@ -188,7 +190,23 @@ class BenchmarkActivity : AppCompatActivity() { } } + private fun getThermalStatus(): Int { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager + return powerManager.currentThermalStatus + } + + return -1; + } + private fun setupMapView() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager + powerManager.addThermalStatusListener { + status -> println("Thermal status changed $status") + } + } + mapView = findViewById(R.id.mapView) as MapView mapView.getMapAsync { maplibreMap: MapLibreMap -> val benchmarkResult = BenchmarkResult(arrayListOf()) @@ -254,7 +272,7 @@ class BenchmarkActivity : AppCompatActivity() { mapView.removeOnDidFinishRenderingFrameListener(listener) - return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore) + return BenchmarkRunResult(fps, encodingTimeStore, renderingTimeStore, getThermalStatus()) } override fun onStart() { diff --git a/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/utils/BenchmarkUtils.kt b/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/utils/BenchmarkUtils.kt index f49a1d014d1..6f07bf49e80 100644 --- a/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/utils/BenchmarkUtils.kt +++ b/platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/utils/BenchmarkUtils.kt @@ -31,7 +31,8 @@ data class BenchmarkRun( data class BenchmarkRunResult( val fps: Double, val encodingTimeStore: FrameTimeStore, - val renderingTimeStore: FrameTimeStore + val renderingTimeStore: FrameTimeStore, + val thermalState: Int ) data class BenchmarkResult ( @@ -46,6 +47,7 @@ fun jsonPayload(benchmarkResult: BenchmarkResult): JsonObject { addJsonObject { put("styleName", JsonPrimitive(run.first.styleName)) put("syncRendering", JsonPrimitive(run.first.syncRendering)) + put("thermalState", JsonPrimitive(run.second.thermalState)) put("fps", JsonPrimitive(run.second.fps)) put("avgEncodingTime", JsonPrimitive(run.second.encodingTimeStore.average())) put("avgRenderingTime", JsonPrimitive(run.second.renderingTimeStore.average()))