# OTA upgrade

## Purpose

Show how the phone checks glass firmware versions, stages transport lanes, downloads payloads, and manages long-running OTA UI state.

## Entry points

Phone home:

- `MainPhoneActivity` → `SystemOtaActivity`

Settings:

- `SettingActivity` → `SystemOtaActivity`

Sample Activity:

- `com.rokid.phone.system.ui.SystemOtaActivity`

## Platform

- Phone

## Main files

- [SystemOtaActivity.kt](https://gitee.com/as_pixar/glass3sdkdemo/blob/main/glass3sdkphonedemo/app/src/main/java/com/rokid/phone/system/ui/SystemOtaActivity.kt)
- [OtaManager.kt](https://gitee.com/as_pixar/glass3sdkdemo/blob/main/glass3sdkphonedemo/app/src/main/java/com/rokid/phone/system/OtaManager.kt)
- [SystemViewModel.kt](https://gitee.com/as_pixar/glass3sdkdemo/blob/main/glass3sdkphonedemo/app/src/main/java/com/rokid/phone/system/viewmodel/SystemViewModel.kt)

## Flow

1. Pull current device metadata on launch.  
2. User taps **Check for update**.  
3. Preconditions: charging, network, BT link, no concurrent OTA.  
4. When updates exist: prep P2P, download payload, push update bundle / command.  
5. UI reflects multi-phase state machine with progress text.

## FAQs

### Why both Bluetooth and P2P must be healthy

Bluetooth carries control / heartbeats; P2P moves large binaries—OTA uses both.

### Why charging is mandatory

Guardrail against mid-flash power loss.

## Caveats

- Heavy debounce + duplicate-click guards—read carefully before extending.  
- Back navigation consults OTA stage to avoid aborting critical steps.  
- Among the most stateful screens in the repo; consider splitting future docs into “check”, “download”, “push”, “telemetry” sub-chapters.
