Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e208b99 authored by Henri Chataing's avatar Henri Chataing Committed by Gerrit Code Review
Browse files

Merge "Replace fmt::format with std::format" into main

parents 26fb7f37 126df582
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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 @@ ndk::ScopedAStatus CanController::getInterfaceName(const std::string& busName,
                                                   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 @@ ndk::ScopedAStatus CanController::upBus(const BusConfig& config, std::string* if
    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 @@ ndk::ScopedAStatus CanController::upBus(const BusConfig& config, std::string* if
    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 @@ ndk::ScopedAStatus CanController::downBus(const std::string& busName) {
    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();
+2 −2
Original line number Diff line number Diff line
@@ -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 @@ IVehicleServer::DumpResult DefaultVehicleHalServer::onDump(
        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;
+11 −9
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
#define LOG_TAG "FakeUserHal"

#include <format>

#include <cutils/log.h>
#include <utils/SystemClock.h>

@@ -312,34 +314,34 @@ Result<std::unique_ptr<VehiclePropValue>> FakeUserHal::sendUserHalResponse(
}

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;
}
+0 −1
Original line number Diff line number Diff line
@@ -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>
+0 −1
Original line number Diff line number Diff line
@@ -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>

Loading