voice: fix incorrect usecase type reported to sthal

To ensure correct usecase type can be reported to sthal
when staring voice call, set the call state early
before reporting device event to sthal, and reset the
call flag after event reported.

Change-Id: I5f7bc0ffefc49d9c706c9067eba5df4e84702ec9
diff --git a/hal/voice.c b/hal/voice.c
index fdca74a..230ceed 100644
--- a/hal/voice.c
+++ b/hal/voice.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2021, The Linux Foundation. All rights reserved.
  * Not a contribution.
  *
  * Copyright (C) 2013 The Android Open Source Project
@@ -204,6 +204,7 @@
     disable_snd_device(adev, uc_info->in_snd_device);
 
     adev->voice.lte_call = false;
+    adev->voice.in_call = false;
 
     list_remove(&uc_info->list);
     free(uc_info);
@@ -244,6 +245,8 @@
         return -ENOMEM;
     }
 
+    adev->voice.in_call = true;
+
     uc_info->id = usecase_id;
     uc_info->type = VOICE_CALL;
     uc_info->stream.out = adev->current_call_output;
@@ -263,7 +266,6 @@
 
     if (is_sco_out_device_type(&uc_info->device_list) && !adev->bt_sco_on) {
         ALOGE("start_call: couldn't find BT SCO, SCO is not ready");
-        adev->voice.in_call = false;
         ret = -EIO;
         goto error_start_voice;
     }
@@ -725,12 +727,12 @@
 {
     int ret = 0;
 
-    adev->voice.in_call = false;
     ret = voice_extn_stop_call(adev);
     if (ret == -ENOSYS) {
         ret = voice_stop_usecase(adev, USECASE_VOICE_CALL);
     }
 
+    adev->voice.in_call = false;
     return ret;
 }