在项目\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
时间: 2024-10-15 21:00:56