diff --git a/CMakeLists.txt b/CMakeLists.txt index a210c682b..5f1fabf78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,26 @@ if (ANDROID OR WIN32 OR APPLE) endif() option(ENABLE_OPENSSL "Enable OpenSSL backend for ISslConnection" ${DEFAULT_ENABLE_OPENSSL}) -# Copy the VVL arm64 binary to src/android/app/main/jniLibs. REF: https://github.com/KhronosGroup/Vulkan-ValidationLayers/actions/workflows/vvl.yml +if (ANDROID AND CITRON_DOWNLOAD_ANDROID_VVL) + set(vvl_version "sdk-1.3.261.1") + set(vvl_zip_file "${CMAKE_BINARY_DIR}/externals/vvl-android.zip") + if (NOT EXISTS "${vvl_zip_file}") + # Download and extract validation layer release to externals directory + set(vvl_base_url "https://github.com/KhronosGroup/Vulkan-ValidationLayers/releases/download") + file(DOWNLOAD "${vvl_base_url}/${vvl_version}/android-binaries-${vvl_version}-android.zip" + "${vvl_zip_file}" SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${vvl_zip_file}" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals") + endif() + + # Copy the arm64 binary to src/android/app/main/jniLibs only if it doesn't exist + set(vvl_lib_path "${CMAKE_CURRENT_SOURCE_DIR}/src/android/app/src/main/jniLibs/arm64-v8a/") + set(vvl_lib_file "${vvl_lib_path}/libVkLayer_khronos_validation.so") + if (NOT EXISTS "${vvl_lib_file}") + file(COPY "${CMAKE_BINARY_DIR}/externals/android-binaries-${vvl_version}/arm64-v8a/libVkLayer_khronos_validation.so" + DESTINATION "${vvl_lib_path}") + endif() +endif() if (ANDROID) set(CMAKE_SKIP_INSTALL_RULES ON) diff --git a/src/android/app/build.gradle.kts b/src/android/app/build.gradle.kts index 93c1bc798..1c740013e 100644 --- a/src/android/app/build.gradle.kts +++ b/src/android/app/build.gradle.kts @@ -35,12 +35,12 @@ android { } compileOptions { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = "21" + jvmTarget = "17" } packaging { diff --git a/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt b/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt index 57e4e37d8..a01530079 100644 --- a/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt +++ b/src/android/app/src/main/java/org/citron/citron_emu/fragments/EmulationFragment.kt @@ -532,20 +532,20 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { !emulationViewModel.isEmulationStopping.value ) { val thermalStatus = when (powerManager.currentThermalStatus) { - PowerManager.THERMAL_STATUS_LIGHT -> "😥" - PowerManager.THERMAL_STATUS_MODERATE -> "🥵" - PowerManager.THERMAL_STATUS_SEVERE -> "🔥" + PowerManager.THERMAL_STATUS_LIGHT -> 0.25f + PowerManager.THERMAL_STATUS_MODERATE -> 0.5f + PowerManager.THERMAL_STATUS_SEVERE -> 0.75f PowerManager.THERMAL_STATUS_CRITICAL, PowerManager.THERMAL_STATUS_EMERGENCY, - PowerManager.THERMAL_STATUS_SHUTDOWN -> "☢️" - else -> "🙂" + PowerManager.THERMAL_STATUS_SHUTDOWN -> 1.0f + else -> 0f } - // Get temperature in Celsius from thermal sensor + // Get temperature from battery thermal sensor val temperature = try { - val process = Runtime.getRuntime().exec("cat /sys/class/thermal/thermal_zone0/temp") + val process = Runtime.getRuntime().exec("cat /sys/class/power_supply/battery/temp") val reader = process.inputStream.bufferedReader() - val temp = reader.readLine().toFloat() / 1000f // Convert from millicelsius to celsius + val temp = reader.readLine().toFloat() / 10f // Convert from decidegrees to degrees reader.close() temp } catch (e: Exception) { @@ -556,16 +556,30 @@ class EmulationFragment : Fragment(), SurfaceHolder.Callback { val fahrenheit = (temperature * 9f / 5f) + 32f if (_binding != null) { - // Color interpolation based on temperature (green at 45°C, red at 85°C) - val normalizedTemp = ((temperature - 45f) / 40f).coerceIn(0f, 1f) + // Color interpolation based on temperature (green at 30°C, red at 45°C) + val normalizedTemp = ((temperature - 30f) / 15f).coerceIn(0f, 1f) val red = (normalizedTemp * 255).toInt() val green = ((1f - normalizedTemp) * 255).toInt() val color = android.graphics.Color.rgb(red, green, 0) + // Create a modern progress bar using block elements + val progressBarLength = 12 + val filledBars = (thermalStatus * progressBarLength).toInt() + val progressBar = buildString { + append("│") // Left border + repeat(filledBars) { append("█") } + repeat(progressBarLength - filledBars) { append("░") } + append("│") // Right border + + // Add percentage + append(" ") + append(String.format("%3d%%", (thermalStatus * 100).toInt())) + } + binding.showThermalsText.setTextColor(color) binding.showThermalsText.text = String.format( - "%s %.1f°C\n%.1f°F", - thermalStatus, + "%s\n%.1f°C • %.1f°F", + progressBar, temperature, fahrenheit )