【笔记】Disable APN 禁用数据连接的逻辑(Android & KaiOS)

简介

通过OTA/OMADM 运营商服务器可以下发消息实现disable APN,从而影响Data PDN建立。APN被disable了会导致无法正常上网。

在Android 和 KaiOS 系统实现上有区别,不过都是通过carrier_enabled 这类字段实现判断控制。

  • Android:上层 Telephony 根据APN carrier_enabled 值判断是否下发PDN
  • KaiOS:上层 gecko DataCall 不做判断,随DataProfile 传给Modem(QCOM),底层决定是否建立PDN。

Android

Telephony 上层DataProfileManager 会根据网络请求选择APN,如果APN 被disable了,ApnSetting 在canHandleType校验过程中会直接return false。

canBeSatisfiedBy => canHandleType

代码逻辑说明:

java 复制代码
//Android U 功能逻辑

//【TelephonyNetworkRequest.java】 选择满足PDN请求的类型
      /**       
        * Check if this network request can be satisfied by a data profile.
       *
       * @param dataProfile The data profile to check.
       * @return {@code true} if this network request can be satisfied by the data profile.
       */
     public boolean canBeSatisfiedBy(@NonNull DataProfile dataProfile) {
            //返回满足请求的APN列表
            return apnTypes.stream().allMatch(dataProfile.getApnSetting()::canHandleType);

    }

//【ApnSetting.java】 校验
      /** @hide */
      public boolean canHandleType(@ApnType int type) {
          if (!mCarrierEnabled) {
              return false;
          }
          // DEFAULT can handle HIPRI.
          return hasApnType(type);
      }

日志举例:根据 ApnSetting结构打印字段顺序找到CarrierEnabled的值。

CarrierEnabled is false, so can not find the profile to setup data PDN.

DataProfile=\[ApnSetting INTERNET , 3086, 310590 , INTERNET, , null, , null, null, 0, supl | hipri | default, IPV4V6, IP, false, 0, true, 0, 0, 0, 0, 0, gid, A1, false, UNKNOWN, UNKNOWN, 0, -1, -1, false, 961, TrafficDescriptor={mDnn=INTERNET, null}, preferred=false],

KaiOS

gecko 不对 APN 的 enable 情况做校验拦截,会随着 RIL_REQUEST_SETUP_DATA_CALL的请求,将其转换成DataProfile的enabled传给qcom。具体QCOM校验需要看其逻辑。

若上层想通过carrier_enabled参数决定是否使用该APN请求网络,可以尝试在以下接口函数中过滤APN,然后再执行DataCall相关流程。

  • gecko/dom/system/gonk/radio/DataCallManager.jsm
javascript 复制代码
//把disable的APN在aNewApnSettings数据中剔除,再执行后续DataCall流程
updateApnSettings(aNewApnSettings) { 
    const kApnSettingKey = "ril.data.apnSettings.sim"
}
相关推荐
xqqxqxxq8 分钟前
DML 表数据:插入、删除、修改
笔记·mysql
不会代码的小猴34 分钟前
Linux note2
linux·笔记
xqqxqxxq2 小时前
MySQL 数据类型笔记
数据库·笔记·mysql
软件技术NINI3 小时前
盗墓笔记html+css+js 2页
css·笔记·html
XiaoYu1__3 小时前
算法进阶·其二:用欧拉路径解决“一笔画”问题并建模转化De Bruijn序列的构造问题
c++·笔记·算法·欧拉路径
智者知已应修善业4 小时前
【用D触发器组成000-001-010-011-100】2025-6-7
驱动开发·经验分享·笔记·硬件架构·硬件工程
纪念 2294 小时前
数据库基础
数据库·笔记·学习方法
AnsonNie4 小时前
处理提示“wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。”【笔记】
笔记
山城码农笑松哥4 小时前
Redis 8.8 新特性实操笔记:原生数组、INCREX 限流、XNACK 流处理
redis·笔记·junit
whyTeaFo4 小时前
GAMES101: Lecture 16: Ray Tracing 4 (Monte Carlo Path Tracing) ppt笔记
笔记