batteryLevelPercent static method
Converts a raw battery level, as reported by the SDK, to a percentage (0–100).
iOS reports a packed value (percentage in the second byte), while Android reports the percentage directly. This method normalizes both.
Implementation
static int batteryLevelPercent(int raw) {
if (raw > 0xFF) {
return (raw >> 8) & 0xFF;
}
return raw;
}