[Settings] Reduce the operation of VoLTE config redraw

There're 3 VoLTE configuration UIs sharing the same configuration,
but only 1 of them will be displayed.

The 3 classes extending Enhanced4gBasePreferenceController are:
1. Enhanced4gAdvancedCallingPreferenceController
2. Enhanced4gCallingPreferenceController
3. Enhanced4gLtePreferenceController
They're different in the value of getMode().

The design within Enhanced4gBasePreferenceController only allows to show one of them.
Which means, the other two don't need to register for PhoneStateListener and should ignore actions in response to it when receiving callback from PhoneStateListener.

Through detecting the VoLTE configuration mode, some operations could be
avoided.
This fix is targeting to avoid these operations from happening.

Bug: 172987488
Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=Enhanced4gBasePreferenceControllerTest
Change-Id: I56d4900b5bcb189693c99e870b013da97ed283db
This commit is contained in:
Bonian Chen
2020-11-11 16:19:50 +08:00
parent 296a4bc62e
commit d2e22f4cee

View File

@@ -127,7 +127,7 @@ public class Enhanced4gBasePreferenceController extends TelephonyTogglePreferenc
@Override
public void onStart() {
if (mPhoneStateListener == null) {
if (!isModeMatched() || (mPhoneStateListener == null)) {
return;
}
mPhoneStateListener.register(mContext, mSubId);
@@ -241,7 +241,9 @@ public class Enhanced4gBasePreferenceController extends TelephonyTogglePreferenc
public void unregister() {
mCallState = null;
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
if (mTelephonyManager != null) {
mTelephonyManager.listen(this, PhoneStateListener.LISTEN_NONE);
}
}
}