@@ -551,15 +551,24 @@ private void applyIntentState(Intent intent) {
551551 @ Override
552552 protected void onPause () {
553553 super .onPause ();
554+ // Restore screen timeout whenever we leave — user is navigating around the device.
555+ try {
556+ android .provider .Settings .System .putInt (
557+ getContentResolver (),
558+ android .provider .Settings .System .SCREEN_OFF_TIMEOUT ,
559+ 120000 );
560+ } catch (Throwable t ) { /* ignore */ }
554561 if (refreshRunnable != null ) {
555562 refreshHandler .removeCallbacks (refreshRunnable );
556563 }
557564 if (pendingSleepRunnable != null ) {
558565 refreshHandler .removeCallbacks (pendingSleepRunnable );
559566 pendingSleepRunnable = null ;
560567 }
561- // Don't cancel pendingScreenOffRunnable on pause — it needs to fire
562- // even after the menu-dismiss causes a brief onPause/onResume cycle.
568+ if (pendingScreenOffRunnable != null ) {
569+ refreshHandler .removeCallbacks (pendingScreenOffRunnable );
570+ pendingScreenOffRunnable = null ;
571+ }
563572 if (pendingWifiWarmupRunnable != null ) {
564573 refreshHandler .removeCallbacks (pendingWifiWarmupRunnable );
565574 pendingWifiWarmupRunnable = null ;
@@ -570,6 +579,13 @@ protected void onPause() {
570579 @ Override
571580 protected void onDestroy () {
572581 cancelConnectivityWait ();
582+ // Safety net: always restore screen timeout in case the app dies before onResume
583+ try {
584+ android .provider .Settings .System .putInt (
585+ getContentResolver (),
586+ android .provider .Settings .System .SCREEN_OFF_TIMEOUT ,
587+ 120000 );
588+ } catch (Throwable t ) { /* ignore */ }
573589 try {
574590 if (alarmReceiver != null ) {
575591 unregisterReceiver (alarmReceiver );
@@ -785,8 +801,15 @@ private void startFetch() {
785801 }
786802 fetchInProgress = true ;
787803 fetchStartedFromMenu = menuVisible ;
788- setBootStatus ("Fetching..." );
789- appendLogLine ("Fetching..." );
804+ // Silent background fetch when aggressive sleep is on — no boot status,
805+ // no log churn, screen stays dark/on screensaver until the new image renders.
806+ boolean silentFetch = ApiPrefs .isSuperSleep (this )
807+ && ApiPrefs .isAllowSleep (this )
808+ && !menuVisible ;
809+ if (!silentFetch ) {
810+ setBootStatus ("Fetching..." );
811+ appendLogLine ("Fetching..." );
812+ }
790813 // Only show Loading in the dialog when user tapped Next. Resume/alarm wake: keep previous display, fetch in background.
791814 if (menuVisible ) {
792815 showMenuStatus ("Loading..." , false );
@@ -1577,30 +1600,27 @@ protected void onPostExecute(Object result) {
15771600 a .lastDisplayedImage = ar .bitmap ;
15781601 // Always write screensaver immediately so TRMNL appears in NOOK's screensaver list
15791602 a .writeScreenshotToScreensaver (ar .bitmap );
1603+ boolean superSleep = ApiPrefs .isSuperSleep (a );
1604+ boolean allowSleep = ApiPrefs .isAllowSleep (a );
1605+ a .logD ("super-sleep check: superSleep=" + superSleep + " allowSleep=" + allowSleep + " fromMenu=" + fromMenu );
1606+ // Always render the image in-app — hides the boot/log UI
1607+ // and ensures errors still surface via the normal error path.
15801608 a .imageView .setVisibility (View .VISIBLE );
15811609 if (a .imageRotateLayout != null ) a .imageRotateLayout .setVisibility (View .VISIBLE );
1582- if (a .contentScroll != null ) {
1583- a .contentScroll .setVisibility (View .GONE );
1584- }
1585- if (a .logView != null ) {
1586- a .logView .setVisibility (View .GONE );
1587- }
1610+ if (a .contentScroll != null ) a .contentScroll .setVisibility (View .GONE );
1611+ if (a .logView != null ) a .logView .setVisibility (View .GONE );
15881612 a .hideMenu ();
1589- if (ar .imageUrl != null ) {
1590- a .logD ("image url: " + ar .imageUrl );
1591- }
1592- a .forceFullRefresh ();
1613+ if (ar .imageUrl != null ) a .logD ("image url: " + ar .imageUrl );
15931614 a .logD ("displayed image" );
1594- a .logD ("next display in " + (a .refreshMs / 1000L ) + "s" );
1595- // Super Sleep: sleep immediately after every background image render.
1596- // Skip only if user tapped Next from the menu.
1597- boolean superSleep = ApiPrefs .isSuperSleep (a );
1598- boolean allowSleep = ApiPrefs .isAllowSleep (a );
1599- a .logD ("super-sleep check: superSleep=" + superSleep + " allowSleep=" + allowSleep + " fromMenu=" + fromMenu );
16001615 if (superSleep && allowSleep && !fromMenu ) {
1601- a .logD ("super sleep: sleeping immediately after image load" );
1616+ // Aggressive sleep: image is visible, screensaver already written.
1617+ // Sleep immediately — no forceFullRefresh, no scheduleNextCycle.
1618+ // The NOOK screensaver renders the single EPD flash on timeout.
1619+ a .logD ("super sleep: sleeping after image render" );
16021620 a .sleepNow ();
16031621 } else {
1622+ a .logD ("next display in " + (a .refreshMs / 1000L ) + "s" );
1623+ a .forceFullRefresh ();
16041624 a .scheduleNextCycle ();
16051625 }
16061626 int pct = getBatteryPercent (a );
0 commit comments