summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2022-04-16 14:25:49 +0100
committerAidan MacDonald <amachronic@protonmail.com>2022-04-16 14:36:39 +0100
commitd55dceff371c4080d179fb26e6f175927cc48768 (patch)
tree65598ecdc8142d4178b1f8b13dce37e871cc7016 /apps
parent90960adf56d4798a23b8fdc7e6a9bb25dd0bf530 (diff)
downloadrockbox-d55dceff371c4080d179fb26e6f175927cc48768.tar.gz
rockbox-d55dceff371c4080d179fb26e6f175927cc48768.zip
apps: Add ability to do a clean reboot
Allow a clean shutdown to end in either power off or reboot. Add a new event SYS_REBOOT to signal it and sys_reboot() to trigger the event. SYS_REBOOT signals a reboot request and should be listened for alongside SYS_POWEROFF events. Change-Id: I99ba7fb5feed2bb5a0a40a274e8466ad74fe3a43
Diffstat (limited to 'apps')
-rw-r--r--apps/iap/iap-core.c1
-rw-r--r--apps/misc.c18
-rw-r--r--apps/plugins/battery_bench.c1
-rw-r--r--apps/plugins/chessbox/chessbox.c3
-rw-r--r--apps/plugins/lastfm_scrobbler.c1
-rw-r--r--apps/plugins/lua/rocklib.c1
-rw-r--r--apps/plugins/mpegplayer/mpeg_misc.c1
-rw-r--r--apps/plugins/plugin_crt0.c3
-rw-r--r--apps/plugins/solitaire.c1
-rw-r--r--apps/recorder/recording.c3
-rw-r--r--apps/tagcache.c2
11 files changed, 29 insertions, 6 deletions
diff --git a/apps/iap/iap-core.c b/apps/iap/iap-core.c
index 885ba2c188..ae05806ae9 100644
--- a/apps/iap/iap-core.c
+++ b/apps/iap/iap-core.c
@@ -364,6 +364,7 @@ static void iap_thread(void)
364 364
365 /* Handle poweroff message */ 365 /* Handle poweroff message */
366 case SYS_POWEROFF: 366 case SYS_POWEROFF:
367 case SYS_REBOOT:
367 { 368 {
368 iap_shutdown = true; 369 iap_shutdown = true;
369 break; 370 break;
diff --git a/apps/misc.c b/apps/misc.c
index 4d8c2e975a..d5e8bb5d98 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -288,7 +288,8 @@ static void system_restore(void)
288 tree_restore(); 288 tree_restore();
289} 289}
290 290
291static bool clean_shutdown(void (*callback)(void *), void *parameter) 291static bool clean_shutdown(enum shutdown_type sd_type,
292 void (*callback)(void *), void *parameter)
292{ 293{
293 long msg_id = -1; 294 long msg_id = -1;
294 295
@@ -392,7 +393,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
392 voice_wait(); 393 voice_wait();
393 } 394 }
394 395
395 shutdown_hw(); 396 shutdown_hw(sd_type);
396 } 397 }
397 return false; 398 return false;
398} 399}
@@ -605,8 +606,17 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
605 return SYS_USB_CONNECTED; 606 return SYS_USB_CONNECTED;
606 607
607 case SYS_POWEROFF: 608 case SYS_POWEROFF:
608 if (!clean_shutdown(callback, parameter)) 609 case SYS_REBOOT:
609 return SYS_POWEROFF; 610 {
611 enum shutdown_type sd_type;
612 if (event == SYS_POWEROFF)
613 sd_type = SHUTDOWN_POWER_OFF;
614 else
615 sd_type = SHUTDOWN_REBOOT;
616
617 if (!clean_shutdown(sd_type, callback, parameter))
618 return event;
619 }
610 break; 620 break;
611#if CONFIG_CHARGING 621#if CONFIG_CHARGING
612 case SYS_CHARGER_CONNECTED: 622 case SYS_CHARGER_CONNECTED:
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index d8e29d73ca..17d3b918cf 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -462,6 +462,7 @@ static void thread(void)
462 in_usb_mode = false; 462 in_usb_mode = false;
463 break; 463 break;
464 case SYS_POWEROFF: 464 case SYS_POWEROFF:
465 case SYS_REBOOT:
465 exit_reason = "power off"; 466 exit_reason = "power off";
466 exit = true; 467 exit = true;
467 break; 468 break;
diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c
index 13df4f177e..089cf7c400 100644
--- a/apps/plugins/chessbox/chessbox.c
+++ b/apps/plugins/chessbox/chessbox.c
@@ -222,6 +222,7 @@ static void cb_wt_callback ( void ) {
222 button = rb->button_get(false); 222 button = rb->button_get(false);
223 switch (button) { 223 switch (button) {
224 case SYS_POWEROFF: 224 case SYS_POWEROFF:
225 case SYS_REBOOT:
225 cb_sysevent = button; 226 cb_sysevent = button;
226#ifdef CB_RC_QUIT 227#ifdef CB_RC_QUIT
227 case CB_RC_QUIT: 228 case CB_RC_QUIT:
@@ -585,6 +586,7 @@ static struct cb_command cb_get_viewer_command (void) {
585 button = rb->button_get(true); 586 button = rb->button_get(true);
586 switch (button) { 587 switch (button) {
587 case SYS_POWEROFF: 588 case SYS_POWEROFF:
589 case SYS_REBOOT:
588 cb_sysevent = button; 590 cb_sysevent = button;
589#ifdef CB_RC_QUIT 591#ifdef CB_RC_QUIT
590 case CB_RC_QUIT: 592 case CB_RC_QUIT:
@@ -848,6 +850,7 @@ static struct cb_command cb_getcommand (void) {
848 button = rb->button_get(true); 850 button = rb->button_get(true);
849 switch (button) { 851 switch (button) {
850 case SYS_POWEROFF: 852 case SYS_POWEROFF:
853 case SYS_REBOOT:
851 cb_sysevent = button; 854 cb_sysevent = button;
852#ifdef CB_RC_QUIT 855#ifdef CB_RC_QUIT
853 case CB_RC_QUIT: 856 case CB_RC_QUIT:
diff --git a/apps/plugins/lastfm_scrobbler.c b/apps/plugins/lastfm_scrobbler.c
index 4d4940945d..7bd213b6d2 100644
--- a/apps/plugins/lastfm_scrobbler.c
+++ b/apps/plugins/lastfm_scrobbler.c
@@ -490,6 +490,7 @@ void thread(void)
490 rb->beep_play(1500, 100, 1000); 490 rb->beep_play(1500, 100, 1000);
491 break; 491 break;
492 case SYS_POWEROFF: 492 case SYS_POWEROFF:
493 case SYS_REBOOT:
493 gCache.force_flush = true; 494 gCache.force_flush = true;
494 /*fall through*/ 495 /*fall through*/
495 case EV_EXIT: 496 case EV_EXIT:
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c
index 6131a479db..cadc8be6ac 100644
--- a/apps/plugins/lua/rocklib.c
+++ b/apps/plugins/lua/rocklib.c
@@ -1090,6 +1090,7 @@ LUALIB_API int luaopen_rock(lua_State *L)
1090 RB_CONSTANT(SYS_USB_DISCONNECTED), 1090 RB_CONSTANT(SYS_USB_DISCONNECTED),
1091 RB_CONSTANT(SYS_TIMEOUT), 1091 RB_CONSTANT(SYS_TIMEOUT),
1092 RB_CONSTANT(SYS_POWEROFF), 1092 RB_CONSTANT(SYS_POWEROFF),
1093 RB_CONSTANT(SYS_REBOOT),
1093 RB_CONSTANT(SYS_CHARGER_CONNECTED), 1094 RB_CONSTANT(SYS_CHARGER_CONNECTED),
1094 RB_CONSTANT(SYS_CHARGER_DISCONNECTED), 1095 RB_CONSTANT(SYS_CHARGER_DISCONNECTED),
1095 1096
diff --git a/apps/plugins/mpegplayer/mpeg_misc.c b/apps/plugins/mpegplayer/mpeg_misc.c
index c85285f4f8..31f0644212 100644
--- a/apps/plugins/mpegplayer/mpeg_misc.c
+++ b/apps/plugins/mpegplayer/mpeg_misc.c
@@ -192,6 +192,7 @@ int mpeg_sysevent_callback(int btn,
192 { 192 {
193 case SYS_USB_CONNECTED: 193 case SYS_USB_CONNECTED:
194 case SYS_POWEROFF: 194 case SYS_POWEROFF:
195 case SYS_REBOOT:
195 mpeg_sysevent_id = btn; 196 mpeg_sysevent_id = btn;
196 return ACTION_STD_CANCEL; 197 return ACTION_STD_CANCEL;
197 } 198 }
diff --git a/apps/plugins/plugin_crt0.c b/apps/plugins/plugin_crt0.c
index 680bb0723d..5564c5575f 100644
--- a/apps/plugins/plugin_crt0.c
+++ b/apps/plugins/plugin_crt0.c
@@ -141,6 +141,7 @@ void exit_on_usb(int button)
141 long result = rb->default_event_handler_ex(button, cleanup_wrapper, NULL); 141 long result = rb->default_event_handler_ex(button, cleanup_wrapper, NULL);
142 if (result == SYS_USB_CONNECTED) 142 if (result == SYS_USB_CONNECTED)
143 _exit(PLUGIN_USB_CONNECTED); 143 _exit(PLUGIN_USB_CONNECTED);
144 else if (result == SYS_POWEROFF) 144 else if (result == SYS_POWEROFF || result == SYS_REBOOT)
145 /* note: nobody actually pays attention to this exit code */
145 _exit(PLUGIN_POWEROFF); 146 _exit(PLUGIN_POWEROFF);
146} 147}
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index b1ede16f90..ebc042f6db 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -2149,6 +2149,7 @@ static int solitaire( int skipmenu )
2149 break; 2149 break;
2150 2150
2151 case SYS_POWEROFF: 2151 case SYS_POWEROFF:
2152 case SYS_REBOOT:
2152 return SOLITAIRE_SAVE_AND_QUIT; 2153 return SOLITAIRE_SAVE_AND_QUIT;
2153 2154
2154 default: 2155 default:
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c
index b973d9750c..a54b762566 100644
--- a/apps/recorder/recording.c
+++ b/apps/recorder/recording.c
@@ -1534,7 +1534,8 @@ bool recording_screen(bool no_source)
1534 break; 1534 break;
1535 1535
1536 case SYS_POWEROFF: 1536 case SYS_POWEROFF:
1537 default_event_handler(SYS_POWEROFF); 1537 case SYS_REBOOT:
1538 default_event_handler(button);
1538 done = true; 1539 done = true;
1539 break; 1540 break;
1540 1541
diff --git a/apps/tagcache.c b/apps/tagcache.c
index 8bc742112b..c18380854e 100644
--- a/apps/tagcache.c
+++ b/apps/tagcache.c
@@ -3989,6 +3989,7 @@ static bool check_event_queue(void)
3989 { 3989 {
3990 case Q_STOP_SCAN: 3990 case Q_STOP_SCAN:
3991 case SYS_POWEROFF: 3991 case SYS_POWEROFF:
3992 case SYS_REBOOT:
3992 case SYS_USB_CONNECTED: 3993 case SYS_USB_CONNECTED:
3993 return true; 3994 return true;
3994 } 3995 }
@@ -4944,6 +4945,7 @@ static void tagcache_thread(void)
4944 break ; 4945 break ;
4945 4946
4946 case SYS_POWEROFF: 4947 case SYS_POWEROFF:
4948 case SYS_REBOOT:
4947 break ; 4949 break ;
4948 4950
4949 case SYS_USB_CONNECTED: 4951 case SYS_USB_CONNECTED: