From 99637baab21a13cfc810d156f187f00c3698006d Mon Sep 17 00:00:00 2001 From: Taesu Lee Date: Tue, 25 Aug 2020 18:53:07 +0900 Subject: [PATCH] Avoid unexpected state changes for enhanced preferences Assigning current call state to mCallState right before registering PhoneStateListener so that the preferences have correct state before first onCallStateChanged() by initial registration even. Bug: 166307650 Test: Check the preferences state when onStop() -> onStart() Change-Id: I861a687497ba4da7a845540fd92ae2b865392d60 Signed-off-by: Taesu Lee --- .../network/telephony/Enhanced4gBasePreferenceController.java | 3 +++ .../network/telephony/VideoCallingPreferenceController.java | 3 +++ .../network/telephony/WifiCallingPreferenceController.java | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java index d6aed676d47..dc915af2d06 100644 --- a/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java +++ b/src/com/android/settings/network/telephony/Enhanced4gBasePreferenceController.java @@ -225,6 +225,9 @@ public class Enhanced4gBasePreferenceController extends TelephonyTogglePreferenc if (SubscriptionManager.isValidSubscriptionId(subId)) { mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId); } + // assign current call state so that it helps to show correct preference state even + // before first onCallStateChanged() by initial registration. + mCallState = mTelephonyManager.getCallState(subId); mTelephonyManager.listen(this, PhoneStateListener.LISTEN_CALL_STATE); final long supportedRadioBitmask = mTelephonyManager.getSupportedRadioAccessFamily(); diff --git a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java index 3321fb3afe5..fa8b47fba41 100644 --- a/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java +++ b/src/com/android/settings/network/telephony/VideoCallingPreferenceController.java @@ -182,6 +182,9 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC if (SubscriptionManager.isValidSubscriptionId(subId)) { mTelephonyManager = mTelephonyManager.createForSubscriptionId(subId); } + // assign current call state so that it helps to show correct preference state even + // before first onCallStateChanged() by initial registration. + mCallState = mTelephonyManager.getCallState(subId); mTelephonyManager.listen(this, PhoneStateListener.LISTEN_CALL_STATE); } diff --git a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java index 32be36e325e..b38fe07fb4d 100644 --- a/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java +++ b/src/com/android/settings/network/telephony/WifiCallingPreferenceController.java @@ -210,6 +210,9 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont public void register(Context context, int subId) { mTelephonyManager = getTelephonyManager(context, subId); + // assign current call state so that it helps to show correct preference state even + // before first onCallStateChanged() by initial registration. + mCallState = mTelephonyManager.getCallState(subId); mTelephonyManager.listen(this, PhoneStateListener.LISTEN_CALL_STATE); }