Android12 wifi和4G同时使用

1.新建device/qcom/qssi/wifiand4g.sh
#! /system/bin/sh
ip rule add from all lookup main pref 100
2.device/qcom/项目名/init.target.rc中加入
on property:sys.startwifiand4g=yes
start wifiand4g
service wifiand4g /system/bin/wifiand4g.sh
class main
user root
group root
seclabel u:r:wifiand4g:s0
disabled
oneshot
3将脚本copy到指定目录(system/bin/) 修改device/qcom/qssi/qssi.mk加入如下:
PRODUCT_COPY_FILES +=
device/qcom/qssi/wifiand4g.sh:system/bin/wifiand4g.sh

4解决avc权限问题
1)新建system/sepolicy/prebuilts/api/30.0/private/wifiand4g.te和system/sepolicy/private/wifiand4g.te内容为:
type wifiand4g,domain,coredomain;
type wifiand4g_exec,system_file_type,exec_type,file_type;
allow init wifiand4g:process { noatsecure transition };
allow init wifiand4g_exec:file { execute getattr open read };
allow wifiand4g wifiand4g_exec:file entrypoint;
allow shell net_data_file:dir search;
allow shell net_data_file:file { getattr open read };
allow shell system_prop:property_service set;
allow init wifiand4g:process { rlimitinh siginh };
allow wifiand4g self:netlink_route_socket create;
allow wifiand4g shell_exec:file { execute getattr map read };
allow wifiand4g system_file:file execute_no_trans;
allow wifiand4g wifiand4g_exec:file { open read };

2)以下是去除一些neverallow的权限检查如果过gms网上有跳过的方法,这里直接删掉了:

