[Settings] fix for Wifi calling settings page crash

UI crash reported due to accessing telephony framework API with invalid
subscription ID from SIM. Which comes with multiple reason.

Besides of avoidance of crash, following updates are also required:
1. Close wifi calling settings UI when pSIM or eSIM not available or
inserted.
2. Keep the selection of tab (under multi-SIM) when screen rotate
3. Only show 1 SIM when multi-SIM are grouped together

Bug: 149190278
Test: local
Change-Id: Ied9a088b6ee5da66972f27649cc07f4a31304f17
(cherry picked from commit fbe1293a54)
(cherry picked from commit 05f29efe34)
This commit is contained in:
Bonian Chen
2021-06-17 11:18:14 +08:00
parent c09f986580
commit e530d93382
2 changed files with 155 additions and 26 deletions

View File

@@ -36,6 +36,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle;
import com.android.internal.util.CollectionUtils;
import com.android.settings.R;
@@ -68,6 +69,7 @@ public class MobileNetworkActivity extends SettingsBaseActivity
// Set initial value to true allows subscription information fragment to be re-created when
// Activity re-create occur.
private boolean mFragmentForceReload = true;
private boolean mPendingSubscriptionChange = false;
@Override
protected void onNewIntent(Intent intent) {
@@ -155,6 +157,10 @@ public class MobileNetworkActivity extends SettingsBaseActivity
* Implementation of ProxySubscriptionManager.OnActiveSubscriptionChangedListener
*/
public void onChanged() {
if (!getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) {
mPendingSubscriptionChange = true;
return;
}
SubscriptionInfo info = getSubscription();
int oldSubIndex = mCurSubscriptionId;
updateSubscriptions(info, null);
@@ -180,6 +186,10 @@ public class MobileNetworkActivity extends SettingsBaseActivity
super.onStart();
// updateSubscriptions doesn't need to be called, onChanged will always be called after we
// register a listener.
if (mPendingSubscriptionChange) {
mPendingSubscriptionChange = false;
onChanged();
}
}
@Override