From ae04f0be555c86ed149f152312d6c41312602a69 Mon Sep 17 00:00:00 2001 From: David Duarte Date: Mon, 28 Nov 2022 19:07:43 +0000 Subject: 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 (cherry picked from commit 9577176310df2a97c5b812c4012cc4d3ee6af7f0) --- host/commands/modem_simulator/call_service.cpp | 7 +++---- 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 active_calls_; bool in_emergency_mode_; bool mute_on_; -- cgit v1.2.3 From 6201074bddfa3474e4da6526dabce08affeaa4b3 Mon Sep 17 00:00:00 2001 From: Mahmoud Elsherif Date: Mon, 26 Sep 2022 22:22:02 +0000 Subject: Move the modem simulator region to 9600 zone for extra spacing. Bug: 245578454 Ignore-AOSP-First: cherry-pick from AOSP Test: build , launch_cvd Change-Id: I74195c984068121f20a7729cf5c8272d4aa29373 Merged-In: I74195c984068121f20a7729cf5c8272d4aa29373 (cherry picked from commit 7dd7f46b09a49b8585240796e04b594ea1f72cb9) --- host/commands/assemble_cvd/flags.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc index 08c2b68a2..609ea4be2 100644 --- a/host/commands/assemble_cvd/flags.cc +++ b/host/commands/assemble_cvd/flags.cc @@ -768,7 +768,7 @@ CuttlefishConfig InitializeCuttlefishConfiguration( const auto vsock_guest_cid = FLAGS_vsock_guest_cid + num - GetInstance(); instance.set_vsock_guest_cid(vsock_guest_cid); auto calc_vsock_port = [vsock_guest_cid](const int base_port) { - // a base (vsock) port is like 9200 for modem_simulator, etc + // a base (vsock) port is like 9600 for modem_simulator, etc return cuttlefish::GetVsockServerPort(base_port, vsock_guest_cid); }; instance.set_session_id(iface_config.mobile_tap.session_id); @@ -891,10 +891,10 @@ CuttlefishConfig InitializeCuttlefishConfiguration( if (modem_simulator_count > 0) { std::stringstream modem_ports; for (auto index {0}; index < modem_simulator_count - 1; index++) { - auto port = 9200 + (modem_simulator_count * (num - 1)) + index; + auto port = 9600 + (modem_simulator_count * (num - 1)) + index; modem_ports << calc_vsock_port(port) << ","; } - auto port = 9200 + (modem_simulator_count * (num - 1)) + + auto port = 9600 + (modem_simulator_count * (num - 1)) + modem_simulator_count - 1; modem_ports << calc_vsock_port(port); instance.set_modem_simulator_ports(modem_ports.str()); -- cgit v1.2.3