Loading res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,9 @@ <!-- Call failure message displayed in an error dialog used to indicate that a phone number was not provided --> <string name="outgoing_call_error_no_phone_number_supplied">Call not sent, no valid number entered.</string> <!-- Message shown when the user tries to make a video call when already in a video call. --> <string name ="duplicate_video_call_not_allowed">Call cannot be added at this time.</string> <!-- missing voicemail number --> <!-- Title of the "Missing voicemail number" dialog --> <string name="no_vm_number">Missing voicemail number</string> Loading src/com/android/server/telecom/CallReceiver.java +30 −0 Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ import android.os.UserHandle; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.DisconnectCause; import android.telephony.PhoneNumberUtils; import android.widget.Toast; /** * Single point of entry for all outgoing and incoming calls. {@link CallActivity} serves as a Loading Loading @@ -44,6 +46,10 @@ public class CallReceiver extends BroadcastReceiver { * @param intent Call intent containing data about the handle to call. */ static void processOutgoingCallIntent(Context context, Intent intent) { if (shouldPreventDuplicateVideoCall(context, intent)) { return; } Uri handle = intent.getData(); String scheme = handle.getScheme(); String uriString = handle.getSchemeSpecificPart(); Loading Loading @@ -149,4 +155,28 @@ public class CallReceiver extends BroadcastReceiver { errorIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivityAsUser(errorIntent, UserHandle.CURRENT); } /** * Whether an outgoing video call should be prevented from going out. Namely, don't allow an * outgoing video call if there is already an ongoing video call. Notify the user if their call * is not sent. * * @return {@code true} if the outgoing call is a video call and should be prevented from going * out, {@code false} otherwise. */ private static boolean shouldPreventDuplicateVideoCall(Context context, Intent intent) { int intentVideoState = intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.VideoState.AUDIO_ONLY); if (intentVideoState == VideoProfile.VideoState.AUDIO_ONLY || !getCallsManager().hasVideoCall()) { return false; } else { // Display an error toast to the user. Toast.makeText( context, context.getResources().getString(R.string.duplicate_video_call_not_allowed), Toast.LENGTH_LONG).show(); return true; } } } src/com/android/server/telecom/CallsManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.PhoneCapabilities; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import com.android.internal.util.IndentingPrintWriter; Loading Loading @@ -312,6 +313,15 @@ public final class CallsManager extends Call.ListenerBase { return false; } boolean hasVideoCall() { for (Call call : mCalls) { if (call.getVideoState() != VideoProfile.VideoState.AUDIO_ONLY) { return true; } } return false; } AudioState getAudioState() { return mCallAudioManager.getAudioState(); } Loading Loading
res/values/strings.xml +3 −0 Original line number Diff line number Diff line Loading @@ -83,6 +83,9 @@ <!-- Call failure message displayed in an error dialog used to indicate that a phone number was not provided --> <string name="outgoing_call_error_no_phone_number_supplied">Call not sent, no valid number entered.</string> <!-- Message shown when the user tries to make a video call when already in a video call. --> <string name ="duplicate_video_call_not_allowed">Call cannot be added at this time.</string> <!-- missing voicemail number --> <!-- Title of the "Missing voicemail number" dialog --> <string name="no_vm_number">Missing voicemail number</string> Loading
src/com/android/server/telecom/CallReceiver.java +30 −0 Original line number Diff line number Diff line Loading @@ -9,8 +9,10 @@ import android.os.UserHandle; import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.DisconnectCause; import android.telephony.PhoneNumberUtils; import android.widget.Toast; /** * Single point of entry for all outgoing and incoming calls. {@link CallActivity} serves as a Loading Loading @@ -44,6 +46,10 @@ public class CallReceiver extends BroadcastReceiver { * @param intent Call intent containing data about the handle to call. */ static void processOutgoingCallIntent(Context context, Intent intent) { if (shouldPreventDuplicateVideoCall(context, intent)) { return; } Uri handle = intent.getData(); String scheme = handle.getScheme(); String uriString = handle.getSchemeSpecificPart(); Loading Loading @@ -149,4 +155,28 @@ public class CallReceiver extends BroadcastReceiver { errorIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivityAsUser(errorIntent, UserHandle.CURRENT); } /** * Whether an outgoing video call should be prevented from going out. Namely, don't allow an * outgoing video call if there is already an ongoing video call. Notify the user if their call * is not sent. * * @return {@code true} if the outgoing call is a video call and should be prevented from going * out, {@code false} otherwise. */ private static boolean shouldPreventDuplicateVideoCall(Context context, Intent intent) { int intentVideoState = intent.getIntExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, VideoProfile.VideoState.AUDIO_ONLY); if (intentVideoState == VideoProfile.VideoState.AUDIO_ONLY || !getCallsManager().hasVideoCall()) { return false; } else { // Display an error toast to the user. Toast.makeText( context, context.getResources().getString(R.string.duplicate_video_call_not_allowed), Toast.LENGTH_LONG).show(); return true; } } }
src/com/android/server/telecom/CallsManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ import android.telecom.PhoneAccount; import android.telecom.PhoneAccountHandle; import android.telecom.PhoneCapabilities; import android.telecom.TelecomManager; import android.telecom.VideoProfile; import android.telephony.TelephonyManager; import com.android.internal.util.IndentingPrintWriter; Loading Loading @@ -312,6 +313,15 @@ public final class CallsManager extends Call.ListenerBase { return false; } boolean hasVideoCall() { for (Call call : mCalls) { if (call.getVideoState() != VideoProfile.VideoState.AUDIO_ONLY) { return true; } } return false; } AudioState getAudioState() { return mCallAudioManager.getAudioState(); } Loading