【笔记】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"
}
相关推荐
楠了个难15 分钟前
HDMI色块移动——FPGA学习笔记13
笔记·学习
秋邱1 小时前
软件设计师——操作系统
笔记·硬件架构·硬件工程
繁依Fanyi2 小时前
828 华为云征文|华为 Flexus 云服务器打造 Laverna 在线笔记应用
运维·服务器·笔记·python·算法·华为·华为云
little redcap2 小时前
KMP整理+个人推导+快速上手理解
数据结构·笔记·算法
liangbm36 小时前
MATLAB系列02:MATLAB基础
开发语言·数据结构·笔记·matlab·教程·工程基础·高级绘图
深蓝海拓8 小时前
迭代器和生成器的学习笔记
笔记·python·学习
createcrystal8 小时前
《算法笔记》例题解析 第3章入门模拟--3图形输出(9题)2021-03-03
c++·笔记·算法
卡戎-caryon8 小时前
【Linux】09.Linux 下的调试器——gdb/cgdb
linux·运维·服务器·开发语言·笔记
代码敲不对.10 小时前
江科大笔记—软件安装
笔记·stm32·单片机·嵌入式硬件
z2014z12 小时前
系统架构设计师教程 第5章 5.4 软件测试 笔记
笔记·系统架构