User:Magick777/Opportunistic Power Saving
(→/usr/bin/set2g) |
|||
Line 1: | Line 1: | ||
+ | <source lang="text"> | ||
+ | #!/bin/sh | ||
+ | |||
+ | # Test the current radio mode and abort if in 3G or dual mode already | ||
+ | TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_selected_radio_access_technology | grep "byte [02]"` | ||
+ | if [ ! -z "$TEST" ] | ||
+ | then | ||
+ | echo "Phone is already in either 3G or dual mode, aborting." | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | # Test whether the phone is on a call, if it is then don't mess with it | ||
+ | TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus | grep "uint32 0"` | ||
+ | #if phone is on call, grep filters out any call status but 0/idle, so we get a zero length output | ||
+ | if [ -z "$TEST" ] | ||
+ | then | ||
+ | echo "Phone is making or receiving a call, aborting." | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | #Before we change the radio mode, check that we're not on WiFi | ||
+ | TEST=`grep 1 /tmp/onwifi` | ||
+ | |||
+ | if [ ! -z "$TEST" ] | ||
+ | then | ||
+ | echo "Phone is connected via WiFi, no point autoswitching to dual mode." | ||
+ | exit 1 | ||
+ | fi | ||
+ | |||
+ | |||
+ | # Make the change to 3G | ||
+ | run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:0 | ||
+ | </source> | ||
+ | |||
==/usr/bin/set2g== | ==/usr/bin/set2g== | ||
<source lang="text"> | <source lang="text"> |
Revision as of 21:15, 19 July 2010
#!/bin/sh # Test the current radio mode and abort if in 3G or dual mode already TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_selected_radio_access_technology | grep "byte [02]"` if [ ! -z "$TEST" ] then echo "Phone is already in either 3G or dual mode, aborting." exit 1 fi # Test whether the phone is on a call, if it is then don't mess with it TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus | grep "uint32 0"` #if phone is on call, grep filters out any call status but 0/idle, so we get a zero length output if [ -z "$TEST" ] then echo "Phone is making or receiving a call, aborting." exit 1 fi #Before we change the radio mode, check that we're not on WiFi TEST=`grep 1 /tmp/onwifi` if [ ! -z "$TEST" ] then echo "Phone is connected via WiFi, no point autoswitching to dual mode." exit 1 fi # Make the change to 3G run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:0
/usr/bin/set2g
#!/bin/sh # This script is intended to be run indirectly from dbus-scripts and to be triggered on # phone lock. It will then attempt to determine whether it makes sense to change the radio # mode to GSM in order to save battery life. # Test the current radio mode and abort if we're in GSM mode already TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.get_selected_radio_access_technology | g$ if [ ! -z "$TEST" ] then echo "Phone is already in 2G mode, aborting." exit 1 fi # If we're on charge, we don't need to save battery so don't downgrade. TEST=`grep 1 /tmp/oncharge` if [ ! -z "$TEST" ] then # it's a non-zero value so we're on charge, abort gracefully echo "Phone is on charge, no need to set 2G mode, aborting." exit 1 fi # Test whether the phone is on a call, if it is don't mess with it TEST=`dbus-send --system --type=method_call --print-reply --dest=com.nokia.csd.Call /com/nokia/csd/call/1 com.nokia.csd.Call.Instance.GetStatus | grep "uint$ #if phone is on call, grep filters out any call status but 0/idle, so we get a zero length output if [ -z "$TEST" ] then echo "Phone is making or receiving a call, aborting." exit 1 fi ## Adding a 30 cooling off period means that if the device gets unlocked again within 30 seconds, we can ## kill this script whilst it's sleeping and leave 3G intact. echo "Scheduling switch to 2G in 30 seconds..." sleep 30 # Make the actual change to 2G radio mode run-standalone.sh dbus-send --system --type=method_call --dest=com.nokia.phone.net /com/nokia/phone/net Phone.Net.set_selected_radio_access_technology byte:1 echo "Phone set to 2G mode." exit 0