Difference between revisions of "Patch webOS Radio Power Switch"

From WebOS Internals
Jump to navigation Jump to search
m (fixing links.)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
{{template:patch}}
 
= Seamless Interface =
 
= Seamless Interface =
  
I took what pEEf did and made it look more like it fits. I liked the original idea, but as mentioned in the concerns below, when changing between Airplane mode and back, it doesn't have the correct information. I made mine look like the Bluetooth and Wi-Fi menus.
+
[[Image:RadioPowerSwitch.jpg|border|right|Radio Power Switch]]
  
== Configuration ==
+
== Introduction ==
  
'''/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html''' Line 97:
+
I took what pEEf did and made it look more like it fits. I liked the original idea, but as mentioned in the concerns below, when changing between Airplane mode and back, it doesn't have the correct information. I made mine look like the Bluetooth and Wi-Fi menus.
<code><pre>
 
<div class="palm-row" id="dm_phone" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
 
<div class="title truncating-text">
 
<div class="label right" id="phonemsg">&nbsp;</div>
 
<span x-mojo-loc=''>Phone</span>
 
</div>
 
</div></div>
 
 
 
<div id='phonedetails' x-mojo-element="Drawer">
 
 
 
<div class="palm-row first" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
 
<div id="phone_radio" class="title truncating-text">
 
</div>
 
</div></div>
 
 
 
</div>
 
 
 
<div class="palm-section-divider"></div>
 
</pre></code>
 
 
 
 
 
'''/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js''' Line 690:
 
<code><pre>
 
var stageController = Mojo.Controller.getAppController().getStageProxy("DeviceMenu");
 
stageController.delegateToSceneAssistant("updatePhone");
 
</pre></code>
 
 
 
Line 2302:
 
<code><pre>
 
getCurrentPhoneState: function() {
 
return this.phoneRadioState;
 
},
 
</pre></code>
 
 
 
 
 
'''/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js''' Line 1:
 
<code><pre>
 
var RadioState = new Hash({wifi: undefined, bluetooth: undefined, phone: undefined});
 
</pre></code>
 
  
Line 39:
+
Works with: 1.0.x, 1.1
<code><pre>
 
this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
 
this.phonedrawer = this.controller.get('phonedetails');
 
</pre></code>
 
  
Line 95:
+
== Procedure ==
<code><pre>
 
if(this.barAssistant.getCurrentPhoneState()) {
 
this.controller.get('phonemsg').innerHTML = $L('On');
 
RadioState.set('phone',true);
 
}
 
else {
 
this.controller.get('phonemsg').innerHTML = $L('Off');
 
RadioState.set('phone',false);
 
}
 
</pre></code>
 
  
Line 118:
+
Run the following commands:
<code><pre>
 
this.controller.get('dm_phone').addEventListener(Mojo.Event.tap, this.togglePhoneList.bindAsEventListener(this));
 
this.controller.get('phone_radio').addEventListener(Mojo.Event.tap, this.togglePhoneRadio.bindAsEventListener(this));
 
</pre></code>
 
  
Line 173:
+
''In this example, I have the patch file located in my home directory under '''patches'''''
<code><pre>
+
<source lang="bash">
updatePhone: function() {
+
cd /
if(this.barAssistant.getCurrentPhoneState()) {
+
sudo patch -p0 --backup-if-mismatch < ~/patches/radiopower.patch
this.controller.get('phonemsg').innerHTML = $L('On');
+
</source>
this.controller.get('phone_radio').innerHTML = $L('Turn off Phone');
 
RadioState.set('phone', true);
 
}
 
else {
 
this.controller.get('phonemsg').innerHTML = $L('Off');
 
this.controller.get('phone_radio').innerHTML = $L('Turn on Phone');
 
RadioState.set('phone', false);
 
}
 
},
 
  
togglePhoneRadio: function(event) {
+
This is what you should see if it ran properly:
this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
+
<source lang="text">
method: 'vibrate', parameters: { 'period': 0,'duration': 250 }
+
patching file /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js
});
+
patching file /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js
if(RadioState.get('phone'))
+
patching file /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html
TelephonyService.tempPowerSet('off',false,null,null);
+
</source>
else
 
