最终效果图:
    image.png

    默认状态下,各个连接符均为“—”或者“\u2014”,容易造成误解。

    这个状态栏是属于SystemUI的,
    但运营商连接符资源在
    alps/frameworks/base/core/res/res/values-xxx/strings.xml

    1. <!-- Sequence of characters used to separate message strings in keyguard. Typically just em-dash
    2. with spaces on either side. [CHAR LIMIT=3] -->
    3. <string name="kg_text_message_separator" product="default">" \u2014 "</string>
    4. <string name="kg_text_message_separator" product="default">" \u007c "</string>
    5. <!-- The delete-widget drop target button text -->
    6. <string name="kg_reordering_delete_drop_target_text">Remove</string>

    各个连接符都是引用的这个字符串资源。
    默认情况下,运营商与“从属”连接符也是引用的上面的资源,因而显示的效果完全一样。

    要想达到图中的区别效果,需要进行如下修改:

    1、修改上面提到的alps/frameworks/base/core/res/res/values-xxx/strings.xml将红色地方改为绿色。
    其他语言下的 kg_text_message_separator 建议同步修改,或修改几个常用的。
    至此,运营商连接符便修改成功了。
    此字符将会在alps/frameworks/base/packages/Keyguard/src/com/android/keyguard/CarrierText.java文件的
    protected void updateCarrierText() 方法中被拼接到运营商字符中,代码如下:

    1. // find all need-to-show carrier text, combine, and set text.
    2. String carrierFinalContent = null;
    3. //Separator for two operators in network name.
    4. //i.e if divider="|", it shows "CU-MOVISTAR | CMCC-GD".
    5. String divider = mCarrierTextExt.customizeCarrierTextDivider(mSeparator.toString());
    6. for (int i = 0 ; i < mNumOfPhone ; i++) {
    7. Log.d(TAG, "updateCarrierText() - mCarrierNeedToShow[i] = " + mCarrierNeedToShow[i]
    8. + " mCarrier[i] = " + mCarrier[i]) ;
    9. ///M: fix ALPS01963660, do not show "null" string.
    10. if (mCarrierNeedToShow[i] && (mCarrier[i] != null)) {
    11. if (carrierFinalContent == null) {
    12. //first need-to-show
    13. carrierFinalContent = mCarrier[i] ;
    14. } else {
    15. carrierFinalContent = new StringBuilder(carrierFinalContent).
    16. append(divider).
    17. append(mCarrier[i]).toString() ;
    18. }
    19. }
    20. }

    2、在上述文件的 kg_text_message_separator 下方加入新的字符串

    1. <!-- Separator for PLMN and SPN in network name. -->
    2. <string name="kg_network_plmn_spn_separator" translatable="false">"\u2014"</string>

    这个字符串将被用作运营商与“从属”连接符。
    但是在 \alps\frameworks\base\packages\SystemUI\res\values\strings.xml 存在

    1. <!-- Separator for PLMN and SPN in network name. -->
    2. <string name="status_bar_network_name_separator" translatable="false">|</string>

    此字符注释与上面加入的字符注释一致,但默认状态下此字符并没有被作为运营商与“从属”连接符使用。

    3、此时在上面步骤2中加入的字符串,还不还能被使用,还需要在同目录下的
    \alps\frameworks\base\core\res\res\values\symbols.xml 文件中为其增加定义,搜索步骤1中的 kg_text_message_separator
    在其下面增加:

    1. <java-symbol type="string" name="kg_text_message_separator" />
    2. <java-symbol type="string" name="kg_network_plmn_spn_separator" />

    至此,kg_network_plmn_spn_separator 字符串就可以被使用了。

    4、修改
    alps\frameworks\opt\telephony\src\java\com\android\internal\telephony\SubscriptionController.java
    文件的 setPlmnSpn 方法中的字符引用,替换为上面添加的。

    1. if (showSpn) {
    2. // Need to show both plmn and spn if both are not same.
    3. if(!Objects.equals(spn, plmn)) {
    4. //Separator for PLMN and SPN in network name.
    5. //i.e if separator="-", it shows "CU-MOVISTAR | CMCC-GD".
    6. String separator = mContext.getString(
    7. com.android.internal.R.string.kg_network_plmn_spn_separator).toString();
    8. carrierText = new StringBuilder().append(carrierText).append(separator)
    9. .append(spn).toString();
    10. }
    11. }

    至此,运营商与“从属”连接符便修改成功了。