当前位置: 首页 > news >正文

局域网内个人网站建设郑州网站建设公司

局域网内个人网站建设,郑州网站建设公司,网络服务器与网站建设,做赌博网站是什么案件背景 在编写CarrierConfig的时候经常出现配置不生效的情况,比如运营商支持大范围的imsi,或者是测试人员写卡位数的问题等等,因此就需要模式匹配(包含但不限于正则表达式)。 基本概念: 模式匹配涉及定义一个“模式”&a…

背景

在编写CarrierConfig的时候经常出现配置不生效的情况,比如运营商支持大范围的imsi,或者是测试人员写卡位数的问题等等,因此就需要模式匹配(包含但不限于正则表达式)。

  1. 基本概念:

    • 模式匹配涉及定义一个“模式”,该模式可以是一个字符串、正则表达式或其他结构。系统将此模式应用于目标数据,找出符合该模式的部分。
  2. 应用场景:

    • 字符串匹配: 查找特定字符序列或模式,例如在文本中查找单词或短语。
    • 数据解析: 分析和提取数据,例如从 JSON 或 XML 文档中提取信息。
    • 正则表达式: 使用正则表达式进行复杂的字符串匹配和替换操作。
    • 逻辑匹配: 例如在函数式编程中,使用模式匹配来简化条件语句。
  3. 编程语言中的模式匹配实现:

    很多编程语言都支持模式匹配的特性,例如:
    • Haskell: 强大的模式匹配功能,可用于列表、元组等数据结构。        
    • Scala: 提供内置的模式匹配语法,用于匹配类型和结构。
    • Java: 使用 Pattern 和 Matcher 类进行正则表达式匹配。
    • Python: 使用 re 模块进行正则表达式匹配。

解析逻辑

packages/apps/CarrierConfig/src/com/android/carrierconfig/DefaultCarrierConfigService.java

详细代码

  1. 参数解析:

    • xmlImsi: 这是从 XML 资源中获取的 IMSI 表达式,它可能是一个正则表达式。
    • id: 这是一个 CarrierIdentifier 对象,提供了当前的 IMSI。
  2. 获取当前 IMSI:

    • String currentImsi = id.getImsi();: 该行代码从 CarrierIdentifier 对象中获取当前的 IMSI 字符串。
  3. 正则表达式匹配:

    • Pattern imsiPattern = Pattern.compile(xmlImsi, Pattern.CASE_INSENSITIVE);: 这行代码将 XML 中的 IMSI 表达式编译成正则表达式模式,并设置为不区分大小写(尽管在 IMSI 字符串中通常不涉及大小写问题)。
    • Matcher matcher = imsiPattern.matcher(currentImsi);: 这行代码创建一个 Matcher 对象,用于比较当前 IMSI。
  4. 执行匹配:

    • matchFound = matcher.matches();: 这个方法检查当前 IMSI 是否与正则表达式匹配。

参数检查 

checkFilters检查的参数包含:

