Skip to content

Commit 9492c8f

Browse files
committed
Crash on suspend.
1 parent 8a471dd commit 9492c8f

File tree

7 files changed

+44
-1
lines changed

7 files changed

+44
-1
lines changed

.gdbinit_mati

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
handle all nostop pass
2+
3+
4+
define target hookpost-remote
5+
monitor reset 0
6+
monitor halt
7+
load
8+
monitor halt
9+
eval "monitor exec SetRTTAddr %p", &_SEGGER_RTT
10+
b main
11+
end

module-apps/application-desktop/windows/DesktopMainWindow.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ void DesktopMainWindow::onBeforeShow( ShowMode mode, uint32_t command, SwitchDat
122122

123123
LockPhoneData* lockData = reinterpret_cast<LockPhoneData*>( data );
124124
lockTimeoutApplilcation = lockData->getPreviousApplication();
125+
126+
sapm::ApplicationManager::messageInitPowerSaveMode(application);
125127
}
126128

127129
setVisibleState();

module-services/service-appmgr/ApplicationManager.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ sys::Message_t ApplicationManager::DataReceivedHandler(sys::DataMessage* msgl,sy
105105
uint32_t msgType = msgl->messageType;
106106

107107
switch( msgType ) {
108+
case static_cast<uint32_t>( MessageType::APMInitPowerSaveMode ): {
109+
handlePowerSavingModeInit();
110+
} break;
108111
case static_cast<uint32_t>( MessageType::APMPreventBlocking ): {
109112
// LOG_INFO("Restarting screen locking timer");
110113
ReloadTimer(blockingTimerID);
@@ -309,6 +312,14 @@ bool ApplicationManager::startApplication( const std::string& appName ) {
309312
return true;
310313
}
311314

315+
bool ApplicationManager::handlePowerSavingModeInit() {
316+
317+
LOG_INFO("Going to suspend mode");
318+
sys::SystemManager::SuspendSystem(this);
319+
320+
return true;
321+
}
322+
312323
//tries to switch the application
313324
bool ApplicationManager::handleSwitchApplication( APMSwitch* msg ) {
314325

@@ -596,4 +607,10 @@ bool ApplicationManager::messagePreventBlocking( sys::Service* sender ) {
596607
return true;
597608
}
598609

610+
bool ApplicationManager::messageInitPowerSaveMode( sys::Service* sender ) {
611+
auto msg = std::make_shared<sapm::APMInitPowerSaveMode>( sender->GetName() );
612+
sys::Bus::SendUnicast(msg, "ApplicationManager", sender);
613+
return true;
614+
}
615+
599616
} /* namespace sapm */

module-services/service-appmgr/ApplicationManager.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ApplicationManager: public sys::Service {
8787
bool handleSwitchPrevApplication( APMSwitchPrevApp* msg );
8888
bool handleRegisterApplication( APMRegister* msg );
8989
bool handleLanguageChange( sapm::APMChangeLanguage* msg );
90+
bool handlePowerSavingModeInit();
9091
/**
9192
* @brief Closes all running applications.
9293
*/
@@ -150,6 +151,10 @@ class ApplicationManager: public sys::Service {
150151
* @brief Sends message to inform Application Manager to reset timer responsible for blocking phone
151152
*/
152153
static bool messagePreventBlocking( sys::Service* sender );
154+
/**
155+
* @brief Sends message to Application Manager. This will initialize procedure of switching to power saving mode.
156+
*/
157+
static bool messageInitPowerSaveMode( sys::Service* sender );
153158
};
154159

155160
} /* namespace sapm */

module-services/service-appmgr/messages/APMMessage.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ class APMPreventBlocking: public APMMessage {
127127
{}
128128
};
129129

130+
class APMInitPowerSaveMode: public APMMessage {
131+
public:
132+
APMInitPowerSaveMode( const std::string& senderName) :
133+
APMMessage( MessageType::APMInitPowerSaveMode, senderName )
134+
{}
135+
};
136+
130137
} /* namespace sapm */
131138

132139

source/MessageType.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ enum class MessageType {
9999
//applications in background and currently active application.
100100
APMClose, //this message will trigger application manager to close itself, all running applications gui and eink services.
101101
APMPreventBlocking, //Prevents application manager from initializing device blocking.
102+
APMInitPowerSaveMode, //This message is sent to application manager from desktop when locking timeout has triggered or user explicitly locked the phone.
102103

103104
//keyboard messages
104105
KBDKeyEvent,

source/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class BlinkyService : public sys::Service {
9494
stopTimer(timer_id);
9595
std::shared_ptr<sys::DataMessage> msg = std::make_shared<sys::DataMessage>(static_cast<uint32_t >(MessageType::AudioSetInputGain));
9696

97-
auto ret = sys::Bus::SendUnicast(msg,GetName(),this);
97+
sys::Bus::SendUnicast(msg,GetName(),this);
9898
#endif
9999

100100
}

0 commit comments

Comments
 (0)