rosalina: autoclose menu on sleep mode/shell closed to prevent lockup

This commit is contained in:
TuxSH 2020-07-11 22:04:13 +01:00
parent 4c01bb453c
commit e3bb1c1b63
2 changed files with 16 additions and 7 deletions

View File

@ -140,6 +140,7 @@ static void handleSleepNotification(u32 notificationId)
switch (notificationId) switch (notificationId)
{ {
case PTMNOTIFID_SLEEP_REQUESTED: case PTMNOTIFID_SLEEP_REQUESTED:
menuShouldExit = true;
PTMSYSM_ReplyToSleepQuery(ROSALINA_PREVENT_DISCONNECT); // deny sleep request if we have network stuff running PTMSYSM_ReplyToSleepQuery(ROSALINA_PREVENT_DISCONNECT); // deny sleep request if we have network stuff running
break; break;
case PTMNOTIFID_GOING_TO_SLEEP: case PTMNOTIFID_GOING_TO_SLEEP:
@ -150,18 +151,26 @@ static void handleSleepNotification(u32 notificationId)
break; break;
case PTMNOTIFID_SLEEP_DENIED: case PTMNOTIFID_SLEEP_DENIED:
case PTMNOTIFID_FULLY_AWAKE: case PTMNOTIFID_FULLY_AWAKE:
menuShouldExit = false;
break;
default: default:
break; break;
} }
ptmSysmExit(); ptmSysmExit();
} }
static void handleShellOpenedNotification(u32 notificationId) static void handleShellNotification(u32 notificationId)
{ {
(void)notificationId; if (notificationId == 0x213) {
// Shell opened
// Note that this is called on system init // Note that this notification is fired on system init
ScreenFiltersMenu_RestoreCct(); ScreenFiltersMenu_RestoreCct();
menuShouldExit = false;
} else {
// Shell closed
menuShouldExit = true;
}
} }
static void handlePreTermNotification(u32 notificationId) static void handlePreTermNotification(u32 notificationId)
@ -221,7 +230,8 @@ static const ServiceManagerNotificationEntry notifications[] = {
{ PTMNOTIFID_FULLY_WAKING_UP, handleSleepNotification }, { PTMNOTIFID_FULLY_WAKING_UP, handleSleepNotification },
{ PTMNOTIFID_FULLY_AWAKE, handleSleepNotification }, { PTMNOTIFID_FULLY_AWAKE, handleSleepNotification },
{ PTMNOTIFID_HALF_AWAKE, handleSleepNotification }, { PTMNOTIFID_HALF_AWAKE, handleSleepNotification },
{ 0x213, handleShellOpenedNotification }, { 0x213, handleShellNotification },
{ 0x214, handleShellNotification },
{ 0x1000, handleNextApplicationDebuggedByForce }, { 0x1000, handleNextApplicationDebuggedByForce },
{ 0x2000, handlePreTermNotification }, { 0x2000, handlePreTermNotification },
{ 0x3000, handleRestartHbAppNotification }, { 0x3000, handleRestartHbAppNotification },

View File

@ -188,6 +188,7 @@ void menuThreadMain(void)
while(!preTerminationRequested) while(!preTerminationRequested)
{ {
svcSleepThread(50 * 1000 * 1000LL);
if (menuShouldExit) if (menuShouldExit)
continue; continue;
@ -200,8 +201,6 @@ void menuThreadMain(void)
menuShow(&rosalinaMenu); menuShow(&rosalinaMenu);
menuLeave(); menuLeave();
} }
svcSleepThread(50 * 1000 * 1000LL);
} }
} }