• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


コミットメタ情報

リビジョン4bf95a18453b01eb0075514249412c11c7a998bc (tree)
日時2019-12-01 09:19:12
作者android-build-team Robot <android-build-team-robot@goog...>
コミッターandroid-build-team Robot

ログメッセージ

Snap for 6041579 from fa6b70419dcdafca30611176df329f9feee07551 to qt-qpr2-release

Change-Id: I97dea43972bfa6991c4d058627dae718ffec3748

変更サマリ

差分

--- a/bta/hearing_aid/hearing_aid.cc
+++ b/bta/hearing_aid/hearing_aid.cc
@@ -1012,13 +1012,16 @@ class HearingAidImpl : public HearingAid {
10121012 }
10131013 }
10141014
1015- void OnAudioSuspend() {
1015+ void OnAudioSuspend(const std::function<void()>& stop_audio_ticks) {
1016+ CHECK(stop_audio_ticks) << "stop_audio_ticks is empty";
1017+
10161018 if (!audio_running) {
10171019 LOG(WARNING) << __func__ << ": Unexpected audio suspend";
10181020 } else {
10191021 LOG(INFO) << __func__ << ": audio_running=" << audio_running;
10201022 }
10211023 audio_running = false;
1024+ stop_audio_ticks();
10221025
10231026 std::vector<uint8_t> stop({CONTROL_POINT_OP_STOP});
10241027 for (auto& device : hearingDevices.devices) {
@@ -1039,23 +1042,33 @@ class HearingAidImpl : public HearingAid {
10391042 }
10401043 }
10411044
1042- void OnAudioResume() {
1045+ void OnAudioResume(const std::function<void()>& start_audio_ticks) {
1046+ CHECK(start_audio_ticks) << "start_audio_ticks is empty";
1047+
10431048 if (audio_running) {
10441049 LOG(ERROR) << __func__ << ": Unexpected Audio Resume";
10451050 } else {
10461051 LOG(INFO) << __func__ << ": audio_running=" << audio_running;
10471052 }
1048- audio_running = true;
1053+
1054+ for (auto& device : hearingDevices.devices) {
1055+ if (!device.accepting_audio) continue;
1056+ audio_running = true;
1057+ SendStart(&device);
1058+ }
1059+
1060+ if (!audio_running) {
1061+ LOG(INFO) << __func__ << ": No device (0/" << GetDeviceCount()
1062+ << ") ready to start";
1063+ return;
1064+ }
10491065
10501066 // TODO: shall we also reset the encoder ?
10511067 encoder_state_release();
10521068 encoder_state_init();
10531069 seq_counter = 0;
10541070
1055- for (auto& device : hearingDevices.devices) {
1056- if (!device.accepting_audio) continue;
1057- SendStart(&device);
1058- }
1071+ start_audio_ticks();
10591072 }
10601073
10611074 uint8_t GetOtherSideStreamStatus(HearingDevice* this_side_device) {
@@ -1147,10 +1160,9 @@ class HearingAidImpl : public HearingAid {
11471160 }
11481161
11491162 if (left == nullptr && right == nullptr) {
1150- HearingAidAudioSource::Stop();
1151- audio_running = false;
1152- encoder_state_release();
1153- current_volume = VOLUME_UNKNOWN;
1163+ LOG(WARNING) << __func__ << ": No more (0/" << GetDeviceCount()
1164+ << ") devices ready";
1165+ DoDisconnectAudioStop();
11541166 return;
11551167 }
11561168
@@ -1463,8 +1475,17 @@ class HearingAidImpl : public HearingAid {
14631475
14641476 hearingDevices.Remove(address);
14651477
1466- if (connected)
1467- callbacks->OnConnectionState(ConnectionState::DISCONNECTED, address);
1478+ if (!connected) {
1479+ return;
1480+ }
1481+
1482+ callbacks->OnConnectionState(ConnectionState::DISCONNECTED, address);
1483+ for (const auto& device : hearingDevices.devices) {
1484+ if (device.accepting_audio) return;
1485+ }
1486+ LOG(INFO) << __func__ << ": No more (0/" << GetDeviceCount()
1487+ << ") devices ready";
1488+ DoDisconnectAudioStop();
14681489 }
14691490
14701491 void OnGattDisconnected(tGATT_STATUS status, uint16_t conn_id,
@@ -1486,7 +1507,16 @@ class HearingAidImpl : public HearingAid {
14861507
14871508 DoDisconnectCleanUp(hearingDevice);
14881509
1510+ // Keep this hearing aid in the list, and allow to reconnect back.
1511+
14891512 callbacks->OnConnectionState(ConnectionState::DISCONNECTED, remote_bda);
1513+
1514+ for (const auto& device : hearingDevices.devices) {
1515+ if (device.accepting_audio) return;
1516+ }
1517+ LOG(INFO) << __func__ << ": No more (0/" << GetDeviceCount()
1518+ << ") devices ready";
1519+ DoDisconnectAudioStop();
14901520 }
14911521
14921522 void DoDisconnectCleanUp(HearingDevice* hearingDevice) {
@@ -1519,6 +1549,13 @@ class HearingAidImpl : public HearingAid {
15191549 hearingDevice->command_acked = false;
15201550 }
15211551
1552+ void DoDisconnectAudioStop() {
1553+ HearingAidAudioSource::Stop();
1554+ audio_running = false;
1555+ encoder_state_release();
1556+ current_volume = VOLUME_UNKNOWN;
1557+ }
1558+
15221559 void SetVolume(int8_t volume) override {
15231560 VLOG(2) << __func__ << ": " << +volume;
15241561 current_volume = volume;
@@ -1730,14 +1767,11 @@ class HearingAidAudioReceiverImpl : public HearingAidAudioReceiver {
17301767 void OnAudioDataReady(const std::vector<uint8_t>& data) override {
17311768 if (instance) instance->OnAudioDataReady(data);
17321769 }
1733- void OnAudioSuspend(std::promise<void> do_suspend_promise) override {
1734- if (instance) instance->OnAudioSuspend();
1735- do_suspend_promise.set_value();
1770+ void OnAudioSuspend(const std::function<void()>& stop_audio_ticks) override {
1771+ if (instance) instance->OnAudioSuspend(stop_audio_ticks);
17361772 }
1737-
1738- void OnAudioResume(std::promise<void> do_resume_promise) override {
1739- if (instance) instance->OnAudioResume();
1740- do_resume_promise.set_value();
1773+ void OnAudioResume(const std::function<void()>& start_audio_ticks) override {
1774+ if (instance) instance->OnAudioResume(start_audio_ticks);
17411775 }
17421776 };
17431777
--- a/bta/hearing_aid/hearing_aid_audio_source.cc
+++ b/bta/hearing_aid/hearing_aid_audio_source.cc
@@ -97,12 +97,20 @@ void hearing_aid_send_ack(tHEARING_AID_CTRL_ACK status) {
9797 }
9898
9999 void start_audio_ticks() {
100+ if (data_interval_ms != HA_INTERVAL_10_MS &&
101+ data_interval_ms != HA_INTERVAL_20_MS) {
102+ LOG(FATAL) << " Unsupported data interval: " << data_interval_ms;
103+ }
104+
100105 wakelock_acquire();
101- audio_timer.SchedulePeriodic(get_main_thread()->GetWeakPtr(), FROM_HERE, base::Bind(&send_audio_data),
102- base::TimeDelta::FromMilliseconds(data_interval_ms));
106+ audio_timer.SchedulePeriodic(
107+ get_main_thread()->GetWeakPtr(), FROM_HERE, base::Bind(&send_audio_data),
108+ base::TimeDelta::FromMilliseconds(data_interval_ms));
109+ LOG(INFO) << __func__ << ": running with data interval: " << data_interval_ms;
103110 }
104111
105112 void stop_audio_ticks() {
113+ LOG(INFO) << __func__ << ": stopped";
106114 audio_timer.CancelAndWait();
107115 wakelock_release();
108116 }
@@ -121,17 +129,12 @@ void hearing_aid_data_cb(tUIPC_CH_ID, tUIPC_EVENT event) {
121129 UIPC_Ioctl(*uipc_hearing_aid, UIPC_CH_ID_AV_AUDIO, UIPC_SET_READ_POLL_TMO,
122130 reinterpret_cast<void*>(0));
123131
124- if (data_interval_ms != HA_INTERVAL_10_MS &&
125- data_interval_ms != HA_INTERVAL_20_MS) {
126- LOG(FATAL) << " Unsupported data interval: " << data_interval_ms;
127- }
128-
129- start_audio_ticks();
132+ do_in_main_thread(FROM_HERE, base::BindOnce(start_audio_ticks));
130133 break;
131134 case UIPC_CLOSE_EVT:
132135 LOG(INFO) << __func__ << ": UIPC_CLOSE_EVT";
133136 hearing_aid_send_ack(HEARING_AID_CTRL_ACK_SUCCESS);
134- stop_audio_ticks();
137+ do_in_main_thread(FROM_HERE, base::BindOnce(stop_audio_ticks));
135138 break;
136139 default:
137140 LOG(ERROR) << "Hearing Aid audio data event not recognized:" << event;
@@ -306,65 +309,52 @@ void hearing_aid_ctrl_cb(tUIPC_CH_ID, tUIPC_EVENT event) {
306309 }
307310
308311 bool hearing_aid_on_resume_req(bool start_media_task) {
309- // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_START)
310- if (localAudioReceiver != nullptr) {
311- // Call OnAudioResume and block till it returns.
312- std::promise<void> do_resume_promise;
313- std::future<void> do_resume_future = do_resume_promise.get_future();
314- bt_status_t status = do_in_main_thread(
315- FROM_HERE, base::BindOnce(&HearingAidAudioReceiver::OnAudioResume,
316- base::Unretained(localAudioReceiver),
317- std::move(do_resume_promise)));
318- if (status == BT_STATUS_SUCCESS) {
319- do_resume_future.wait();
320- } else {
321- LOG(ERROR) << __func__
322- << ": HEARING_AID_CTRL_CMD_START: do_in_main_thread err="
323- << status;
324- return false;
325- }
326- } else {
312+ if (localAudioReceiver == nullptr) {
327313 LOG(ERROR) << __func__
328314 << ": HEARING_AID_CTRL_CMD_START: audio receiver not started";
329315 return false;
330316 }
331-
332- // hearing_aid_data_cb(UIPC_OPEN_EVT): start_media_task
317+ bt_status_t status;
333318 if (start_media_task) {
334- if (data_interval_ms != HA_INTERVAL_10_MS &&
335- data_interval_ms != HA_INTERVAL_20_MS) {
336- LOG(FATAL) << " Unsupported data interval: " << data_interval_ms;
337- data_interval_ms = HA_INTERVAL_10_MS;
338- }
339- start_audio_ticks();
319+ status = do_in_main_thread(
320+ FROM_HERE, base::BindOnce(&HearingAidAudioReceiver::OnAudioResume,
321+ base::Unretained(localAudioReceiver),
322+ start_audio_ticks));
323+ } else {
324+ auto start_dummy_ticks = []() {
325+ LOG(INFO) << "start_audio_ticks: waiting for data path opened";
326+ };
327+ status = do_in_main_thread(
328+ FROM_HERE, base::BindOnce(&HearingAidAudioReceiver::OnAudioResume,
329+ base::Unretained(localAudioReceiver),
330+ start_dummy_ticks));
331+ }
332+ if (status != BT_STATUS_SUCCESS) {
333+ LOG(ERROR) << __func__
334+ << ": HEARING_AID_CTRL_CMD_START: do_in_main_thread err="
335+ << status;
336+ return false;
340337 }
341338 return true;
342339 }
343340
344341 bool hearing_aid_on_suspend_req() {
345- // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_SUSPEND): stop_media_task
346- stop_audio_ticks();
347- if (localAudioReceiver != nullptr) {
348- // Call OnAudioSuspend and block till it returns.
349- std::promise<void> do_suspend_promise;
350- std::future<void> do_suspend_future = do_suspend_promise.get_future();
351- bt_status_t status = do_in_main_thread(
352- FROM_HERE, base::BindOnce(&HearingAidAudioReceiver::OnAudioSuspend,
353- base::Unretained(localAudioReceiver),
354- std::move(do_suspend_promise)));
355- if (status == BT_STATUS_SUCCESS) {
356- do_suspend_future.wait();
357- return true;
358- } else {
359- LOG(ERROR) << __func__
360- << ": HEARING_AID_CTRL_CMD_SUSPEND: do_in_main_thread err="
361- << status;
362- }
363- } else {
342+ if (localAudioReceiver == nullptr) {
364343 LOG(ERROR) << __func__
365344 << ": HEARING_AID_CTRL_CMD_SUSPEND: audio receiver not started";
345+ return false;
366346 }
367- return false;
347+ bt_status_t status = do_in_main_thread(
348+ FROM_HERE,
349+ base::BindOnce(&HearingAidAudioReceiver::OnAudioSuspend,
350+ base::Unretained(localAudioReceiver), stop_audio_ticks));
351+ if (status != BT_STATUS_SUCCESS) {
352+ LOG(ERROR) << __func__
353+ << ": HEARING_AID_CTRL_CMD_SUSPEND: do_in_main_thread err="
354+ << status;
355+ return false;
356+ }
357+ return true;
368358 }
369359 } // namespace
370360
--- a/bta/include/bta_hearing_aid_api.h
+++ b/bta/include/bta_hearing_aid_api.h
@@ -21,7 +21,6 @@
2121 #include <base/callback_forward.h>
2222 #include <hardware/bt_hearing_aid.h>
2323 #include <deque>
24-#include <future>
2524 #include <vector>
2625
2726 constexpr uint16_t HEARINGAID_MAX_NUM_UUIDS = 1;
@@ -39,8 +38,22 @@ class HearingAidAudioReceiver {
3938 public:
4039 virtual ~HearingAidAudioReceiver() = default;
4140 virtual void OnAudioDataReady(const std::vector<uint8_t>& data) = 0;
42- virtual void OnAudioSuspend(std::promise<void> do_suspend_promise) = 0;
43- virtual void OnAudioResume(std::promise<void> do_resume_promise) = 0;
41+
42+ // API to stop our feeding timer, and notify hearing aid devices that the
43+ // streaming would stop, too.
44+ //
45+ // @param stop_audio_ticks a callable function calls out to stop the media
46+ // timer for reading data.
47+ virtual void OnAudioSuspend(
48+ const std::function<void()>& stop_audio_ticks) = 0;
49+
50+ // To notify hearing aid devices to be ready for streaming, and start the
51+ // media timer to feed the audio data.
52+ //
53+ // @param start_audio_ticks a callable function calls out to start a periodic
54+ // timer for feeding data from the audio HAL.
55+ virtual void OnAudioResume(
56+ const std::function<void()>& start_audio_ticks) = 0;
4457 };
4558
4659 // Number of rssi reads to attempt when requested
--- a/stack/btm/btm_acl.cc
+++ b/stack/btm/btm_acl.cc
@@ -1085,7 +1085,7 @@ void btm_read_remote_features_complete(uint8_t* p) {
10851085 * Returns void
10861086 *
10871087 ******************************************************************************/
1088-void btm_read_remote_ext_features_complete(uint8_t* p) {
1088+void btm_read_remote_ext_features_complete(uint8_t* p, uint8_t evt_len) {
10891089 tACL_CONN* p_acl_cb;
10901090 uint8_t page_num, max_page;
10911091 uint16_t handle;
@@ -1093,6 +1093,14 @@ void btm_read_remote_ext_features_complete(uint8_t* p) {
10931093
10941094 BTM_TRACE_DEBUG("btm_read_remote_ext_features_complete");
10951095
1096+ if (evt_len < HCI_EXT_FEATURES_SUCCESS_EVT_LEN) {
1097+ android_errorWriteLog(0x534e4554, "141552859");
1098+ BTM_TRACE_ERROR(
1099+ "btm_read_remote_ext_features_complete evt length too short. length=%d",
1100+ evt_len);
1101+ return;
1102+ }
1103+
10961104 ++p;
10971105 STREAM_TO_UINT16(handle, p);
10981106 STREAM_TO_UINT8(page_num, p);
@@ -1112,6 +1120,19 @@ void btm_read_remote_ext_features_complete(uint8_t* p) {
11121120 return;
11131121 }
11141122
1123+ if (page_num > HCI_EXT_FEATURES_PAGE_MAX) {
1124+ android_errorWriteLog(0x534e4554, "141552859");
1125+ BTM_TRACE_ERROR("btm_read_remote_ext_features_complete num_page=%d invalid",
1126+ page_num);
1127+ return;
1128+ }
1129+
1130+ if (page_num > max_page) {
1131+ BTM_TRACE_WARNING(
1132+ "btm_read_remote_ext_features_complete num_page=%d, max_page=%d "
1133+ "invalid", page_num, max_page);
1134+ }
1135+
11151136 p_acl_cb = &btm_cb.acl_db[acl_idx];
11161137
11171138 /* Copy the received features page */
--- a/stack/btm/btm_int.h
+++ b/stack/btm/btm_int.h
@@ -119,7 +119,7 @@ extern uint16_t btm_get_acl_disc_reason_code(void);
119119 extern tBTM_STATUS btm_remove_acl(const RawAddress& bd_addr,
120120 tBT_TRANSPORT transport);
121121 extern void btm_read_remote_features_complete(uint8_t* p);
122-extern void btm_read_remote_ext_features_complete(uint8_t* p);
122+extern void btm_read_remote_ext_features_complete(uint8_t* p, uint8_t evt_len);
123123 extern void btm_read_remote_ext_features_failed(uint8_t status,
124124 uint16_t handle);
125125 extern void btm_read_remote_version_complete(uint8_t* p);
--- a/stack/btu/btu_hcif.cc
+++ b/stack/btu/btu_hcif.cc
@@ -75,7 +75,8 @@ static void btu_hcif_authentication_comp_evt(uint8_t* p);
7575 static void btu_hcif_rmt_name_request_comp_evt(uint8_t* p, uint16_t evt_len);
7676 static void btu_hcif_encryption_change_evt(uint8_t* p);
7777 static void btu_hcif_read_rmt_features_comp_evt(uint8_t* p);
78-static void btu_hcif_read_rmt_ext_features_comp_evt(uint8_t* p);
78+static void btu_hcif_read_rmt_ext_features_comp_evt(uint8_t* p,
79+ uint8_t evt_len);
7980 static void btu_hcif_read_rmt_version_comp_evt(uint8_t* p);
8081 static void btu_hcif_qos_setup_comp_evt(uint8_t* p);
8182 static void btu_hcif_command_complete_evt(BT_HDR* response, void* context);
@@ -295,7 +296,7 @@ void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id, BT_HDR* p_msg) {
295296 btu_hcif_read_rmt_features_comp_evt(p);
296297 break;
297298 case HCI_READ_RMT_EXT_FEATURES_COMP_EVT:
298- btu_hcif_read_rmt_ext_features_comp_evt(p);
299+ btu_hcif_read_rmt_ext_features_comp_evt(p, hci_evt_len);
299300 break;
300301 case HCI_READ_RMT_VERSION_COMP_EVT:
301302 btu_hcif_read_rmt_version_comp_evt(p);
@@ -1211,7 +1212,8 @@ static void btu_hcif_read_rmt_features_comp_evt(uint8_t* p) {
12111212 * Returns void
12121213 *
12131214 ******************************************************************************/
1214-static void btu_hcif_read_rmt_ext_features_comp_evt(uint8_t* p) {
1215+static void btu_hcif_read_rmt_ext_features_comp_evt(uint8_t* p,
1216+ uint8_t evt_len) {
12151217 uint8_t* p_cur = p;
12161218 uint8_t status;
12171219 uint16_t handle;
@@ -1219,7 +1221,7 @@ static void btu_hcif_read_rmt_ext_features_comp_evt(uint8_t* p) {
12191221 STREAM_TO_UINT8(status, p_cur);
12201222
12211223 if (status == HCI_SUCCESS)
1222- btm_read_remote_ext_features_complete(p);
1224+ btm_read_remote_ext_features_complete(p, evt_len);
12231225 else {
12241226 STREAM_TO_UINT16(handle, p_cur);
12251227 btm_read_remote_ext_features_failed(status, handle);
--- a/stack/include/hcidefs.h
+++ b/stack/include/hcidefs.h
@@ -1323,6 +1323,8 @@ typedef struct {
13231323
13241324 #define HCI_FEATURE_BYTES_PER_PAGE 8
13251325
1326+#define HCI_EXT_FEATURES_SUCCESS_EVT_LEN 13
1327+
13261328 #define HCI_FEATURES_KNOWN(x) \
13271329 (((x)[0] | (x)[1] | (x)[2] | (x)[3] | (x)[4] | (x)[5] | (x)[6] | (x)[7]) != 0)
13281330