Difference between revisions of "Patch webOS Radio Power Switch"

From WebOS Internals
Jump to navigation Jump to search
(→‎Seamless Interface: syntax highlighting)
(→‎Seamless Interface: added image and updated headers)
Line 1: Line 1:
 
= Seamless Interface =
 
= Seamless Interface =
 +
 +
[[Image:RadioPowerSwitch.jpg|border|right|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.
 
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.
  
== Configuration ==
+
== Procedure ==
  
 
'''/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html''' Line 97:
 
'''/usr/lib/luna/system/luna-systemui/app/views/devicemenu/devicemenu-scene.html''' Line 97:
Line 123: Line 127:
 
</source>
 
</source>
  
== Other Thoughts ==
+
== Acknowledgements ==
 +
 
 +
* pEEf, for figuring everything out
 +
* [[User:HattCzech|HattCzech]]
  
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]]
  
 
----
 
----

Revision as of 05:16, 23 July 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.

Procedure

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

 

Phone

</source>


/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>

Acknowledgements

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 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 [/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">   
                                         </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.