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

Commit 96af57b4 authored by Brad Ebinger's avatar Brad Ebinger Committed by android-build-merger
Browse files

Merge "Resolve the SIM call manager per subId" into qt-dev

am: 1350309e

Change-Id: I3d5c730efde6c0a8a1ecdba4e70793696ad7a598
parents 9761dd46 1350309e
Loading
Loading
Loading
Loading
+12 −7
Original line number Original line Diff line number Diff line
@@ -80,12 +80,16 @@ public class MobileNetworkUtils {
    }
    }


    /**
    /**
     * Returns true if Wifi calling is enabled for at least one phone.
     * Returns true if Wifi calling is enabled for at least one subscription.
     */
     */
    public static boolean isWifiCallingEnabled(Context context) {
    public static boolean isWifiCallingEnabled(Context context) {
        int phoneCount = context.getSystemService(TelephonyManager.class).getPhoneCount();
        SubscriptionManager subManager = context.getSystemService(SubscriptionManager.class);
        for (int i = 0; i < phoneCount; i++) {
        if (subManager == null) {
            if (isWifiCallingEnabled(context, i)) {
            Log.e(TAG, "isWifiCallingEnabled: couldn't get system service.");
            return false;
        }
        for (int subId : subManager.getActiveSubscriptionIdList()) {
            if (isWifiCallingEnabled(context, subId)) {
                return true;
                return true;
            }
            }
        }
        }
@@ -93,11 +97,12 @@ public class MobileNetworkUtils {
    }
    }


    /**
    /**
     * Returns true if Wifi calling is enabled for the specific phone with id {@code phoneId}.
     * Returns true if Wifi calling is enabled for the specific subscription with id {@code subId}.
     */
     */
    public static boolean isWifiCallingEnabled(Context context, int phoneId) {
    public static boolean isWifiCallingEnabled(Context context, int subId) {
        final PhoneAccountHandle simCallManager =
        final PhoneAccountHandle simCallManager =
                TelecomManager.from(context).getSimCallManager();
                TelecomManager.from(context).getSimCallManagerForSubscription(subId);
        final int phoneId = SubscriptionManager.getSlotIndex(subId);


        boolean isWifiCallingEnabled;
        boolean isWifiCallingEnabled;
        if (simCallManager != null) {
        if (simCallManager != null) {
+1 −2
Original line number Original line Diff line number Diff line
@@ -63,8 +63,7 @@ public class VideoCallingPreferenceController extends TelephonyTogglePreferenceC
    @Override
    @Override
    public int getAvailabilityStatus(int subId) {
    public int getAvailabilityStatus(int subId) {
        return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
        return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                && MobileNetworkUtils.isWifiCallingEnabled(mContext,
                && MobileNetworkUtils.isWifiCallingEnabled(mContext, subId)
                SubscriptionManager.getPhoneId(subId))
                && isVideoCallEnabled(subId)
                && isVideoCallEnabled(subId)
                ? AVAILABLE
                ? AVAILABLE
                : CONDITIONALLY_UNAVAILABLE;
                : CONDITIONALLY_UNAVAILABLE;
+3 −3
Original line number Original line Diff line number Diff line
@@ -68,7 +68,6 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
        super(context, key);
        super(context, key);
        mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
        mCarrierConfigManager = context.getSystemService(CarrierConfigManager.class);
        mTelephonyManager = context.getSystemService(TelephonyManager.class);
        mTelephonyManager = context.getSystemService(TelephonyManager.class);
        mSimCallManager = context.getSystemService(TelecomManager.class).getSimCallManager();
        mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
        mPhoneStateListener = new PhoneCallStateListener(Looper.getMainLooper());
        mEditableWfcRoamingMode = true;
        mEditableWfcRoamingMode = true;
        mUseWfcHomeModeForRoaming = false;
        mUseWfcHomeModeForRoaming = false;
@@ -77,8 +76,7 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
    @Override
    @Override
    public int getAvailabilityStatus(int subId) {
    public int getAvailabilityStatus(int subId) {
        return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
        return subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID
                && MobileNetworkUtils.isWifiCallingEnabled(mContext,
                && MobileNetworkUtils.isWifiCallingEnabled(mContext, subId)
                SubscriptionManager.getPhoneId(subId))
                ? AVAILABLE
                ? AVAILABLE
                : UNSUPPORTED_ON_DEVICE;
                : UNSUPPORTED_ON_DEVICE;
    }
    }
@@ -155,6 +153,8 @@ public class WifiCallingPreferenceController extends TelephonyBasePreferenceCont
        mSubId = subId;
        mSubId = subId;
        mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
        mTelephonyManager = TelephonyManager.from(mContext).createForSubscriptionId(mSubId);
        mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
        mImsManager = ImsManager.getInstance(mContext, SubscriptionManager.getPhoneId(mSubId));
        mSimCallManager = mContext.getSystemService(TelecomManager.class)
                .getSimCallManagerForSubscription(mSubId);
        if (mCarrierConfigManager != null) {
        if (mCarrierConfigManager != null) {
            final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
            final PersistableBundle carrierConfig = mCarrierConfigManager.getConfigForSubId(mSubId);
            if (carrierConfig != null) {
            if (carrierConfig != null) {