feat(android): add home screen battery and status widget (#7150)

TH
2mo ago
+385-6

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

  1. Android AppWidget Implementation:
    • Added OmiBatteryWidgetProvider in app/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.xml and ic_widget_mic_off.xml with neutral dark theme background widget_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.
  2. Native Bridge:
    • Handled com.omi.battery_widget MethodChannel in MainActivity.kt for updateBatteryInfo and updateMuteState, safely parsing battery numbers and triggering AppWidgetManager redraws.
  3. Dart Service:
    • Updated BatteryWidgetService in app/lib/services/battery_widget_service.dart to support both iOS and Android platforms (if (!Platform.isIOS && !Platform.isAndroid) return;).
  4. Hermetic Testing:
    • Added unit tests in app/test/unit/battery_widget_service_test.dart verifying singleton guarantees, channel invocations, and graceful exception resilience.

Verification & Testing

  • Unit Tests (app/test/unit/battery_widget_service_test.dart):
    • BatteryWidgetService singleton instance returns identical reference: PASSED
    • BatteryWidgetService updateBatteryInfo invokes method channel with correct arguments: PASSED
    • BatteryWidgetService updateMuteState executes safely: PASSED
    • BatteryWidgetService recovers safely from channel platform exceptions without throwing: PASSED
  • Static Analysis:
    • flutter analyze on modified Dart files: 0 issues found.
  • Preflight Gate:
    • scripts/pr-preflight verified cleanly.

Failure-Class: none
PayPal: rwilcox413@gmail.com