aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-15 00:03:59 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-15 00:03:59 +0000
commitf07697d695a94e6263117eb7907553982d2c3032 (patch)
tree3018e8b6ba2d1c16a438c2357997c01aca3a8853
parent80f9c7ee1f540a7fb985e8a6f8a38b56a603a97f (diff)
parent7dd7f46b09a49b8585240796e04b594ea1f72cb9 (diff)
downloadcuttlefish-android13-qpr2-s9-release.tar.gz
Change-Id: I74ccd6c042f7589d1f68f57f79c9e83f84d59065
-rw-r--r--host/commands/assemble_cvd/flags.cc6
-rw-r--r--host/commands/modem_simulator/call_service.cpp7
-rw-r--r--host/commands/modem_simulator/call_service.h8
3 files changed, 13 insertions, 8 deletions
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 5d01c80bc..a68a475df 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -759,7 +759,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);
@@ -882,10 +882,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());
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_;