TelephonyService.tempPowerSet('on',false,null,null);
 
this.toggleDeviceMenu();
 
},
 
  
togglePhoneList: function(event) {
+
These modifications will require LunaSysMgr to be restarted. A rescan will not work. After you've run the commands above, run one more command:
if(this.apModeInProgress)
+
<source lang="bash">
return;
+
pkill LunaSysMgr
 +
</source>
  
if (this.phonedrawer.mojo.getOpenState()) {
+
== radiopower.patch ==
this.controller.hideWidgetContainer(this.controller.get('phonedetails'));
 
}
 
else {
 
if(RadioState.get('phone'))
 
this.controller.get('phone_radio').innerHTML = $L('Turn off Phone');
 
else
 
this.controller.get('phone_radio').innerHTML = $L('Turn on Phone');
 
  
this.controller.showWidgetContainer(this.controller.get('phonedetails'));
+
<source lang="diff">
}
+
diff -ur /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js /usr/lib/luna/sysmod/luna-systemui/app/controllers/bar-assistant.js
this.phonedrawer.mojo.setOpenState(!this.phonedrawer.mojo.getOpenState());
+
--- /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js 2009-07-18 00:21:30.000000000 -0500
},
+
+++ /usr/lib/luna/sysmod/luna-systemui/app/controllers/bar-assistant.js 2009-07-24 00:44:08.000000000 -0500
</pre></code>
+
@@ -789,6 +789,8 @@
 +
this.callForwardNotificationSession = null;
 +
}
 +
}
 +
+ var stageController = Mojo.Controller.getAppController().getStageProxy("DeviceMenu");
 +
+ stageController.delegateToSceneAssistant("updatePhone");
 +
}
 +
else if (payload.eventNetwork && this.phoneRadioState) {
 +
var networkMsg = payload.eventNetwork;
 +
@@ -2572,6 +2574,10 @@
 +
return this.wifiState;
 +
},
 +
 +
+getCurrentPhoneState: function() {
 +
+ return this.phoneRadioState;
 +
+},
 +
+
 +
setDeviceMenuAssistant: function(menuassistant) {
 +
this.deviceMenuAssistant = menuassistant;
 +
},
 +
diff -ur /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js /usr/lib/luna/sysmod/luna-systemui/app/controllers/devicemenu-assistant.js
 +
--- /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js 2009-07-18 00:21:30.000000000 -0500
 +
+++ /usr/lib/luna/sysmod/luna-systemui/app/controllers/devicemenu-assistant.js 2009-07-24 10:46:55.000000000 -0500
 +
@@ -1,6 +1,6 @@
 +
/* Copyright 2009 Palm, Inc.  All rights reserved. */
 +
 +
-var RadioState = new Hash({wifi: undefined, bluetooth: undefined});
 +
+var RadioState = new Hash({wifi: undefined, bluetooth: undefined, phone: undefined});
 +
 +
var DevicemenuAssistant = Class.create({
 +
 +
@@ -36,6 +36,8 @@
 +
this.drawerModel = {myOpenProperty:false};
 +
this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
 +
this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
 +
+ this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
 +
+ this.phonedrawer = this.controller.get('phonedetails');
 +
this.wifidrawer = this.controller.get('wifidetails');
 +
this.btdrawer = this.controller.get('btdetails');
 +
 +
@@ -92,6 +94,17 @@
 +
else
 +
this.controller.get('wifimsg').innerHTML = wifistate.escapeHTML();
 +
}
 +
+
 +
+ var phonestate = this.barAssistant.getCurrentPhoneState();
 +
+ if(phonestate === 'Off') {
 +
+ this.controller.get('phonemsg').innerHTML = $L('Off');
 +
+ RadioState.set('phone',false);
 +
+ }
 +
+ else {
 +
+ this.controller.get('phonemsg').innerHTML = $L('On');
 +
+ RadioState.set('phone',true);
 +
+ }
 +
+
 +
this.controller.listen(this.controller.document, Mojo.Event.deactivate, this.close.bindAsEventListener(this));
 +
this.isVisible = true;
 +
 +
@@ -115,6 +128,8 @@
 +
this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bindAsEventListener(this));
 +
