AndroidWIFIPower managmentWord格式.docx

上传人:b****6 文档编号:16825101 上传时间:2022-11-26 格式:DOCX 页数:47 大小:191.19KB
下载 相关 举报
AndroidWIFIPower managmentWord格式.docx_第1页
第1页 / 共47页
AndroidWIFIPower managmentWord格式.docx_第2页
第2页 / 共47页
AndroidWIFIPower managmentWord格式.docx_第3页
第3页 / 共47页
AndroidWIFIPower managmentWord格式.docx_第4页
第4页 / 共47页
AndroidWIFIPower managmentWord格式.docx_第5页
第5页 / 共47页
点击查看更多>>
下载资源
资源描述

AndroidWIFIPower managmentWord格式.docx

《AndroidWIFIPower managmentWord格式.docx》由会员分享,可在线阅读,更多相关《AndroidWIFIPower managmentWord格式.docx(47页珍藏版)》请在冰豆网上搜索。

AndroidWIFIPower managmentWord格式.docx

mNotificationTask

->

mContext.sendOrderedBroadcast(mScreenOnIntent,null,

mScreenOnBroadcastDone,mHandler,0,null,null);

4.WifiServicewillreceivetheSCREEN_ONintent,willenableRssipolling,thencallupdateWifiState.

if(action.equals(Intent.ACTION_SCREEN_ON)){

Log.d(TAG,"

ACTION_SCREEN_ON"

);

mAlarmManager.cancel(mIdleIntent);

mDeviceIdle=false;

mScreenOff=false;

mWifiStateTracker.enableRssiPolling(true);

5.updateWifiStatewillsendstartdrivermessage:

MESSAGE_START_WIFItoWifiServiceitself.

if(wifiShouldBeEnabled){

if(wifiShouldBeStarted){

sWakeLock.acquire();

sendEnableMessage(true,false,mLastEnableUid);

sendStartMessage(strongestLockMode==WifiManager.WIFI_MODE_SCAN_ONLY);

}

6.HandleMessagewillcallrestartofWifiStateTracker

publicvoidhandleMessage(Messagemsg){

switch(msg.what){

caseMESSAGE_START_WIFI:

mWifiStateTracker.setScanOnlyMode(msg.arg1!

=0);

mWifiStateTracker.restart();

sWakeLock.release();

break;

7.restartofWifiStateTrackerwillresetinterface,callWifiNative.startDriverCommand

publicsynchronizedbooleanrestart(){

if(mRunState==RUN_STATE_STOPPED){

mRunState=RUN_STATE_STARTING;

resetInterface(true);

returnWifiNative.startDriverCommand();

}elseif(mRunState==RUN_STATE_STOPPING){

returntrue;

8.resetInterfacewillclearwifiipaddress,resetConnectionsandstopDHCP.

/**

*ResetstheWi-Fiinterfacebyclearinganystate,resettinganysockets

*usingtheinterface,stoppingDHCP,anddisablingtheinterface.

*/

publicvoidresetInterface(booleanreenable){

mHaveIpAddress=false;

mObtainingIpAddress=false;

mWifiInfo.setIpAddress(0);

/*

*ResetconnectiondependsonboththeinterfaceandtheIPassigned,

*soitshouldbedonebeforeanychanceoftheIPbeinglost.

NetworkUtils.resetConnections(mInterfaceName);

//StopDHCP

if(mDhcpTarget!

=null){

mDhcpTarget.setCancelCallback(true);

mDhcpTarget.removeMessages(EVENT_DHCP_START);

if(!

NetworkUtils.stopDhcp(mInterfaceName)){

Log.e(TAG,"

CouldnotstopDHCP"

//[Marvell:

]can'

tdisableInterfacehereasthedriverwon'

tturnitonautomatically

//NetworkUtils.disableInterface(mInterfaceName);

//wenolongernettostarttheinterface(driverdoesthisforus)

//anditledtoproblems-removed.

}

*Thesupplicantisreportingthatwearedisconnectedfromthecurrent

*accesspoint.Often,however,adisconnectwillbefollowedveryshortly

*byareconnecttothesameaccesspoint.Therefore,wedelayresetting

*theconnection'

sIPstateforabit.

8.WifiNative.startDriverCommandsendstartdrivereventtowpa_suppliant

9.Wpa_supplicantcallwexttohandlestartdriverevent,wpa_supplicant_run–〉eloop_run(void)–〉tmp->

handler(tmp->

eloop_data,tmp->

user_data);

-〉wpa_supplicant_ctrl_iface_receive–〉wpa_supplicant_ctrl_iface_process-〉wpa_supplicant_driver_cmd–〉wpa_drv_driver_cmd-〉wpa_s->

driver->

driver_cmd(wpa_s->

drv_priv,cmd,buf,buf_len);

10.WextwillcallioctltosendcommandtoWlankerneldriver

11.Wlankerneldriverwillhandlestartdrivercommand(nownotsupportyet)

1.3Screenoff

1.WhenAndroidisinrunningmode,ifthepowerkeyispressed,ThreadInputDeviceReaderwillbecreatedandprocessthekeyevent.SendamessagetoWindowsmanager.

3.PowermanagerServicewillcallsetPowerStatetosetpowerstate,callsendNotificationLockedtonotifypoweronevent.willcallscreenTurnedOffofKeyguardViewMediatortoturnoffscreen,callgoingToSleep()ofActivityManagerServicetopauseactivity,broadcastintent,Intent(Intent.ACTION_SCREEN_OFF),sendbroadcastmessage:

4.WifiServicewillreceivetheSCREEN_OFFintent,willdisableRssipolling,

SetanalarmtimertosendACTION_DEVICE_IDLE

elseif(action.equals(Intent.ACTION_SCREEN_OFF)){

ACTION_SCREEN_OFF"

mScreenOff=true;

mWifiStateTracker.enableRssiPolling(false);

*SetatimertoputWi-Fitosleep,butonlyifthescreenisoff

*ANDthe"

stayonwhilepluggedin"

settingdoesn'

tmatchthe

*currentpowerconditions(i.e,notpluggedin,pluggedintoUSB,

*orpluggedintoAC).

shouldWifiStayAwake(stayAwakeConditions,mPluggedType)){

WifiInfoinfo=mWifiStateTracker.requestConnectionInfo();

if(info.getSupplicantState()!

=SupplicantState.COMPLETED){

//weusedtogotosleepimmediately,butthiscausedsomeraceconditions

//wedon'

thavetimetotrackdownforthisrelease.Delayinstead,butnot

//aslongaswewouldifconnected(below)

//TODO-fixtheraceconditionsandswitchbacktotheimmediateturn-off

longtriggerTime=System.currentTimeMillis()+(2*60*1000);

//2min

settingACTION_DEVICE_IDLEtimerfor120,000ms"

mAlarmManager.set(AlarmManager.RTC_WAKEUP,triggerTime,mIdleIntent);

////donotkeepWifiawakewhenscreenisoffifWifiisnotassociated

//mDeviceIdle=true;

//updateWifiState();

}else{

longtriggerTime=System.currentTimeMillis()+idleMillis;

settingACTION_DEVICE_IDLEtimerfor"

+idleMillis+"

ms"

MESSAGE_STOP_WIFItoWifiServiceitself.

sDriverStopWakeLock.acquire();

mWifiHandler.sendEmptyMessage(MESSAGE_STOP_WIFI);

mWifiHandler.sendEmptyMessageDelayed(MESSAGE_RELEASE_WAKELOCK,wakeLockTimeout);

6.HandleMessagewillcalldisconnectAndStopofWifiStateTracker

caseMESSAGE_STOP_WIFI:

mWifiStateTracker.disconnectAndStop();

//don'

treleasewakelock

7.disconnectAndStopofWifiStateTrackercallWifiNative.disconnectCommandfirsttodisconnectthewifinetwork.

/**

*Wewanttostopthedriver,butifwe'

reconnectedtoanetwork,

*wefirstwanttodisconnect,sothatthesupplicantisalwaysin

*aknownstate(DISCONNECTED)whenthedriverisstopped.

*@return{@codetrue}iftheoperationsucceeds,whichmeansthatthe

*disconnectorstopcommandwasinitiated.

publicsynchronizedbooleandisconnectAndStop(){

if(mRunState!

=RUN_STATE_STOPPING&

&

mRunState!

=RUN_STATE_STOPPED){

//Takedownanyopennetworknotifications

setNotificationVisible(false,0,false,0);

mRunState=RUN_STATE_STOPPING;

if(mWifiInfo.getSupplicantState()==SupplicantState.DORMANT){

returnWifiNative.stopDriverCommand();

returnWifiNative.disconnectCommand();

*The"

driver-stop"

wakelocknormallyisreleasedfromthe

*connectivitymanagerafterthemobiledataconnectionhas

*beenestablished,orafteratimeoutperiod,ifthatnever

*happens.BecauseWifiService.updateWifiState()cangetcalled

*multipletimes,wecanendupacquiringthewakelockandcalling

*disconnectAndStop()evenwhenadisconnectorstopoperation

*isalreadyinprogress.Inthatcase,wewanttoignorethe

*disconnectAndStoprequestandreleasethe(ref-counted)wake

*lock,sothateventually,whenthemobiledataconnectionis

*established,therefcountwilldroptozero.

releaseWakeLock();

8.wpa_supplicant_ctrl_iface_processofhandles“DISCONNECT”command,willcallwpa_supplicant_disassociate,thencallwpa_drv_disassociate

voidwpa_supplicant_disassociate(structwpa_supplicant*wpa_s,

intreason_code)

{

u8*addr=NULL;

if(os_memcmp(wpa_s->

bssid,"

\x00\x00\x00\x00\x00\x00"

ETH_ALEN)!

=0)

{

if(wpa_s->

use_client_mlme)

ieee80211_sta_disassociate(wpa_s,reason_code);

else

wpa_drv_disassociate(wpa_s,wpa_s->

bssid,reason_code);

addr=wpa_s->

bssid;

wpa_clear_keys(wpa_s,addr);

wpa_supplicant_mark_disassoc(wpa_s);

wpa_s->

current_ssid=NULL;

wpa_sm_set_config(wpa_s->

wpa,NULL);

9.wpa_drv_disassociatewillcallwpa_driver_wext_disassociate

staticintwpa_driver_wext_disassociate(void*priv,constu8*addr,

intreason_code)

structwpa_driver_wext_data*drv=priv;

wpa_printf(MSG_DEBUG,"

%s"

__FUNCTION__);

returnwpa_driver_wext_mlme(drv,addr,IW_MLME_DISASSOC,

reason_code);

10.wpa_driver_wext_disassociatecallwpa_driver_wext

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 语文

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1