View Single Post
Old 07-11-2010, 05:44 PM   #29
dima_tr
Groupie
dima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-booksdima_tr has learned how to read e-books
 
Posts: 175
Karma: 863
Join Date: Oct 2009
Location: Germany, Karlsruhe
Device: Iliad v2, DR800S (inlove)
Working with Notepad application as well as "Hello World" I might have gotten a hint. Every respectable app has a callback describing what to do on suspend. E.g. Notepad saves its state:
Code:
     static void on_prepare_standby( 
            eripc_context_t          *context,
            const eripc_event_info_t *info,
            void                     *user_data )
    {
        LOGPRINTF("entry");
        (void) gInstance->save();
        LOGPRINTF("exit");
    }
So, the idea is to launch an application with the lowest priority which should have in this callback
Code:
  * wait for say 5 seconds for others to prepare for suspend
  * call /sbin/shutdown
Having this app running we then can trigger a software/hardware suspend - either special menu item or use power button for 0.5 sec. The system will be switched off due to the callback in our special app. Sending "suspend" signal we guarantee everything is saved before shutdown.

What do you say?


Edit: calling unmount_sd might not work clean, e.g. Notepad does gInstance->quit(); instead of saving. And we can just try modifying GregorRichards's code by explicit call of suspend (will this work though?).

Last edited by dima_tr; 07-11-2010 at 05:56 PM. Reason: have read GregorRichards's solution code
dima_tr is offline   Reply With Quote