this.controller.get('dm_wifi').addEventListener(Mojo.Event.tap, this.togglewifiList.bindAsEventListener(this));
 +
this.controller.get('dm_bluetooth').addEventListener(Mojo.Event.tap, this.togglebluetoothList.bindAsEventListener(this));
 +
+ this.controller.get('dm_phone').addEventListener(Mojo.Event.tap, this.togglePhoneList.bindAsEventListener(this));
 +
+ this.controller.get('phone_radio').addEventListener(Mojo.Event.tap, this.togglePhoneRadio.bindAsEventListener(this));
 +
this.controller.get('wifi_radio').addEventListener(Mojo.Event.tap, this.toggleWifiRadio.bindAsEventListener(this));
 +
this.controller.get('bt_radio').addEventListener(Mojo.Event.tap, this.toggleBTRadio.bindAsEventListener(this));
 +
this.controller.get('bt_pref').addEventListener(Mojo.Event.tap,this.handleBluetoothLaunch.bindAsEventListener(this));
 +
@@ -175,6 +190,48 @@
 +
this.apModeInProgress = false;
 +
},
 +
 +
+ updatePhone: function() {
 +
+ if(this.barAssistant.getCurrentPhoneState()) {
 +
+ this.controller.get('phonemsg').innerHTML = $L('On');
 +
+ this.controller.get('phone_radio').innerHTML = $L('Turn off Phone');
 +
+ RadioState.set('phone', true);
 +
+ }
 +
+ else {
 +
+ this.controller.get('phonemsg').innerHTML = $L('Off');
 +
+ this.controller.get('phone_radio').innerHTML = $L('Turn on Phone');
 +
+ RadioState.set('phone', false);
 +
+ }
 +
+ },
 +
+
 +
+ togglePhoneRadio: function(event) {
 +
+ this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
 +
+ method: 'vibrate', parameters: { 'period': 0,'duration': 250 }
 +
+ });
 +
+ if(RadioState.get('phone'))
 +
+ TelephonyService.tempPowerSet('off',false,null,null);
 +
+ else
 +
+ TelephonyService.tempPowerSet('on',false,null,null);
 +
+ this.toggleDeviceMenu();
 +
+ },
 +
+
 +
+ togglePhoneList: function(event) {
 +
+ if(this.apModeInProgress)
 +
+ return;
 +
+
 +
+ if (this.phonedrawer.mojo.getOpenState()) {
 +
+ this.controller.hideWidgetContainer(this.controller.get('phonedetails'));
 +
+ }
 +
+ else {
 +
+ if(RadioState.get('phone'))
 +
+ this.controller.get('phone_radio').innerHTML = $L('Turn off Phone');
 +
+ else
 +
+ this.controller.get('phone_radio').innerHTML = $L('Turn on Phone');
 +
+
 +
+ this.controller.showWidgetContainer(this.controller.get('phonedetails'));
 +
+ }
 +
+ this.phonedrawer.mojo.setOpenState(!this.phonedrawer.mojo.getOpenState());
 +
+ },
 +
+
 +
