~aleteoryx/muditaos

9744d391372781313a157336eba1aed3c001b4a0 — Bartosz 3 years ago fc076fa
[MOS-856] Another approach to MTP path in DeviceInfo

This time it's device-agnostic from purefs paths
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +5 -0
@@ 362,3 362,8 @@ auto ServiceDesktop::handle(sevm::USBPlugEvent *msg) -> std::shared_ptr<sys::Mes
    }
    return sys::MessageNone{};
}

auto ServiceDesktop::getMtpPath() const noexcept -> std::filesystem::path
{
    return mtpRootPath;
}

M module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpointCommon.cpp => module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpointCommon.cpp +9 -2
@@ 83,12 83,19 @@ namespace sdesktop::endpoints

    auto DeviceInfoEndpointCommon::requestLogsFlush() const -> void
    {
        auto owner = dynamic_cast<ServiceDesktop *>(ownerServicePtr);
        if (owner) {
        if (const auto owner = dynamic_cast<ServiceDesktop *>(ownerServicePtr); owner != nullptr) {
            owner->requestLogsFlush();
        }
    }

    auto DeviceInfoEndpointCommon::getMtpPath() const -> std::filesystem::path
    {
        if (const auto owner = dynamic_cast<ServiceDesktop *>(ownerServicePtr); owner != nullptr) {
            return owner->getMtpPath();
        }
        return std::filesystem::path{};
    }

    auto DeviceInfoEndpointCommon::fileListToJsonObject(const std::vector<std::string> &fileList) const
        -> json11::Json::object const
    {

M module-services/service-desktop/endpoints/include/endpoints/deviceInfo/DeviceInfoEndpointCommon.hpp => module-services/service-desktop/endpoints/include/endpoints/deviceInfo/DeviceInfoEndpointCommon.hpp +2 -1
@@ 8,7 8,7 @@

#include <string>
#include <tuple>

#include <filesystem>
#include <json11.hpp>

namespace sdesktop::endpoints


@@ 30,6 30,7 @@ namespace sdesktop::endpoints
        auto requestLogsFlush() const -> void;
        auto getStorageStats(const std::string &path) -> std::tuple<long, long>;
        auto getStorageInfo() -> std::tuple<long, long, long>;
        auto getMtpPath() const -> std::filesystem::path;

        explicit DeviceInfoEndpointCommon(sys::Service *ownerServicePtr) : Endpoint(ownerServicePtr)
        {

M module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp => module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp +1 -0
@@ 81,6 81,7 @@ class ServiceDesktop : public sys::Service

    auto getNotificationEntries() const -> std::vector<Outbox::NotificationEntry>;
    void removeNotificationEntries(const std::vector<uint32_t> &);
    auto getMtpPath() const noexcept -> std::filesystem::path;

  private:
    std::unique_ptr<sdesktop::USBSecurityModel> usbSecurityModel;

M module-vfs/paths/filesystem_paths.cpp => module-vfs/paths/filesystem_paths.cpp +0 -8
@@ 80,14 80,6 @@ namespace purefs
        {
            return getSystemDiskPath() / PATH_VAR;
        }
        std::filesystem::path getMusicPlayerPath() noexcept
        {
            return purefs::dir::getUserMediaPath() / "app/music_player";
        }
        std::filesystem::path getRelaxationPath() noexcept
        {
            return purefs::dir::getUserMediaPath() / "app/relaxation";
        }

    } // namespace dir
} // namespace purefs

M module-vfs/paths/include/purefs/filesystem_paths.hpp => module-vfs/paths/include/purefs/filesystem_paths.hpp +0 -2
@@ 21,8 21,6 @@ namespace purefs
        std::filesystem::path getAssetsDirPath() noexcept;
        std::filesystem::path getSystemDataDirPath() noexcept;
        std::filesystem::path getSystemVarDirPath() noexcept;
        std::filesystem::path getMusicPlayerPath() noexcept;
        std::filesystem::path getRelaxationPath() noexcept;

    } // namespace dir


M products/BellHybrid/BellHybridMain.cpp => products/BellHybrid/BellHybridMain.cpp +1 -1
@@ 82,7 82,7 @@ int main()
    systemServices.emplace_back(sys::CreatorFor<service::ServiceFileIndexer>(std::move(fileIndexerAudioPaths)));
    systemServices.emplace_back(sys::CreatorFor<ServiceDB>());
    systemServices.emplace_back(sys::CreatorFor<service::Audio>());
    systemServices.emplace_back(sys::CreatorFor<ServiceDesktop>(purefs::dir::getRelaxationPath()));
    systemServices.emplace_back(sys::CreatorFor<ServiceDesktop>(purefs::dir::getUserMediaPath() / "app/relaxation"));
    systemServices.emplace_back(sys::CreatorFor<stm::ServiceTime>(std::make_shared<alarms::AlarmOperationsFactory>()));
    systemServices.emplace_back(sys::CreatorFor<service::eink::ServiceEink>(service::eink::ExitAction::None));
    systemServices.emplace_back(

M products/BellHybrid/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => products/BellHybrid/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +1 -1
@@ 47,7 47,7 @@ namespace sdesktop::endpoints
             {json::updateFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::updateFilename).string()},
             {json::backupFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::backupFilename).string()},
             {json::syncFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::syncFilename).string()},
             {json::mtpPath, purefs::dir::getRelaxationPath().string()}}));
             {json::mtpPath, getMtpPath().string()}}));

        return http::Code::OK;
    }

M products/PurePhone/PurePhoneMain.cpp => products/PurePhone/PurePhoneMain.cpp +1 -1
@@ 182,7 182,7 @@ int main()
    systemServices.emplace_back(sys::CreatorFor<ServiceBluetooth>());
#endif
#ifdef ENABLE_SERVICE_DESKTOP
    systemServices.emplace_back(sys::CreatorFor<ServiceDesktop>(purefs::dir::getMusicPlayerPath()));
    systemServices.emplace_back(sys::CreatorFor<ServiceDesktop>(purefs::dir::getUserMediaPath() / "app/music_player"));
#endif
#ifdef ENABLE_SERVICE_TIME
    systemServices.emplace_back(sys::CreatorFor<stm::ServiceTime>(std::make_shared<alarms::AlarmOperationsFactory>()));

M products/PurePhone/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => products/PurePhone/services/desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +1 -1
@@ 62,7 62,7 @@ namespace sdesktop::endpoints
             {json::updateFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::updateFilename).string()},
             {json::backupFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::backupFilename).string()},
             {json::syncFilePath, (purefs::dir::getTemporaryPath() / sdesktop::paths::syncFilename).string()},
             {json::mtpPath, purefs::dir::getMusicPlayerPath().string()},
             {json::mtpPath, getMtpPath().string()},
             {json::deviceToken, getDeviceToken()}}));

        return http::Code::OK;