在项目\frameworks\base\wifi\java\android\net\wifi\WifiStateMachine.java里面,有如下的代码,是设置wifi热点保持状态的:如下:

private class HotspotAutoDisableObserver extends ContentObserver {

public HotspotAutoDisableObserver(Handler handler) {

super(handler);

mContext.getContentResolver().registerContentObserver(Settings.System.getUriFor(

Settings.System.WIFI_HOTSPOT_AUTO_DISABLE), false, this);

}

@Override

public void onChange(boolean selfChange) {

super.onChange(selfChange);

mDuration = Settings.System.getInt(mContext.getContentResolver(), Settings.System.WIFI_HOTSPOT_AUTO_DISABLE,

Settings.System.WIFI_HOTSPOT_AUTO_DISABLE_FOR_FIVE_MINS);

if (mDuration != Settings.System.WIFI_HOTSPOT_AUTO_DISABLE_OFF && mPluggedType == 0) {

if (mClientNum == 0 && WifiStateMachine.this.getCurrentState() == mTetheredState) {

mAlarmManager.cancel(mIntentStopHotspot);

Xlog.d(TAG, "Set alarm for setting changed, mDuration:" + mDuration);

mAlarmManager.set(AlarmManager.RTC_WAKEUP,

System.currentTimeMillis() + mDuration * HOTSPOT_DISABLE_MS, mIntentStopHotspot);

}

} else {

mAlarmManager.cancel(mIntentStopHotspot);

}

}

}

修改默认值为始终:

mDuration = Settings.System.getInt(mContext.getContentResolver(), Settings.System.WIFI_HOTSPOT_AUTO_DISABLE,

Settings.System.WIFI_HOTSPOT_AUTO_DISABLE_OFF);

另外,System.xxxx的常量定义在源码中的路径:项目\frameworks\base\core\java\android\provider\Settings.java

原文:http://www.cnblogs.com/suxiaoqi/p/5619741.html

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