Improved infinite-sleep-loop handling, and use it for appletStartShutdownSequenceForOverlay/appletStartRebootSequenceForOverlay.

This commit is contained in:
yellows8 2019-08-18 19:40:17 -04:00
parent ac75527491
commit c34bea8d4c
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43
2 changed files with 21 additions and 9 deletions

View File

@ -1850,13 +1850,13 @@ Result appletTerminateApplicationAndSetReason(Result reason);
Result appletSetScreenShotPermissionGlobally(bool flag); Result appletSetScreenShotPermissionGlobally(bool flag);
/** /**
* @brief Start the system-shutdown sequence. * @brief Start the system-shutdown sequence. This will enter an infinite-sleep-loop on success.
* @note Only available with AppletType_OverlayApplet on [6.0.0+]. * @note Only available with AppletType_OverlayApplet on [6.0.0+].
*/ */
Result appletStartShutdownSequenceForOverlay(void); Result appletStartShutdownSequenceForOverlay(void);
/** /**
* @brief Start the system-reboot sequence. * @brief Start the system-reboot sequence. This will enter an infinite-sleep-loop on success.
* @note Only available with AppletType_OverlayApplet on [6.0.0+]. * @note Only available with AppletType_OverlayApplet on [6.0.0+].
*/ */
Result appletStartRebootSequenceForOverlay(void); Result appletStartRebootSequenceForOverlay(void);

View File

@ -343,10 +343,14 @@ Result appletInitialize(void)
return rc; return rc;
} }
static void _appletInfiniteSleepLoop(void) {
while(1) svcSleepThread(86400000000000ULL);
}
static void NORETURN _appletExitProcess(int result_code) { static void NORETURN _appletExitProcess(int result_code) {
appletExit(); appletExit();
if (R_SUCCEEDED(g_appletExitProcessResult)) while(1)svcSleepThread(86400000000000ULL); if (R_SUCCEEDED(g_appletExitProcessResult)) _appletInfiniteSleepLoop();
svcExitProcess(); svcExitProcess();
__builtin_unreachable(); __builtin_unreachable();
@ -2965,7 +2969,7 @@ Result appletHolderJump(AppletHolder *h) {
if (R_SUCCEEDED(rc)) rc = _appletWindAndDoReserved(); if (R_SUCCEEDED(rc)) rc = _appletWindAndDoReserved();
if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc; return rc;
} }
@ -3931,7 +3935,7 @@ Result appletRequestToShutdown(void) {
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
rc = _appletCmdNoIO(&g_appletIFunctions, 70); rc = _appletCmdNoIO(&g_appletIFunctions, 70);
if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc; return rc;
} }
@ -3944,7 +3948,7 @@ Result appletRequestToReboot(void) {
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
rc = _appletCmdNoIO(&g_appletIFunctions, 71); rc = _appletCmdNoIO(&g_appletIFunctions, 71);
if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc; return rc;
} }
@ -3957,7 +3961,7 @@ Result appletExitAndRequestToShowThanksMessage(void) {
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
rc = _appletCmdNoIO(&g_appletIFunctions, 80); rc = _appletCmdNoIO(&g_appletIFunctions, 80);
if (R_SUCCEEDED(rc)) while(1)svcSleepThread(86400000000000ULL); if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc; return rc;
} }
@ -5076,21 +5080,29 @@ Result appletSetScreenShotPermissionGlobally(bool flag) {
} }
Result appletStartShutdownSequenceForOverlay(void) { Result appletStartShutdownSequenceForOverlay(void) {
Result rc=0;
if (__nx_applet_type != AppletType_OverlayApplet) if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (hosversionBefore(6,0,0)) if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _appletCmdNoIO(&g_appletIFunctions, 10); rc = _appletCmdNoIO(&g_appletIFunctions, 10);
if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc;
} }
Result appletStartRebootSequenceForOverlay(void) { Result appletStartRebootSequenceForOverlay(void) {
Result rc=0;
if (__nx_applet_type != AppletType_OverlayApplet) if (__nx_applet_type != AppletType_OverlayApplet)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized); return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (hosversionBefore(6,0,0)) if (hosversionBefore(6,0,0))
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
return _appletCmdNoIO(&g_appletIFunctions, 11); rc = _appletCmdNoIO(&g_appletIFunctions, 11);
if (R_SUCCEEDED(rc)) _appletInfiniteSleepLoop();
return rc;
} }
Result appletSetHandlingHomeButtonShortPressedEnabled(bool flag) { Result appletSetHandlingHomeButtonShortPressedEnabled(bool flag) {