Android6.0之来电转接号码显示修改

时间:2023-12-27 17:04:13

Android6.0之来电转接号码显示修改

手机来电转接界面是在,点开Dialer-搜索框右边的三个点-设置-通话账户(要先插卡)-中国移动或者中国联通--来电转接--第一行,显示始终转接

将所有来电转接到+86xxxxxxxxxxx

当按home键回到主界面,然后在设置里切换语言,然后在recent键回到来电转接设置界面时发现来电转接的号码变成了{0},

通过搜索字符串

package/service/Telephony/res/values/strings.xml:219:

<string name="sum_cfu_enabled">Forwarding all calls to <xliff:g id="phonenumber" example="555-1212">{0}</xliff:g></string>

发现引用的地方在package/service/Telephony/res/xml/callforward_options.xml

<com.android.phone.CallForwardEditPreference
android:key="button_cfu_key"
android:title="@string/labelCFU"
android:persistent="false"

android:summaryOn="@string/sum_cfu_enabled"
android:summaryOff="@string/sum_cfu_disabled"
android:dialogTitle="@string/labelCFU"

android:dialogMessage="@string/messageCFU"
phone:confirmMode="activation"
phone:serviceClass="voice"

phone:reason="unconditional"
android:singleLine="true"
android:autoText="false"
android:enabled="false" />

发现这是一个自定义的com.android.phone.CallForwardEditPreference

用eng的手机通过View视图查看工具可以发现

当前的界面是package/service/Telephony/src/com/android/phone/GsmUmtsCallForwardOptions.java

private static final String BUTTON_CFU_KEY   = "button_cfu_key";

PreferenceScreen prefSet = getPreferenceScreen();
mButtonCFU = (CallForwardEditPreference) prefSet.findPreference(BUTTON_CFU_KEY);

mButtonCFU.setParentActivity(this, mButtonCFU.reason);
mButtonCFB.setParentActivity(this, mButtonCFB.reason);

mPreferences.add(mButtonCFU);
mPreferences.add(mButtonCFB);

switch (requestCode) {
case CommandsInterface.CF_REASON_UNCONDITIONAL:
mButtonCFU.onPickActivityResult(getArabCharNumber(cursor.getString(0)));

@Override
public void onResume() {
super.onResume();

if (mFirstResume) {
if (mIcicle == null) {
if (DBG) Log.d(LOG_TAG, "start to init ");
mPreferences.get(mInitIndex).init(this, false, mPhone);
} else {
mInitIndex = mPreferences.size();

for (CallForwardEditPreference pref : mPreferences) {
Bundle bundle = mIcicle.getParcelable(pref.getKey());
pref.setToggled(bundle.getBoolean(KEY_TOGGLE));
pref.setEnabled(bundle.getBoolean(KEY_STATE));
CallForwardInfo cf = new CallForwardInfo();
cf.number = bundle.getString(KEY_NUMBER);
cf.status = bundle.getInt(KEY_STATUS);

pref.handleCallForwardResult(cf);
pref.init(this, true, mPhone);
}
}
mFirstResume = false;
mIcicle = null;
}
}

中的

cf.number = bundle.getString(KEY_NUMBER);
cf.status = bundle.getInt(KEY_STATUS);

pref.handleCallForwardResult(cf);

进到handleCallForwardResult()这个方法中

然后可以发现进到了package/service/Telephony/src/com/android/phone/CallForwardEditPreference.java中

void handleCallForwardResult(CallForwardInfo cf) {
callForwardInfo = cf;
if (DBG) Log.d(LOG_TAG, "handleGetCFResponse done, callForwardInfo=" + callForwardInfo);

setToggled(callForwardInfo.status == 1);
setPhoneNumber(callForwardInfo.number);
}

然后发现

private void updateSummaryText() {
if (isToggled()) {
CharSequence summaryOn;
final String number = getRawPhoneNumber();
if (number != null && number.length() > 0) {
// Wrap the number to preserve presentation in RTL languages.

String wrappedNumber = BidiFormatter.getInstance().unicodeWrap(
number, TextDirectionHeuristics.LTR);
String values[] = { wrappedNumber };

/// M: for Plug-in @{

ExtensionManager.getCallForwardExt().updateSummaryTimeSlotText(this, values);
/// }@

summaryOn = TextUtils.replace(mSummaryOnTemplate, SRC_TAGS, values);
} else {

summaryOn = getContext().getString(R.string.sum_cfu_enabled_no_number);
}
setSummaryOn(summaryOn);
}

}

所以在

/// }@ /// }@ 78
Android6.0之来电转接号码显示修改 79 mPhone.getCallForwardingOption(reason, mPhone.getCallForwardingOption(reason, 79
  80 mHandler.obtainMessage(MyHandler.MESSAGE_GET_CF, mHandler.obtainMessage(MyHandler.MESSAGE_GET_CF, 80
  81 // unused in this case // unused in this case 81
  82 CommandsInterface.CF_ACTION_DISABLE, CommandsInterface.CF_ACTION_DISABLE, 82
  83 MyHandler.MESSAGE_GET_CF, null)); MyHandler.MESSAGE_GET_CF, null)); 83
  84 } } 84
  85 if (mTcpListener != null) { if (mTcpListener != null) { 85
  86 mTcpListener.onStarted(this, true); mTcpListener.onStarted(this, true); 86
  87 } } 87
      } else { 88
      updateSummaryText(); 89
  88 } } 90
  89 } } 91
  90     92
  91 @Override @Override 93
  92 protected void onBindDialogView(View view) { protected void onBindDialogView(View view) { 94
  93 // default the button clicked to be the cancel button. // default the button clicked to be the cancel button. 95
  94 mButtonClicked = DialogInterface.BUTTON_NEGATIVE; mButtonClicked = DialogInterface.BUTTON_NEGATIVE; 96
  95 super.onBindDialogView(view); super.onBindDialogView(view); 97
  96 /// M: for Plug-in @{ /// M: for Plug-in @{ 98
  97 ExtensionManager.getCallForwardExt().onBindDialogView(this, view); ExtensionManager.getCallForwardExt().onBindDialogView(this, view);

void init(TimeConsumingPreferenceListener listener, boolean skipReading, Phone phone) {
mPhone = phone;
mTcpListener = listener;

if (!skipReading) {
/// M: for Plug-in @{

} else {
updateSummaryText();
}
}

调用已经写好的updateSummaryText();方法便可以实现通过recent键进到来电转接界面来电转接号码的显示