Snap for 9406096 from 7dd7f46b09a49b8585240796e04b594ea1f72cb9 to tm-qpr2-release
Change-Id: I74ccd6c042f7589d1f68f57f79c9e83f84d59065
diff --git a/host/commands/assemble_cvd/flags.cc b/host/commands/assemble_cvd/flags.cc
index 5d01c80..a68a475 100644
--- a/host/commands/assemble_cvd/flags.cc
+++ b/host/commands/assemble_cvd/flags.cc
@@ -759,7 +759,7 @@
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 @@
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 674c153..7e40870 100644
--- a/host/commands/modem_simulator/call_service.cpp
+++ b/host/commands/modem_simulator/call_service.cpp
@@ -37,7 +37,6 @@
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 @@
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 @@
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 @@
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 1870372..f57eb05 100644
--- a/host/commands/modem_simulator/call_service.h
+++ b/host/commands/modem_simulator/call_service.h
@@ -42,6 +42,13 @@
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 @@
// 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_;