diff options
author | David Duarte <licorne@google.com> | 2022-11-28 19:07:43 +0000 |
---|---|---|
committer | Thomas Girardier <girardier@google.com> | 2022-12-13 02:31:11 +0000 |
commit | 9577176310df2a97c5b812c4012cc4d3ee6af7f0 (patch) | |
tree | 5f3be90150e8376640e27aade2f03e39b1be1bbc | |
parent | 9cc9ce67245a38bdacae78a0defe967ce4246495 (diff) | |
download | cuttlefish-9577176310df2a97c5b812c4012cc4d3ee6af7f0.tar.gz |
modem_simulator: Reuse active call indexes
Android Telephony stack have a hard limit on number of
active calls.
https://cs.android.com/android/platform/superproject/+/master:frameworks/opt/telephony/src/java/com/android/internal/telephony/GsmCdmaCallTracker.java;l=69;drc=ba17c7243d0e297efbc6fb5385d6d5aa81db9152
This limit makes that `handlePollCalls` only look for
active calls with an index <= `LIMIT (19) + 1`.
As modem_simulator was always increasing active calls indexes
this means that after 20 calls, Android will ignore new calls.
To fix that we instead reuse indexes of calls that where hang up.
Bug: 245578454
Ignore-AOSP-First: cherry-pick from AOSP
Test: atest pts-bot:HFP
Change-Id: Ib8356db812f0e150d0b175cd0085fbd4a4dbd73b
Merged-In: Ib8356db812f0e150d0b175cd0085fbd4a4dbd73b
-rw-r--r-- | host/commands/modem_simulator/call_service.cpp | 7 | ||||
-rw-r--r-- | host/commands/modem_simulator/call_service.h | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/host/commands/modem_simulator/call_service.cpp b/host/commands/modem_simulator/call_service.cpp index 674c15361..7e40870ea 100644 --- a/host/commands/modem_simulator/call_service.cpp +++ b/host/commands/modem_simulator/call_service.cpp @@ -37,7 +37,6 @@ void CallService::InitializeServiceState() { auto instance = nvram_config->ForInstance(service_id_); in_emergency_mode_ = instance.emergency_mode(); - last_active_call_index_ = 1; mute_on_ = false; } @@ -216,7 +215,7 @@ void CallService::HandleDial(const Client& client, const std::string& command) { call_status.is_mobile_terminated = false; call_status.call_state = CallStatus::CALL_STATE_DIALING; call_status.remote_client = remote_client; - int index = last_active_call_index_++; + auto index = FindFreeCallIndex(); auto call_token = std::make_pair(index, call_status.number); call_status.timeout_serial = thread_looper_->Post( @@ -232,7 +231,7 @@ void CallService::HandleDial(const Client& client, const std::string& command) { CallStatus call_status(number); call_status.is_mobile_terminated = false; call_status.call_state = CallStatus::CALL_STATE_DIALING; - auto index = last_active_call_index_++; + auto index = FindFreeCallIndex(); active_calls_[index] = call_status; if (emergency_number) { @@ -707,7 +706,7 @@ void CallService::HandleRemoteCall(const Client& client, call_status.remote_client = client.client_fd; call_status.call_state = CallStatus::CALL_STATE_INCOMING; - auto index = last_active_call_index_++; + auto index = FindFreeCallIndex(); active_calls_[index] = call_status; break; } diff --git a/host/commands/modem_simulator/call_service.h b/host/commands/modem_simulator/call_service.h index 187037226..f57eb05f6 100644 --- a/host/commands/modem_simulator/call_service.h +++ b/host/commands/modem_simulator/call_service.h @@ -42,6 +42,13 @@ class CallService : public ModemService, public std::enable_shared_from_this<Cal void HandleCancelUssd(const Client& client, const std::string& command); void HandleEmergencyMode(const Client& client, const std::string& command); void HandleRemoteCall(const Client& client, const std::string& command); + int FindFreeCallIndex() const { + for (int index = 1; true; index++) { + if (active_calls_.find(index) == active_calls_.end()) { + return index; + } + } + } private: void InitializeServiceState(); @@ -141,7 +148,6 @@ class CallService : public ModemService, public std::enable_shared_from_this<Cal // private data members SimService* sim_service_; NetworkService* network_service_; - int32_t last_active_call_index_; std::map<int, CallStatus> active_calls_; bool in_emergency_mode_; bool mute_on_; |