Does anyone have a code snippet giving the CPU clock speed on an Android device?
Reason
I have written an Wear OS App using the watch GPS to calculate Speed and Bearing to a (pre-entered) GPS location. The problem I am experiencing is after some random time period the GPS stops providing updates.
I am running the App on a Samsung Galaxy Watch 4 and assume the reliability issue is related to the reported overheating issues with Samsung's latest watch
A fellow crew member suggested I try using the CPU clock speed to detect overheating. He points out many modern mobile devices lower their CPU clock speed when they detect they are getting too hot.
I hope to use CPU clock as an early warning of overheating. I can then slow down the rate of GPS updates allowing the App to retain reduced functionality which is far better than totally losing the GPS.
So can anyone provide a code snippet giving the CPU clock speed on an Android device?
EDIT #1
It is possible to obtain the thermal state of the CPU directly using the following code snippet
val powerManager = getSystemService(Context.POWER_SERVICE) as PowerManager
val thermalState = powerManager.currentThermalStatus
/* Values
THERMAL_STATUS_NONE,
THERMAL_STATUS_LIGHT,
THERMAL_STATUS_MODERATE,
THERMAL_STATUS_SEVERE,
THERMAL_STATUS_CRITICAL,
THERMAL_STATUS_EMERGENCY,
THERMAL_STATUS_SHUTDOWN,
*/
EDIT #2
The current working theory is this is probably not a watch overheating issue but a separate Galaxy Watch 4 "feature". Despite specifying the App as standalone the GPS updates stop when the connection with the phone is lost as discussed here
Notes:
I looked at measuring the execution time of the GPS calculations but this varies depending on the current heading. This is due to the need to handle "wrap" when averaging bearings, e.g. the average of a bearing of 3degrees and 359degrees is 1 degree (not 181degrees!)
Code available from Small Kotlin demo ACCESS_FINE_LOCATION