toggleBTRadio: function(event) {
 +
if(RadioState.get('bluetooth')) {
 +
BtService.radiooff(null,null);
 +
@@ -880,7 +937,10 @@
 +
},
 +
 +
close: function() {
 +
-
 +
+ if(this.phonedrawer.mojo.getOpenState()) {
 +
+ this.controller.hideWidgetContainer(this.controller.get('phonedetails'));
 +
+ this.phonedrawer.mojo.setOpenState(false);
 +
+ }
 +
if (this.btdrawer.mojo.getOpenState()) {
 +
this.clearBTList();
 +
this.controller.hideWidgetContainer(this.controller.get('btdetails'));
 +
diff -ur /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html /usr/lib/luna/sysmod/luna-systemui/app/views/devicemenu/devicemenu-scene.html
 +
--- /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html 2009-07-18 00:21:30.000000000 -0500
 +
+++ /usr/lib/luna/sysmod/luna-systemui/app/views/devicemenu/devicemenu-scene.html 2009-07-24 00:52:11.000000000 -0500
 +
@@ -94,6 +94,22 @@
 +
 +
<div class="palm-section-divider"></div>
 +
 +
+ <div class="palm-row" id="dm_phone" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
 +
+ <div class="title truncating-text">
 +
+ <div class="label right" id="phonemsg">&nbsp;</div>
 +
+ <span x-mojo-loc=''>Phone</span>
 +
+ </div>
 +
+ </div></div>
 +
+
 +
+ <div id='phonedetails' x-mojo-element="Drawer">
 +
+ <div class="palm-row first" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
 +
+ <div id="phone_radio" class="title truncating-text">
 +
+ </div>
 +
+ </div></div>
 +
+ </div>
 +
+
 +
+ <div class="palm-section-divider"></div>
 +
+
 +
<div id="dm_airplanemode" class="palm-row last" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
 +
<div id="dm_airplanemode_status" class="title truncating-text">
 +
</div>
 +
</source>
  
Line 921:
+
== Acknowledgements ==
<code><pre>
 
if(this.phonedrawer.mojo.getOpenState()) {
 
this.controller.hideWidgetContainer(this.controller.get('phonedetails'));
 
this.phonedrawer.mojo.setOpenState(false);
 
}
 
</pre></code>
 
  
== Other Thoughts ==
+
* pEEf, for figuring everything out
 +
* [[User:HattCzech|HattCzech]]
 +
* NetWhiz, for fixing it to work with 1.1.0
  
Please let me know if this doesn't work the way it's supposed to. I tried a few times to get it to work properly, and from what I can tell, it works for me. pEEf, thanks for getting me started. -[[User:HattCzech|HattCzech]]
+
== Concerns ==
  
* Concerns for new method:  Airplane mode still always turns the radio on regardless of the state before airplane mode was turned on.  Otherwise, very nice.
+
* Airplane mode still always turns the radio on regardless of the state before airplane mode was turned on.  Otherwise, very nice.
* Comments: For the Airplane mode: I may try to add in a way for it to remember the phone state, but I figured that was the point of Airplane mode, so I haven't looked into it yet. I will look through the code again and see if it's worth it. -[[User:HattCzech|HattCzech]]
+
** I may try to add in a way for it to remember the phone state, but I figured that was the point of Airplane mode, so I haven't looked into it yet. I will look through the code again and see if it's worth it. -[[User:HattCzech|HattCzech]]
  
 
----
 
----
Line 136: Line 211:
 
I created this mod so I can turn off the cellular radio, but keep WiFi and Bluetooth on.  Strangely, The Pre does not seem to have an existing way to do this, only the "Airplane Mode" which shuts off ALL radios!
 
I created this mod so I can turn off the cellular radio, but keep WiFi and Bluetooth on.  Strangely, The Pre does not seem to have an existing way to do this, only the "Airplane Mode" which shuts off ALL radios!
  
I currently do not have Sprint service on my Pre, and am just using it with WiFi. (See [/bypassing-activation Bypassing Activation] for info on how to do this.)
+
I currently do not have Sprint service on my Pre, and am just using it with WiFi. (See [[Bypassing Activation]] for info on how to do this.)
  
 
This will also be useful for people wishing to save their battery if in a poor or no service area, yet still wanting to use WiFi.
 
This will also be useful for people wishing to save their battery if in a poor or no service area, yet still wanting to use WiFi.
Line 150: Line 225:
 
== Installation ==
 
== Installation ==
  
NOTE: If you have never modified any code on the phone, please see [/stock-application-mods Modifiying Stock Applications] first.
+
NOTE: If you have never modified any code on the phone, please see [[Modifying Stock Applications]] first.
  
 
This mod is simply additional code to be added to 3 files on your Pre. WARNING: MAKE BACKUPS FIRST!
 
This mod is simply additional code to be added to 3 files on your Pre. WARNING: MAKE BACKUPS FIRST!

Latest revision as of 10:16, 3 August 2009


Seamless Interface

Radio Power Switch

Introduction

I took what pEEf did and made it look more like it fits. I liked the original idea, but as mentioned in the concerns below, when changing between Airplane mode and back, it doesn't have the correct information. I made mine look like the Bluetooth and Wi-Fi menus.

Works with: 1.0.x, 1.1

Procedure

Run the following commands:

In this example, I have the patch file located in my home directory under patches <source lang="bash"> cd / sudo patch -p0 --backup-if-mismatch < ~/patches/radiopower.patch </source>

This is what you should see if it ran properly: <source lang="text"> patching file /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js patching file /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js patching file /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html </source>

These modifications will require LunaSysMgr to be restarted. A rescan will not work. After you've run the commands above, run one more command: <source lang="bash"> pkill LunaSysMgr </source>

radiopower.patch

<source lang="diff"> diff -ur /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js /usr/lib/luna/sysmod/luna-systemui/app/controllers/bar-assistant.js --- /usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js 2009-07-18 00:21:30.000000000 -0500 +++ /usr/lib/luna/sysmod/luna-systemui/app/controllers/bar-assistant.js 2009-07-24 00:44:08.000000000 -0500 @@ -789,6 +789,8 @@

				this.callForwardNotificationSession = null;	
			}				
		}

+ var stageController = Mojo.Controller.getAppController().getStageProxy("DeviceMenu"); + stageController.delegateToSceneAssistant("updatePhone");

	}
	else if (payload.eventNetwork && this.phoneRadioState) {
		var networkMsg = payload.eventNetwork;

@@ -2572,6 +2574,10 @@

	return this.wifiState;
},

