[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
Merged-In: I56d4900b5bcb189693c99e870b013da97ed283db
(cherry picked from commit d2e22f4cee)
Change-Id: I92e4b84b81622548fb356a4c7af99668bd2a9e00
This commit is contained in:
Bonian Chen
2020-11-11 16:19:50 +08:00
parent e763da5884
commit f9256b41f2

View File

@@ -128,7 +128,7 @@ public class Enhanced4gBasePreferenceController extends TelephonyTogglePreferenc
@Override
public void onStart() {
if (mPhoneStateListener == null) {
if (!isModeMatched() || (mPhoneStateListener == null)) {
return;
}
mPhoneStateListener.register(mContext, mSubId);
@@ -237,7 +237,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);
}
}
}