【笔记】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"
}
相关推荐
十月的皮皮17 小时前
C语言学习笔记20260615-有序升序序列合并
c语言·笔记·学习
辣香牛肉面20 小时前
CintaNotes个人笔记管理软件v3.14(v3.13.0 绿色汉化版)
笔记
yoothey1 天前
异常学习笔记:为什么自定义异常后还要 throw?
笔记·学习
sulikey1 天前
数据库系统概论4 - 更新与视图 期末速成课笔记
数据库·笔记·考试·期末速成·数据库系统概论
لا معنى له1 天前
NeoVerse: Enhancing 4D World Model with in-the-wild Monocular Videos
人工智能·笔记·机器学习·语言模型
黄毛火烧雪下1 天前
Java 基础笔记:文件、递归与字符编码
java·开发语言·笔记
学计算机的计算基1 天前
链表算法上篇:LeetCode 206/234/141/142/160/21 题解与易错点
java·笔记·算法·链表
二哈赛车手1 天前
新人笔记---idea索引失效问题解决方案
java·笔记·spring·elasticsearch·intellij-idea
A.零点1 天前
【2个月 C 语言从入门到精通:零基础系统教程】第十二讲:深入了解指针(五)
c语言·开发语言·网络·笔记·visual studio
ctrl_v助手1 天前
VisionPro (R) QuickBuild相机的连接
服务器·笔记·数码相机·c#