+getCurrentPhoneState: function() { + return this.phoneRadioState; +}, +

setDeviceMenuAssistant: function(menuassistant) {
	this.deviceMenuAssistant = menuassistant;
},

diff -ur /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js /usr/lib/luna/sysmod/luna-systemui/app/controllers/devicemenu-assistant.js --- /usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js 2009-07-18 00:21:30.000000000 -0500 +++ /usr/lib/luna/sysmod/luna-systemui/app/controllers/devicemenu-assistant.js 2009-07-24 10:46:55.000000000 -0500 @@ -1,6 +1,6 @@

/* Copyright 2009 Palm, Inc.  All rights reserved. */

-var RadioState = new Hash({wifi: undefined, bluetooth: undefined}); +var RadioState = new Hash({wifi: undefined, bluetooth: undefined, phone: undefined});

var DevicemenuAssistant = Class.create({
	

@@ -36,6 +36,8 @@

		this.drawerModel = {myOpenProperty:false};
		this.controller.setupWidget('wifidetails', {modelProperty:'myOpenProperty'}, this.drawerModel);
		this.controller.setupWidget('btdetails', {modelProperty:'myOpenProperty'}, this.drawerModel);

+ this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel); + this.phonedrawer = this.controller.get('phonedetails');

		this.wifidrawer = this.controller.get('wifidetails');
		this.btdrawer = this.controller.get('btdetails');
		

@@ -92,6 +94,17 @@

			else
				this.controller.get('wifimsg').innerHTML = wifistate.escapeHTML();			
		}		

