默认启用 WLAN 热点
核心方法打开关闭 WLAN 热点从 SystemUI 中的 qsTile 快捷开关中提取
既然要默认启用这里选择加到 KeyguardUpdateMonitor.java 中,监听开机广播
vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+import com.android.systemui.Dependency; +import com.android.systemui.statusbar.policy.HotspotController; /** * Watches for updates that may be interesting to the keyguard, and provides * the up to date information as well as a registration for callbacks that care @@ -237,6 +239,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { private final IDreamManager mDreamManager; private boolean mIsDreaming; + private final HotspotController mController; + /** * Short delay before restarting fingerprint authentication after a successful try * This should be slightly longer than the time between onFingerprintAuthenticated and @@ -835,6 +839,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { dispatchBootCompleted(); + mController.setHotspotEnabled(true); + android.provider.Settings.System.putInt(mContext.getContentResolver(), + com.mediatek.provider.MtkSettingsExt.System.WIFI_HOTSPOT_AUTO_DISABLE, 0); } else if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(action)) { ///M: fix ALPS01821063, we should assume that extra value may not exist. /// Although the extra value of AIRPLANE_MODE_CHANGED intent should exist in fact. @@ -1364,6 +1372,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener { SystemServicesProxy.getInstance(mContext).registerTaskStackListener(mTaskStackListener); mUserManager = context.getSystemService(UserManager.class); + + mController = Dependency.get(HotspotController.class); } private void updateFingerprintListeningState() {
WLAN 热点保持开启,休眠不关闭
核心方法通过 adb shell dumpsys window | findstr mCurrentFocus 指令追踪到设置界面为
mCurrentFocus=Window{ffb4936 u0 com.android.settings/com.android.settings.Settings$TetherWifiSettingsActivity}
从 TetherWifiSettingsActivity.java 中得到
0 始终开启 1 空闲5分钟后关闭 2 空闲10分钟后关闭
android.provider.Settings.System.putInt(mContext.getContentResolver(), + com.mediatek.provider.MtkSettingsExt.System.WIFI_HOTSPOT_AUTO_DISABLE, 0);
WLAN 热点默认名称和密码
可通过 prop 值灵活配置默认名称和密码
frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiApConfigStore.java
private WifiConfiguration getDefaultApConfiguration() { WifiConfiguration config = new WifiConfiguration(); - config.SSID = mContext.getResources().getString( - R.string.wifi_tether_configure_ssid_default) + "_" + getRandomIntForDefaultSsid(); + //config.SSID = mContext.getResources().getString( + // R.string.wifi_tether_configure_ssid_default) + "_" + getRandomIntForDefaultSsid(); + config.SSID = android.os.SystemProperties.get("persist.temp.wifiap.ssid", "WlanAP"); config.allowedKeyManagement.set(KeyMgmt.WPA2_PSK); String randomUUID = UUID.randomUUID().toString(); //first 12 chars from xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx - config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9, 13); + //config.preSharedKey = randomUUID.substring(0, 8) + randomUUID.substring(9, 13); + config.preSharedKey = android.os.SystemProperties.get("persist.temp.wifiap.key", "123456789"); return config; }