Loading src/com/android/server/telecom/CreateConnectionProcessor.java +2 −1 Original line number Diff line number Diff line Loading @@ -403,6 +403,7 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { // When testing emergency calls, we want the calls to go through to the test connection // service, not the telephony ConnectionService. if (mCall.isTestEmergencyCall()) { Log.i(this, "Processing test emergency call -- special rules"); allAccounts = mPhoneAccountRegistrar.filterRestrictedPhoneAccounts(allAccounts); } Loading @@ -411,7 +412,7 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { preferredPAH); // Next, add all SIM phone accounts which can place emergency calls. sortSimPhoneAccountsForEmergency(allAccounts, preferredPA); // and pick the fist one that can place emergency calls. // and pick the first one that can place emergency calls. for (PhoneAccount phoneAccount : allAccounts) { if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS) && phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) { Loading src/com/android/server/telecom/PhoneStateBroadcaster.java +39 −0 Original line number Diff line number Diff line Loading @@ -17,8 +17,16 @@ package com.android.server.telecom; import android.telecom.Log; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyRegistryManager; import android.telephony.emergency.EmergencyNumber; import java.util.List; import java.util.Objects; import java.util.Optional; /** * Send a {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} broadcast when the call state Loading Loading @@ -52,6 +60,10 @@ final class PhoneStateBroadcaster extends CallsManagerListenerBase { return; } updateStates(call); if (call.isEmergencyCall() && !call.isIncoming()) { sendOutgoingEmergencyCallEvent(call); } } @Override Loading Loading @@ -113,4 +125,31 @@ final class PhoneStateBroadcaster extends CallsManagerListenerBase { Log.i(this, "Broadcasted state change: %s", mCurrentState); } } private void sendOutgoingEmergencyCallEvent(Call call) { TelephonyManager tm = mCallsManager.getContext().getSystemService(TelephonyManager.class); String strippedNumber = PhoneNumberUtils.stripSeparators(call.getHandle().getSchemeSpecificPart()); Optional<EmergencyNumber> emergencyNumber = tm.getEmergencyNumberList().values().stream() .flatMap(List::stream) .filter(numberObj -> Objects.equals(numberObj.getNumber(), strippedNumber)) .findFirst(); int subscriptionId = tm.getSubscriptionId(call.getTargetPhoneAccount()); SubscriptionManager subscriptionManager = mCallsManager.getContext().getSystemService(SubscriptionManager.class); int simSlotIndex = SubscriptionManager.DEFAULT_PHONE_INDEX; if (subscriptionManager != null) { SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subscriptionId); if (subInfo != null) { simSlotIndex = subInfo.getSimSlotIndex(); } } if (emergencyNumber.isPresent()) { mRegistry.notifyOutgoingEmergencyCall( simSlotIndex, subscriptionId, emergencyNumber.get()); } } } Loading
src/com/android/server/telecom/CreateConnectionProcessor.java +2 −1 Original line number Diff line number Diff line Loading @@ -403,6 +403,7 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { // When testing emergency calls, we want the calls to go through to the test connection // service, not the telephony ConnectionService. if (mCall.isTestEmergencyCall()) { Log.i(this, "Processing test emergency call -- special rules"); allAccounts = mPhoneAccountRegistrar.filterRestrictedPhoneAccounts(allAccounts); } Loading @@ -411,7 +412,7 @@ public class CreateConnectionProcessor implements CreateConnectionResponse { preferredPAH); // Next, add all SIM phone accounts which can place emergency calls. sortSimPhoneAccountsForEmergency(allAccounts, preferredPA); // and pick the fist one that can place emergency calls. // and pick the first one that can place emergency calls. for (PhoneAccount phoneAccount : allAccounts) { if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS) && phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) { Loading
src/com/android/server/telecom/PhoneStateBroadcaster.java +39 −0 Original line number Diff line number Diff line Loading @@ -17,8 +17,16 @@ package com.android.server.telecom; import android.telecom.Log; import android.telephony.PhoneNumberUtils; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyRegistryManager; import android.telephony.emergency.EmergencyNumber; import java.util.List; import java.util.Objects; import java.util.Optional; /** * Send a {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} broadcast when the call state Loading Loading @@ -52,6 +60,10 @@ final class PhoneStateBroadcaster extends CallsManagerListenerBase { return; } updateStates(call); if (call.isEmergencyCall() && !call.isIncoming()) { sendOutgoingEmergencyCallEvent(call); } } @Override Loading Loading @@ -113,4 +125,31 @@ final class PhoneStateBroadcaster extends CallsManagerListenerBase { Log.i(this, "Broadcasted state change: %s", mCurrentState); } } private void sendOutgoingEmergencyCallEvent(Call call) { TelephonyManager tm = mCallsManager.getContext().getSystemService(TelephonyManager.class); String strippedNumber = PhoneNumberUtils.stripSeparators(call.getHandle().getSchemeSpecificPart()); Optional<EmergencyNumber> emergencyNumber = tm.getEmergencyNumberList().values().stream() .flatMap(List::stream) .filter(numberObj -> Objects.equals(numberObj.getNumber(), strippedNumber)) .findFirst(); int subscriptionId = tm.getSubscriptionId(call.getTargetPhoneAccount()); SubscriptionManager subscriptionManager = mCallsManager.getContext().getSystemService(SubscriptionManager.class); int simSlotIndex = SubscriptionManager.DEFAULT_PHONE_INDEX; if (subscriptionManager != null) { SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfo(subscriptionId); if (subInfo != null) { simSlotIndex = subInfo.getSimSlotIndex(); } } if (emergencyNumber.isPresent()) { mRegistry.notifyOutgoingEmergencyCall( simSlotIndex, subscriptionId, emergencyNumber.get()); } } }