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 <taesu82.lee@samsung.com>
This commit is contained in:
Taesu Lee
2020-08-25 18:53:07 +09:00
parent 36cfa7db8e
commit 99637baab2
3 changed files with 9 additions and 0 deletions

View File

@@ -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);
}