aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-17 13:02:24 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-12-17 13:02:24 +0000
commit274a09c4b54fbfdb9bcb18cfcca32af564d2fd37 (patch)
tree7cc7e53f5a5304cf3ed725a6d322eebf293029cd
parent608a0498b176690b45f5ec4c4454ed2e16fa9e81 (diff)
parentfede3049bcb4a2e20c9e9d37a3d7b644050a52e7 (diff)
downloadcuttlefish-android13-mainline-media-release.tar.gz
Snap for 9416319 from fede3049bcb4a2e20c9e9d37a3d7b644050a52e7 to mainline-media-releaseaml_med_331911000aml_med_331712010aml_med_331612000aml_med_331511000android13-mainline-media-release
Change-Id: Iaa2db67adc4e308e0db6e9db7da3ef01150f9913
-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 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());
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_;