+ + var phonestate = this.barAssistant.getCurrentPhoneState(); + if(phonestate === 'Off') { + this.controller.get('phonemsg').innerHTML = $L('Off'); + RadioState.set('phone',false); + } + else { + this.controller.get('phonemsg').innerHTML = $L('On'); + RadioState.set('phone',true); + } +

		this.controller.listen(this.controller.document, Mojo.Event.deactivate, this.close.bindAsEventListener(this));
		this.isVisible = true;
		

@@ -115,6 +128,8 @@

		this.controller.get('btlist').addEventListener(Mojo.Event.listTap,this.handleBTTap.bindAsEventListener(this));		
		this.controller.get('dm_wifi').addEventListener(Mojo.Event.tap, this.togglewifiList.bindAsEventListener(this));
		this.controller.get('dm_bluetooth').addEventListener(Mojo.Event.tap, this.togglebluetoothList.bindAsEventListener(this));

+ this.controller.get('dm_phone').addEventListener(Mojo.Event.tap, this.togglePhoneList.bindAsEventListener(this)); + this.controller.get('phone_radio').addEventListener(Mojo.Event.tap, this.togglePhoneRadio.bindAsEventListener(this));

		this.controller.get('wifi_radio').addEventListener(Mojo.Event.tap, this.toggleWifiRadio.bindAsEventListener(this));
		this.controller.get('bt_radio').addEventListener(Mojo.Event.tap, this.toggleBTRadio.bindAsEventListener(this));
		this.controller.get('bt_pref').addEventListener(Mojo.Event.tap,this.handleBluetoothLaunch.bindAsEventListener(this));

@@ -175,6 +190,48 @@

		this.apModeInProgress = false;
	},
	

