[PATCH] zhone: use Suspend() instead of system("apm -s")
Timo Juhani Lindfors
timo.lindfors at iki.fi
Thu Sep 25 20:49:18 CEST 2008
Hi,
"apm -s" is currently the only reason I need to give zhone root
privileges. Here's a patch that'll make zhone use Suspend() of
org.freesmartphone.Device.RealTimeClock.Suspend() instead of "apm -s"
if it is available. Does this look ok?
best regards,
Timo Lindfors
diff --git a/src/zhone b/src/zhone
index 9dec301..d9b7ab7 100755
--- a/src/zhone
+++ b/src/zhone
@@ -1997,6 +1997,8 @@ class DBusObject( object ):
self.inputnotifier_iface = None
self.display_obj = None
self.display_iface = None
+ self.rtc_obj = None
+ self.rtc_iface = None
self.prefs_obj = None
self.prefs_iface = None
@@ -2102,6 +2104,9 @@ class DBusObject( object ):
if self.display_obj is not None:
self.display_iface = Interface( self.display_obj, "org.freesmartphone.Device.Display" )
self.display_iface.SetBrightness( 90 )
+ self.rtc_obj = self.tryGetProxy( "org.freesmartphone.odeviced", self.fw.ListObjectsByInterface( "org.freesmartphone.Device.RealTimeClock" )[0] )
+ if self.rtc_obj is not None:
+ self.rtc_iface = Interface( self.rtc_obj, "org.freesmartphone.Device.RealTimeClock" )
if self.device_obj is None:
failcount += 1
else:
@@ -2178,13 +2183,19 @@ class DBusObject( object ):
elif name+action == "POWERheld":
self.willSuspend = ( seconds >= 1 )
+ logger.info("willSuspend now set to %s" % self.willSuspend)
elif name+action == "POWERreleased":
+ logger.info("about to suspend")
if self.willSuspend:
+ logger.info("really about to suspend")
self.willSuspend = False
self.gsm_device_iface.PrepareForSuspend()
logger.info( "ENTERING SUSPEND" )
- os.system( "apm -s" )
+ if self.rtc_iface is not None:
+ self.rtc_iface.Suspend()
+ else:
+ os.system( "apm -s" )
logger.info( "RETURN FROM SUSPEND" )
self.gsm_device_iface.RecoverFromSuspend()
self.idlenotifier_iface.SetState("BUSY")
More information about the smartphones-standards
mailing list