# Android12 wifi和4G同时使用

news/2024/11/17 5:26:24/

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;

http://www.ppmy.cn/news/539715.html

相关文章

Linux驱动开发|4G通信

4G通信 使用有线网络或者 WIFI 有很多限制&#xff0c;因为要布线&#xff0c;即使是 WIFI 也得先布线&#xff0c;然后接个路由器。因此在不方便布线的场合&#xff0c;就可以通过 4G 连接到网络。下面介绍如何在 I.MX6U-ALPHA 开发板中使用 4G 来实现联网功能 一、4G网络连…

oracle 日志大于4g,Oracle日志文件达到4G

解决方案一:停止监听器 1)LSNRCTL进入交互模式 cmd 输入 LSNRCTL 2)执行set current_listener LISTENER 3)set log_status off 4)stop 停止监听器 5)手工删除ADR指定的监听日志路径下的listener.log文件 6)start重启监听器 7)status查看状态 解决方案二:脚本定时清除log文件 …

[4G5G专题-27]:架构-UE终端的4G+5G双连接详解

目录 第1章. 什么是多连接 1.1 多连接概述 1.2 多连接的聚合和分离点的分类 1.3 多连接好处 1.4 双连接的本质 1.5 多连接的控制面与数据面连接方法分类 1.6 1C2U模式下数据承载的三种方式 1.7 分清各种场景的基本思路 1.8 关于终端与基站之间的无线控制信道 第2章 4…

Python基础篇(十一):装饰器

装饰器 前言1. 装饰器的定义2. 装饰器的应用3. 装饰器的语法4. func(*args, **kwargs) 前言 装饰器是Python中一种强大的函数或类修饰机制&#xff0c;用于在不修改原始函数或类代码的情况下&#xff0c;对其进行功能扩展或修改。装饰器基于函数式编程的概念&#xff0c;通过将…

4G和5G频谱共享技术

【摘 要】目前4G向5G重耕过程中存在频谱利用不平衡的问题,可采用动态频谱共享的技术解决。基于对现有频谱共享方案的原理分析,通过理论测算和实验室测试结合的方法研究终端和基站各功能特性对于终端性能的影响。动态频谱共享对下行影响较大,对上行影响较小,不同功能选择会…

c语言log库,Log4g

软件简介 Log4g是一个基于GObject 的日志工具。Log4g 的设计基于对流行的Log4j 1.2 日志包的移植。Log4j已经被移植到了很多编程语言中&#xff0c;包括(不限于)C、Perl和Python。Log4g将这个功能带到C/GLib/GObject编程栈中。 Log4g 的核心组件是记录器(loggers)、附加器(appe…

4G全网构建仿真

4G指的是第四代移动电话行动通信标准&#xff0c;是第四代移动通信技术&#xff0c;也是3G的延伸。4G是集3G与WLAN于一体&#xff0c;并能够传输高质量视频图像&#xff0c;它的图像传输质量与高清晰度电视不相上下。4G系统能够以10Mbps的速度下载&#xff0c;比拨号上网快200倍…

华为云学院-人人学loT学习笔记及扩展- 第一章 初识物联网

1.1初探物联网 一&#xff0c;物联网 百度解释&#xff1a; 物联网&#xff08;The Internet of Things&#xff0c;简称IOT&#xff09;是指通过 各种信息传感器、射频识别技术、全球定位系统、红外感应器、激光扫描器等各种装置与技术(可理解为通信感知技术)&#xff0c;实…