[Settings] Support phone number talkback

Support phone number talkback in about phone UI pages.

Bug: 182923869
Test: local, junit
Change-Id: I159827070a954dee13230ff7cf6de81dbbaa7545
This commit is contained in:
Bonian Chen
2021-12-03 00:05:00 +08:00
parent 4c450d6b4c
commit d051e65d3c
10 changed files with 241 additions and 76 deletions

View File

@@ -134,7 +134,7 @@ public class SimStatusDialogController implements LifecycleObserver {
}
if (SubscriptionManager.isValidSubscriptionId(nextSubId)) {
mTelephonyManager =
mTelephonyManager.createForSubscriptionId(nextSubId);
getTelephonyManager().createForSubscriptionId(nextSubId);
registerImsRegistrationCallback(nextSubId);
}
}
@@ -228,6 +228,11 @@ public class SimStatusDialogController implements LifecycleObserver {
}
}
@VisibleForTesting
public TelephonyManager getTelephonyManager() {
return mTelephonyManager;
}
public void initialize() {
requestForUpdateEid();
@@ -235,7 +240,7 @@ public class SimStatusDialogController implements LifecycleObserver {
return;
}
mTelephonyManager =
mTelephonyManager.createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
getTelephonyManager().createForSubscriptionId(mSubscriptionInfo.getSubscriptionId());
mTelephonyCallback = new SimStatusDialogTelephonyCallback();
updateLatestAreaInfo();
updateSubscriptionStatus();
@@ -246,8 +251,8 @@ public class SimStatusDialogController implements LifecycleObserver {
// getServiceState() may return null when the subscription is inactive
// or when there was an error communicating with the phone process.
final ServiceState serviceState = mTelephonyManager.getServiceState();
final SignalStrength signalStrength = mTelephonyManager.getSignalStrength();
final ServiceState serviceState = getTelephonyManager().getServiceState();
final SignalStrength signalStrength = getTelephonyManager().getSignalStrength();
updatePhoneNumber();
updateServiceState(serviceState);
@@ -279,9 +284,10 @@ public class SimStatusDialogController implements LifecycleObserver {
if (mSubscriptionInfo == null) {
return;
}
mTelephonyManager = mTelephonyManager.createForSubscriptionId(
mTelephonyManager = getTelephonyManager().createForSubscriptionId(
mSubscriptionInfo.getSubscriptionId());
mTelephonyManager.registerTelephonyCallback(mContext.getMainExecutor(), mTelephonyCallback);
getTelephonyManager()
.registerTelephonyCallback(mContext.getMainExecutor(), mTelephonyCallback);
mSubscriptionManager.addOnSubscriptionsChangedListener(
mContext.getMainExecutor(), mOnSubscriptionsChangedListener);
registerImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
@@ -304,7 +310,7 @@ public class SimStatusDialogController implements LifecycleObserver {
if (mIsRegisteredListener) {
mSubscriptionManager.removeOnSubscriptionsChangedListener(
mOnSubscriptionsChangedListener);
mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
getTelephonyManager().unregisterTelephonyCallback(mTelephonyCallback);
if (mShowLatestAreaInfo) {
mContext.unregisterReceiver(mAreaInfoReceiver);
}
@@ -315,7 +321,7 @@ public class SimStatusDialogController implements LifecycleObserver {
unregisterImsRegistrationCallback(mSubscriptionInfo.getSubscriptionId());
mSubscriptionManager.removeOnSubscriptionsChangedListener(mOnSubscriptionsChangedListener);
mTelephonyManager.unregisterTelephonyCallback(mTelephonyCallback);
getTelephonyManager().unregisterTelephonyCallback(mTelephonyCallback);
if (mShowLatestAreaInfo) {
mContext.unregisterReceiver(mAreaInfoReceiver);
@@ -329,7 +335,7 @@ public class SimStatusDialogController implements LifecycleObserver {
}
@VisibleForTesting
protected void updatePhoneNumber() {
public void updatePhoneNumber() {
// If formattedNumber is null or empty, it'll display as "Unknown".
mDialog.setText(PHONE_NUMBER_VALUE_ID,
DeviceInfoUtils.getBidiFormattedPhoneNumber(mContext, mSubscriptionInfo));
@@ -433,7 +439,7 @@ public class SimStatusDialogController implements LifecycleObserver {
private void updateLatestAreaInfo() {
mShowLatestAreaInfo = Resources.getSystem().getBoolean(
com.android.internal.R.bool.config_showAreaUpdateInfoSettings)
&& mTelephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA;
&& getTelephonyManager().getPhoneType() != TelephonyManager.PHONE_TYPE_CDMA;
if (mShowLatestAreaInfo) {
// Bind cell broadcast service to get the area info. The info will be updated once
@@ -451,7 +457,7 @@ public class SimStatusDialogController implements LifecycleObserver {
resetSignalStrength();
} else if (!Utils.isInService(mPreviousServiceState)) {
// If ServiceState changed from out of service -> in service, update signal strength.
updateSignalStrength(mTelephonyManager.getSignalStrength());
updateSignalStrength(getTelephonyManager().getSignalStrength());
}
String serviceStateValue;
@@ -498,7 +504,7 @@ public class SimStatusDialogController implements LifecycleObserver {
return;
}
ServiceState serviceState = mTelephonyManager.getServiceState();
ServiceState serviceState = getTelephonyManager().getServiceState();
if (!Utils.isInService(serviceState)) {
return;
}
@@ -536,8 +542,8 @@ public class SimStatusDialogController implements LifecycleObserver {
String dataNetworkTypeName = null;
String voiceNetworkTypeName = null;
final int subId = mSubscriptionInfo.getSubscriptionId();
final int actualDataNetworkType = mTelephonyManager.getDataNetworkType();
final int actualVoiceNetworkType = mTelephonyManager.getVoiceNetworkType();
final int actualDataNetworkType = getTelephonyManager().getDataNetworkType();
final int actualVoiceNetworkType = getTelephonyManager().getVoiceNetworkType();
final int overrideNetworkType = mTelephonyDisplayInfo == null
? TelephonyDisplayInfo.OVERRIDE_NETWORK_TYPE_NONE
: mTelephonyDisplayInfo.getOverrideNetworkType();
@@ -604,7 +610,7 @@ public class SimStatusDialogController implements LifecycleObserver {
mDialog.removeSettingFromScreen(ICCID_INFO_LABEL_ID);
mDialog.removeSettingFromScreen(ICCID_INFO_VALUE_ID);
} else {
mDialog.setText(ICCID_INFO_VALUE_ID, mTelephonyManager.getSimSerialNumber());
mDialog.setText(ICCID_INFO_VALUE_ID, getTelephonyManager().getSimSerialNumber());
}
}
@@ -617,10 +623,10 @@ public class SimStatusDialogController implements LifecycleObserver {
}
@VisibleForTesting
protected AtomicReference<String> getEid(int slotIndex) {
public AtomicReference<String> getEid(int slotIndex) {
boolean shouldHaveEid = false;
String eid = null;
if (mTelephonyManager.getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) {
if (getTelephonyManager().getActiveModemCount() > MAX_PHONE_COUNT_SINGLE_SIM) {
// Get EID per-SIM in multi-SIM mode
final Map<Integer, Integer> mapping = mTelephonyManager
.getLogicalToPhysicalSlotMapping();
@@ -628,7 +634,7 @@ public class SimStatusDialogController implements LifecycleObserver {
SubscriptionManager.INVALID_SIM_SLOT_INDEX);
if (pSlotId != SubscriptionManager.INVALID_SIM_SLOT_INDEX) {
final List<UiccCardInfo> infos = mTelephonyManager.getUiccCardsInfo();
final List<UiccCardInfo> infos = getTelephonyManager().getUiccCardsInfo();
for (UiccCardInfo info : infos) {
if (info.getPhysicalSlotIndex() == pSlotId) {