feat(android): add home screen battery and status widget (#7150)
TH
2mo ago+385+385+012345678901234567890123456789-6-6-0123456789
Summary
Fixes #7150
Adds a native Android Home Screen Widget (OmiBatteryWidgetProvider) displaying live Omi device connection status, battery percentage, and microphone mute state, achieving feature parity with the iOS BatteryWidget.
Key Changes
- Android AppWidget Implementation:
- Added
OmiBatteryWidgetProviderinapp/android/app/src/main/kotlin/com/friend/ios/widget/OmiBatteryWidgetProvider.kt. - Created RemoteViews widget layout (
res/layout/omi_battery_widget.xml) featuring Omi logo, device name, battery percentage indicator, and mic/mute status icon. - Added vector drawables
ic_widget_mic.xmlandic_widget_mic_off.xmlwith neutral dark theme backgroundwidget_background.xml(no purple, conforming strictly with brand invariants). - Configured appwidget provider info in
res/xml/omi_battery_widget_info.xml. - Registered widget receiver in
AndroidManifest.xml.
- Added
- Native Bridge:
- Handled
com.omi.battery_widgetMethodChannelinMainActivity.ktforupdateBatteryInfoandupdateMuteState, safely parsing battery numbers and triggeringAppWidgetManagerredraws.
- Handled
- Dart Service:
- Updated
BatteryWidgetServiceinapp/lib/services/battery_widget_service.dartto support both iOS and Android platforms (if (!Platform.isIOS && !Platform.isAndroid) return;).
- Updated
- Hermetic Testing:
- Added unit tests in
app/test/unit/battery_widget_service_test.dartverifying singleton guarantees, channel invocations, and graceful exception resilience.
- Added unit tests in
Verification & Testing
- Unit Tests (
app/test/unit/battery_widget_service_test.dart):BatteryWidgetService singleton instance returns identical reference: PASSEDBatteryWidgetService updateBatteryInfo invokes method channel with correct arguments: PASSEDBatteryWidgetService updateMuteState executes safely: PASSEDBatteryWidgetService recovers safely from channel platform exceptions without throwing: PASSED
- Static Analysis:
flutter analyzeon modified Dart files: 0 issues found.
- Preflight Gate:
scripts/pr-preflightverified cleanly.
Failure-Class: none
PayPal: rwilcox413@gmail.com