Merge "Minor refactors in modem_simulator" into main
diff --git a/host/commands/modem_simulator/main.cpp b/host/commands/modem_simulator/main.cpp
index a979c36..c22d11d 100644
--- a/host/commands/modem_simulator/main.cpp
+++ b/host/commands/modem_simulator/main.cpp
@@ -92,7 +92,7 @@
   }
 
   auto nvram_config = NvramConfig::Get();
-  auto nvram_config_file = nvram_config->ConfigFileLocation();
+  const auto nvram_config_file = nvram_config->ConfigFileLocation();
 
   // Start channel monitor, wait for RIL to connect
   int32_t modem_id = 0;
diff --git a/host/commands/modem_simulator/network_service.cpp b/host/commands/modem_simulator/network_service.cpp
index 25a2f97..03d0a59 100644
--- a/host/commands/modem_simulator/network_service.cpp
+++ b/host/commands/modem_simulator/network_service.cpp
@@ -160,18 +160,15 @@
     current_operator_numeric_ = operator_list_.begin()->numeric;
     operator_list_.begin()->operator_state = NetworkOperator::OPER_STATE_CURRENT;
   } else if (oper_selection_mode_ == OperatorSelectionMode::OPER_SELECTION_MANUAL_AUTOMATIC) {
-    auto iter = operator_list_.begin();
-    for (; iter != operator_list_.end(); ++iter) {
-      if (iter->numeric == current_operator_numeric_) {
-        break;
+    for (auto& iter : operator_list_) {
+      if (iter.numeric == current_operator_numeric_) {
+        iter.operator_state = NetworkOperator::OPER_STATE_CURRENT;
+        return;
       }
     }
-    if (iter == operator_list_.end()) {
-      current_operator_numeric_ = operator_list_.begin()->numeric;
-      operator_list_.begin()->operator_state = NetworkOperator::OPER_STATE_CURRENT;
-    } else {
-      iter->operator_state = NetworkOperator::OPER_STATE_CURRENT;
-    }
+    current_operator_numeric_ = operator_list_.begin()->numeric;
+    operator_list_.begin()->operator_state =
+        NetworkOperator::OPER_STATE_CURRENT;
   }
 }
 
diff --git a/host/commands/modem_simulator/nvram_config.cpp b/host/commands/modem_simulator/nvram_config.cpp
index 22b3373..021ba73 100644
--- a/host/commands/modem_simulator/nvram_config.cpp
+++ b/host/commands/modem_simulator/nvram_config.cpp
@@ -45,11 +45,9 @@
  * Returns nullptr if there was an error loading from file
  */
 NvramConfig* NvramConfig::BuildConfigImpl(size_t num_instances, int sim_type) {
-  auto nvram_config_path =
-      cuttlefish::modem::DeviceConfig::PerInstancePath("modem_nvram.json");
-
   auto ret = new NvramConfig(num_instances, sim_type);
   if (ret) {
+    const auto nvram_config_path = ConfigFileLocation();
     if (!cuttlefish::FileExists(nvram_config_path) ||
         !cuttlefish::FileHasContent(nvram_config_path.c_str())) {
       ret->InitDefaultNvramConfig();
@@ -82,7 +80,7 @@
 
 void NvramConfig::SaveToFile() {
   auto nvram_config = Get();
-  auto nvram_config_file = nvram_config->ConfigFileLocation();
+  const auto nvram_config_file = ConfigFileLocation();
   nvram_config->SaveToFile(nvram_config_file);
 }
 
@@ -101,7 +99,7 @@
   return InstanceSpecific(this, std::to_string(num));
 }
 
-std::string NvramConfig::ConfigFileLocation() const {
+/* static */ std::string NvramConfig::ConfigFileLocation() {
   return cuttlefish::AbsolutePath(
       cuttlefish::modem::DeviceConfig::PerInstancePath("modem_nvram.json"));
 }
diff --git a/host/commands/modem_simulator/nvram_config.h b/host/commands/modem_simulator/nvram_config.h
index fc51c80..bf4370a 100644
--- a/host/commands/modem_simulator/nvram_config.h
+++ b/host/commands/modem_simulator/nvram_config.h
@@ -32,7 +32,7 @@
   ~NvramConfig();
   NvramConfig& operator=(NvramConfig&&);
 
-  std::string ConfigFileLocation() const;
+  static std::string ConfigFileLocation();
   // Saves the configuration object in a file
   bool SaveToFile(const std::string& file) const;