fix(ota): block business interactions during updates
This commit is contained in:
@@ -145,6 +145,7 @@ bool control_plane_local_wake_prompt_gate_active(void);
|
|||||||
void control_plane_ptt_reset_capture_window(void);
|
void control_plane_ptt_reset_capture_window(void);
|
||||||
bool control_plane_voice_turn_is_idle(void);
|
bool control_plane_voice_turn_is_idle(void);
|
||||||
bool control_plane_ota_voice_services_allowed(void);
|
bool control_plane_ota_voice_services_allowed(void);
|
||||||
|
bool control_plane_ota_business_interactions_allowed(void);
|
||||||
bool control_plane_runtime_is_stopping(void);
|
bool control_plane_runtime_is_stopping(void);
|
||||||
|
|
||||||
esp_err_t control_plane_battery_service_stop(int timeout_ms);
|
esp_err_t control_plane_battery_service_stop(int timeout_ms);
|
||||||
|
|||||||
@@ -686,6 +686,10 @@ esp_err_t control_plane_multimodal_request_to_respond(
|
|||||||
|
|
||||||
esp_err_t control_plane_request_cloud_chouqian(void)
|
esp_err_t control_plane_request_cloud_chouqian(void)
|
||||||
{
|
{
|
||||||
|
if (!control_plane_ota_business_interactions_allowed()) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t requested_ms = control_plane_now_ms();
|
uint32_t requested_ms = control_plane_now_ms();
|
||||||
|
|
||||||
portENTER_CRITICAL(&s_multimodal_runtime_lock);
|
portENTER_CRITICAL(&s_multimodal_runtime_lock);
|
||||||
|
|||||||
@@ -140,6 +140,17 @@ bool control_plane_ota_voice_services_allowed(void)
|
|||||||
return allowed;
|
return allowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool control_plane_ota_business_interactions_allowed(void)
|
||||||
|
{
|
||||||
|
bool allowed;
|
||||||
|
portENTER_CRITICAL(&s_ota_lock);
|
||||||
|
allowed = !s_ota_voice_services_reserved &&
|
||||||
|
s_ota_snapshot.state != CONTROL_PLANE_OTA_STATE_DOWNLOADING &&
|
||||||
|
s_ota_snapshot.state != CONTROL_PLANE_OTA_STATE_READY_TO_REBOOT;
|
||||||
|
portEXIT_CRITICAL(&s_ota_lock);
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
|
||||||
static void control_plane_ota_set_state(control_plane_ota_state_t state,
|
static void control_plane_ota_set_state(control_plane_ota_state_t state,
|
||||||
esp_err_t error,
|
esp_err_t error,
|
||||||
int http_status)
|
int http_status)
|
||||||
|
|||||||
@@ -688,6 +688,11 @@ static void control_plane_set_ptt_active_with_trigger(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!control_plane_ota_business_interactions_allowed()) {
|
||||||
|
ESP_LOGI(TAG, "PTT activation ignored during OTA");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
control_plane_local_wake_pause_for_foreground();
|
control_plane_local_wake_pause_for_foreground();
|
||||||
ptt_state_t old_state = PTT_STATE_IDLE;
|
ptt_state_t old_state = PTT_STATE_IDLE;
|
||||||
ptt_state_t new_state = PTT_STATE_IDLE;
|
ptt_state_t new_state = PTT_STATE_IDLE;
|
||||||
|
|||||||
@@ -140,6 +140,20 @@ static void control_plane_dispatch_key_event(const control_plane_key_event_t *ev
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!control_plane_ota_business_interactions_allowed()) {
|
||||||
|
if (event->key_id == CONTROL_PLANE_KEY_ID_PTT &&
|
||||||
|
(event->type == CONTROL_PLANE_KEY_EVENT_RELEASED ||
|
||||||
|
event->type == CONTROL_PLANE_KEY_EVENT_LONG_PRESS_RELEASE ||
|
||||||
|
event->type == CONTROL_PLANE_KEY_EVENT_CANCELLED)) {
|
||||||
|
control_plane_set_ptt_active(false);
|
||||||
|
}
|
||||||
|
ESP_LOGI(TAG,
|
||||||
|
"Business key ignored during OTA: key=%s type=%s",
|
||||||
|
control_plane_key_id_name(event->key_id),
|
||||||
|
control_plane_key_event_type_name(event->type));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event->key_id == CONTROL_PLANE_KEY_ID_SW2) {
|
if (event->key_id == CONTROL_PLANE_KEY_ID_SW2) {
|
||||||
if (event->type == CONTROL_PLANE_KEY_EVENT_SHORT_PRESS) {
|
if (event->type == CONTROL_PLANE_KEY_EVENT_SHORT_PRESS) {
|
||||||
esp_err_t request_err = control_plane_request_cloud_chouqian();
|
esp_err_t request_err = control_plane_request_cloud_chouqian();
|
||||||
|
|||||||
Reference in New Issue
Block a user