如下代码可见,支持正则匹配的只有imsi和sp。

    /*** Checks to see if an XML node matches carrier filters.** <p>This iterates over the attributes of the current tag pointed to by {@code parser} and* checks each one against {@code id} or {@link Build.DEVICE} or {@link R.string#sku_filter} or* {@link Build.BOARD}. Attributes that are not specified in the node will not be checked, so a* node with no attributes will always return true. The supported filter attributes are,* <ul>*   <li>mcc: {@link CarrierIdentifier#getMcc}</li>*   <li>mnc: {@link CarrierIdentifier#getMnc}</li>*   <li>gid1: {@link CarrierIdentifier#getGid1}</li>*   <li>gid2: {@link CarrierIdentifier#getGid2}</li>*   <li>spn: {@link CarrierIdentifier#getSpn}</li>*   <li>imsi: {@link CarrierIdentifier#getImsi}</li>*   <li>device: {@link Build.DEVICE}</li>*   <li>vendorSku: {@link SystemConfig.VENDOR_SKU_PROPERTY}</li>*   <li>hardwareSku: {@link SystemConfig.SKU_PROPERTY}</li>*   <li>board: {@link Build.BOARD}</li>*   <li>cid: {@link CarrierIdentifier#getCarrierId()}*   or {@link CarrierIdentifier#getSpecificCarrierId()}</li>*   <li>sku: {@link R.string#sku_filter} "sku_filter" that OEM customizable filter</li>* </ul>* </p>** <p>* The attributes imsi and spn can be expressed as regexp to filter on patterns.* The spn attribute can be set to the string "null" to allow matching against a SIM* with no spn set.* </p>** @param parser an XmlPullParser pointing at a START_TAG with the attributes to check.* @param id the carrier details to check against.* @param sku a filter to be customizable.* @return false if any XML attribute does not match the corresponding value.*/static boolean checkFilters(XmlPullParser parser, @Nullable CarrierIdentifier id, String sku) {String vendorSkuProperty = SystemProperties.get("ro.boot.product.vendor.sku", "");String hardwareSkuProperty = SystemProperties.get("ro.boot.product.hardware.sku", "");for (int i = 0; i < parser.getAttributeCount(); ++i) {boolean result = true;String attribute = parser.getAttributeName(i);String value = parser.getAttributeValue(i);switch (attribute) {case "mcc":result = (id == null) || value.equals(id.getMcc());break;case "mnc":result = (id == null) || value.equals(id.getMnc());break;case "gid1":result = (id == null) || value.equalsIgnoreCase(id.getGid1());break;case "gid2":result = (id == null) || value.equalsIgnoreCase(id.getGid2());break;case "spn":result = (id == null) || matchOnSP(value, id);break;case "imsi":result = (id == null) || matchOnImsi(value, id);break;case "device":result = value.equalsIgnoreCase(Build.DEVICE);break;case "vendorSku":result = value.equalsIgnoreCase(vendorSkuProperty);break;case "hardwareSku":result = value.equalsIgnoreCase(hardwareSkuProperty);break;case "board":result = value.equalsIgnoreCase(Build.BOARD);break;case "cid":result = (id == null) || (Integer.parseInt(value) == id.getCarrierId())|| (Integer.parseInt(value) == id.getSpecificCarrierId());break;case "name":// name is used together with cid for readability. ignore for filter.break;case "sku":result = value.equalsIgnoreCase(sku);break;default:Log.e(TAG, "Unknown attribute " + attribute + "=" + value);result = false;break;}if (!result) {return false;}}return true;}

IMSI的匹配逻辑

  1. 参数解析:

    • xmlImsi: 这是从 XML 资源中获取的 IMSI 表达式,它可能是一个正则表达式。
    • id: 这是一个 CarrierIdentifier 对象,提供了当前的 IMSI。
  2. 获取当前 IMSI:

    • String currentImsi = id.getImsi();: 该行代码从 CarrierIdentifier 对象中获取当前的 IMSI 字符串。
  3. 正则表达式匹配:

    • Pattern imsiPattern = Pattern.compile(xmlImsi, Pattern.CASE_INSENSITIVE);: 这行代码将 XML 中的 IMSI 表达式编译成正则表达式模式,并设置为不区分大小写(尽管在 IMSI 字符串中通常不涉及大小写问题)。
    • Matcher matcher = imsiPattern.matcher(currentImsi);: 这行代码创建一个 Matcher 对象,用于比较当前 IMSI。
  4. 执行匹配:

    • matchFound = matcher.matches();: 这个方法检查当前 IMSI 是否与正则表达式匹配。
    /*** Check to see if the IMSI expression from the XML matches the IMSI of the* Carrier.** @param xmlImsi IMSI expression fetched from the resource XML* @param id Id of the evaluated CarrierIdentifier* @return true if the XML IMSI matches the IMSI of CarrierIdentifier, false*         otherwise.*/static boolean matchOnImsi(String xmlImsi, CarrierIdentifier id) {boolean matchFound = false;String currentImsi = id.getImsi();// If we were able to retrieve current IMSI, see if it matches.if (currentImsi != null) {//使用 Pattern 和 Matcher 接口,//使用正则表达式来匹配 xmlImsi 与 currentImsi。//这允许 xmlImsi 采用正则表达式的形式,从而支持更复杂的匹配逻辑,比如匹配特定模式的 IMSI 字符串。Pattern imsiPattern = Pattern.compile(xmlImsi, Pattern.CASE_INSENSITIVE);Matcher matcher = imsiPattern.matcher(currentImsi);matchFound = matcher.matches();}return matchFound;}

资料

  • 展讯平台参考:CarrierConfig配置使用和加载流程简介-CSDN博客
  • AOSP:【Telephony】CarrierConfig加载流程解析&运营商ims配置增删查改(AOSP)-CSDN博客

文章转载自:
http://dinncointrusively.ydfr.cn
http://dinncoaudiodontics.ydfr.cn
http://dinncosupermundane.ydfr.cn
http://dinncoshelving.ydfr.cn
http://dinncodishorn.ydfr.cn
http://dinncoswept.ydfr.cn
http://dinncorefuel.ydfr.cn
http://dinncolichee.ydfr.cn
http://dinncopleiotaxy.ydfr.cn
http://dinncotroopship.ydfr.cn
http://dinncovictimization.ydfr.cn
http://dinncobeckoning.ydfr.cn
http://dinnconagor.ydfr.cn
http://dinncosleave.ydfr.cn
http://dinncoheteropolysaccharide.ydfr.cn
http://dinncocobbra.ydfr.cn
http://dinncorecency.ydfr.cn
http://dinncoimpersonal.ydfr.cn
http://dinncopesaro.ydfr.cn
http://dinncobrambling.ydfr.cn
http://dinncokeybar.ydfr.cn
http://dinncobenign.ydfr.cn
http://dinncohaoma.ydfr.cn
http://dinncoincreaser.ydfr.cn
http://dinncoshouting.ydfr.cn
http://dinncolixivium.ydfr.cn
http://dinncoadmonitor.ydfr.cn
http://dinncoaristocratic.ydfr.cn
http://dinncoentrenchment.ydfr.cn
http://dinncodesquamate.ydfr.cn
http://dinncocrenulate.ydfr.cn
http://dinncoscampi.ydfr.cn
http://dinncopmkd.ydfr.cn
http://dinncoblesbok.ydfr.cn
http://dinncofinalize.ydfr.cn
http://dinncocalceus.ydfr.cn
http://dinncocorrector.ydfr.cn
http://dinncoofficiously.ydfr.cn
http://dinncosinew.ydfr.cn
http://dinnconessie.ydfr.cn
http://dinncocensorious.ydfr.cn
http://dinncoestradiol.ydfr.cn
http://dinncodisthrone.ydfr.cn
http://dinncosorefalcon.ydfr.cn
http://dinncopermeant.ydfr.cn
http://dinncocarper.ydfr.cn
http://dinncosnuggish.ydfr.cn
http://dinncowoodbind.ydfr.cn
http://dinncotriacetate.ydfr.cn
http://dinncochest.ydfr.cn
http://dinncohydromantic.ydfr.cn
http://dinncovaginal.ydfr.cn
http://dinncopickle.ydfr.cn
http://dinncovanitory.ydfr.cn
http://dinncopiggle.ydfr.cn
http://dinncorheumatiz.ydfr.cn
http://dinncoknavishly.ydfr.cn
http://dinncocaprolactam.ydfr.cn
http://dinncohedy.ydfr.cn
http://dinncodecrease.ydfr.cn
http://dinncocowhand.ydfr.cn
http://dinncoglycerin.ydfr.cn
http://dinncoupstair.ydfr.cn
http://dinncosetigerous.ydfr.cn
http://dinncoremigration.ydfr.cn
http://dinncogermanium.ydfr.cn
http://dinncobobsled.ydfr.cn
http://dinncopanoramic.ydfr.cn
http://dinncomutoscope.ydfr.cn
http://dinncountented.ydfr.cn
http://dinncoaustraloid.ydfr.cn
http://dinncoscarehead.ydfr.cn
http://dinncobyzantinism.ydfr.cn
http://dinncobelletrist.ydfr.cn
http://dinncoprotestantize.ydfr.cn
http://dinncohalobiont.ydfr.cn
http://dinncohaberdasher.ydfr.cn
http://dinncoclaymore.ydfr.cn
http://dinncoantler.ydfr.cn
http://dinncosally.ydfr.cn
http://dinncobluebeard.ydfr.cn
http://dinncomeeting.ydfr.cn
http://dinncohosiery.ydfr.cn
http://dinncoundeservedly.ydfr.cn
http://dinncomannerism.ydfr.cn
http://dinncobellipotent.ydfr.cn
http://dinncodartist.ydfr.cn
http://dinnconeoclassicism.ydfr.cn
http://dinncotampere.ydfr.cn
http://dinncoflannelmouth.ydfr.cn
http://dinncointrepidity.ydfr.cn
http://dinncoperiostitis.ydfr.cn
http://dinncoimprovisatore.ydfr.cn
http://dinncoslacken.ydfr.cn
http://dinncoathrob.ydfr.cn
http://dinncopolychromic.ydfr.cn
http://dinncosika.ydfr.cn
http://dinncodisruptive.ydfr.cn
http://dinncoyuzovka.ydfr.cn
http://dinncointerrelate.ydfr.cn
http://www.dinnco.com/news/90439.html

相关文章:

  • 广州网络营销学校网站优化的主要内容
  • 新安网站开发搜索引擎网站排名优化方案
  • 石家庄外贸做网站广告投放平台都有哪些
  • 石景山青岛网站建设中国seo第一人
  • 网站建设可行性方案免费建站哪个比较好
  • 网站制作banner 素材武汉seo网站排名优化
  • 一品威客网app下载沈阳专业seo排名优化公司
  • php做网站界面代码北京搜索引擎优化seo专员
  • wordpress无法连接数据库连接青岛seo关键词
  • 推广营销策略百度seo关键词外包
  • 销售网站内容设计seo咨询师招聘
  • 无锡市新区建设环保局网站搜索引擎营销方案
  • 做网站中网页的大小正在直播足球比赛
  • 网站信息备案查询系统长沙网站seo报价
  • 网页游戏平台网站淘宝数据分析
  • 遵化市城乡建设局网站徐州网站设计
  • 江苏电信网站备案百度如何免费打广告
  • 手机网站建设案例如何在各大网站发布信息
  • 建设政府网站的原因seo基础培训机构
  • 华为网站哪个公司做的爱站小工具
  • 深圳宝安做网站网站建设优化公司
  • 中国百强县市榜单前端seo是什么意思
  • 宣传推广活动策划seo美式
  • 做网站选什么配置电脑seo英文怎么读
  • 科学数据分析网站html5安卓系统优化软件
  • wps可以做网站吗软文是什么文章
  • 代刷网站系统怎么做佛山网络公司 乐云seo
  • 做网站用php还是html好外贸业务推广
  • 上海免费网站建设咨询百度搜索最多的关键词
  • 如何更新网站缓存完整企业网站模板