+ updatePhone: function() { + if(this.barAssistant.getCurrentPhoneState()) { + this.controller.get('phonemsg').innerHTML = $L('On'); + this.controller.get('phone_radio').innerHTML = $L('Turn off Phone'); + RadioState.set('phone', true); + } + else { + this.controller.get('phonemsg').innerHTML = $L('Off'); + this.controller.get('phone_radio').innerHTML = $L('Turn on Phone'); + RadioState.set('phone', false); + } + }, + + togglePhoneRadio: function(event) { + this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", { + method: 'vibrate', parameters: { 'period': 0,'duration': 250 } + }); + if(RadioState.get('phone')) + TelephonyService.tempPowerSet('off',false,null,null); + else + TelephonyService.tempPowerSet('on',false,null,null); + this.toggleDeviceMenu(); + }, + + togglePhoneList: function(event) { + if(this.apModeInProgress) + return; + + if (this.phonedrawer.mojo.getOpenState()) { + this.controller.hideWidgetContainer(this.controller.get('phonedetails')); + } + else { + if(RadioState.get('phone')) + this.controller.get('phone_radio').innerHTML = $L('Turn off Phone'); + else + this.controller.get('phone_radio').innerHTML = $L('Turn on Phone'); + + this.controller.showWidgetContainer(this.controller.get('phonedetails')); + } + this.phonedrawer.mojo.setOpenState(!this.phonedrawer.mojo.getOpenState()); + }, +

	toggleBTRadio: function(event) {
		if(RadioState.get('bluetooth')) {
			BtService.radiooff(null,null);			

@@ -880,7 +937,10 @@

	},
	
	close: function() {

- + if(this.phonedrawer.mojo.getOpenState()) { + this.controller.hideWidgetContainer(this.controller.get('phonedetails')); + this.phonedrawer.mojo.setOpenState(false); + }

		if (this.btdrawer.mojo.getOpenState()) {
			this.clearBTList();			
			this.controller.hideWidgetContainer(this.controller.get('btdetails'));

diff -ur /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html /usr/lib/luna/sysmod/luna-systemui/app/views/devicemenu/devicemenu-scene.html --- /usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html 2009-07-18 00:21:30.000000000 -0500 +++ /usr/lib/luna/sysmod/luna-systemui/app/views/devicemenu/devicemenu-scene.html 2009-07-24 00:52:11.000000000 -0500 @@ -94,6 +94,22 @@

+

+
+
 

+ Phone

+
+

+

+

+
+
+
+
+

+

+

+

</source>

Acknowledgements

  • pEEf, for figuring everything out
  • HattCzech
  • NetWhiz, for fixing it to work with 1.1.0

Concerns

  • Airplane mode still always turns the radio on regardless of the state before airplane mode was turned on. Otherwise, very nice.
    • I may try to add in a way for it to remember the phone state, but I figured that was the point of Airplane mode, so I haven't looked into it yet. I will look through the code again and see if it's worth it. -HattCzech

Original Version

I created this mod so I can turn off the cellular radio, but keep WiFi and Bluetooth on. Strangely, The Pre does not seem to have an existing way to do this, only the "Airplane Mode" which shuts off ALL radios!

I currently do not have Sprint service on my Pre, and am just using it with WiFi. (See Bypassing Activation for info on how to do this.)

This will also be useful for people wishing to save their battery if in a poor or no service area, yet still wanting to use WiFi.

Another great use is shutting off the phone so calls will not disturb you while allowing the phone to do all of its network-related activity.

How it works: Simply click the upper right of the screen where the status bar is (signal strength). You will get a drop-down menu, this is where the stock "Airplane Mode" is. I have added a "Toggle Radio Power" function here. If the radio is on it will turn it off, and vice-versa. It will not turn off WiFi or Bluetooth like Airplane mode does.

Note

The Pre actually already lets you turn off the cell radio. You can just turn on Airplane Mode, then turn on WiFi, Bluetooth, or both. ~ lolaiba

Installation

NOTE: If you have never modified any code on the phone, please see Modifying Stock Applications first.

This mod is simply additional code to be added to 3 files on your Pre. WARNING: MAKE BACKUPS FIRST!

I will update the page later with proper diffs, but for now you can just get into the shell, make your backups, fire up vi (or nano) then paste in the relevant lines. Once you are done, you can test it without rebooting by forcing the Luna manager to reinitialize its cache:

luna-send -n 1 palm://com.palm.applicationManager/rescan {}

Here is the code, Enjoy!

/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html Line 94:

                                <div class="palm-section-divider"></div><!-- Added by pEEf -->

                                <div id="dm_power" class="palm-row" x-mojo-tap-highlight='momentary'><div class="palm-row-wrapper">
                                        <div id="dm_power_status" class="title truncating-text">   
                                         </div>
                                </div></div>

/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js Line 2039:

//Returns the Radio Power. Called by DeviceMenu. Added by pEEf        
getPower: function() {       
	return this.phoneRadioState;
},

/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js Line 59:

//		Toggle for Radio Power - Added by pEEf
		if(this.barAssistant.getPower()) {
			this.controller.get('dm_power_status').innerHTML = $L('Turn off Phone Radio');
		}
		else {
			this.controller.get('dm_power_status').innerHTML = $L('Turn on Phone Radio');
		}

/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js Line 107:

this.controller.get('dm_power').addEventListener(Mojo.Event.tap, this.togglePower.bindAsEventListener(this));

/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js Line 126:

//	Toggles the Radio Power - Added by pEEf           

	togglePower: function() {
		this.serviceRequest = new Mojo.Service.Request("palm://com.palm.vibrate", {
			method: 'vibrate', parameters: { 'period': 0,'duration': 250 }
		});
		if(this.barAssistant.getPower()) {
			TelephonyService.tempPowerSet('off',false,null,null);
			this.controller.get('dm_power_status').innerHTML = $L('Turn on Phone Radio');
		}
		else {
			TelephonyService.tempPowerSet('on',false,null,null);
			this.controller.get('dm_power_status').innerHTML = $L('Turn off Phone Radio');
		}
		this.toggleDeviceMenu();
	},

Concerns

  • Turn off the radio, then turn on airplane mode, and upon turning off airplane mode, the toggle displays the wrong message.
  • Turn on airplane mode, toggle displays wrong message

Credits

Brought to you by pEEf.