/// Signals that the app is ready to sleep.
void aptSignalReadyForSleep(void);
+/**
+ * @brief Gets whether to allow the system to enter sleep mode.
+ * @return Whether sleep mode is allowed.
+ */
+bool aptIsSleepAllowed();
+
+/**
+ * @brief Sets whether to allow the system to enter sleep mode.
+ * @param allowed Whether to allow sleep mode.
+ */
+void aptSetSleepAllowed(bool allowed);
+
/**
* @brief Gets the menu's app ID.
* @return The menu's app ID.
APT_AppStatus aptStatusBeforeSleep = APP_NOTINITIALIZED;
u32 aptStatusPower;
Handle aptSleepSync;
+static bool aptSleepAllowed = true;
u32 aptParameters[0x1000/4]; //TEMP
case APTSIGNAL_PREPARESLEEP:
// Reply to sleep-request.
- aptStatusBeforeSleep = aptGetStatus();
- aptSetStatus(APP_PREPARE_SLEEPMODE);
- svcWaitSynchronization(aptSleepSync, U64_MAX);
- svcClearEvent(aptSleepSync);
+ if(aptIsSleepAllowed())
+ {
+ aptStatusBeforeSleep = aptGetStatus();
+ aptSetStatus(APP_PREPARE_SLEEPMODE);
+ svcWaitSynchronization(aptSleepSync, U64_MAX);
+ svcClearEvent(aptSleepSync);
- aptOpenSession();
- APT_ReplySleepQuery(currentAppId, 0x1);
- aptCloseSession();
+ aptOpenSession();
+ APT_ReplySleepQuery(currentAppId, 0x1);
+ aptCloseSession();
+ } else
+ {
+ aptOpenSession();
+ APT_ReplySleepQuery(currentAppId, 0x0);
+ aptCloseSession();
+ }
break;
case APTSIGNAL_ENTERSLEEP:
svcSignalEvent(aptSleepSync);
}
+bool aptIsSleepAllowed()
+{
+ return aptSleepAllowed;
+}
+
+void aptSetSleepAllowed(bool allowed)
+{
+ aptSleepAllowed = allowed;
+}
+
Result APT_GetLockHandle(u16 flags, Handle* lockHandle)
{
u32* cmdbuf=getThreadCommandBuffer();