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.");
相关推荐
AD钙奶-lalala3 小时前
Android编译C++代码步骤详解
android·开发语言·c++
特立独行的猫a5 小时前
Kuikly多端框架(KMP)实战:KMP中的 Ktor 网络库的多端适配指南
android·网络·harmonyos·ktor·compose·kmp·kuikly
滑板上的老砒霜8 小时前
AI 共舞,还是被“注意力刺客”偷袭?——程序员的数字专注力守护指南
android·ai编程·客户端
钛态8 小时前
Flutter for OpenHarmony 实战:Stack Trace — 异步堆栈调试专家
android·flutter·ui·华为·架构·harmonyos
二流小码农8 小时前
2026年,在鸿蒙生态里,继续深耕自己
android·ios·harmonyos
2501_915106329 小时前
iPhone 文件管理,如何进行应用沙盒文件查看
android·ios·小程序·https·uni-app·iphone·webview
非凡ghost9 小时前
Ookla Speedtest安卓版(网速测试工具)
android·windows·学习·智能手机·软件需求
Flywith2410 小时前
【2025 年终总结】北漂五年,而立,婚礼,折叠车
android·前端·程序员
独自破碎E10 小时前
题解 | 灵异背包?
android·java·开发语言
奔跑吧 android13 小时前
【车载audio】【AudioPolicyManager 01】【AudioPolicyClient 类介绍】
android·audio·audioflinger·aosp15·音频开发·车载音频·audiopolicym