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.");
相关推荐
百***92028 分钟前
【MySQL】MySQL库的操作
android·数据库·mysql
2501_916008892 小时前
没有源码如何加密 IPA 实战流程与多工具组合落地指南
android·ios·小程序·https·uni-app·iphone·webview
2501_940094023 小时前
PS1模拟器 DuckStation更新最新版整合 下载即玩 附PS1Bios/游戏/金手指 安卓版+电脑版
android·游戏·电脑
橙武低代码5 小时前
业务流低代码平台:从理念到实战
android·低代码·ai编程
空白格975 小时前
三方框架必学系列#Retrofit
android
安卓程序猿5 小时前
kotlin build.gradle.kts下修改APK的输出名称
android·kotlin·gradle
wuwu_q5 小时前
通俗易懂 + Android 开发实战的方式,详细讲讲 Kotlin 中的 StateFlow
android·开发语言·kotlin
峰哥的Android进阶之路5 小时前
Kotlin面试题总结
android·开发语言·kotlin
美摄科技6 小时前
android短视频sdk,灵活集成,快速上线!
android·音视频
佳哥的技术分享6 小时前
图形化android可视化开机观测工具bootchart
android