Replace fmt::format with std::format

Bug: 378773651
Test: TreeHugger
Change-Id: I2df28b081abaafe015adc729239baa39528f9adb
diff --git a/automotive/can/aidl/default/CanController.cpp b/automotive/can/aidl/default/CanController.cpp
index 1435a02..40332d5 100644
--- a/automotive/can/aidl/default/CanController.cpp
+++ b/automotive/can/aidl/default/CanController.cpp
@@ -20,10 +20,10 @@
 #include "CanBusSlcan.h"
 #include "CanBusVirtual.h"
 
-#include <android-base/format.h>
 #include <android-base/logging.h>
 
 #include <filesystem>
+#include <format>
 #include <fstream>
 #include <regex>
 
@@ -235,7 +235,7 @@
                                                    std::string* ifaceName) {
     *ifaceName = {};
     if (mBusesByName.find(busName) == mBusesByName.end()) {
-        return resultToStatus(Result::BAD_BUS_NAME, fmt::format("{} doesn't exist", busName));
+        return resultToStatus(Result::BAD_BUS_NAME, std::format("{} doesn't exist", busName));
     }
     *ifaceName = std::string(mBusesByName[busName]->getIfaceName());
     return ok();
@@ -245,11 +245,11 @@
     if (!isValidName(config.name)) {
         LOG(ERROR) << "Bus name " << config.name << " is invalid";
         return resultToStatus(Result::BAD_BUS_NAME,
-                              fmt::format("{} is not a valid bus name", config.name));
+                              std::format("{} is not a valid bus name", config.name));
     } else if (mBusesByName.find(config.name) != mBusesByName.end()) {
         LOG(ERROR) << "A bus named " << config.name << " already exists!";
         return resultToStatus(Result::INVALID_STATE,
-                              fmt::format("A bus named {} already exists", config.name));
+                              std::format("A bus named {} already exists", config.name));
     }
 
     if (config.interfaceId.getTag() == BusConfig::InterfaceId::Tag::virtualif) {
@@ -310,7 +310,7 @@
     if (result != Result::OK) {
         // the bus failed to come up, don't leave a broken entry in the map.
         mBusesByName.erase(config.name);
-        return resultToStatus(result, fmt::format("CanBus::up failed for {}", config.name));
+        return resultToStatus(result, std::format("CanBus::up failed for {}", config.name));
     }
 
     *ifaceName = mBusesByName[config.name]->getIfaceName();
@@ -321,11 +321,11 @@
     if (mBusesByName.find(busName) == mBusesByName.end()) {
         return resultToStatus(
                 Result::UNKNOWN_ERROR,
-                fmt::format("Couldn't bring down {}, because it doesn't exist", busName));
+                std::format("Couldn't bring down {}, because it doesn't exist", busName));
     }
     Result result = mBusesByName[busName]->down();
     if (result != Result::OK) {
-        return resultToStatus(result, fmt::format("Couldn't bring down {}!", busName));
+        return resultToStatus(result, std::format("Couldn't bring down {}!", busName));
     }
     mBusesByName.erase(busName);
     return ok();
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp
index 86fc70a..6c83339 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/DefaultVehicleHalServer.cpp
@@ -16,10 +16,10 @@
 
 #define LOG_TAG "DefaultVehicleHalServer"
 
+#include <format>
 #include <fstream>
 #include <regex>
 
-#include <android-base/format.h>
 #include <android-base/logging.h>
 #include <android-base/parsedouble.h>
 #include <android-base/parseint.h>
@@ -237,7 +237,7 @@
         auto values = mServerSidePropStore.readAllValues();
         size_t i = 0;
         for (const auto& value : values) {
-            result.buffer += fmt::format("[{}]: {}\n", i, toString(value));
+            result.buffer += std::format("[{}]: {}\n", i, toString(value));
             i++;
         }
         return result;
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/FakeUserHal.cpp b/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/FakeUserHal.cpp
index e9ebcc6..c735b05 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/FakeUserHal.cpp
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/FakeUserHal.cpp
@@ -15,6 +15,8 @@
  */
 #define LOG_TAG "FakeUserHal"
 
+#include <format>
+
 #include <cutils/log.h>
 #include <utils/SystemClock.h>
 
