~aleteoryx/muditaos

ab02490917d8b7fdf743b1024e674da4b15adb3c — Lefucjusz 3 years ago 660c221
[MOS-559] Fix phone unlock after mode change

Correction of the previous fix addressing this issue.
Previous idea didn't work when popup tried to
display in application other than ApplicationDesktop
M module-apps/apps-common/ApplicationCommon.cpp => module-apps/apps-common/ApplicationCommon.cpp +0 -24
@@ 28,8 28,6 @@
#include <popups/data/PhoneModeParams.hpp>
#include <popups/data/BluetoothModeParams.hpp>

#include <locks/data/PhoneLockMessages.hpp>

#if DEBUG_INPUT_EVENTS == 1
#define debug_input_events(...) LOG_DEBUG(__VA_ARGS__)
#else


@@ 94,7 92,6 @@ namespace app

        bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);
        bus.channels.push_back(sys::BusChannel::USBNotifications);
        bus.channels.push_back(sys::BusChannel::PhoneLockChanges);

        longPressTimer = sys::TimerFactory::createPeriodicTimer(this,
                                                                "LongPress",


@@ 115,16 112,6 @@ namespace app
        connect(typeid(sdesktop::usb::USBDisconnected),
                [&](sys::Message *msg) -> sys::MessagePointer { return handleUSBStatusChange(); });

        connect(typeid(locks::UnlockedPhone), [&](sys::Message *msg) {
            phoneIsLocked = false;
            return sys::MessageNone{};
        });

        connect(typeid(locks::LockedPhone), [&](sys::Message *msg) {
            phoneIsLocked = true;
            return sys::MessageNone{};
        });

        addActionReceiver(app::manager::actions::PhoneModeChanged, [this](auto &&params) {
            if (params != nullptr) {
                auto modeParams                  = static_cast<gui::PhoneModeParams *>(params.get());


@@ 564,17 551,6 @@ namespace app
            return sys::msgHandled();
        }

        // Workaround for corner case when phone started with mode slider in position different than "Connected".
        // This triggers race condition between PhoneLockPopup and PhoneModesPopup. Usually PhoneLockPopup got placed
        // on PhoneModesPopup in windows stack, which resulted in PhoneLockPopup being dropped when phone mode was
        // changed again (see how pushWindow method works), what bypassed the phone lock.
        if (phoneIsLocked && (not windowsStack().isWindowOnStack(gui::popup::window::phone_lock_window)) &&
            (windowName == gui::popup::window::phone_modes_window)) {
            LOG_ERROR(
                "Tried to show PhoneModesPopup on locked phone, but PhoneLockPopup was not at the window stack yet!");
            return sys::msgHandled();
        }

        auto switchData = std::move(msg->getData());
        if (switchData && switchData->ignoreCurrentWindowOnStack) {
            windowsStack().pop();

M module-apps/apps-common/ApplicationCommon.hpp => module-apps/apps-common/ApplicationCommon.hpp +2 -2
@@ 122,7 122,7 @@ namespace app
    class StatusIndicators
    {
      public:
        sys::phone_modes::PhoneMode phoneMode       = sys::phone_modes::PhoneMode::Connected;
        sys::phone_modes::PhoneMode phoneMode       = sys::phone_modes::PhoneMode::Uninitialized;
        sys::bluetooth::BluetoothMode bluetoothMode = sys::bluetooth::BluetoothMode::Disabled;
        bool alarmClockStatus                       = false;
    };


@@ 187,7 187,7 @@ namespace app
        std::unique_ptr<WindowsStack> windowsStackImpl;
        std::string default_window;
        State state = State::DEACTIVATED;
        bool phoneIsLocked = true;
        bool phoneIsLocked = false;

        sys::MessagePointer handleSignalStrengthUpdate(sys::Message *msgl);
        sys::MessagePointer handleNetworkAccessTechnologyUpdate(sys::Message *msgl);

M module-apps/apps-common/notifications/policies/CallNotificationPolicy.cpp => module-apps/apps-common/notifications/policies/CallNotificationPolicy.cpp +2 -0
@@ 12,6 12,8 @@ void CallNotificationPolicy::updateCurrentCall(sys::phone_modes::PhoneMode phone
    numberCheckNeeded = false;

    switch (phoneMode) {
    case sys::phone_modes::PhoneMode::Uninitialized:
        [[fallthrough]];
    case sys::phone_modes::PhoneMode::Connected:
        popupOn    = true;
        ringtoneOn = true;

M module-apps/apps-common/notifications/policies/NotificationsListPolicy.cpp => module-apps/apps-common/notifications/policies/NotificationsListPolicy.cpp +3 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "NotificationsListPolicy.hpp"


@@ 17,6 17,8 @@ void NotificationsListPolicy::updateCurrentList(sys::phone_modes::PhoneMode phon
        showWhenLocked = lockedScreenNotificationSetting;
        updateAllowed  = (isLocked && lockedScreenNotificationSetting) || (!isLocked);
        break;
    case sys::phone_modes::PhoneMode::Uninitialized:
        [[fallthrough]];
    case sys::phone_modes::PhoneMode::Connected:
        [[fallthrough]];
    case sys::phone_modes::PhoneMode::Offline:

M module-apps/apps-common/notifications/policies/SMSNotificationPolicy.cpp => module-apps/apps-common/notifications/policies/SMSNotificationPolicy.cpp +3 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SMSNotificationPolicy.hpp"


@@ 12,6 12,8 @@ void SMSNotificationPolicy::updateCurrentSMS(sys::phone_modes::PhoneMode phoneMo
    case sys::phone_modes::PhoneMode::DoNotDisturb:
        ringtoneOn = false;
        break;
    case sys::phone_modes::PhoneMode::Uninitialized:
        [[fallthrough]];
    case sys::phone_modes::PhoneMode::Connected:
        [[fallthrough]];
    case sys::phone_modes::PhoneMode::Offline:

M module-bsp/board/rt1051/bsp/magnetometer/magnetometer.cpp => module-bsp/board/rt1051/bsp/magnetometer/magnetometer.cpp +1 -1
@@ 195,7 195,7 @@ namespace bsp
                timerHandle = xTimerCreate(
                    "SliderTimer", pdMS_TO_TICKS(MAGNETOMETER_POLL_INTERVAL_MS), true, nullptr, TimerHandler);
                if (timerHandle == nullptr) {
                    LOG_FATAL("Could not create the timer for Headset insertion/removal detection");
                    LOG_ERROR("Could not create the timer for magnetometer state change detection!");
                    return kStatus_Fail;
                }
            }

M module-gui/gui/widgets/StatusBar.hpp => module-gui/gui/widgets/StatusBar.hpp +1 -1
@@ 132,7 132,7 @@ namespace gui::status_bar
        };

        /// Phone mode
        sys::phone_modes::PhoneMode mPhoneMode = sys::phone_modes::PhoneMode::Connected;
        sys::phone_modes::PhoneMode mPhoneMode = sys::phone_modes::PhoneMode::Uninitialized;

        /// Bluetooth mode
        sys::bluetooth::BluetoothMode mBluetoothMode = sys::bluetooth::BluetoothMode::Disabled;

M module-gui/gui/widgets/status-bar/PhoneMode.cpp => module-gui/gui/widgets/status-bar/PhoneMode.cpp +2 -0
@@ 31,6 31,8 @@ namespace gui::status_bar
            setText(utils::translate("home_modes_offline"));
            break;

        case sys::phone_modes::PhoneMode::Uninitialized:
            [[fallthrough]];
        case sys::phone_modes::PhoneMode::Connected:
            setText("");
            break;

M module-services/service-cellular/call/include/call/CellularCall.hpp => module-services/service-cellular/call/include/call/CellularCall.hpp +1 -1
@@ 35,7 35,7 @@ namespace call
    struct CallData
    {
        CalllogRecord record             = {};
        sys::phone_modes::PhoneMode mode = sys::phone_modes::PhoneMode::Connected;
        sys::phone_modes::PhoneMode mode      = sys::phone_modes::PhoneMode::Uninitialized;
        sys::phone_modes::Tethering tethering = sys::phone_modes::Tethering::Off;
    };


M module-sys/PhoneModes/include/PhoneModes/Observer.hpp => module-sys/PhoneModes/include/PhoneModes/Observer.hpp +1 -1
@@ 35,7 35,7 @@ namespace sys::phone_modes

        OnPhoneModeChangedCallback onPhoneModeChangedCallback;
        OnTetheringChangedCallback onTetheringChangedCallback;
        PhoneMode phoneMode     = PhoneMode::Connected;
        PhoneMode phoneMode     = PhoneMode::Uninitialized;
        Tethering tetheringMode = Tethering::Off;
    };
} // namespace sys::phone_modes

M module-sys/PhoneModes/include/PhoneModes/PhoneMode.hpp => module-sys/PhoneModes/include/PhoneModes/PhoneMode.hpp +2 -1
@@ 9,6 9,7 @@ namespace sys::phone_modes
    {
        Connected,
        DoNotDisturb,
        Offline
        Offline,
        Uninitialized
    };
}

M module-sys/PhoneModes/include/PhoneModes/Subject.hpp => module-sys/PhoneModes/include/PhoneModes/Subject.hpp +1 -1
@@ 51,7 51,7 @@ namespace sys::phone_modes
        void notifyTetheringChange();

        Service *owner;
        PhoneMode phoneMode     = PhoneMode::Connected;
        PhoneMode phoneMode     = PhoneMode::Uninitialized;
        Tethering tetheringMode = Tethering::Off;
        const std::function<bool()> activeSimSelected;
        const std::function<bool()> isCallOngoing;

M products/PurePhone/services/appmgr/ApplicationManager.cpp => products/PurePhone/services/appmgr/ApplicationManager.cpp +5 -0
@@ 138,7 138,12 @@ namespace app::manager

        phoneModeObserver->connect(this);
        phoneModeObserver->subscribe([this](sys::phone_modes::PhoneMode phoneMode) {
            static bool isFirstUpdateAfterStartup = true;
            handlePhoneModeChanged(phoneMode);
            if (isFirstUpdateAfterStartup) {
                isFirstUpdateAfterStartup = false;
                return;
            }
            actionsRegistry.enqueue(
                ActionEntry{actions::ShowPopup, std::make_unique<gui::PhoneModePopupRequestParams>(phoneMode)});
        });