[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82

Michael 'Mickey' Lauer mickey at vanille-media.de
Mon Feb 2 18:51:29 UTC 2009


The following commit has been merged in the master branch:
commit d3299e92e30c3616b5e68864000f04cfb9b608ab
Author: Michael 'Mickey' Lauer <mickey at vanille-media.de>
Date:   Tue Dec 2 21:57:32 2008 +0100

    ousaged: Preliminary implementation of org.freesmartphone.Usage.[Shutdown|Reboot]() -> ()
    Send signal org.freesmartphone.Usage.SystemAction() before suspending, after resuming,
    before shutting down, before rebooting. This fixes FSO ticket #287.

diff --git a/ChangeLog b/ChangeLog
index bb80f3d..3ddff49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,7 @@
 	* [onetworkd] Simple connection sharing now works. See
 	  org.freesmartphone.Network.StartConnectionSharingWithInterface(s) -> ()
 	  This fixes FSO ticket #244.
-	* [odeviced] Add two new resources: 'CPU' and 'Display':
+	* [odeviced] Added two new resources: 'CPU' and 'Display':
 	  Requesting the CPU resource will prevent the idle notifier from falling
 	  into the 'suspend' state, requesting the Display resource will prevent
 	  the idle notifier from falling into the 'idle_dim' (and following) state(s).
@@ -13,6 +13,10 @@
 	  of timing out (call did not return before the actual suspend was triggered).
 	  As an inherent result, the suspend now occurs asynchronous.
 	  This fixes FSO ticket #215.
+	* [ousaged] Added org.freesmartphone.Usage.[Shutdown|Reboot]() -> ()
+	* [ousaged] Send signal org.freesmartphone.Usage.SystemAction()
+	  before suspending, after resuming, before shutting down, before rebooting.
+	  This fixes FSO ticket #287.
 
 2008-11-30	Michael Lauer	<mickey at openmoko.org>
 
diff --git a/framework/subsystems/ousaged/generic.py b/framework/subsystems/ousaged/generic.py
index 9226fd0..44290ce 100644
--- a/framework/subsystems/ousaged/generic.py
+++ b/framework/subsystems/ousaged/generic.py
@@ -24,7 +24,7 @@ import gobject
 import dbus
 import dbus.service
 
-import time, os
+import time, os, subprocess
 
 import logging
 logger = logging.getLogger( MODULE_NAME )
@@ -288,6 +288,8 @@ class GenericUsageControl( dbus.service.Object ):
         """
         The actual suspending tasklet, phase 1 (suspending resources)
         """
+        self.SystemAction( "suspend" ) # send as early as possible
+
         logger.info( "suspending all resources..." )
         for resource in self.resources.values():
             logger.debug( "suspending %s", resource.name )
@@ -309,6 +311,7 @@ class GenericUsageControl( dbus.service.Object ):
         # FIXME might want to traverse /etc/apm.d/... and launch them scripts
 
         logger.info( "triggering kernel suspend" )
+        subprocess.call( "echo apm -s", shell=True )
         open( "/sys/power/state", "w" ).write( "mem\n" )
 
         logger.info( "kernel has resumed - resuming resources..." )
@@ -317,6 +320,8 @@ class GenericUsageControl( dbus.service.Object ):
             yield resource._resume()
         logger.info( "...completed." )
 
+        gobject.idle_add( lambda self=self:self.SystemAction( "resume" ) and False ) # send as late as possible
+
     def _nameOwnerChangedHandler( self, name, old_owner, new_owner ):
         if old_owner and not new_owner:
             for resource in self.resources.values():
@@ -375,7 +380,9 @@ class GenericUsageControl( dbus.service.Object ):
         else:
             resource.release( sender ).start_dbus( dbus_ok, dbus_error )
 
-    @dbus.service.method( DBUS_INTERFACE, "so", "", sender_keyword='sender', async_callbacks=( "dbus_ok", "dbus_error" ) )
+    @dbus.service.method( DBUS_INTERFACE, "so", "",
+                          sender_keyword='sender',
+                          async_callbacks=( "dbus_ok", "dbus_error" ) )
     def RegisterResource( self, resourcename, path, sender, dbus_ok, dbus_error ):
         """
         Register a new resource from a client.
@@ -391,14 +398,37 @@ class GenericUsageControl( dbus.service.Object ):
             self._addResource( resource )
             dbus_ok()
 
-    @dbus.service.method( DBUS_INTERFACE, "", "", async_callbacks=( "dbus_ok", "dbus_error" ) )
+    @dbus.service.method( DBUS_INTERFACE, "", "",
+                          async_callbacks=( "dbus_ok", "dbus_error" ) )
     def Suspend( self, dbus_ok, dbus_error ):
         """
-        Suspend all the resources.
+        Suspend all resources and the system.
         """
         # Call the _suspend task connected to the dbus callbacks
         self._suspend().start_dbus( dbus_ok, dbus_error )
 
+    @dbus.service.method( DBUS_INTERFACE, "", "",
+                          async_callbacks=( "dbus_ok", "dbus_error" ) )
+    def Shutdown( self, dbus_ok, dbus_error ):
+        """
+        Shutdown the system.
+        """
+        self.SystemAction( "shutdown" ) # send signal
+        dbus_ok()
+        # FIXME this is not a clean shutdown
+        subprocess.call( "shutdown -h now &", shell=True )
+
+    @dbus.service.method( DBUS_INTERFACE, "", "",
+                          async_callbacks=( "dbus_ok", "dbus_error" ) )
+    def Reboot( self, dbus_ok, dbus_error ):
+        """
+        Reboot the system.
+        """
+        # FIXME should we cleanly shutdown resources here -- will it matter?
+        self.SystemAction( "reboot" ) # send signal
+        dbus_ok()
+        subprocess.call( "reboot &", shell=True )
+
     #
     # dbus signals
     #
@@ -410,6 +440,10 @@ class GenericUsageControl( dbus.service.Object ):
     def ResourceAvailable( self, resourcename, state ):
         pass
 
+    @dbus.service.signal( DBUS_INTERFACE, "s" )
+    def SystemAction( self, action ):
+        pass
+
 #----------------------------------------------------------------------------#
 def factory( prefix, controller ):
 #----------------------------------------------------------------------------#

-- 
FSO frameworkd Debian packaging



More information about the pkg-fso-commits mailing list