@@ -312,34 +314,34 @@
 }
 
 std::string FakeUserHal::showDumpHelp() {
-    return fmt::format("{}: dumps state used for user management\n", kUserHalDumpOption);
+    return std::format("{}: dumps state used for user management\n", kUserHalDumpOption);
 }
 
 std::string FakeUserHal::dump(std::string indent) {
     std::string info;
     if (mInitialUserResponseFromCmd != nullptr) {
-        info += fmt::format("{}InitialUserInfo response: {}\n", indent.c_str(),
+        info += std::format("{}InitialUserInfo response: {}\n", indent.c_str(),
                             toString(*mInitialUserResponseFromCmd).c_str());
     } else {
-        info += fmt::format("{}No InitialUserInfo response\n", indent.c_str());
+        info += std::format("{}No InitialUserInfo response\n", indent.c_str());
     }
     if (mSwitchUserResponseFromCmd != nullptr) {
-        info += fmt::format("{}SwitchUser response: {}\n", indent.c_str(),
+        info += std::format("{}SwitchUser response: {}\n", indent.c_str(),
                             toString(*mSwitchUserResponseFromCmd).c_str());
     } else {
-        info += fmt::format("{}No SwitchUser response\n", indent.c_str());
+        info += std::format("{}No SwitchUser response\n", indent.c_str());
     }
     if (mCreateUserResponseFromCmd != nullptr) {
-        info += fmt::format("{}CreateUser response: {}\n", indent.c_str(),
+        info += std::format("{}CreateUser response: {}\n", indent.c_str(),
                             toString(*mCreateUserResponseFromCmd).c_str());
     } else {
-        info += fmt::format("{}No CreateUser response\n", indent.c_str());
+        info += std::format("{}No CreateUser response\n", indent.c_str());
     }
     if (mSetUserIdentificationAssociationResponseFromCmd != nullptr) {
-        info += fmt::format("{}SetUserIdentificationAssociation response: {}\n", indent.c_str(),
+        info += std::format("{}SetUserIdentificationAssociation response: {}\n", indent.c_str(),
                             toString(*mSetUserIdentificationAssociationResponseFromCmd).c_str());
     } else {
-        info += fmt::format("{}No SetUserIdentificationAssociation response\n", indent.c_str());
+        info += std::format("{}No SetUserIdentificationAssociation response\n", indent.c_str());
     }
     return info;
 }
diff --git a/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/include/FakeUserHal.h b/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/include/FakeUserHal.h
index 122aee8..33cef54 100644
--- a/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/include/FakeUserHal.h
+++ b/automotive/vehicle/2.0/default/impl/vhal_v2_0/userhal/include/FakeUserHal.h
@@ -17,7 +17,6 @@
 #ifndef android_hardware_automotive_vehicle_V2_0_impl_FakeUserHal_H_
 #define android_hardware_automotive_vehicle_V2_0_impl_FakeUserHal_H_
 
-#include <android-base/format.h>
 #include <android-base/result.h>
 
 #include <android/hardware/automotive/vehicle/2.0/types.h>
diff --git a/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h b/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h
index fcbe8fd..1bf5ce1 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h
+++ b/automotive/vehicle/aidl/impl/fake_impl/userhal/include/FakeUserHal.h
@@ -17,7 +17,6 @@
 #ifndef android_hardware_automotive_vehicle_aidl_impl_fake_impl_userhal_include_FakeUserHal_H_
 #define android_hardware_automotive_vehicle_aidl_impl_fake_impl_userhal_include_FakeUserHal_H_
 
-#include <android-base/format.h>
 #include <android-base/result.h>
 #include <android-base/thread_annotations.h>
 
diff --git a/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp b/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp
index 878c2e7..309dd5f 100644
--- a/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp
+++ b/automotive/vehicle/aidl/impl/fake_impl/userhal/src/FakeUserHal.cpp
@@ -19,6 +19,8 @@
 
 #include "UserHalHelper.h"
 
+#include <format>
+
 #include <VehicleUtils.h>
 #include <utils/Log.h>
 #include <utils/SystemClock.h>
@@ -336,7 +338,7 @@
 }
 
 std::string FakeUserHal::showDumpHelp() const {
-    return fmt::format("{}: dumps state used for user management\n", kUserHalDumpOption);
+    return std::format("{}: dumps state used for user management\n", kUserHalDumpOption);
 }
 
 std::string FakeUserHal::dump() const {
@@ -344,23 +346,23 @@
 
     std::string info;
     if (mInitialUserResponseFromCmd != nullptr) {
-        info += fmt::format("InitialUserInfo response: {}\n",
+        info += std::format("InitialUserInfo response: {}\n",
                             mInitialUserResponseFromCmd->toString());
     } else {
         info += "No InitialUserInfo response\n";
     }
     if (mSwitchUserResponseFromCmd != nullptr) {
-        info += fmt::format("SwitchUser response: {}\n", mSwitchUserResponseFromCmd->toString());
+        info += std::format("SwitchUser response: {}\n", mSwitchUserResponseFromCmd->toString());
     } else {
         info += "No SwitchUser response\n";
     }
     if (mCreateUserResponseFromCmd != nullptr) {
-        info += fmt::format("CreateUser response: {}\n", mCreateUserResponseFromCmd->toString());
+        info += std::format("CreateUser response: {}\n", mCreateUserResponseFromCmd->toString());
     } else {
         info += "No CreateUser response\n";
     }
     if (mSetUserIdentificationAssociationResponseFromCmd != nullptr) {
-        info += fmt::format("SetUserIdentificationAssociation response: {}\n",
+        info += std::format("SetUserIdentificationAssociation response: {}\n",
                             mSetUserIdentificationAssociationResponseFromCmd->toString());
     } else {
         info += "No SetUserIdentificationAssociation response\n";
diff --git a/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/test/proto_message_converter_test.cpp b/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/test/proto_message_converter_test.cpp
index 2efda5b..6fe40a6 100644
--- a/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/test/proto_message_converter_test.cpp
+++ b/automotive/vehicle/aidl/impl/grpc/utils/proto_message_converter/test/proto_message_converter_test.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <format>
 #include <vector>
 
 #include <JsonConfigLoader.h>
@@ -21,7 +22,6 @@
 #include <VehicleHalTypes.h>
 
 #include <android-base/file.h>
-#include <android-base/format.h>
 #include <android/hardware/automotive/vehicle/SubscribeOptions.pb.h>
 #include <android/hardware/automotive/vehicle/VehiclePropConfig.pb.h>
 #include <android/hardware/automotive/vehicle/VehiclePropValue.pb.h>
@@ -106,13 +106,13 @@
 INSTANTIATE_TEST_SUITE_P(DefaultConfigs, PropConfigConversionTest,
                          ::testing::ValuesIn(prepareTestConfigs()),
                          [](const ::testing::TestParamInfo<aidl_vehicle::VehiclePropConfig>& info) {
-                             return ::fmt::format("property_{:d}", info.param.prop);
+                             return ::std::format("property_{:d}", info.param.prop);
                          });
 
 INSTANTIATE_TEST_SUITE_P(TestValues, PropValueConversionTest,
                          ::testing::ValuesIn(prepareTestValues()),
                          [](const ::testing::TestParamInfo<aidl_vehicle::VehiclePropValue>& info) {
-                             return ::fmt::format("property_{:d}", info.param.prop);
+                             return ::std::format("property_{:d}", info.param.prop);
                          });
 
 TEST_F(PropValueConversionTest, testConvertSubscribeOption) {
diff --git a/automotive/vehicle/aidl/impl/utils/common/include/VehicleUtils.h b/automotive/vehicle/aidl/impl/utils/common/include/VehicleUtils.h
index 90a7c46..2bb4ba8 100644
--- a/automotive/vehicle/aidl/impl/utils/common/include/VehicleUtils.h
+++ b/automotive/vehicle/aidl/impl/utils/common/include/VehicleUtils.h
@@ -17,9 +17,10 @@
 #ifndef android_hardware_automotive_vehicle_aidl_impl_utils_common_include_VehicleUtils_H_
 #define android_hardware_automotive_vehicle_aidl_impl_utils_common_include_VehicleUtils_H_
 
+#include <format>
+
 #include <VehicleHalTypes.h>
 
-#include <android-base/format.h>
 #include <android-base/result.h>
 #include <math/HashCombine.h>
 #include <utils/Log.h>
@@ -289,7 +290,7 @@
     }
     return ndk::ScopedAStatus::fromServiceSpecificErrorWithMessage(
             toInt(status),
-            fmt::format("{}, error: {}", additionalErrorMsg, getErrorMsg(result)).c_str());
+            std::format("{}, error: {}", additionalErrorMsg, getErrorMsg(result)).c_str());
 }
 
 template <class T, class E>
diff --git a/macsec/aidl/default/MacsecPskPlugin.cpp b/macsec/aidl/default/MacsecPskPlugin.cpp
index 82d2545..8cb5283 100644
--- a/macsec/aidl/default/MacsecPskPlugin.cpp
+++ b/macsec/aidl/default/MacsecPskPlugin.cpp
@@ -18,7 +18,6 @@
 #include <openssl/cipher.h>
 #include <openssl/mem.h>
 
-#include <android-base/format.h>
 #include <android-base/logging.h>
 
 namespace aidl::android::hardware::macsec {
diff --git a/security/keymint/support/remote_prov_utils.cpp b/security/keymint/support/remote_prov_utils.cpp
index eaeec32..48fc5ac 100644
--- a/security/keymint/support/remote_prov_utils.cpp
+++ b/security/keymint/support/remote_prov_utils.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#include <format>
 #include <iomanip>
 #include <iterator>
 #include <memory>
@@ -535,7 +536,7 @@
     switch (rpcHardwareInfo.versionNumber) {
         case 3:
             if (isTeeDeviceInfo(*parsed) && parsed->size() != kNumTeeDeviceInfoEntries) {
-                error += fmt::format(
+                error += std::format(
                         "Err: Incorrect number of device info entries. Expected {} but got "
                         "{}\n",
                         kNumTeeDeviceInfoEntries, parsed->size());
@@ -544,7 +545,7 @@
             // may omit `os_version`
             if (!isTeeDeviceInfo(*parsed) && (parsed->size() != kNumTeeDeviceInfoEntries &&
                                               parsed->size() != kNumTeeDeviceInfoEntries - 1)) {
-                error += fmt::format(
+                error += std::format(
                         "Err: Incorrect number of device info entries. Expected {} or {} but got "
                         "{}\n",
                         kNumTeeDeviceInfoEntries - 1, kNumTeeDeviceInfoEntries, parsed->size());