Wiring videoState through from telephony.
- Adding call video state history tracking, which is used to ensure
we log whether video was active at any point to the call log.
- Adding logging of video state to call log.
Bug: 16285417
Bug: 16013178
Change-Id: I3b47c88b13dc73941ca80463fc0c6ae7cdd86749
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index b06b043..27a995a 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -16,14 +16,11 @@
package com.android.telecomm;
-import android.content.ComponentName;
-import android.content.ContentUris;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
-import android.provider.ContactsContract.Contacts;
import android.telecomm.CallPropertyPresentation;
import android.telecomm.CallState;
import android.telecomm.ConnectionRequest;
@@ -31,7 +28,6 @@
import android.telecomm.PhoneAccount;
import android.telecomm.Response;
import android.telecomm.StatusHints;
-import android.telecomm.TelecommConstants;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
@@ -202,6 +198,12 @@
private boolean mSpeakerphoneOn;
+ /**
+ * Tracks the video states which were applicable over the duration of a call.
+ * See {@link android.telecomm.VideoCallProfile} for a list of valid video states.
+ */
+ private int mVideoStateHistory;
+
private int mVideoState;
/**
@@ -294,7 +296,9 @@
if (mConnectionService != null && mConnectionService.getComponentName() != null) {
component = mConnectionService.getComponentName().flattenToShortString();
}
- return String.format(Locale.US, "[%s, %s, %s]", mState, component, Log.piiHandle(mHandle));
+
+ return String.format(Locale.US, "[%s, %s, %s, %d]", mState, component,
+ Log.piiHandle(mHandle), getVideoState());
}
CallState getState() {
@@ -1068,15 +1072,29 @@
}
/**
- * At the start of the call, determines the desired video state for the call.
+ * Returns the video states which were applicable over the duration of a call.
+ * See {@link android.telecomm.VideoCallProfile} for a list of valid video states.
+ *
+ * @return The video states applicable over the duration of the call.
+ */
+ public int getVideoStateHistory() {
+ return mVideoStateHistory;
+ }
+
+ /**
+ * Determines the current video state for the call.
+ * For an outgoing call determines the desired video state for the call.
* Valid values: {@link android.telecomm.VideoCallProfile#VIDEO_STATE_AUDIO_ONLY},
* {@link android.telecomm.VideoCallProfile#VIDEO_STATE_BIDIRECTIONAL},
* {@link android.telecomm.VideoCallProfile#VIDEO_STATE_TX_ENABLED},
* {@link android.telecomm.VideoCallProfile#VIDEO_STATE_RX_ENABLED}.
*
- * @param videoState The desired video state for the call.
+ * @param videoState The video state for the call.
*/
public void setVideoState(int videoState) {
+ // Track which video states were applicable over the duration of the call.
+ mVideoStateHistory = mVideoStateHistory | videoState;
+
mVideoState = videoState;
for (Listener l : mListeners) {
l.onVideoStateChanged(this);
diff --git a/src/com/android/telecomm/CallLogManager.java b/src/com/android/telecomm/CallLogManager.java
index cf7e7ae..d1e2196 100644
--- a/src/com/android/telecomm/CallLogManager.java
+++ b/src/com/android/telecomm/CallLogManager.java
@@ -22,6 +22,7 @@
import android.provider.CallLog.Calls;
import android.telecomm.CallState;
import android.telecomm.PhoneAccount;
+import android.telecomm.VideoCallProfile;
import android.telephony.PhoneNumberUtils;
import com.android.internal.telephony.CallerInfo;
@@ -120,9 +121,10 @@
final int presentation = getPresentation(call);
final PhoneAccount account = call.getPhoneAccount();
- // TODO: Once features and data usage are available, wire them up here.
- logCall(call.getCallerInfo(), logNumber, presentation, callLogType, Calls.FEATURES_NONE,
- account, creationTime, age, null);
+ // TODO(vt): Once data usage is available, wire it up here.
+ int callFeatures = getCallFeatures(call.getVideoStateHistory());
+ logCall(call.getCallerInfo(), logNumber, presentation, callLogType, callFeatures, account,
+ creationTime, age, null);
}
/**
@@ -171,6 +173,20 @@
}
/**
+ * Based on the video state of the call, determines the call features applicable for the call.
+ *
+ * @param videoState The video state.
+ * @return The call features.
+ */
+ private static int getCallFeatures(int videoState) {
+ if ((videoState & VideoCallProfile.VIDEO_STATE_TX_ENABLED)
+ == VideoCallProfile.VIDEO_STATE_TX_ENABLED) {
+ return Calls.FEATURES_VIDEO;
+ }
+ return Calls.FEATURES_NONE;
+ }
+
+ /**
* Retrieve the phone number from the call, and then process it before returning the
* actual number that is to be logged.
*
diff --git a/src/com/android/telecomm/ConnectionServiceWrapper.java b/src/com/android/telecomm/ConnectionServiceWrapper.java
index a47dc09..fb9d34c 100644
--- a/src/com/android/telecomm/ConnectionServiceWrapper.java
+++ b/src/com/android/telecomm/ConnectionServiceWrapper.java
@@ -76,6 +76,7 @@
private static final int MSG_SET_STATUS_HINTS = 18;
private static final int MSG_SET_HANDLE = 19;
private static final int MSG_SET_CALLER_DISPLAY_NAME = 20;
+ private static final int MSG_SET_VIDEO_STATE = 21;
private final Handler mHandler = new Handler() {
@Override
@@ -308,6 +309,12 @@
}
break;
}
+ case MSG_SET_VIDEO_STATE: {
+ call = mCallIdMapper.getCall(msg.obj);
+ if (call != null) {
+ call.setVideoState(msg.arg1);
+ }
+ }
}
}
};
@@ -444,6 +451,13 @@
}
@Override
+ public void setVideoState(String callId, int videoState) {
+ logIncoming("setVideoState %s %d", callId, videoState);
+ mCallIdMapper.checkValidCallId(callId);
+ mHandler.obtainMessage(MSG_SET_VIDEO_STATE, videoState, 0, callId).sendToTarget();
+ }
+
+ @Override
public void setAudioModeIsVoip(String callId, boolean isVoip) {
logIncoming("setAudioModeIsVoip %s %b", callId, isVoip);
mCallIdMapper.checkValidCallId(callId);
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index f93a7a7..fce9c04 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -156,7 +156,7 @@
PhoneAccount registeredAccount = mPhoneAccountRegistrar.getRegisteredAccount(account);
if (registeredAccount != null) {
return new PhoneAccountMetadata(
- registeredAccount, 0, account.getComponentName().getPackageName(), null);
+ registeredAccount, 0, account.getComponentName().getPackageName(), null, false);
}
return null;
}