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

Commit 6d063c95 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

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

When the default voice sub is changed in SubscriptionManager, ensure that
the corresponding setting in Telecom is also changed.

Test: Manual
Bug: 128916238
Change-Id: I5a32a87d0ad79d0383642a3e5b0ff9380b9f9b33
parent b5b81e57
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;
@@ -2008,9 +2010,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);
        }