From dcc0736c4341335dc73856d98ac940c2ad7eba8f Mon Sep 17 00:00:00 2001 From: Etan Cohen Date: Tue, 23 Sep 2014 16:03:44 -0700 Subject: [PATCH] Added mechanism to merge voice & baseline ServiceState objects. Needed in the context of separate phones handling baseline connectivity and voice connectivity (e.g. IMS). Bug: 17627405 Change-Id: Ifb5a6ea11f6350090b989408e9eed80958d8558b --- .../java/android/telephony/ServiceState.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java index 1ee390fb90b39..ce89538f90fe2 100644 --- a/telephony/java/android/telephony/ServiceState.java +++ b/telephony/java/android/telephony/ServiceState.java @@ -861,4 +861,23 @@ public class ServiceState implements Parcelable { || radioTechnology == RIL_RADIO_TECHNOLOGY_EVDO_B || radioTechnology == RIL_RADIO_TECHNOLOGY_EHRPD; } + + /** + * Returns a merged ServiceState consisting of the base SS with voice settings from the + * voice SS. The voice SS is only used if it is IN_SERVICE (otherwise the base SS is returned). + * @hide + * */ + public static ServiceState mergeServiceStates(ServiceState baseSs, ServiceState voiceSs) { + if (voiceSs.mVoiceRegState != STATE_IN_SERVICE) { + return baseSs; + } + + ServiceState newSs = new ServiceState(baseSs); + + // voice overrides + newSs.mVoiceRegState = voiceSs.mVoiceRegState; + newSs.mIsEmergencyOnly = false; // only get here if voice is IN_SERVICE + + return newSs; + } }