Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc6f2df0 authored by SongFerng Wang's avatar SongFerng Wang Committed by Android (Google) Code Review
Browse files

Merge "[WFC] The WFC UI did not refresh after the subscriptionInfoChanged" into tm-qpr-dev

parents 51d087cd d9bc33e3
Loading
Loading
Loading
Loading
+27 −15
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ public class NetworkProviderWifiCallingGroup extends
    private Map<Integer, PhoneAccountHandle> mSimCallManagerList = new HashMap<>();
    private Map<Integer, Preference> mWifiCallingForSubPreferences;
    private List<SubscriptionInfo> mSubInfoListForWfc;
    private SubscriptionsChangeListener mChangeListener;

    public NetworkProviderWifiCallingGroup(Context context, Lifecycle lifecycle,
            String preferenceGroupKey) {
@@ -87,12 +88,12 @@ public class NetworkProviderWifiCallingGroup extends
            mTelephonyCallback = new PhoneCallStateTelephonyCallback();
        }
        lifecycle.addObserver(this);
        mChangeListener = new SubscriptionsChangeListener(context, this);
    }

    private void setSubscriptionInfoList(Context context) {
        mSubInfoListForWfc = new ArrayList<>(
                SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager));
        if (mSubInfoListForWfc != null) {
        mSubInfoListForWfc.removeIf(info -> {
            final int subId = info.getSubscriptionId();
            setTelephonyManagerForSubscriptionId(context, subId);
@@ -104,9 +105,8 @@ public class NetworkProviderWifiCallingGroup extends
            }
            return false;
        });
        } else {
            Log.d(TAG, "No active subscriptions");
        }
        Log.d(TAG, "setSubscriptionInfoList: mSubInfoListForWfc size:"
                + mSubInfoListForWfc.size());
    }

    private void setTelephonyManagerForSubscriptionId(Context context, int subId) {
@@ -137,12 +137,18 @@ public class NetworkProviderWifiCallingGroup extends

    @OnLifecycleEvent(Event.ON_RESUME)
    public void onResume() {
        if (mChangeListener != null) {
            mChangeListener.start();
        }
        updateListener();
        update();
    }

    @OnLifecycleEvent(Event.ON_PAUSE)
    public void onPause() {
        if (mChangeListener != null) {
            mChangeListener.stop();
        }
        if ((mTelephonyCallback != null)) {
            mTelephonyCallback.unregister();
        }
@@ -176,6 +182,7 @@ public class NetworkProviderWifiCallingGroup extends

    private void update() {
        if (mPreferenceGroup == null) {
            Log.d(TAG, "mPreferenceGroup == null");
            return;
        }

@@ -255,7 +262,11 @@ public class NetworkProviderWifiCallingGroup extends

    @Override
    public void onSubscriptionsChanged() {
        Log.d(TAG, "onSubscriptionsChanged:");
        setSubscriptionInfoList(mContext);
        if (mPreferenceGroup != null) {
            mPreferenceGroup.setVisible(isAvailable());
        }
        updateListener();
        update();
    }
@@ -322,6 +333,7 @@ public class NetworkProviderWifiCallingGroup extends
                        CarrierConfigManager.KEY_CARRIER_WFC_IMS_AVAILABLE_BOOL);
            }
        }
        Log.d(TAG, "isWifiCallingAvailableForCarrier:" + isWifiCallingAvailableForCarrier);
        return isWifiCallingAvailableForCarrier;
    }