~aleteoryx/muditaos

2d44f964a88e3a7f08f4818c39351d8f9597e2a0 — Marek Niepieklo 4 years ago 1648ea4
[CP-120] Fixed USB comm. when Pure reconnected unlocked

USB comm. was secured when Pure was reconnected to PC while unlocked
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +4 -8
@@ 220,14 220,11 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
                            service::name::system_manager);
        }

        if (!usbSecurityModel->isSecurityEnabled()) {
            LOG_INFO("Endpoint security disabled.");
            return sys::MessageNone{};
        }
        if (usbSecurityModel->isSecurityEnabled()) {
            LOG_INFO("Endpoint security enabled, requesting passcode");

        LOG_INFO("USB connected with endpoint security enabled. Requesting passcode.");
        usbSecurityModel->setEndpointSecurity(EndpointSecurity::Block);
        bus.sendUnicast(std::make_shared<locks::UnlockPhone>(), app::manager::ApplicationManager::ServiceName);
            bus.sendUnicast(std::make_shared<locks::UnlockPhone>(), app::manager::ApplicationManager::ServiceName);
        }

        return sys::MessageNone{};
    });


@@ 235,7 232,6 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
    connect(sdesktop::usb::USBDisconnected(), [&](sys::Message *msg) {
        LOG_INFO("USB disconnected");
        if (usbSecurityModel->isSecurityEnabled()) {
            LOG_INFO("Enabling secured endpoints.");
            bus.sendUnicast(std::make_shared<locks::CancelUnlockPhone>(),
                            app::manager::ApplicationManager::ServiceName);
        }

M module-services/service-desktop/USBSecurityModel.cpp => module-services/service-desktop/USBSecurityModel.cpp +7 -0
@@ 28,6 28,13 @@ namespace sdesktop
                lockPassHash = utils::getNumericValue<unsigned int>(value);
            },
            ::settings::SettingsScope::Global);

        if (isSecurityEnabled()) {
            setEndpointSecurity(EndpointSecurity::Block);
        }
        else {
            setEndpointSecurity(EndpointSecurity::Allow);
        }
    }

    auto USBSecurityModel::isBound(DeviceID id) const -> bool