IMS-VT: Change parameter type of data usage
Change Data Usage methods to take parameters of type long
instead of int.
Change-Id: I6a277dedb5976261035084955ed8a90da256061a
IMS-VT: When TTY is ON, do not allow MO VT call
When TTY mode is ON, the user SHOULD NOT be allowed to make
a Mobile Originating (MO) VT call and an UI alert message will
be displayed explaining MO VT call cannot be initiated.
Propagate the call substate changed message to the UI
IMS-VT : Set the flag to start call with speaker on for incoming VT calls
- There seems to be a race condition between when InCallUI
enters the video mode and sets the speaker phone on and
when call state changes to active.
- As a result, the audio route gets reset to earpiece as we
are not setting speaker phone on flag for the incoming
case. This change fixes that issue.
IMS-VT: Set speaker phone to true only if bluetooth or headset is not connected
IMS-VT: Convert emergency video call to voice call.
Convert emergency video call to voice call.
Change-Id: I09b82dcb6308a1177716b77e87da68161000518b
IMS-VT: Enable Video conferencing.
Enable Video conferencing.
Change-Id: Ief145e0592e58de46c7a75d858effdd72fa8b476
IMS-VT: Check for property before enabling speaker for MT VT calls
Check persist.radio.ims.audio.output before enabling speaker
if property is set to disable speaker then MT VT calls should not
use the speaker.
Change-Id: I0c6288a8fd672c9b7a13edac11e29875d0df4eb7
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 37e59c0..b09cdce 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -83,6 +83,9 @@
<!-- 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>
+ <!-- Message indicating video calls not allowed if user enabled TTY Mode -->
+ <string name="video_call_not_allowed_if_tty_enabled">Please disable TTY Mode to make video calls.</string>
+
<!-- missing voicemail number -->
<!-- Title of the "Missing voicemail number" dialog -->
<string name="no_vm_number">Missing voicemail number</string>
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index daedb91..0654ae3 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -93,6 +93,7 @@
void onPhoneAccountChanged(Call call);
void onConferenceableCallsChanged(Call call);
boolean onCanceledViaNewOutgoingCallBroadcast(Call call);
+ void onCallSubstateChanged(Call call);
}
public abstract static class ListenerBase implements Listener {
@@ -148,6 +149,7 @@
public boolean onCanceledViaNewOutgoingCallBroadcast(Call call) {
return false;
}
+ public void onCallSubstateChanged(Call call) {}
}
private static final OnQueryCompleteListener sCallerInfoQueryListener =
@@ -307,6 +309,7 @@
private final Context mContext;
private final CallsManager mCallsManager;
private final TelecomSystem.SyncRoot mLock;
+ private int mCallSubstate;
private boolean mWasConferencePreviouslyMerged = false;
@@ -413,7 +416,7 @@
component = mConnectionService.getComponentName().flattenToShortString();
}
- return String.format(Locale.US, "[%s, %s, %s, %s, %d, childs(%d), has_parent(%b), [%s]",
+ return String.format(Locale.US, "[%s, %s, %s, %s, %d, childs(%d), has_parent(%b), [%s], %d]",
System.identityHashCode(this),
CallState.toString(mState),
component,
@@ -421,7 +424,8 @@
getVideoState(),
getChildCalls().size(),
getParentCall() != null,
- Connection.capabilitiesToString(getConnectionCapabilities()));
+ Connection.capabilitiesToString(getConnectionCapabilities()),
+ getCallSubstate());
}
int getState() {
@@ -805,6 +809,7 @@
setRingbackRequested(connection.isRingbackRequested());
setIsVoipAudioMode(connection.getIsVoipAudioMode());
setStatusHints(connection.getStatusHints());
+ setCallSubstate(connection.getCallSubstate());
mConferenceableCalls.clear();
for (String id : connection.getConferenceableConnectionIds()) {
@@ -1498,4 +1503,25 @@
}
return CallState.DISCONNECTED;
}
+
+ /**
+ * The current call substate.
+ */
+ public int getCallSubstate() {
+ return mCallSubstate;
+ }
+
+
+ /**
+ * Determines the current substate for the call.
+ *
+ * @param callSubstate The substate for the call.
+ */
+ public void setCallSubstate(int callSubstate) {
+ mCallSubstate = callSubstate;
+
+ for (Listener l : mListeners) {
+ l.onCallSubstateChanged(this);
+ }
+ }
}
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 8e5927d..ca4a436 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -21,6 +21,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
+import android.os.SystemProperties;
import android.os.Trace;
import android.provider.CallLog.Calls;
import android.telecom.AudioState;
@@ -39,6 +40,8 @@
import android.telephony.TelephonyManager;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.telephony.PhoneConstants;
+import com.android.internal.telephony.TelephonyProperties;
import com.android.internal.util.IndentingPrintWriter;
import java.util.Collection;
@@ -77,6 +80,7 @@
void onIsVoipAudioModeChanged(Call call);
void onVideoStateChanged(Call call);
void onCanAddCallChanged(boolean canAddCall);
+ void onCallSubstateChanged(Call call);
}
private static final String TAG = "CallsManager";
@@ -368,6 +372,12 @@
return Collections.unmodifiableCollection(mCalls);
}
+ public void onCallSubstateChanged(Call call) {
+ for (CallsManagerListener listener : mListeners) {
+ listener.onCallSubstateChanged(call);
+ }
+ }
+
Call getForegroundCall() {
return mForegroundCall;
}
@@ -692,9 +702,21 @@
// We do not update the UI until we get confirmation of the answer() through
// {@link #markCallAsActive}.
call.answer(videoState);
+ if (VideoProfile.VideoState.isVideo(videoState) &&
+ !mWiredHeadsetManager.isPluggedIn() &&
+ !mCallAudioManager.isBluetoothDeviceAvailable() &&
+ isSpeakerEnabledForVideoCalls()) {
+ call.setStartWithSpeakerphoneOn(true);
+ }
}
}
+ private static boolean isSpeakerEnabledForVideoCalls() {
+ return (SystemProperties.getInt(TelephonyProperties.PROPERTY_VIDEOCALL_AUDIO_OUTPUT,
+ PhoneConstants.AUDIO_OUTPUT_DEFAULT) ==
+ PhoneConstants.AUDIO_OUTPUT_ENABLE_SPEAKER);
+ }
+
/**
* Instructs Telecom to reject the specified call. Intended to be invoked by the in-call
* app through {@link InCallAdapter} after Telecom notifies it of an incoming call followed by
@@ -1089,6 +1111,8 @@
setCallState(call, Call.getStateFromConnectionState(parcelableConference.getState()));
call.setConnectionCapabilities(parcelableConference.getConnectionCapabilities());
+ call.setVideoState(parcelableConference.getVideoState());
+ call.setVideoProvider(parcelableConference.getVideoProvider());
// TODO: Move this to be a part of addCall()
call.addListener(this);
diff --git a/src/com/android/server/telecom/CallsManagerListenerBase.java b/src/com/android/server/telecom/CallsManagerListenerBase.java
index 6b54709..07839db 100644
--- a/src/com/android/server/telecom/CallsManagerListenerBase.java
+++ b/src/com/android/server/telecom/CallsManagerListenerBase.java
@@ -76,4 +76,8 @@
@Override
public void onCanAddCallChanged(boolean canAddCall) {
}
+
+ @Override
+ public void onCallSubstateChanged(Call call) {
+ }
}
diff --git a/src/com/android/server/telecom/ConnectionServiceWrapper.java b/src/com/android/server/telecom/ConnectionServiceWrapper.java
index 2d94a24..fc5e099 100644
--- a/src/com/android/server/telecom/ConnectionServiceWrapper.java
+++ b/src/com/android/server/telecom/ConnectionServiceWrapper.java
@@ -128,7 +128,8 @@
try {
synchronized (mLock) {
logIncoming("setVideoProvider %s", callId);
- if (mCallIdMapper.isValidCallId(callId)) {
+ if (mCallIdMapper.isValidCallId(callId)
+ || mCallIdMapper.isValidConferenceId(callId)) {
Call call = mCallIdMapper.getCall(callId);
if (call != null) {
call.setVideoProvider(videoProvider);
@@ -405,7 +406,8 @@
try {
synchronized (mLock) {
logIncoming("setVideoState %s %d", callId, videoState);
- if (mCallIdMapper.isValidCallId(callId)) {
+ if (mCallIdMapper.isValidCallId(callId)
+ || mCallIdMapper.isValidConferenceId(callId)) {
Call call = mCallIdMapper.getCall(callId);
if (call != null) {
call.setVideoState(videoState);
@@ -535,6 +537,25 @@
Binder.restoreCallingIdentity(token);
}
}
+
+ @Override
+ public void setCallSubstate(String callId, int callSubstate) {
+ long token = Binder.clearCallingIdentity();
+ try {
+ synchronized (mLock) {
+ logIncoming("setCallSubstate %s %d", callId, callSubstate);
+ if (mCallIdMapper.isValidCallId(callId)) {
+ Call call = mCallIdMapper.getCall(callId);
+
+ if (call != null) {
+ call.setCallSubstate(callSubstate);
+ }
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
}
private final Adapter mAdapter = new Adapter();
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index e959bd7..5d06ddc 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -119,6 +119,11 @@
public void onConferenceableCallsChanged(Call call) {
updateCall(call);
}
+
+ @Override
+ public void onCallSubstateChanged(Call call) {
+ updateCall(call);
+ }
};
/**
@@ -553,7 +558,8 @@
call.getStatusHints(),
call.getVideoState(),
conferenceableCallIds,
- call.getExtras());
+ call.getExtras(),
+ call.getCallSubstate());
}
private static final int[] CONNECTION_TO_CALL_CAPABILITY = new int[] {
@@ -615,7 +621,10 @@
android.telecom.Call.Details.CAPABILITY_GENERIC_CONFERENCE,
Connection.CAPABILITY_SHOW_CALLBACK_NUMBER,
- android.telecom.Call.Details.CAPABILITY_SHOW_CALLBACK_NUMBER
+ android.telecom.Call.Details.CAPABILITY_SHOW_CALLBACK_NUMBER,
+
+ Connection.CAPABILITY_CAN_UPGRADE_TO_VIDEO,
+ android.telecom.Call.Details.CAPABILITY_CAN_UPGRADE_TO_VIDEO
};
private static int convertConnectionToCallCapabilities(int connectionCapabilities) {
diff --git a/src/com/android/server/telecom/components/UserCallIntentProcessor.java b/src/com/android/server/telecom/components/UserCallIntentProcessor.java
index 97a3497..a3e9b1b 100644
--- a/src/com/android/server/telecom/components/UserCallIntentProcessor.java
+++ b/src/com/android/server/telecom/components/UserCallIntentProcessor.java
@@ -27,8 +27,10 @@
import android.net.Uri;
import android.os.UserHandle;
import android.os.UserManager;
+import android.provider.Settings;
import android.telecom.PhoneAccount;
import android.telecom.TelecomManager;
+import android.telecom.VideoProfile;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.widget.Toast;
@@ -104,10 +106,37 @@
return;
}
+ int videoState = intent.getIntExtra(
+ TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
+ VideoProfile.VideoState.AUDIO_ONLY);
+ Log.d(this, "processOutgoingCallIntent videoState = " + videoState);
+
+ if (VideoProfile.VideoState.isVideo(videoState)
+ && TelephonyUtil.shouldProcessAsEmergency(mContext, handle)) {
+ Log.d(this, "Emergency call...Converting video call to voice...");
+ videoState = VideoProfile.VideoState.AUDIO_ONLY;
+ intent.putExtra(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE,
+ videoState);
+ }
+
+ if (VideoProfile.VideoState.isVideo(videoState) && isTtyModeEnabled()) {
+ Toast.makeText(mContext, mContext.getResources().getString(R.string.
+ video_call_not_allowed_if_tty_enabled), Toast.LENGTH_SHORT).show();
+ Log.d(this, "Rejecting video calls as tty is enabled");
+ return;
+ }
+
intent.putExtra(CallIntentProcessor.KEY_IS_DEFAULT_DIALER, isDefaultDialer(callingPackageName));
sendBroadcastToReceiver(intent);
}
+ private boolean isTtyModeEnabled() {
+ return (android.provider.Settings.Secure.getInt(
+ mContext.getContentResolver(),
+ android.provider.Settings.Secure.PREFERRED_TTY_MODE,
+ TelecomManager.TTY_MODE_OFF) != TelecomManager.TTY_MODE_OFF);
+ }
+
private boolean isDefaultDialer(String callingPackageName) {
if (TextUtils.isEmpty(callingPackageName)) {
return false;
diff --git a/testapps/src/com/android/server/telecom/testapps/TestConnectionManager.java b/testapps/src/com/android/server/telecom/testapps/TestConnectionManager.java
index a27be39..b99ee13 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestConnectionManager.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestConnectionManager.java
@@ -118,6 +118,11 @@
}
setConferenceableConnections(c);
}
+
+ @Override
+ public void onCallSubstateChanged(RemoteConnection connection, int callSubstate) {
+ setCallSubstate(callSubstate);
+ }
};
private final RemoteConnection mRemote;
diff --git a/testapps/src/com/android/server/telecom/testapps/TestManagedVideoProvider.java b/testapps/src/com/android/server/telecom/testapps/TestManagedVideoProvider.java
index 649d0c0..68206e4 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestManagedVideoProvider.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestManagedVideoProvider.java
@@ -52,7 +52,7 @@
}
@Override
- public void onCallDataUsageChanged(RemoteConnection.VideoProvider rvp, int dataUsage) {
+ public void onCallDataUsageChanged(RemoteConnection.VideoProvider rvp, long dataUsage) {
super.onCallDataUsageChanged(rvp, dataUsage);
}
diff --git a/testapps/src/com/android/server/telecom/testapps/TestVideoProvider.java b/testapps/src/com/android/server/telecom/testapps/TestVideoProvider.java
index d372e46..655d73b 100644
--- a/testapps/src/com/android/server/telecom/testapps/TestVideoProvider.java
+++ b/testapps/src/com/android/server/telecom/testapps/TestVideoProvider.java
@@ -171,7 +171,7 @@
@Override
public void onRequestConnectionDataUsage() {
log("Requested connection data usage");
- int dataUsageKb = (10 *1024) + random.nextInt(50 * 1024);
+ long dataUsageKb = (10 *1024) + random.nextInt(50 * 1024);
changeCallDataUsage(dataUsageKb);
}
diff --git a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
index a6fe378..8779f41 100644
--- a/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/ConnectionServiceFixture.java
@@ -85,6 +85,8 @@
int state;
int capabilities;
final List<String> connectionIds = new ArrayList<>();
+ IVideoProvider videoProvider;
+ int videoState;
long connectTimeMillis;
}
@@ -331,6 +333,8 @@
c.state,
c.capabilities,
c.connectionIds,
+ c.videoProvider,
+ c.videoState,
c.connectTimeMillis);
}
@@ -349,6 +353,7 @@
false, /* voip audio mode */
c.statusHints,
c.disconnectCause,
- c.conferenceableConnectionIds);
+ c.conferenceableConnectionIds,
+ 0 /* call substate */);
}
}