Android11 MTK 开机默认启动热点

1、需求:开机后不锁屏,默认打开热点,且长时间没有设备连接热点时保证热点也是打开的。
2、开机后不锁屏:
复制代码
	路径:vendor/mediatek/proprietary/packages/apps/SettingsProvider/res/values/defaults.xml
xml 复制代码
<bool name="def_networks_available_notification_on">false</bool>
<bool name="def_lockscreen_disabled">true</bool>
3、默认打开热点

路径:(1)vendor/mediatek/proprietary/packages/apps/MtkSettings/AndroidManifest.xml

xml 复制代码
<receiver android:name=".fuelgauge.batterytip.AnomalyDetectionReceiver"
                   android:exported="false" />
 
-        <receiver android:name=".fuelgauge.batterytip.AnomalyConfigReceiver">
-            <intent-filter>
+        <receiver android:name=".fuelgauge.batterytip.AnomalyConfigReceiver"
+                       android:exported="true">
+            <intent-filter android:priority="2147483647">
                 <action android:name="android.app.action.STATSD_STARTED"/>
                 <action android:name="android.intent.action.BOOT_COMPLETED"/>
             </intent-filter>

路径:(2)vendor/mediatek/proprietary/packages/apps/MtkSettings/src/com/android/settings/fuelgauge/batterytip/AnomalyConfigReceiver.java

java 复制代码
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
                 AnomalyCleanupJobService.scheduleCleanUp(context);
+                                Log.w(TAG, "Receive the startup broadcast and turn on the hotspot");            
+                               Settings.Global.putInt(context.getContentResolver(),
+                               Settings.Global.SOFT_AP_TIMEOUT_ENABLED, 0);                    
+                               ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
+                               connectivityManager.startTethering(ConnectivityManager.TETHERING_WIFI,
+                true, new ConnectivityManager.OnStartTetheringCallback() {
+                                       
+                    @Override
+                    public void onTetheringFailed() {
+                        super.onTetheringFailed();
+                        Log.d("MTK6739", "onTetheringFailed");
+                    }
+
+                    @Override
+                    public void onTetheringStarted() {
+                        super.onTetheringStarted();
+                        Log.d("MTK6739", "onTetheringStarted");
+                    }
+
+                });
             }
4、关闭热点未连接时自动关闭功能

路径:/frameworks/opt/net/wifi/service/java/com/android/server/wifi/SoftApManager.java

java 复制代码
// Already started, ignore this command.
                         break;
                     case CMD_NO_ASSOCIATED_STATIONS_TIMEOUT:
-                        if (!mTimeoutEnabled) {
+                        /*if (!mTimeoutEnabled) {
                             Log.wtf(TAG, "Timeout message received while timeout is disabled."
                                     + " Dropping.");
                             break;
@@ -933,7 +933,7 @@ public class SoftApManager implements ActiveModeManager {
                         Log.i(TAG, "Timeout message received. Stopping soft AP.");
                         updateApState(WifiManager.WIFI_AP_STATE_DISABLING,
                                 WifiManager.WIFI_AP_STATE_ENABLED, 0);
-                        quitNow();
+                        quitNow();*/
                         break;
                     case CMD_INTERFACE_DESTROYED:
                         Log.d(TAG, "Interface was cleanly destroyed.");
相关推荐
alexhilton1 天前
使用FunctionGemma进行设备端函数调用
android·kotlin·android jetpack
冬奇Lab1 天前
InputManagerService:输入事件分发与ANR机制
android·源码阅读
张小潇1 天前
AOSP15 Input专题InputManager源码分析
android·操作系统
RdoZam1 天前
Android-封装基类Activity\Fragment,从0到1记录
android·kotlin
奥陌陌2 天前
android 打印函数调用堆栈
android
用户985120035832 天前
Compose Navigation 3 深度解析(二):基础用法
android·android jetpack
恋猫de小郭2 天前
Android 官方正式官宣 AI 支持 AppFunctions ,Android 官方 MCP 和系统级 OpenClaw 雏形
android·前端·flutter
黄林晴2 天前
Android 17 Beta 2,隐私这把锁又拧紧了
android
Kapaseker2 天前
研究表明,开发者对Kotlin集合的了解不到 20%
android·kotlin
bqliang2 天前
Compose 媒体查询 (Media Query API) 🖱️👇🕹️
android·android jetpack