The original process of the wireless module during the boot process. If the SIM card lock is enabled or the PIN is locked, the pin or Puk is required, however, this unlock action can only be implemented after the system is initialized. (How do I enter the password before the graphics system is original ?) After the system is initialized, WM. systemready () is called to notify the public. You can do what you do at this time.
The original process of the wireless module during the boot process:
Rild calls the functions in the reference implementation Reference-ril.c (Hardware/RIL/reference-RIL:
Const ril_radiofunctions * ril_init (const struct ril_env * ENV, int argc, char ** argv)
Ret = pthread_create (& s_tid_mainloop, & ATTR, mainloop, null );
Static void * mainloop (void * PARAM)
Ret = at_open (FD, onunsolicited );
Ril_requesttimedcallback (initializecallback, null, & timeval_0 );
In the initializecallback function, the cat is initialized.
Static void initializecallback (void * PARAM)
{
Atresponse * p_response = NULL;
Int err;
Setradiostate (radio_state_off );
At_handshake ();
/* Note: We don't check errors here. Everything important will
Be handled in onattimeout and onatreaderclosed */
/* Atchannel is tolerant of ECHO but it must */
/* Have verbose result codes */
At_send_command ("ate0q0v1", null );
/* No auto-answer */
At_send_command ("ats0 = 0", null );
/* Extended errors */
At_send_command ("at + cmee = 1", null );
/* Network registration events */
Err = at_send_command ("at + CREG = 2", & p_response );
/* Some handsets -- In tethered mode -- don't support CREG = 2 */
If (ERR <0 p_response-> success = 0 ){
At_send_command ("at + CREG = 1", null );
}
At_response_free (p_response );
/* GPRS registration events */
At_send_command ("at + cgreg = 1", null );
/* Call Waiting notifications */
At_send_command ("at + ccwa = 1", null );
/* Alternating Voice/Data off */
At_send_command ("at + cmod = 0", null );
/* Not muted */
At_send_command ("at + cmut = 0", null );
/* + Cssu unsolicited supp service specifications */
At_send_command ("at + cssn = 0, 1", null );
/* No connected line identification */
At_send_command ("at + Colp = 0", null );
/* Hex Character Set */
At_send_command ("at + CSCs =/" hex/"", null );
/* Ussd unsolicited */
At_send_command ("at + cusd = 1", null );
/* Enable + cgev GPRS event configurations, but don't buffer */
At_send_command ("at + cgerep = 1, 0", null );
/* Sms pdu mode */
At_send_command ("at + cmgf = 0", null );
# Ifdef use_ti_commands
At_send_command ("at % CPI = 3", null );
/* Ti specific -- notifications when SMS is ready (currently ignored )*/
At_send_command ("at % cstat = 1", null );
# Endif/* use_ti_commands */
/* Assume radio is off on Error */
If (isradioon ()> 0 ){
Setradiostate (radio_state_sim_not_ready );
}
}
By default, it is assumed that the RF module is good,
The setradiostate (radio_state_sim_not_ready) is used to trigger the modularization of the wireless module.
Discuss static void onradiopoweron () to initialize the wireless module.
The first decision is pollsimstate (null); Round-Robin SIM card status.
Static void pollsimstate (void * PARAM)
{
Atresponse * p_response;
Int ret;
If (sState! = Radio_state_sim_not_ready ){
// No longer valid to poll
Return;
}
Switch (getsimstatus ()){
Case ril_sim_absent:
Case ril_sim_pin:
Case ril_sim_puk:
Case ril_sim_network_personalization:
Default:
Setradiostate (radio_state_sim_locked_or_absent );
Return;
Case ril_sim_not_ready:
Ril_requesttimedcallback (pollsimstate, null, & timeval_simpoll );
Return;
Case ril_sim_ready:
Setradiostate (radio_state_sim_ready );
Return;
}
}
The function used to read the SIM card status is getsimstatus ()
Err = at_send_command_singleline ("at + cpin? "," + Cpin: ", & p_response );
It sends the AT command at + cpin to the cat? To query the status of the wireless module. If the wireless module is not ready, it will continue to call
SIM card status polling function pollsimstate until the SIM card status is obtained.
When the SIM card status is ready, it is suggested that the setradiostate (radio_state_sim_ready) configuration variable Sstate is:
Radio_state_sim_ready, which calls the static void onsimready () function to further initialize the wireless module.
The at command is as follows:
At_send_command_singleline ("at + CSMs = 1", "+ CSMs:", null );
At_send_command ("at + cnmi = 1, 2, 1, 1", null );
If the SIM card lock is enabled or the PIN is locked, the pin or Puk is required. However, this unlock action must be completed after the system is initialized.
Implemented. (How do I enter the password before the graphics system is original ?) After the system is initialized, WM. systemready () is called to notify the public.
You can do what you do at this time.
WM. systemready () calls will trigger the unlock interface. The detailed process is as follows:
Because there are: windowmanagerservice WM = NULL; so WM. systemready ()
The function in windowmanagerservice is called:
Public void systemready (){
Mpolicy. systemready ();
}
Windowmanagerservice includes:
Final windowmanagerpolicy mpolicy = policymanager. makenewwindowmanager ();
Policymanager. makenewwindowmanager calls the functions in the file policymanager. Java:
Public static windowmanagerpolicy makenewwindowmanager (){
Return spolicy. makenewwindowmanager ();
}
Spolicy. makenewwindowmanager calls the functions in the policy. Java file:
Public phonewindowmanager makenewwindowmanager (){
Return new phonewindowmanager ();
}
Because phonewindowmanager inherits from windowmanagerpolicy
Therefore, mpolicy. systemready () finally calls the function in phonewindowmanager. Java:
Public void systemready ()
Mkeyguardmediator. onsystemready ();
Dokeyguard ();
Showlocked ();
Message MSG = mhandler. obtainmessage (show );
Mhandler. sendmessage (MSG );
Send the show message.
Message Processing functions in the keyguardviewmediator. Java file:
Public void handlemessage (Message MSG) processes the show message.
If MSG. What is equal to show, execute:
Handleshow ();
Private void handleshow ()
...
Mcallback. onkeyguardshow ();
Mkeyguardviewmanager. Show ();
Mshowing = true;
Mkeyguardviewmanager. Show () calls the functions in the keyguardviewmanager. Java file:
Public synchronized void show ()
...
Mkeyguardview = mkeyguardviewproperties. createkeyguardview (mcontext, mupdatemonitor, this );
...
Mkeyguardviewproperties. createkeyguardview calls the file lockpatternkeyguardviewproperties. Java
Functions in:
Public keyguardviewbase createkeyguardview (context,
Keyguardupdatemonitor updatemonitor,
Keyguardwindowcontroller Controller ){
Return new lockpatternkeyguardview (context, updatemonitor,
Mlockpatternutils, Controller );
}
New lockpatternkeyguardview calls the constructor like lockpatternkeyguardview:
Public lockpatternkeyguardview (
Context context,
Keyguardupdatemonitor updatemonitor,
Lockpatternutils,
Keyguardwindowcontroller Controller)
...
Mlockscreen = createlockscreen ();
Addview (mlockscreen );
Final unlockmode = getunlockmode ();
Munlockscreen = createunlockscreenfor (unlockmode );
Munlockscreenmode = unlockmode;
Addview (munlockscreen );
Updatescreen (mmode );
Execute the above program and then bring up the unlock interface. getunlockmode gets the lock type. There are usually three types:
Enum unlockmode {
Pattern, // pattern lock
Simpin, // enter the pin or Puk
Account // account lock
}
We can understand the above process. When the rild is started in the initial stage of the system, the rild communicates with the cat, and the cat is initialized.
Saves a series of network statuses.
==========
Analysis of the flight mode switching process in standby mode:
Flight mode switching is complex, and it involves switching the status of a large module:
GSM module, bluetooth module, and WiFi module.
The enabler layer in flight mode sends a broadcast message: action_airplane_mode_changed
Private void setairplanemodeon (Boolean enabling ){
Mcheckboxp ref. setenabled (false );
Mcheckboxp ref. setsummary (enabling? R. String. airplane_mode_turning_on
: R. String. airplane_mode_turning_off );
// Change the system setting
Settings. system. putint (mcontext. getcontentresolver (), settings. system. airplane_mode_on,
Enabling? 1: 0 );
// Post the intent
Intent intent = new intent (intent. action_airplane_mode_changed );
Intent. putextra ("State", enabling );
Mcontext. sendbroadcast (intent );
}
Because the GSM, Bluetooth, and Wi-Fi modules have registered the monitoring of action_airplane_mode_changed messages, they receive
After the message is sent, the module switches over.
Bluetoothdeviceservice. Java
Enable Bluetooth: Enable (false );
Disable Bluetooth: Disable (false );
Phoneapp. Java (packages/apps/phone/src/COM/Android/phone)
Configure the status of the GSM module phone. setradiopower (Enabled );
Wifiservice. Java
Configure the WiFi status setwifienabledblocking (wifienabled, false, process. myuid ());
===
Analysis of GSM module switching process:
Phone. setradiopower (Enabled) calls:
Functions in file gsmphone. Java:
Public void setradiopower (Boolean power)
Msst. setradiopower (power );
Because servicestatetracker msst is available;
Msst. setradiopower calls the functions in the file servicestatetracker. Java:
Public void setradiopower (Boolean power)
Mdesiredpowerstate = power;
Setpowerstatetodesired ();
Cm. setradiopower (true, null );
Or
Cm. setradiopower (false, null );
Because:
Commandsinterface cm;
Public final class RIL extends basecommands implements commandsinterface
Therefore, CM. setradiopower calls the functions in the file RIL. Java:
Public void setradiopower (Boolean on, message result)
Rilrequest RR = rilrequest. Obtain (ril_request_radio_power, result );
Rr. MP. writeint (1 );
...
Send (RR)
We recommend that you send the ril_request_radio_power request to rild to enable or disable the GSM module.
Rild data receiving process:
Run the following command to receive ril_request_radio_power:
Requestradiopower (data, datalen, t );
Then, send the request to the wireless module based on the conditions.
The primary at Commands include:
Err = at_send_command ("at + cfun = 0", & p_response );
Err = at_send_command ("at + cfun = 1", & p_response );
===
Bluetooth module switching process analysis:
Enable (false );
Enable the function in the callback thdeviceservice. Java file by using Bluetooth:
Public synchronized Boolean enable (Boolean savesetting)
Seteffecthstate (effecthdevice. effecth_state_turning_on );
Menablethread = new enablethread (savesetting );
Menablethread. Start ();
----
Disable (false)
Call the function in the file after Bluetooth shutdown:
Public synchronized Boolean disable (Boolean savesetting)
Seteffecthstate (effecthdevice. effecth_state_turning_off );
===
Wi-Fi module switching process analysis:
Message for changing the broadcast WiFi status: wifi_state_changed_action
Setwifienabledstate (enable? Wifi_state_enabling: wifi_state_disabling, UID );
Update WiFi status:
Private void updatewifistate ()
If you need to enable WiFi, the message will be sent:
Sendenablemessage (true, false, mlastenableuid );
Sendstartmessage (strongestlockmode = wifimanager. wifi_mode_scan_only );
Mwifihandler. sendemptymessage (message_stop_wifi );
Process command messages in a message loop:
Public void handlemessage (Message MSG)
If enabling WiFi: setwifienabledblocking (true, MSG. arg1 = 1, MSG. arg2 );
Enable WiFi: mwifistatetracker. setscanonlymode (msg. arg1! = 0 );
Setwifienabledblocking (false, MSG. arg1 = 1, MSG. arg2 );
Disconnect mwifistatetracker. disconnectandstop ();
Procedure:
1> mount the WiFi DRIVER: wifinative. loaddriver ()
2> daemo supplicant: wifinative. startsupplicant ()
Close process steps:
1> stop and return daemo supplicant: wifinative. stopsupplicant ()
2> uninstall the WiFi DRIVER: wifinative. unloaddriver ()
If the WiFi status is enabled by default, the constructor of the wifiservice service is as follows:
Wifiservice (context, wifistatetracker tracker)
Boolean wifienabled = getpersistedwifienabled ();
Setwifienabledblocking (wifienabled, false, process. myuid ());
The wifi module is enabled.