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

怎么给网站做网站地图抖音seo优化系统招商

怎么给网站做网站地图,抖音seo优化系统招商,vps网站访问不了,野望赏析背景 在编写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://www.hkea.cn/news/343405/

相关文章:

  • 网站优化页面动态网站建设
  • 做网站域名公司每日重大军事新闻
  • 网站改版数据来源表改怎么做外链百科
  • wordpress怎样做单页网站谷歌查询关键词的工具叫什么
  • 县城做二手车网站自己建网站需要多少钱
  • 有没有专业做挂的网站引流推广方案
  • 购物网站开发文献综述百度收录需要多久
  • 营销型企业网站建设案例设计公司网站
  • 国际外贸网站电子商务
  • 南充做网站 www.xinbay.com全国免费发布广告信息
  • 备案 个人网站软件开发培训中心
  • 江苏网站建设网络推广关键词批量调词 软件
  • 东莞企业网站建设价格怎么在百度发布免费广告
  • 网站后台地址一般是在线seo优化工具
  • 海曙区住房和建设局网站备案域名
  • 网站建设硬件环境志鸿优化设计答案
  • 网页游戏网址推荐宁波网站推广网站优化
  • 福建就福建省住房与城乡建设厅网站高端网站建设企业
  • 网站如何做seo规划app怎么开发出来的
  • 吴江住房和城乡建设局官方网站产品软文是什么
  • 公司网站制作设谷歌seo是什么职业
  • 北京品牌高端网站建设公司燕郊今日头条
  • 网站制作公司徐州宁波网站seo哪家好
  • 做网站基本费用大概需要多少全媒体运营师报考官网在哪里
  • 网站建设款属于什么科目营业推广策划
  • 建设网站查证书网络广告有哪些形式
  • 分布式网站开发网络销售平台排名
  • 网站建设模板购买品牌seo培训
  • 深圳网站建设 cms网站推广交换链接
  • 标准物质网站建设5118站长工具箱