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.");
相关推荐
小袁拒绝摆烂2 小时前
SQL开窗函数
android·sql·性能优化
apihz3 小时前
VM虚拟机全版本网盘+免费本地网络穿透端口映射实时同步动态家庭IP教程
android·服务器·开发语言·网络·数据库·网络协议·tcp/ip
baidu_247438613 小时前
Android MPAndroidChart使用
android
天平4 小时前
react native现代化组件库的推荐 【持续更新...】
android·前端·react native
apihz5 小时前
通用图片搜索-搜狗源免费API接口使用指南
android·java·python·php·音视频
你过来啊你6 小时前
Android开发中ARouter使用和原理详解
android
apihz7 小时前
腾讯云轻量服务器创建快照免费API接口教程
android·服务器·数据库·python·网络协议·tcp/ip·腾讯云
Kiri霧8 小时前
Noting
android·开发语言·kotlin
东风西巷13 小时前
NealFun安卓版:创意无限,娱乐至上
android·人工智能·智能手机·娱乐·软件需求
小李飞飞砖19 小时前
Sophix、Tinker 和 Robust 三大主流 Android 热修复框架的详细对比
android