[RadioInfo] Unique mobile radio power setting and fix crash
1. There's a restriction on current mobile radio power settings API.
Which restrict the controll of setRadioPower need to be applied to
all phone instances at the same time.
2.Fix a crash due to the update happening outside of UI thread
Bug: 145681511
Bug: 149258622
Test: manual
Test: make TeleService; adb shell am start -a \
android.intent.action.MAIN -n com.android.phone/.settings.RadioInfo; \
press on cbrs switch
Change-Id: Id04f288e1e6e01323cbff6923d3a563c10f6cd5b
Merged-In: I4c52012ca3c842bc8d11a2d8b12a5e68ad22843e
Merged-In: I426240afd700414f1b946239a89bdd4c01376051
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index 77f1135..31b7a9e 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -1449,8 +1449,18 @@
OnCheckedChangeListener mRadioPowerOnChangeListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- log("toggle radio power: currently " + (isRadioOn() ? "on" : "off"));
- mPhone.setRadioPower(isChecked);
+ // TODO: b/145681511. Within current design, radio power on all of the phones need
+ // to be controlled at the same time.
+ Phone[] phones = PhoneFactory.getPhones();
+ if (phones == null) {
+ return;
+ }
+ log("toggle radio power: phone*" + phones.length + " " + (isRadioOn() ? "on" : "off"));
+ for (int phoneIndex = 0; phoneIndex < phones.length; phoneIndex++) {
+ if (phones[phoneIndex] != null) {
+ phones[phoneIndex].setRadioPower(isChecked);
+ }
+ }
}
};
@@ -1718,7 +1728,7 @@
mQueuedWork.execute(new Runnable() {
public void run() {
mTelephonyManager.setOpportunisticNetworkState(state);
- mCbrsDataSwitch.setChecked(getCbrsDataState());
+ mHandler.post(() -> mCbrsDataSwitch.setChecked(getCbrsDataState()));
}
});
}