Android 1.5: flight mode analysis

Source: Internet
Author: User

Author: Xu jianxiang (netpirate@gmail.com)
Date: 2009/11/05
Web: http://www.anymobile.org

1.1 enable the flight mode through COM. Android. settings. wirelesssettings;

1.1.1 set the flight mode value;
Settings. system. putint (mcontext. getcontentresolver (), settings. system. airplane_mode_on, enabling? 1: 0 );

1.1.2 send intent (intent. action_airplane_mode_changed ).
Airplanemodeenabler. setairplanemodeon (Boolean enabling)

1.2 close related service connections

1.2.1 disable wifi;
Frameworks/base/services/Java/COM/Android/Server/wifiservice. broadcastreceiver. onreceive (...)

1.2.2 disable Bluetooth;
Frameworks/base/CORE/Java/Android/Server/javasthdeviceservice. broadcastreceiver. onreceive (...)

1.2.3 disable radio.
Phoneapp. phoneappbroadcastreceiver. onreceive (...) -> gsmphone. setradiopower (false)-> servicestatetracker. setradiopower (false)-> servicestatetracker. setpowerstatetodesired ()-> RIL. setradiopower (true, null)

2. Cancel the flight mode.

Similar to the process of enabling the flight mode, set false to true or omitted.

3/flight mode Startup Process

After sim_ready, servicestatetracker closes radio after receiving the radio_state_changed notification. For WiFi and BluetoothProgramDetermines the flight mode settings. If it is a flight mode, it is unavailable.

The following is the radio off process:

3.1 boot normally. After the radio state is switched to the sim_ready state, the event_radio_state_changed notification will be sent up;
Radio. State = radio_state_unavailable-> radio_state_off-> sim_not_ready-> sim_ready
(Hardware/RIL/reference-RIL/reference-ril.c)

3.2 servicestatetracker. Java initialization, set mdesiredpowerstate =! (Airplanemode> 0), and call the RIL interface to register event_radio_state_changed;
Frameworks/base/telephony/Java/COM/Android/Internal/telephony/GSM/servicestatetracker. Java

3.3 servicestatetracker. Java handles radio state changes. If it is not in flight mode, set the radio status to on. If it is in flight mode and the system is in startup status, disable radio; 1 Public   Void Handlemessage (Message MSG)
2 Case Event_radio_state_changed:
3 // This will do nothing in the radio not
4 // Available case
5 Setpowerstatetodesired ();
6 Pollstate ();
7 Break ;
8 Private   Void Setpowerstatetodesired ()
9 If (Mdesiredpowerstate
10 && Cm. getradiostate () = Commandsinterface. radiostate. radio_off
11 ){
12 Cm. setradiopower ( True , Null );
13 } Else   If ( ! Mdesiredpowerstate && Cm. getradiostate (). ISON ()){
14 Dctracker. cleanconnectionbeforeradiooff ();
15 // If it's on and available and we want it off ..
16 Cm. setradiopower ( False , Null );
17 } // Otherwise, we're in the desired state
18 }

3.4 after the radio is switched off (the status changes to radio_off), send an event_radio_state_changed notification to the upstream. For details, refer to 3.3.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.