π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Separate device health core from Flutter
Neeraj Gupta23b4c37186c7
diff --git a/mobile/apps/photos/integration_test/device_health_test.dart b/mobile/apps/photos/integration_test/device_health_test.dartindex 19de7305a3..b84b7e4b7f 100644--- a/mobile/apps/photos/integration_test/device_health_test.dart+++ b/mobile/apps/photos/integration_test/device_health_test.dart@@ -10,8 +10,8 @@ void main() {testWidgets('native device health snapshot is current and usable', (tester,) async {- final snapshot = await EntePhotosDeviceHealth.instance.getSnapshot();- final memory = await EntePhotosDeviceHealth.instance.getMemorySnapshot();+ final snapshot = await DeviceHealthClient.instance.getSnapshot();+ final memory = await DeviceHealthClient.instance.getMemorySnapshot();final now = DateTime.now();expect(snapshot.isFreshAt(now, const Duration(seconds: 10)), isTrue);diff --git a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dartindex c64502f85b..b62ee09961 100644--- a/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart+++ b/mobile/apps/photos/lib/services/machine_learning/compute_controller.dart@@ -64,8 +64,7 @@ class ComputeController {this._localSettings, {DeviceHealthSource? deviceHealthSource,DeviceHealthPolicy deviceHealthPolicy = const DeviceHealthPolicy(),- }) : _deviceHealthSource =- deviceHealthSource ?? EntePhotosDeviceHealth.instance,+ }) : _deviceHealthSource = deviceHealthSource ?? DeviceHealthClient.instance,_deviceHealthPolicy = deviceHealthPolicy {_logger.info('ComputeController constructor');unawaited(init());diff --git a/mobile/apps/photos/lib/utils/ram_check_util.dart b/mobile/apps/photos/lib/utils/ram_check_util.dartindex 8fd64c489a..2f169bea05 100644--- a/mobile/apps/photos/lib/utils/ram_check_util.dart+++ b/mobile/apps/photos/lib/utils/ram_check_util.dart@@ -16,7 +16,7 @@ bool get enoughRamForLocalGalleryLocalIndexing =>Future<int?> checkDeviceTotalRAM() async {if (deviceTotalRAM != null) return deviceTotalRAM;try {- final memory = await EntePhotosDeviceHealth.instance.getMemorySnapshot();+ final memory = await DeviceHealthClient.instance.getMemorySnapshot();if (memory.status == DeviceSignalStatus.available) {deviceTotalRAM = memory.totalBytes! ~/ (1024 * 1024);}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/EntePhotosPlatformPlugin.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/EntePhotosPlatformPlugin.ktdeleted file mode 100644index e3802a2a3e..0000000000--- a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/EntePhotosPlatformPlugin.kt+++ /dev/null@@ -1,273 +0,0 @@-package io.ente.photos.platform--import android.app.ActivityManager-import android.content.BroadcastReceiver-import android.content.Context-import android.content.Intent-import android.content.IntentFilter-import android.os.BatteryManager-import android.os.Build-import android.os.Handler-import android.os.Looper-import android.os.PowerManager-import io.flutter.embedding.engine.plugins.FlutterPlugin-import io.flutter.plugin.common.EventChannel-import io.flutter.plugin.common.MethodCall-import io.flutter.plugin.common.MethodChannel--class EntePhotosPlatformPlugin :- FlutterPlugin,- MethodChannel.MethodCallHandler,- EventChannel.StreamHandler {- private lateinit var context: Context- private lateinit var methodChannel: MethodChannel- private lateinit var eventChannel: EventChannel- private val mainHandler = Handler(Looper.getMainLooper())- private var eventSink: EventChannel.EventSink? = null- private var batteryReceiverRegistered = false- private var thermalListenerRegistered = false- private var snapshotPending = false- private var lastEmittedState: Map<String, Any?>? = null-- private val batteryReceiver =- object : BroadcastReceiver() {- override fun onReceive(context: Context, intent: Intent) {- emitSnapshot()- }- }-- private val thermalListener =- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- PowerManager.OnThermalStatusChangedListener { emitSnapshot() }- } else {- null- }-- override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {- context = binding.applicationContext- methodChannel = MethodChannel(binding.binaryMessenger, METHOD_CHANNEL)- eventChannel = EventChannel(binding.binaryMessenger, EVENT_CHANNEL)- methodChannel.setMethodCallHandler(this)- eventChannel.setStreamHandler(this)- }-- override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {- when (call.method) {- "deviceHealth.getSnapshot" -> result.success(snapshot())- "deviceHealth.getMemorySnapshot" -> result.success(memorySnapshot())- else -> result.notImplemented()- }- }-- override fun onListen(arguments: Any?, events: EventChannel.EventSink) {- stopObserving()- eventSink = events- lastEmittedState = null- startObserving()- emitSnapshot()- }-- override fun onCancel(arguments: Any?) {- eventSink = null- lastEmittedState = null- stopObserving()- }-- override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {- eventSink = null- stopObserving()- methodChannel.setMethodCallHandler(null)- eventChannel.setStreamHandler(null)- }-- private fun startObserving() {- try {- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {- context.registerReceiver(- batteryReceiver,- IntentFilter(Intent.ACTION_BATTERY_CHANGED),- Context.RECEIVER_NOT_EXPORTED,- )- } else {- @Suppress("DEPRECATION")- context.registerReceiver(- batteryReceiver,- IntentFilter(Intent.ACTION_BATTERY_CHANGED),- )- }- batteryReceiverRegistered = true- } catch (_: RuntimeException) {- batteryReceiverRegistered = false- }-- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {- try {- val powerManager = context.getSystemService(PowerManager::class.java)- val listener = thermalListener ?: return- powerManager.addThermalStatusListener(context.mainExecutor, listener)- thermalListenerRegistered = true- } catch (_: RuntimeException) {- thermalListenerRegistered = false- }- }- }-- private fun stopObserving() {- if (batteryReceiverRegistered) {- try {- context.unregisterReceiver(batteryReceiver)- } catch (_: IllegalArgumentException) {- // Already unregistered by the platform.- }- batteryReceiverRegistered = false- }-- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && thermalListenerRegistered) {- try {- val listener = thermalListener- if (listener != null) {- context.getSystemService(PowerManager::class.java)- .removeThermalStatusListener(listener)- }- } catch (_: RuntimeException) {- // Engine teardown has no remaining consumer for this listener.- }- thermalListenerRegistered = false- }- }-- private fun emitSnapshot() {- if (eventSink == null || snapshotPending) return- snapshotPending = true- mainHandler.post {- snapshotPending = false- val sink = eventSink ?: return@post- val snapshot = snapshot()- val state = mapOf(- "battery" to snapshot["battery"],- "thermal" to snapshot["thermal"],- )- if (state != lastEmittedState) {- lastEmittedState = state- sink.success(snapshot)- }- }- }-- private fun snapshot(): Map<String, Any?> =- mapOf(- "platform" to "android",- "observedAtMs" to System.currentTimeMillis(),- "battery" to batterySnapshot(),- "thermal" to thermalSnapshot(),- )-- private fun batterySnapshot(): Map<String, Any?> {- return try {- val intent = stickyBatteryIntent()- ?: return unavailable("battery_intent_missing")- if (!intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true)) {- return unavailable("battery_not_present")- }- val level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)- val scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)- if (level < 0 || scale <= 0 || level > scale) {- return unavailable("battery_level_missing")- }- val levelPercent = ((level.toDouble() / scale) * 100).toInt()- val temperature = intent.getIntExtra(- BatteryManager.EXTRA_TEMPERATURE,- Int.MIN_VALUE,- )- val values =- mutableMapOf<String, Any?>(- "status" to "available",- "levelPercent" to levelPercent,- "health" to batteryHealth(- intent.getIntExtra(- BatteryManager.EXTRA_HEALTH,- BatteryManager.BATTERY_HEALTH_UNKNOWN,- ),- ),- )- if (temperature != Int.MIN_VALUE) {- values["temperatureCelsius"] = temperature / 10.0- }- values- } catch (_: SecurityException) {- unavailable("battery_access_denied")- } catch (_: RuntimeException) {- unavailable("battery_read_failed")- }- }-- private fun stickyBatteryIntent(): Intent? {- val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)- return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {- context.registerReceiver(null, filter, Context.RECEIVER_NOT_EXPORTED)- } else {- @Suppress("DEPRECATION")- context.registerReceiver(null, filter)- }- }-- private fun thermalSnapshot(): Map<String, Any?> {- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {- return mapOf("status" to "unsupported")- }- return try {- val status = context.getSystemService(PowerManager::class.java).currentThermalStatus- val state = thermalState(status)- ?: return unavailable("thermal_status_unknown")- mapOf("status" to "available", "state" to state)- } catch (_: RuntimeException) {- unavailable("thermal_read_failed")- }- }-- private fun memorySnapshot(): Map<String, Any?> {- return try {- val info = ActivityManager.MemoryInfo()- context.getSystemService(ActivityManager::class.java).getMemoryInfo(info)- if (info.totalMem <= 0) {- unavailable("memory_total_missing")- } else {- mapOf("status" to "available", "totalBytes" to info.totalMem)- }- } catch (_: RuntimeException) {- unavailable("memory_read_failed")- }- }-- private fun unavailable(errorCode: String): Map<String, Any?> =- mapOf("status" to "unavailable", "errorCode" to errorCode)-- private fun batteryHealth(value: Int): String =- when (value) {- BatteryManager.BATTERY_HEALTH_GOOD -> "good"- BatteryManager.BATTERY_HEALTH_COLD -> "cold"- BatteryManager.BATTERY_HEALTH_OVERHEAT -> "overheating"- BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE -> "overVoltage"- BatteryManager.BATTERY_HEALTH_DEAD -> "dead"- BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE -> "failure"- else -> "unknown"- }-- private fun thermalState(value: Int): String? =- when (value) {- PowerManager.THERMAL_STATUS_NONE -> "nominal"- PowerManager.THERMAL_STATUS_LIGHT -> "light"- PowerManager.THERMAL_STATUS_MODERATE -> "moderate"- PowerManager.THERMAL_STATUS_SEVERE -> "serious"- PowerManager.THERMAL_STATUS_CRITICAL -> "critical"- PowerManager.THERMAL_STATUS_EMERGENCY -> "emergency"- PowerManager.THERMAL_STATUS_SHUTDOWN -> "shutdown"- else -> null- }-- private companion object {- private const val METHOD_CHANNEL = "io.ente.photos.platform"- private const val EVENT_CHANNEL =- "io.ente.photos.platform/device_health_events"- }-}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/PhotosPlatformPlugin.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/PhotosPlatformPlugin.ktnew file mode 100644index 0000000000..038f1cb6a3--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/PhotosPlatformPlugin.kt@@ -0,0 +1,132 @@+package io.ente.photos.platform++import io.ente.photos.platform.devicehealth.BatteryHealth+import io.ente.photos.platform.devicehealth.BatteryReading+import io.ente.photos.platform.devicehealth.DeviceHealthError+import io.ente.photos.platform.devicehealth.DeviceHealthService+import io.ente.photos.platform.devicehealth.DeviceHealthSnapshot+import io.ente.photos.platform.devicehealth.DeviceSignal+import io.ente.photos.platform.devicehealth.ThermalState+import io.flutter.embedding.engine.plugins.FlutterPlugin+import io.flutter.plugin.common.EventChannel+import io.flutter.plugin.common.MethodCall+import io.flutter.plugin.common.MethodChannel++class PhotosPlatformPlugin :+ FlutterPlugin,+ MethodChannel.MethodCallHandler,+ EventChannel.StreamHandler {+ private lateinit var methodChannel: MethodChannel+ private lateinit var eventChannel: EventChannel+ private lateinit var healthService: DeviceHealthService+ private var eventSink: EventChannel.EventSink? = null++ override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {+ healthService = DeviceHealthService(binding.applicationContext)+ methodChannel = MethodChannel(binding.binaryMessenger, METHOD_CHANNEL)+ eventChannel = EventChannel(binding.binaryMessenger, EVENT_CHANNEL)+ methodChannel.setMethodCallHandler(this)+ eventChannel.setStreamHandler(this)+ }++ override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {+ when (call.method) {+ "deviceHealth.getSnapshot" -> result.success(healthService.snapshot().toChannelMap())+ "deviceHealth.getMemorySnapshot" ->+ result.success(healthService.memorySnapshot().toMemoryChannelMap())+ else -> result.notImplemented()+ }+ }++ override fun onListen(arguments: Any?, events: EventChannel.EventSink) {+ eventSink = events+ healthService.startObserving { snapshot ->+ eventSink?.success(snapshot.toChannelMap())+ }+ }++ override fun onCancel(arguments: Any?) {+ eventSink = null+ healthService.stopObserving()+ }++ override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {+ eventSink = null+ healthService.stopObserving()+ methodChannel.setMethodCallHandler(null)+ eventChannel.setStreamHandler(null)+ }++ private fun DeviceHealthSnapshot.toChannelMap(): Map<String, Any?> =+ mapOf(+ "platform" to "android",+ "observedAtMs" to observedAtMs,+ "battery" to battery.toBatteryChannelMap(),+ "thermal" to thermal.toThermalChannelMap(),+ )++ private fun DeviceSignal<BatteryReading>.toBatteryChannelMap(): Map<String, Any?> =+ when (this) {+ is DeviceSignal.Available ->+ buildMap {+ put("status", "available")+ put("levelPercent", value.levelPercent)+ value.temperatureCelsius?.let { put("temperatureCelsius", it) }+ put("health", value.health.channelValue)+ }+ DeviceSignal.Unsupported -> mapOf("status" to "unsupported")+ is DeviceSignal.Unavailable -> unavailableChannelMap(error)+ }++ private fun DeviceSignal<ThermalState>.toThermalChannelMap(): Map<String, Any?> =+ when (this) {+ is DeviceSignal.Available ->+ mapOf("status" to "available", "state" to value.channelValue)+ DeviceSignal.Unsupported -> mapOf("status" to "unsupported")+ is DeviceSignal.Unavailable -> unavailableChannelMap(error)+ }++ private fun DeviceSignal<Long>.toMemoryChannelMap(): Map<String, Any?> =+ when (this) {+ is DeviceSignal.Available -> mapOf("status" to "available", "totalBytes" to value)+ DeviceSignal.Unsupported -> mapOf("status" to "unsupported")+ is DeviceSignal.Unavailable -> unavailableChannelMap(error)+ }++ private val BatteryHealth.channelValue: String+ get() =+ when (this) {+ BatteryHealth.GOOD -> "good"+ BatteryHealth.COLD -> "cold"+ BatteryHealth.OVERHEATING -> "overheating"+ BatteryHealth.OVER_VOLTAGE -> "overVoltage"+ BatteryHealth.DEAD -> "dead"+ BatteryHealth.FAILURE -> "failure"+ BatteryHealth.UNKNOWN -> "unknown"+ }++ private val ThermalState.channelValue: String+ get() = name.lowercase()++ private fun unavailableChannelMap(error: DeviceHealthError): Map<String, Any?> =+ mapOf("status" to "unavailable", "errorCode" to error.channelValue)++ private val DeviceHealthError.channelValue: String+ get() =+ when (this) {+ DeviceHealthError.BATTERY_INTENT_MISSING -> "battery_intent_missing"+ DeviceHealthError.BATTERY_NOT_PRESENT -> "battery_not_present"+ DeviceHealthError.BATTERY_LEVEL_MISSING -> "battery_level_missing"+ DeviceHealthError.BATTERY_ACCESS_DENIED -> "battery_access_denied"+ DeviceHealthError.BATTERY_READ_FAILED -> "battery_read_failed"+ DeviceHealthError.THERMAL_STATUS_UNKNOWN -> "thermal_status_unknown"+ DeviceHealthError.THERMAL_READ_FAILED -> "thermal_read_failed"+ DeviceHealthError.MEMORY_TOTAL_MISSING -> "memory_total_missing"+ DeviceHealthError.MEMORY_READ_FAILED -> "memory_read_failed"+ }++ private companion object {+ const val METHOD_CHANNEL = "io.ente.photos.platform"+ const val EVENT_CHANNEL = "io.ente.photos.platform/device_health_events"+ }+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthModels.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthModels.ktnew file mode 100644index 0000000000..25d2c20f02--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthModels.kt@@ -0,0 +1,64 @@+package io.ente.photos.platform.devicehealth++sealed interface DeviceSignal<out T> {+ data class Available<T>(val value: T) : DeviceSignal<T>++ data object Unsupported : DeviceSignal<Nothing>++ data class Unavailable(val error: DeviceHealthError) : DeviceSignal<Nothing>+}++enum class DeviceHealthError {+ BATTERY_INTENT_MISSING,+ BATTERY_NOT_PRESENT,+ BATTERY_LEVEL_MISSING,+ BATTERY_ACCESS_DENIED,+ BATTERY_READ_FAILED,+ THERMAL_STATUS_UNKNOWN,+ THERMAL_READ_FAILED,+ MEMORY_TOTAL_MISSING,+ MEMORY_READ_FAILED,+}++data class BatteryReading(+ val levelPercent: Int,+ val temperatureCelsius: Double?,+ val health: BatteryHealth,+) {+ init {+ require(levelPercent in 0..100) { "Battery level is outside 0..100" }+ require(temperatureCelsius == null || temperatureCelsius.isFinite()) {+ "Battery temperature is not finite"+ }+ }+}++enum class BatteryHealth {+ GOOD,+ COLD,+ OVERHEATING,+ OVER_VOLTAGE,+ DEAD,+ FAILURE,+ UNKNOWN,+}++enum class ThermalState {+ NOMINAL,+ LIGHT,+ MODERATE,+ SERIOUS,+ CRITICAL,+ EMERGENCY,+ SHUTDOWN,+}++data class DeviceHealthSnapshot(+ val observedAtMs: Long,+ val battery: DeviceSignal<BatteryReading>,+ val thermal: DeviceSignal<ThermalState>,+) {+ init {+ require(observedAtMs > 0) { "Observation time must be positive" }+ }+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthService.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthService.ktnew file mode 100644index 0000000000..ad8fb0584e--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/devicehealth/DeviceHealthService.kt@@ -0,0 +1,237 @@+package io.ente.photos.platform.devicehealth++import android.app.ActivityManager+import android.content.BroadcastReceiver+import android.content.Context+import android.content.Intent+import android.content.IntentFilter+import android.os.BatteryManager+import android.os.Build+import android.os.Handler+import android.os.Looper+import android.os.PowerManager++class DeviceHealthService(context: Context) {+ private val context = context.applicationContext+ private val mainHandler = Handler(Looper.getMainLooper())+ private var observer: ((DeviceHealthSnapshot) -> Unit)? = null+ private var receiverRegistered = false+ private var thermalListenerRegistered = false+ private var snapshotPending = false+ private var lastState: HealthState? = null++ private val batteryReceiver =+ object : BroadcastReceiver() {+ override fun onReceive(context: Context, intent: Intent) {+ scheduleSnapshot()+ }+ }++ private val thermalListener =+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {+ PowerManager.OnThermalStatusChangedListener { scheduleSnapshot() }+ } else {+ null+ }++ fun snapshot(): DeviceHealthSnapshot =+ DeviceHealthSnapshot(+ observedAtMs = System.currentTimeMillis(),+ battery = batterySnapshot(),+ thermal = thermalSnapshot(),+ )++ fun memorySnapshot(): DeviceSignal<Long> =+ try {+ val info = ActivityManager.MemoryInfo()+ context.getSystemService(ActivityManager::class.java).getMemoryInfo(info)+ if (info.totalMem > 0) {+ DeviceSignal.Available(info.totalMem)+ } else {+ DeviceSignal.Unavailable(DeviceHealthError.MEMORY_TOTAL_MISSING)+ }+ } catch (_: RuntimeException) {+ DeviceSignal.Unavailable(DeviceHealthError.MEMORY_READ_FAILED)+ }++ fun startObserving(observer: (DeviceHealthSnapshot) -> Unit) {+ requireMainThread()+ stopObserving()+ this.observer = observer+ registerBatteryReceiver()+ registerThermalListener()+ scheduleSnapshot()+ }++ fun stopObserving() {+ requireMainThread()+ observer = null+ lastState = null+ snapshotPending = false+ mainHandler.removeCallbacksAndMessages(null)+ unregisterBatteryReceiver()+ unregisterThermalListener()+ }++ private fun registerBatteryReceiver() {+ receiverRegistered =+ try {+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {+ context.registerReceiver(+ batteryReceiver,+ IntentFilter(Intent.ACTION_BATTERY_CHANGED),+ Context.RECEIVER_NOT_EXPORTED,+ )+ } else {+ @Suppress("DEPRECATION")+ context.registerReceiver(+ batteryReceiver,+ IntentFilter(Intent.ACTION_BATTERY_CHANGED),+ )+ }+ true+ } catch (_: RuntimeException) {+ false+ }+ }++ private fun registerThermalListener() {+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return+ thermalListenerRegistered =+ try {+ context.getSystemService(PowerManager::class.java)+ .addThermalStatusListener(context.mainExecutor, requireNotNull(thermalListener))+ true+ } catch (_: RuntimeException) {+ false+ }+ }++ private fun unregisterBatteryReceiver() {+ if (!receiverRegistered) return+ try {+ context.unregisterReceiver(batteryReceiver)+ } catch (_: IllegalArgumentException) {+ // The platform already removed the receiver.+ }+ receiverRegistered = false+ }++ private fun unregisterThermalListener() {+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q || !thermalListenerRegistered) return+ try {+ context.getSystemService(PowerManager::class.java)+ .removeThermalStatusListener(requireNotNull(thermalListener))+ } catch (_: RuntimeException) {+ // No observer remains during teardown.+ }+ thermalListenerRegistered = false+ }++ private fun scheduleSnapshot() {+ if (observer == null || snapshotPending) return+ snapshotPending = true+ mainHandler.post {+ snapshotPending = false+ val observer = observer ?: return@post+ val snapshot = snapshot()+ val state = HealthState(snapshot.battery, snapshot.thermal)+ if (state != lastState) {+ lastState = state+ observer(snapshot)+ }+ }+ }++ private fun batterySnapshot(): DeviceSignal<BatteryReading> {+ return try {+ val intent = stickyBatteryIntent()+ ?: return DeviceSignal.Unavailable(DeviceHealthError.BATTERY_INTENT_MISSING)+ if (!intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, true)) {+ return DeviceSignal.Unavailable(DeviceHealthError.BATTERY_NOT_PRESENT)+ }+ val level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1)+ val scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1)+ if (level < 0 || scale <= 0 || level > scale) {+ return DeviceSignal.Unavailable(DeviceHealthError.BATTERY_LEVEL_MISSING)+ }+ val temperature = intent.getIntExtra(+ BatteryManager.EXTRA_TEMPERATURE,+ Int.MIN_VALUE,+ )+ DeviceSignal.Available(+ BatteryReading(+ levelPercent = ((level.toDouble() / scale) * 100).toInt(),+ temperatureCelsius =+ temperature.takeUnless { it == Int.MIN_VALUE }?.div(10.0),+ health = batteryHealth(+ intent.getIntExtra(+ BatteryManager.EXTRA_HEALTH,+ BatteryManager.BATTERY_HEALTH_UNKNOWN,+ ),+ ),+ ),+ )+ } catch (_: SecurityException) {+ DeviceSignal.Unavailable(DeviceHealthError.BATTERY_ACCESS_DENIED)+ } catch (_: RuntimeException) {+ DeviceSignal.Unavailable(DeviceHealthError.BATTERY_READ_FAILED)+ }+ }++ private fun stickyBatteryIntent(): Intent? {+ val filter = IntentFilter(Intent.ACTION_BATTERY_CHANGED)+ return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {+ context.registerReceiver(null, filter, Context.RECEIVER_NOT_EXPORTED)+ } else {+ @Suppress("DEPRECATION")+ context.registerReceiver(null, filter)+ }+ }++ private fun thermalSnapshot(): DeviceSignal<ThermalState> {+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) return DeviceSignal.Unsupported+ return try {+ val state = thermalState(+ context.getSystemService(PowerManager::class.java).currentThermalStatus,+ ) ?: return DeviceSignal.Unavailable(DeviceHealthError.THERMAL_STATUS_UNKNOWN)+ DeviceSignal.Available(state)+ } catch (_: RuntimeException) {+ DeviceSignal.Unavailable(DeviceHealthError.THERMAL_READ_FAILED)+ }+ }++ private fun batteryHealth(value: Int): BatteryHealth =+ when (value) {+ BatteryManager.BATTERY_HEALTH_GOOD -> BatteryHealth.GOOD+ BatteryManager.BATTERY_HEALTH_COLD -> BatteryHealth.COLD+ BatteryManager.BATTERY_HEALTH_OVERHEAT -> BatteryHealth.OVERHEATING+ BatteryManager.BATTERY_HEALTH_OVER_VOLTAGE -> BatteryHealth.OVER_VOLTAGE+ BatteryManager.BATTERY_HEALTH_DEAD -> BatteryHealth.DEAD+ BatteryManager.BATTERY_HEALTH_UNSPECIFIED_FAILURE -> BatteryHealth.FAILURE+ else -> BatteryHealth.UNKNOWN+ }++ private fun thermalState(value: Int): ThermalState? =+ when (value) {+ PowerManager.THERMAL_STATUS_NONE -> ThermalState.NOMINAL+ PowerManager.THERMAL_STATUS_LIGHT -> ThermalState.LIGHT+ PowerManager.THERMAL_STATUS_MODERATE -> ThermalState.MODERATE+ PowerManager.THERMAL_STATUS_SEVERE -> ThermalState.SERIOUS+ PowerManager.THERMAL_STATUS_CRITICAL -> ThermalState.CRITICAL+ PowerManager.THERMAL_STATUS_EMERGENCY -> ThermalState.EMERGENCY+ PowerManager.THERMAL_STATUS_SHUTDOWN -> ThermalState.SHUTDOWN+ else -> null+ }++ private fun requireMainThread() {+ check(Looper.myLooper() == Looper.getMainLooper()) {+ "Device health observation must be managed from the main thread"+ }+ }++ private data class HealthState(+ val battery: DeviceSignal<BatteryReading>,+ val thermal: DeviceSignal<ThermalState>,+ )+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/.swift-format b/mobile/apps/photos/plugins/ente_photos_platform/ios/.swift-formatnew file mode 100644index 0000000000..46b20d5169--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/ios/.swift-format@@ -0,0 +1,13 @@+{+ "indentation": { "spaces": 4 },+ "lineLength": 120,+ "respectsExistingLineBreaks": true,+ "rules": {+ "AllPublicDeclarationsHaveDocumentation": false,+ "AlwaysUseLowerCamelCase": true,+ "DoNotUseSemicolons": true,+ "FileScopedDeclarationPrivacy": true,+ "NeverForceUnwrap": true,+ "NeverUseImplicitlyUnwrappedOptionals": true+ }+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthModels.swift b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthModels.swiftnew file mode 100644index 0000000000..ae20d1a2a0--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthModels.swift@@ -0,0 +1,51 @@+import Foundation++public enum DeviceSignal<Value: Equatable & Sendable>: Equatable, Sendable {+ case available(Value)+ case unsupported+ case unavailable(DeviceHealthError)+}++public enum DeviceHealthError: Equatable, Sendable {+ case batteryLevelUnavailable+ case thermalStatusUnknown+ case memoryTotalMissing+}++public struct BatteryReading: Equatable, Sendable {+ public let levelPercent: Int++ public init(levelPercent: Int) throws {+ guard (0...100).contains(levelPercent) else {+ throw DeviceHealthModelError.invalidBatteryReading+ }+ self.levelPercent = levelPercent+ }+}++public enum ThermalState: Equatable, Sendable {+ case nominal+ case moderate+ case serious+ case critical+}++public struct DeviceHealthSnapshot: Equatable, Sendable {+ public let observedAt: Date+ public let battery: DeviceSignal<BatteryReading>+ public let thermal: DeviceSignal<ThermalState>++ public init(+ observedAt: Date,+ battery: DeviceSignal<BatteryReading>,+ thermal: DeviceSignal<ThermalState>+ ) {+ self.observedAt = observedAt+ self.battery = battery+ self.thermal = thermal+ }+}++public enum DeviceHealthModelError: Error {+ case invalidBatteryReading+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthService.swift b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthService.swiftnew file mode 100644index 0000000000..a0b6e09152--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/DeviceHealthService.swift@@ -0,0 +1,125 @@+import Foundation+import UIKit++@MainActor+public final class DeviceHealthService {+ private typealias Observer = @MainActor (DeviceHealthSnapshot) -> Void++ private var observer: Observer?+ private var observerTokens: [NSObjectProtocol] = []+ private var enabledBatteryMonitoring = false+ private var lastState: HealthState?++ public init() {}++ public func snapshot() -> DeviceHealthSnapshot {+ let device = UIDevice.current+ let restoreMonitoring = !device.isBatteryMonitoringEnabled+ if restoreMonitoring {+ device.isBatteryMonitoringEnabled = true+ }+ defer {+ if restoreMonitoring {+ device.isBatteryMonitoringEnabled = false+ }+ }+ return currentSnapshot()+ }++ public func memorySnapshot() -> DeviceSignal<UInt64> {+ let totalBytes = ProcessInfo.processInfo.physicalMemory+ return totalBytes > 0+ ? .available(totalBytes)+ : .unavailable(.memoryTotalMissing)+ }++ public func startObserving(_ observer: @escaping @MainActor (DeviceHealthSnapshot) -> Void) {+ stopObserving()+ self.observer = observer++ let device = UIDevice.current+ if !device.isBatteryMonitoringEnabled {+ device.isBatteryMonitoringEnabled = true+ enabledBatteryMonitoring = true+ }++ let center = NotificationCenter.default+ observerTokens = [+ center.addObserver(+ forName: UIDevice.batteryLevelDidChangeNotification,+ object: device,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor [weak self] in self?.emitSnapshot() }+ },+ center.addObserver(+ forName: UIDevice.batteryStateDidChangeNotification,+ object: device,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor [weak self] in self?.emitSnapshot() }+ },+ center.addObserver(+ forName: ProcessInfo.thermalStateDidChangeNotification,+ object: ProcessInfo.processInfo,+ queue: .main+ ) { [weak self] _ in+ Task { @MainActor [weak self] in self?.emitSnapshot() }+ },+ ]+ emitSnapshot()+ }++ public func stopObserving() {+ observer = nil+ lastState = nil+ observerTokens.forEach(NotificationCenter.default.removeObserver)+ observerTokens.removeAll()+ if enabledBatteryMonitoring {+ UIDevice.current.isBatteryMonitoringEnabled = false+ enabledBatteryMonitoring = false+ }+ }++ private func emitSnapshot() {+ guard let observer else { return }+ let snapshot = currentSnapshot()+ let state = HealthState(battery: snapshot.battery, thermal: snapshot.thermal)+ guard state != lastState else { return }+ lastState = state+ observer(snapshot)+ }++ private func currentSnapshot() -> DeviceHealthSnapshot {+ DeviceHealthSnapshot(+ observedAt: Date(),+ battery: batterySnapshot(),+ thermal: thermalSnapshot()+ )+ }++ private func batterySnapshot() -> DeviceSignal<BatteryReading> {+ let level = UIDevice.current.batteryLevel+ guard level >= 0, level <= 1,+ let reading = try? BatteryReading(levelPercent: Int(level * 100))+ else {+ return .unavailable(.batteryLevelUnavailable)+ }+ return .available(reading)+ }++ private func thermalSnapshot() -> DeviceSignal<ThermalState> {+ switch ProcessInfo.processInfo.thermalState {+ case .nominal: .available(.nominal)+ case .fair: .available(.moderate)+ case .serious: .available(.serious)+ case .critical: .available(.critical)+ @unknown default: .unavailable(.thermalStatusUnknown)+ }+ }++ private struct HealthState: Equatable {+ let battery: DeviceSignal<BatteryReading>+ let thermal: DeviceSignal<ThermalState>+ }+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/EntePhotosPlatformPlugin.swift b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/EntePhotosPlatformPlugin.swiftdeleted file mode 100644index c7868a1ac9..0000000000--- a/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/EntePhotosPlatformPlugin.swift+++ /dev/null@@ -1,178 +0,0 @@-import Flutter-import Foundation-import UIKit--public final class EntePhotosPlatformPlugin: NSObject, FlutterPlugin, FlutterStreamHandler {- private let methodChannel: FlutterMethodChannel- private let eventChannel: FlutterEventChannel- private var eventSink: FlutterEventSink?- private var observerTokens: [NSObjectProtocol] = []- private var enabledBatteryMonitoring = false-- private init(registrar: FlutterPluginRegistrar) {- methodChannel = FlutterMethodChannel(- name: "io.ente.photos.platform",- binaryMessenger: registrar.messenger()- )- eventChannel = FlutterEventChannel(- name: "io.ente.photos.platform/device_health_events",- binaryMessenger: registrar.messenger()- )- super.init()- }-- public static func register(with registrar: FlutterPluginRegistrar) {- let instance = EntePhotosPlatformPlugin(registrar: registrar)- registrar.addMethodCallDelegate(instance, channel: instance.methodChannel)- instance.eventChannel.setStreamHandler(instance)- registrar.publish(instance)- }-- public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {- switch call.method {- case "deviceHealth.getSnapshot":- result(snapshotWithBatteryMonitoring())- case "deviceHealth.getMemorySnapshot":- result(memorySnapshot())- default:- result(FlutterMethodNotImplemented)- }- }-- public func onListen(- withArguments arguments: Any?,- eventSink events: @escaping FlutterEventSink- ) -> FlutterError? {- stopObserving()- eventSink = events- startObserving()- emitSnapshot()- return nil- }-- public func onCancel(withArguments arguments: Any?) -> FlutterError? {- eventSink = nil- stopObserving()- return nil- }-- public func detachFromEngine(for registrar: FlutterPluginRegistrar) {- eventSink = nil- stopObserving()- methodChannel.setMethodCallHandler(nil)- eventChannel.setStreamHandler(nil)- }-- private func startObserving() {- let device = UIDevice.current- if !device.isBatteryMonitoringEnabled {- device.isBatteryMonitoringEnabled = true- enabledBatteryMonitoring = true- }-- let center = NotificationCenter.default- observerTokens = [- center.addObserver(- forName: UIDevice.batteryLevelDidChangeNotification,- object: device,- queue: .main- ) { [weak self] _ in self?.emitSnapshot() },- center.addObserver(- forName: UIDevice.batteryStateDidChangeNotification,- object: device,- queue: .main- ) { [weak self] _ in self?.emitSnapshot() },- center.addObserver(- forName: ProcessInfo.thermalStateDidChangeNotification,- object: ProcessInfo.processInfo,- queue: .main- ) { [weak self] _ in self?.emitSnapshot() },- ]- }-- private func stopObserving() {- for token in observerTokens {- NotificationCenter.default.removeObserver(token)- }- observerTokens.removeAll()- if enabledBatteryMonitoring {- UIDevice.current.isBatteryMonitoringEnabled = false- enabledBatteryMonitoring = false- }- }-- private func emitSnapshot() {- guard let sink = eventSink else { return }- if Thread.isMainThread {- sink(snapshot())- } else {- DispatchQueue.main.async { [weak self] in- guard let self, let sink = self.eventSink else { return }- sink(self.snapshot())- }- }- }-- private func snapshotWithBatteryMonitoring() -> [String: Any] {- let device = UIDevice.current- let restoreMonitoring = !device.isBatteryMonitoringEnabled- if restoreMonitoring {- device.isBatteryMonitoringEnabled = true- }- defer {- if restoreMonitoring {- device.isBatteryMonitoringEnabled = false- }- }- return snapshot()- }-- private func snapshot() -> [String: Any] {- [- "platform": "ios",- "observedAtMs": Int64(Date().timeIntervalSince1970 * 1000),- "battery": batterySnapshot(),- "thermal": thermalSnapshot(),- ]- }-- private func batterySnapshot() -> [String: Any] {- let level = UIDevice.current.batteryLevel- guard level >= 0, level <= 1 else {- return unavailable("battery_level_unavailable")- }- return [- "status": "available",- "levelPercent": Int(level * 100),- ]- }-- private func thermalSnapshot() -> [String: Any] {- let state: String- switch ProcessInfo.processInfo.thermalState {- case .nominal:- state = "nominal"- case .fair:- state = "moderate"- case .serious:- state = "serious"- case .critical:- state = "critical"- @unknown default:- return unavailable("thermal_status_unknown")- }- return ["status": "available", "state": state]- }-- private func memorySnapshot() -> [String: Any] {- let totalBytes = ProcessInfo.processInfo.physicalMemory- guard totalBytes > 0 else {- return unavailable("memory_total_missing")- }- return ["status": "available", "totalBytes": Int64(totalBytes)]- }-- private func unavailable(_ errorCode: String) -> [String: Any] {- ["status": "unavailable", "errorCode": errorCode]- }-}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/PhotosPlatformPlugin.swift b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/PhotosPlatformPlugin.swiftnew file mode 100644index 0000000000..5dee8677f6--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/ios/Classes/PhotosPlatformPlugin.swift@@ -0,0 +1,147 @@+@preconcurrency import Flutter+import Foundation++@MainActor+public final class PhotosPlatformPlugin: NSObject, @preconcurrency FlutterPlugin {+ private let methodChannel: FlutterMethodChannel+ private let eventChannel: FlutterEventChannel+ private let healthService = DeviceHealthService()+ private var eventSink: FlutterEventSink?++ private init(registrar: FlutterPluginRegistrar) {+ methodChannel = FlutterMethodChannel(+ name: Self.methodChannelName,+ binaryMessenger: registrar.messenger()+ )+ eventChannel = FlutterEventChannel(+ name: Self.eventChannelName,+ binaryMessenger: registrar.messenger()+ )+ super.init()+ }++ public static func register(with registrar: FlutterPluginRegistrar) {+ let instance = PhotosPlatformPlugin(registrar: registrar)+ registrar.addMethodCallDelegate(instance, channel: instance.methodChannel)+ instance.eventChannel.setStreamHandler(instance)+ registrar.publish(instance)+ }++ public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {+ switch call.method {+ case "deviceHealth.getSnapshot":+ result(healthService.snapshot().channelValue)+ case "deviceHealth.getMemorySnapshot":+ result(healthService.memorySnapshot().memoryChannelValue)+ default:+ result(FlutterMethodNotImplemented)+ }+ }++ public func detachFromEngine(for registrar: FlutterPluginRegistrar) {+ eventSink = nil+ healthService.stopObserving()+ methodChannel.setMethodCallHandler(nil)+ eventChannel.setStreamHandler(nil)+ }++ private static let methodChannelName = "io.ente.photos.platform"+ private static let eventChannelName = "io.ente.photos.platform/device_health_events"+}++extension PhotosPlatformPlugin: @preconcurrency FlutterStreamHandler {+ public func onListen(+ withArguments arguments: Any?,+ eventSink events: @escaping FlutterEventSink+ ) -> FlutterError? {+ eventSink = events+ healthService.startObserving { [weak self] snapshot in+ self?.eventSink?(snapshot.channelValue)+ }+ return nil+ }++ public func onCancel(withArguments arguments: Any?) -> FlutterError? {+ eventSink = nil+ healthService.stopObserving()+ return nil+ }+}++private extension DeviceHealthSnapshot {+ var channelValue: [String: Any] {+ [+ "platform": "ios",+ "observedAtMs": Int64(observedAt.timeIntervalSince1970 * 1000),+ "battery": battery.batteryChannelValue,+ "thermal": thermal.thermalChannelValue,+ ]+ }+}++private extension DeviceSignal where Value == BatteryReading {+ var batteryChannelValue: [String: Any] {+ switch self {+ case .available(let reading):+ return [+ "status": "available",+ "levelPercent": reading.levelPercent,+ ]+ case .unsupported:+ return ["status": "unsupported"]+ case .unavailable(let error):+ return error.channelValue+ }+ }+}++private extension DeviceSignal where Value == ThermalState {+ var thermalChannelValue: [String: Any] {+ switch self {+ case .available(let state):+ return ["status": "available", "state": state.channelValue]+ case .unsupported:+ return ["status": "unsupported"]+ case .unavailable(let error):+ return error.channelValue+ }+ }+}++private extension DeviceSignal where Value == UInt64 {+ var memoryChannelValue: [String: Any] {+ switch self {+ case .available(let totalBytes):+ return ["status": "available", "totalBytes": Int64(totalBytes)]+ case .unsupported:+ return ["status": "unsupported"]+ case .unavailable(let error):+ return error.channelValue+ }+ }+}++private extension DeviceHealthError {+ var channelValue: [String: Any] {+ ["status": "unavailable", "errorCode": errorCode]+ }++ var errorCode: String {+ switch self {+ case .batteryLevelUnavailable: "battery_level_unavailable"+ case .thermalStatusUnknown: "thermal_status_unknown"+ case .memoryTotalMissing: "memory_total_missing"+ }+ }+}++private extension ThermalState {+ var channelValue: String {+ switch self {+ case .nominal: "nominal"+ case .moderate: "moderate"+ case .serious: "serious"+ case .critical: "critical"+ }+ }+}diff --git a/mobile/apps/photos/plugins/ente_photos_platform/ios/Package.swift b/mobile/apps/photos/plugins/ente_photos_platform/ios/Package.swiftnew file mode 100644index 0000000000..8f59a09032--- /dev/null+++ b/mobile/apps/photos/plugins/ente_photos_platform/ios/Package.swift@@ -0,0 +1,19 @@+// swift-tools-version: 5.9++import PackageDescription++let package = Package(+ name: "PhotosPlatformCore",+ platforms: [.iOS(.v15)],+ products: [+ .library(name: "PhotosPlatformCore", targets: ["PhotosPlatformCore"])+ ],+ targets: [+ .target(+ name: "PhotosPlatformCore",+ path: "Classes",+ exclude: ["PhotosPlatformPlugin.swift"]+ )+ ],+ swiftLanguageVersions: [.v5]+)diff --git a/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_health.dart b/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_health.dartindex af31c397cf..c176b22b77 100644--- a/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_health.dart+++ b/mobile/apps/photos/plugins/ente_photos_platform/lib/src/device_health.dart@@ -214,15 +214,12 @@ abstract interface class DeviceMemorySource {Future<DeviceMemorySnapshot> getMemorySnapshot();}-class EntePhotosDeviceHealth implements DeviceHealthSource, DeviceMemorySource {- EntePhotosDeviceHealth({- MethodChannel? methodChannel,- EventChannel? eventChannel,- }) : _methodChannel =- methodChannel ?? const MethodChannel(_methodChannelName),- _eventChannel = eventChannel ?? const EventChannel(_eventChannelName);-- static final instance = EntePhotosDeviceHealth();+class DeviceHealthClient implements DeviceHealthSource, DeviceMemorySource {+ DeviceHealthClient({MethodChannel? methodChannel, EventChannel? eventChannel})+ : _methodChannel = methodChannel ?? const MethodChannel(_methodChannelName),+ _eventChannel = eventChannel ?? const EventChannel(_eventChannelName);++ static final instance = DeviceHealthClient();static const _methodChannelName = 'io.ente.photos.platform';static const _eventChannelName ='io.ente.photos.platform/device_health_events';diff --git a/mobile/apps/photos/plugins/ente_photos_platform/pubspec.yaml b/mobile/apps/photos/plugins/ente_photos_platform/pubspec.yamlindex df0ce967fc..9417e6bec3 100644--- a/mobile/apps/photos/plugins/ente_photos_platform/pubspec.yaml+++ b/mobile/apps/photos/plugins/ente_photos_platform/pubspec.yaml@@ -20,6 +20,6 @@ flutter:platforms:android:package: io.ente.photos.platform- pluginClass: EntePhotosPlatformPlugin+ pluginClass: PhotosPlatformPluginios:- pluginClass: EntePhotosPlatformPlugin+ pluginClass: PhotosPlatformPlugindiff --git a/mobile/apps/photos/plugins/ente_photos_platform/test/device_health_test.dart b/mobile/apps/photos/plugins/ente_photos_platform/test/device_health_test.dartindex 777b8ecba6..01d38d611f 100644--- a/mobile/apps/photos/plugins/ente_photos_platform/test/device_health_test.dart+++ b/mobile/apps/photos/plugins/ente_photos_platform/test/device_health_test.dart@@ -94,7 +94,7 @@ void main() {.setMockMethodCallHandler(channel, null),);- final source = EntePhotosDeviceHealth(methodChannel: channel);+ final source = DeviceHealthClient(methodChannel: channel);expect((await source.getSnapshot()).battery.levelPercent, 64);expect((await source.getMemorySnapshot()).totalBytes,