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

Commit 498a3a40 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

Merge "Ensure Telecom user selected phone account changes with default voice sub."

am: ccebe7ab

Change-Id: Ie110e1aa7c098943ea52d382e7fb0b44656f7b42
parents 160bc49e ccebe7ab
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.SubscriptionInfo;
@@ -2039,9 +2041,31 @@ public class SubscriptionController extends ISub.Stub {
            throw new RuntimeException("setDefaultVoiceSubId called with DEFAULT_SUB_ID");
        }
        if (DBG) logdl("[setDefaultVoiceSubId] subId=" + subId);

        int previousSetting = Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION,
                SubscriptionManager.DEFAULT_SUBSCRIPTION_ID);

        Settings.Global.putInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId);
        broadcastDefaultVoiceSubIdChanged(subId);

        if (previousSetting != subId) {
            PhoneAccountHandle newHandle =
                    subId == SubscriptionManager.INVALID_SUBSCRIPTION_ID
                            ? null : mTelephonyManager.getPhoneAccountHandleForSubscriptionId(
                            subId);

            TelecomManager telecomManager = mContext.getSystemService(TelecomManager.class);
            PhoneAccountHandle currentHandle = telecomManager.getUserSelectedOutgoingPhoneAccount();

            if (!Objects.equals(currentHandle, newHandle)) {
                telecomManager.setUserSelectedOutgoingPhoneAccount(newHandle);
                logd("[setDefaultVoiceSubId] change to phoneAccountHandle=" + newHandle);
            } else {
                logd("[setDefaultVoiceSubId] default phone account not changed");
            }
        }
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -263,6 +263,8 @@ public class ContextFixture implements TestFixture<Context> {
                return Context.TELEPHONY_SUBSCRIPTION_SERVICE;
            } else if (serviceClass == AppOpsManager.class) {
                return Context.APP_OPS_SERVICE;
            } else if (serviceClass == TelecomManager.class) {
                return Context.TELECOM_SERVICE;
            }
            return super.getSystemServiceName(serviceClass);
        }