~aleteoryx/muditaos

ed806a4566f3303669c1385ffa873a4db2d05098 — Mateusz Piesta 3 years ago 4894002
[MOS-807] Fix MTP root path

Fixed MTP root paths for both Harmony and
Pure due to the MTP implementation
not supporting hierarchical directories.
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +4 -3
@@ 11,14 11,15 @@
#include <system/messages/TetheringStateRequest.hpp>
#include <Timers/TimerFactory.hpp>

ServiceDesktop::ServiceDesktop()
ServiceDesktop::ServiceDesktop(const std::filesystem::path &mtpRootPath)
    : sys::Service(service::name::service_desktop, "", sdesktop::service_stack),
      btMsgHandler(std::make_unique<sdesktop::bluetooth::BluetoothMessagesHandler>(this)),
      connectionActiveTimer{sys::TimerFactory::createSingleShotTimer(
          this,
          sdesktop::connectionActiveTimerName,
          sdesktop::connectionActiveTimerDelayMs,
          [this](sys::Timer & /*timer*/) { outboxNotifications.clearNotifications(); })}
          [this](sys::Timer & /*timer*/) { outboxNotifications.clearNotifications(); })},
      mtpRootPath{mtpRootPath}
{
    LOG_INFO("[ServiceDesktop] Initializing");
    bus.channels.push_back(sys::BusChannel::PhoneLockChanges);


@@ 180,7 181,7 @@ auto ServiceDesktop::usbWorkerInit() -> sys::ReturnCodes
                                                    *usbSecurityModel,
                                                    serialNumber,
                                                    caseColour,
                                                    purefs::dir::getUserMediaPath());
                                                    mtpRootPath);

    initialized =
        desktopWorker->init({{sdesktop::RECEIVE_QUEUE_BUFFER_NAME, sizeof(std::string *), sdesktop::cdc_queue_len},

M module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp => module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp +2 -1
@@ 51,7 51,7 @@ namespace sdesktop::bluetooth
class ServiceDesktop : public sys::Service
{
  public:
    ServiceDesktop();
    explicit ServiceDesktop(const std::filesystem::path &mtpRootPath);
    ~ServiceDesktop() override;

    std::unique_ptr<WorkerDesktop> desktopWorker;


@@ 92,6 92,7 @@ class ServiceDesktop : public sys::Service
    bool initialized                                         = false;
    bool isPlugEventUnhandled                                = false;
    bool isUsbConfigured                                     = false;
    std::filesystem::path mtpRootPath;

    void generateDeviceUniqueId();
    auto getDeviceUniqueId() const -> std::string;

M module-vfs/paths/filesystem_paths.cpp => module-vfs/paths/filesystem_paths.cpp +5 -6
@@ 11,12 11,11 @@ namespace
    constexpr inline auto PATH_DB          = "db";
    constexpr inline auto PATH_LOGS        = "log";
    constexpr inline auto PATH_CRASH_DUMPS = "crash_dumps";
    constexpr inline auto PATH_USER_MEDIA =
        "media"; // TODO this won't work with our current non-hierarchical MTP implementation
    constexpr inline auto PATH_TMP    = "temp";
    constexpr inline auto PATH_ASSETS = "assets";
    constexpr inline auto PATH_DATA   = "data";
    constexpr inline auto PATH_VAR    = "var";
    constexpr inline auto PATH_USER_MEDIA  = "media";
    constexpr inline auto PATH_TMP         = "temp";
    constexpr inline auto PATH_ASSETS      = "assets";
    constexpr inline auto PATH_DATA        = "data";
    constexpr inline auto PATH_VAR         = "var";
} // namespace

namespace purefs

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>());
    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/paths/Paths.cpp => products/BellHybrid/paths/Paths.cpp +1 -1
@@ 6,7 6,7 @@

std::filesystem::path paths::audio::user() noexcept
{
    return purefs::dir::getUserDiskPath() / "audio";
    return purefs::dir::getUserMediaPath() / "app";
}
std::filesystem::path paths::audio::proprietary() noexcept
{

M products/PurePhone/PurePhoneMain.cpp => products/PurePhone/PurePhoneMain.cpp +3 -0
@@ 181,6 181,9 @@ int main()
#ifdef ENABLE_SERVICE_BLUETOOTH
    systemServices.emplace_back(sys::CreatorFor<ServiceBluetooth>());
#endif
#ifdef ENABLE_SERVICE_DESKTOP
    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>()));
#endif