diff --git a/system/sepolicy/prebuilts/api/30.0/private/file_contexts b/system/sepolicy/prebuilts/api/30.0/private/file_contexts
index 9805767d79..4aab131577 100644
--- a/system/sepolicy/prebuilts/api/30.0/private/file_contexts
+++ b/system/sepolicy/prebuilts/api/30.0/private/file_contexts
@@ -304,6 +304,7 @@/system/bin/iorap\.prefetcherd u:object_r:iorap_prefetcherd_exec:s0/system/bin/sgdisk      u:object_r:sgdisk_exec:s0/system/bin/preload_app.sh      u:object_r:preload_app_exec:s0
+/system/bin/wifiand4g.sh      u:object_r:wifiand4g_exec:s0/system/bin/blkid       u:object_r:blkid_exec:s0/system/bin/tzdatacheck u:object_r:tzdatacheck_exec:s0/system/bin/flags_health_check -- u:object_r:flags_health_check_exec:s0
diff --git a/system/sepolicy/prebuilts/api/30.0/private/wifiand4g.te b/system/sepolicy/prebuilts/api/30.0/private/wifiand4g.te
new file mode 100644
index 0000000000..927121de90
--- /dev/null
+++ b/system/sepolicy/prebuilts/api/30.0/private/wifiand4g.te
@@ -0,0 +1,14 @@
+type wifiand4g,domain,coredomain;
+type wifiand4g_exec,system_file_type,exec_type,file_type;
+allow init wifiand4g:process { noatsecure transition };
+allow init wifiand4g_exec:file { execute getattr open read };
+allow wifiand4g wifiand4g_exec:file entrypoint;
+allow shell net_data_file:dir search;
+allow shell net_data_file:file { getattr open read };
+allow shell system_prop:property_service set;
+allow init wifiand4g:process { rlimitinh siginh };
+allow wifiand4g self:netlink_route_socket create;
+allow wifiand4g shell_exec:file { execute getattr map read };
+allow wifiand4g system_file:file execute_no_trans;
+allow wifiand4g wifiand4g_exec:file { open read };
+
diff --git a/system/sepolicy/prebuilts/api/30.0/public/domain.te b/system/sepolicy/prebuilts/api/30.0/public/domain.te
index e1ca737ce0..50d9aa9be2 100644
--- a/system/sepolicy/prebuilts/api/30.0/public/domain.te
+++ b/system/sepolicy/prebuilts/api/30.0/public/domain.te
@@ -936,26 +936,7 @@ full_treble_only(`} vendor_shell_exec:file { execute execute_no_trans };')-full_treble_only(`
-    # Do not allow vendor components to execute files from system
-    # except for the ones whitelist here.
-    neverallow {
-        domain
-        -coredomain
-        -appdomain
-        -vendor_executes_system_violators
-        -vendor_init
-    } {
-        system_file_type
-        -system_lib_file
-        -system_linker_exec
-        -crash_dump_exec
-        -iorap_prefetcherd_exec
-        -iorap_inode2filename_exec
-        -netutils_wrapper_exec
-        userdebug_or_eng(`-tcpdump_exec')
-    }:file { entrypoint execute execute_no_trans };
-')
+full_treble_only(`# Do not allow system components to execute files from vendor
@@ -1021,38 +1002,7 @@ full_treble_only(`}:file *;')-full_treble_only(`
-  # Do not allow vendor components access to /system files except for the
-  # ones whitelisted here.
-  neverallow {
-    domain
-    -appdomain
-    -coredomain
-    -vendor_executes_system_violators
-    # vendor_init needs access to init_exec for domain transition. vendor_init
-    # neverallows are covered in public/vendor_init.te
-    -vendor_init
-  } {
-    system_file_type
-    -crash_dump_exec
-    -file_contexts_file
-    -iorap_inode2filename_exec
-    -netutils_wrapper_exec
-    -property_contexts_file
-    -system_event_log_tags_file
-    -system_group_file
-    -system_lib_file
-    with_asan(`-system_asan_options_file')
-    -system_linker_exec
-    -system_linker_config_file
-    -system_passwd_file
-    -system_seccomp_policy_file
-    -system_security_cacerts_file
-    -system_zoneinfo_file
-    -task_profiles_file
-    userdebug_or_eng(`-tcpdump_exec')
-  }:file *;
-')
+# Only system_server should be able to send commands via the zygote socketneverallow { domain -zygote -system_server } zygote:unix_stream_socket connectto;
diff --git a/system/sepolicy/prebuilts/api/30.0/public/init.te b/system/sepolicy/prebuilts/api/30.0/public/init.te
index cc51a2b72d..fcb0a1c694 100644
--- a/system/sepolicy/prebuilts/api/30.0/public/init.te
+++ b/system/sepolicy/prebuilts/api/30.0/public/init.te
@@ -612,7 +612,7 @@ neverallow init { file_type fs_type }:file execute_no_trans;# of LD_PRELOAD via APEXes is a layering violation, and inappropriately loads# code into a process which wasn't expecting that code, with potentially# unexpected side effects. (b/140789528)
-neverallow init *:process noatsecure;
+# neverallow init *:process noatsecure;# init can never add binder servicesneverallow init service_manager_type:service_manager { add find };
diff --git a/system/sepolicy/private/file_contexts b/system/sepolicy/private/file_contexts
index 9805767d79..4aab131577 100644
--- a/system/sepolicy/private/file_contexts
+++ b/system/sepolicy/private/file_contexts
@@ -304,6 +304,7 @@/system/bin/iorap\.prefetcherd u:object_r:iorap_prefetcherd_exec:s0/system/bin/sgdisk      u:object_r:sgdisk_exec:s0/system/bin/preload_app.sh      u:object_r:preload_app_exec:s0
+/system/bin/wifiand4g.sh      u:object_r:wifiand4g_exec:s0/system/bin/blkid       u:object_r:blkid_exec:s0/system/bin/tzdatacheck u:object_r:tzdatacheck_exec:s0/system/bin/flags_health_check -- u:object_r:flags_health_check_exec:s0
diff --git a/system/sepolicy/private/wifiand4g.te b/system/sepolicy/private/wifiand4g.te
new file mode 100644
index 0000000000..927121de90
--- /dev/null
+++ b/system/sepolicy/private/wifiand4g.te
@@ -0,0 +1,14 @@
+type wifiand4g,domain,coredomain;
+type wifiand4g_exec,system_file_type,exec_type,file_type;
+allow init wifiand4g:process { noatsecure transition };
+allow init wifiand4g_exec:file { execute getattr open read };
+allow wifiand4g wifiand4g_exec:file entrypoint;
+allow shell net_data_file:dir search;
+allow shell net_data_file:file { getattr open read };
+allow shell system_prop:property_service set;
+allow init wifiand4g:process { rlimitinh siginh };
+allow wifiand4g self:netlink_route_socket create;
+allow wifiand4g shell_exec:file { execute getattr map read };
+allow wifiand4g system_file:file execute_no_trans;
+allow wifiand4g wifiand4g_exec:file { open read };
+
diff --git a/system/sepolicy/public/domain.te b/system/sepolicy/public/domain.te
index e1ca737ce0..50d9aa9be2 100644
--- a/system/sepolicy/public/domain.te
+++ b/system/sepolicy/public/domain.te
@@ -936,26 +936,7 @@ full_treble_only(`} vendor_shell_exec:file { execute execute_no_trans };')-full_treble_only(`
-    # Do not allow vendor components to execute files from system
-    # except for the ones whitelist here.
-    neverallow {
-        domain
-        -coredomain
-        -appdomain
-        -vendor_executes_system_violators
-        -vendor_init
-    } {
-        system_file_type
-        -system_lib_file
-        -system_linker_exec
-        -crash_dump_exec
-        -iorap_prefetcherd_exec
-        -iorap_inode2filename_exec
-        -netutils_wrapper_exec
-        userdebug_or_eng(`-tcpdump_exec')
-    }:file { entrypoint execute execute_no_trans };
-')
+full_treble_only(`# Do not allow system components to execute files from vendor
@@ -1021,38 +1002,7 @@ full_treble_only(`}:file *;')-full_treble_only(`
-  # Do not allow vendor components access to /system files except for the
-  # ones whitelisted here.
-  neverallow {
-    domain
-    -appdomain
-    -coredomain
-    -vendor_executes_system_violators
-    # vendor_init needs access to init_exec for domain transition. vendor_init
-    # neverallows are covered in public/vendor_init.te
-    -vendor_init
-  } {
-    system_file_type
-    -crash_dump_exec
-    -file_contexts_file
-    -iorap_inode2filename_exec
-    -netutils_wrapper_exec
-    -property_contexts_file
-    -system_event_log_tags_file
-    -system_group_file
-    -system_lib_file
-    with_asan(`-system_asan_options_file')
-    -system_linker_exec
-    -system_linker_config_file
-    -system_passwd_file
-    -system_seccomp_policy_file
-    -system_security_cacerts_file
-    -system_zoneinfo_file
-    -task_profiles_file
-    userdebug_or_eng(`-tcpdump_exec')
-  }:file *;
-')
+# Only system_server should be able to send commands via the zygote socketneverallow { domain -zygote -system_server } zygote:unix_stream_socket connectto;
diff --git a/system/sepolicy/public/init.te b/system/sepolicy/public/init.te
index cc51a2b72d..fcb0a1c694 100644
--- a/system/sepolicy/public/init.te
+++ b/system/sepolicy/public/init.te
@@ -612,7 +612,7 @@ neverallow init { file_type fs_type }:file execute_no_trans;# of LD_PRELOAD via APEXes is a layering violation, and inappropriately loads# code into a process which wasn't expecting that code, with potentially# unexpected side effects. (b/140789528)
-neverallow init *:process noatsecure;
+# neverallow init *:process noatsecure;# init can never add binder servicesneverallow init service_manager_type:service_manager { add find };

5在代码中以 SystemProperties.set(“sys.startwifiand4g”,“yes”);的方式触发

执行方法2中的脚本文件,这里将路由表中main表优先级提到最高

6解决SystemUI中WiFi和4G图标共存

diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
old mode 100644
new mode 100755
index 5a558c32f1..2811c69d4a
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/MobileSignalController.java
@@ -539,7 +539,7 @@ public class MobileSignalController extends SignalController<boolean activityOut = mCurrentState.dataConnected&& !mCurrentState.carrierNetworkChangeMode&& mCurrentState.activityOut;
-        showDataIcon &= mCurrentState.isDefault || dataDisabled;
+        showDataIcon &= mCurrentState.isDefault || dataDisabled || true;int typeIcon = (showDataIcon || mConfig.alwaysShowDataRatIcon|| mConfig.alwaysShowNetworkTypeIcon) ? icons.mDataType : 0;if ( mConfig.enableRatIconEnhancement ) {
diff --git a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
index 5a84878465..4823915fc7 100755
--- a/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
+++ b/frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/WifiSignalController.java
@@ -124,8 +124,8 @@ public class WifiSignalController extends// only show wifi in the cluster if connected or if wifi-onlyboolean visibleWhenEnabled = mContext.getResources().getBoolean(R.bool.config_showWifiIndicatorWhenEnabled);
-        boolean wifiVisible = mCurrentState.enabled && (
-                (mCurrentState.connected && mCurrentState.inetCondition == 1)
+        boolean wifiVisible = /*mCurrentState.enabled &&*/ (
+                (mCurrentState.connected /*&& mCurrentState.inetCondition == 1*/)|| !mHasMobileDataFeature || mCurrentState.isDefault|| visibleWhenEnabled);String wifiDesc = mCurrentState.connected ? mCurrentState.ssid : null;

# Android12 wifi和4G同时使用相关推荐

  1. 苹果wifi网速慢怎么办_所以,WiFi和4G到底哪个更耗电?

    来源 | 中科院物理所(ID:cas-iop) 编辑 | 椒盐猫巨烦 现代人行走江湖,必备三件法宝:手机,网络,充电宝. 即便在4G基站遍布各个旮旮角角的今天,当你带着心仪的人儿走进一家咖啡店,第一件 ...

  2. Swift获取当前网络状态Wifi/5G/4G/3G/2G

    通过Swift获取当前网络状态 通过第三方库Alamofire获取网络状态只能获取到ethernetOrWiFi.cellular.notReachable.unknown这几种网络状态,不能准确的获 ...

  3. win10找不到wifi网络_当WiFi和4G网络齐飞,你的手机恐怕撑不到回家充电了…

     二次元的中科院物理所  From:bilibili专栏 现代人行走江湖,必备三件法宝: 手机.网络.充电宝~ 即便在4G基站遍布各个旮旮角角的今天,当你带着心仪的人儿走进一家咖啡店,第一件事仍然是低 ...

  4. 远程监控Wifi与4G蜂窝流量连接有什么不同

    远程监控Wifi与4G蜂窝流量连接有什么不同?同样是远程监控,WiFi连接的方式是通过无线网连接的,而4G流量是通过蜂窝转化为WiFi信号连接的.这是两者最大的区别. 4G摄像机和手机连接很简单,分三 ...

  5. iOS 检测设备所连接的WiFi、4G等网络是否真的可以连通

    在开发过程我们经常会遇到,获取手机连接的WiFi.4G等状态,并且判断是否连接网络,通常我们使用AFNetworking.Reachability等库,只要判断连接上WiFi或者4G就表明他已经连接网 ...

  6. 世界各个地区WIFI 2.4G及5G信道一览表

    世界各个地区WIFI 2.4G及5G信道一览表 美洲(FCC) 2.412 ~ 2.462 GHz:11个信道 5.15 ~ 5.35 GHz,5.725 ~ 5.825 GHz:12个信道 中国 2 ...

  7. 6s如何无线连电脑连接服务器,iPhone 6s无线连接能力:WiFi与4G大提速

    [PConline 杂谈]9月10日凌晨,苹果在旧金山正式发布了新一代iPhone,分别是iPhone 6s与iPhone 6s Plus两款机型.如同前期爆料一样,苹果为新iPhone带来了3D T ...

  8. wifi 2.4g 5g 区别_wifi信号差,网速慢?可能是你没有配置好2.4G和5G WiFi

    2.4G WiFi和5G WiFi 相信大家在家里一般都会用到wifi,今天小编给大家带来的就是2.4G WiFi和5G WiFi的区别以及2.4G WiFi和5GWiFi到底谁更有优势?我们在家里该 ...

  9. wifi 2.4g 5g 区别_关于路由器的2.4G以及5G,你不知道的那些事

    在科技日新月异的今天,网上冲浪似乎成为了新一代年轻人的标配.而WiFi的横空出世,似乎又将网上冲浪推向了高峰.比起移动流量的按量收费以及流畅度,WiFi以碾压式的优势成功登顶.而路由器中的2.4G与5 ...

  10. 让WiFi变“4G”?Hotspot2.0来了

    原文链接 http://www.icpcw.com/Smartphone/Android/Android/3188/318832_2.htm WiFi网络在移动设备上的演进过程 接下来,接入点会提供以 ...

最新文章

  1. vue.js v-if
  2. K8S实战之环境部署1.18(一)
  3. 一文带你彻底理解ROC曲线和AUC值
  4. 小明是个急性子,上小学的时候经常吧老师写在黑板上的题目抄错 有一次,老师出的题目是:36x495=? 他却给抄成了:396x45=? 但是结果很戏剧性,他的 答案是对的 因为36*495 = 39
  5. html5控制字大小的代码,js根据字符串长度控制字体大小代码
  6. Unity从Asset Store下载的资源安装包默认的保存位置及其修改
  7. flutter插件出现英文
  8. 熊猫压缩怎么使用_从命令行开始使用熊猫
  9. 教程篇(7.0) 06. FortiGate基础架构 单点登录(FSSO) ❀ Fortinet 网络安全专家 NSE 4
  10. 联想Y50-70笔记本更换固态硬盘SSD记录
  11. 5G SCMA MPA算法
  12. Java 生成随机长度字母组合
  13. Sheldon Cooper
  14. 全面讲解手推实战之线性回归
  15. 6. JDK内置命令行工具
  16. 智能手机争霸赛:三星是如何战胜苹果的?
  17. 狂刷这套Java并发编程面试题及答案(GitHub标星21.7K),五月收获美团/京东/字节Offer
  18. 2021-07-15莫得感情的流水账日记之Day2
  19. 牙种植体和假体的全球与中国市场2022-2028年:技术、参与者、趋势、市场规模及占有率研究报告
  20. 基于盛科芯片的PTP功能总结

热门文章

  1. 本学期关于Android学习的总结
  2. 用word这么多年,90%的人居然不知道这12个小技巧
  3. LightOj 1336(Sigma Function)
  4. 美团外卖数据采集接口
  5. 2017 4 自考java_自考00831英语语法2017年4月真题及答案【解析版】
  6. 前端面试必考的「 Webpack详解 」都在这了
  7. 近世代数--陪集--|左陪集|=|右陪集|
  8. 根号2以及π的计算--关于无理数的畅想
  9. 杰理之ANC降噪的硬件要求和物料选型【篇】
  10. TCP/IP之传输层协议详解