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

Commit aee7e37d authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Ensure Telecom user selected phone account changes with default voice sub." into qt-dev

parents 9e969a91 6d063c95
Loading
Loading
Loading
Loading
+24 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,8 @@ import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager;
import android.os.UserHandle;
import android.os.UserHandle;
import android.provider.Settings;
import android.provider.Settings;
import android.telecom.PhoneAccountHandle;
import android.telecom.TelecomManager;
import android.telephony.RadioAccessFamily;
import android.telephony.RadioAccessFamily;
import android.telephony.Rlog;
import android.telephony.Rlog;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionInfo;
@@ -2053,9 +2055,31 @@ public class SubscriptionController extends ISub.Stub {
            throw new RuntimeException("setDefaultVoiceSubId called with DEFAULT_SUB_ID");
            throw new RuntimeException("setDefaultVoiceSubId called with DEFAULT_SUB_ID");
        }
        }
        if (DBG) logdl("[setDefaultVoiceSubId] subId=" + subId);
        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.putInt(mContext.getContentResolver(),
                Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId);
                Settings.Global.MULTI_SIM_VOICE_CALL_SUBSCRIPTION, subId);
        broadcastDefaultVoiceSubIdChanged(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 Original line Diff line number Diff line
@@ -263,6 +263,8 @@ public class ContextFixture implements TestFixture<Context> {
                return Context.TELEPHONY_SUBSCRIPTION_SERVICE;
                return Context.TELEPHONY_SUBSCRIPTION_SERVICE;
            } else if (serviceClass == AppOpsManager.class) {
            } else if (serviceClass == AppOpsManager.class) {
                return Context.APP_OPS_SERVICE;
                return Context.APP_OPS_SERVICE;
            } else if (serviceClass == TelecomManager.class) {
                return Context.TELECOM_SERVICE;
            }
            }
            return super.getSystemServiceName(serviceClass);
            return super.getSystemServiceName(serviceClass);
        }
        }