Difference between revisions of "Patch webOS Radio Power Switch"

From WebOS Internals
Jump to navigation Jump to search
Line 8: Line 8:
Works with: 1.0.3
Works with: 1.0.3
Does NOT currently work with: 1.1
Does NOT currently work with: 1.1

Revision as of 06:01, 24 July 2009

Seamless Interface

Radio Power Switch


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.3

Does NOT currently work with: 1.1


/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html Line 97: <source lang="HTML4Strict">




/usr/lib/luna/system/luna-systemui/app/controllers/bar-assistant.js Line 690: <source lang="JavaScript"> var stageController = Mojo.Controller.getAppController().getStageProxy("DeviceMenu"); stageController.delegateToSceneAssistant("updatePhone"); </source>

Line 2302:

<source lang="JavaScript"> getCurrentPhoneState: function() { return this.phoneRadioState; }, </source>

/usr/lib/luna/system/luna-systemui/app/controllers/devicemenu-assistant.js Line 1: <source lang="JavaScript"> var RadioState = new Hash({wifi: undefined, bluetooth: undefined, phone: undefined}); </source>

Line 39:

<source lang="JavaScript"> this.controller.setupWidget('phonedetails', {modelProperty:'myOpenProperty'}, this.drawerModel); this.phonedrawer = this.controller.get('phonedetails'); </source>

Line 95:

<source lang="JavaScript"> 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); } </source>

Line 118:

<source lang="JavaScript"> 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)); </source>

Line 173:

<source lang="JavaScript"> 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()); }, </source>

Line 921:

<source lang="JavaScript"> if(this.phonedrawer.mojo.getOpenState()) { this.controller.hideWidgetContainer(this.controller.get('phonedetails')); this.phonedrawer.mojo.setOpenState(false); } </source>



  • 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 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.


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


NOTE: If you have never modified any code on the phone, please see [/stock-application-mods Modifiying 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">   

/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()) {
			this.controller.get('dm_power_status').innerHTML = $L('Turn on Phone Radio');
		else {
			this.controller.get('dm_power_status').innerHTML = $L('Turn off Phone Radio');


  • 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


Brought to you by pEEf.