Add audio mode and audio focus support to Telecomm
This CL adds support for:
- audio focus
- switching to speaker phone
- mute
- wired headset
Bluetooth support is coming in a different CL.
Change-Id: Iaf4013ea747548451cff45b48bcbb5b1dd1b8498
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index 568d7c6..0789135 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -20,6 +20,7 @@
import android.telecomm.CallInfo;
import android.telecomm.CallState;
import android.telecomm.GatewayInfo;
+import android.telephony.PhoneNumberUtils;
import com.google.android.collect.Sets;
import com.google.common.base.Preconditions;
@@ -80,6 +81,8 @@
*/
private Set<CallServiceWrapper> mIncompatibleCallServices;
+ private boolean mIsEmergencyCall;
+
/**
* Creates an empty call object with a unique call ID.
*
@@ -100,7 +103,7 @@
Call(Uri handle, ContactInfo contactInfo, GatewayInfo gatewayInfo, boolean isIncoming) {
mId = UUID.randomUUID().toString(); // UUIDs should provide sufficient uniqueness.
mState = CallState.NEW;
- mHandle = handle;
+ setHandle(handle);
mContactInfo = contactInfo;
mGatewayInfo = gatewayInfo;
mIsIncoming = isIncoming;
@@ -141,6 +144,12 @@
void setHandle(Uri handle) {
mHandle = handle;
+ mIsEmergencyCall = mHandle != null && PhoneNumberUtils.isLocalEmergencyNumber(
+ mHandle.getSchemeSpecificPart(), TelecommApp.getInstance());
+ }
+
+ boolean isEmergencyCall() {
+ return mIsEmergencyCall;
}
/**
@@ -332,6 +341,19 @@
return new CallInfo(mId, mState, mHandle, mGatewayInfo);
}
+ /** Checks if this is a live call or not. */
+ boolean isAlive() {
+ switch (mState) {
+ case NEW:
+ case RINGING:
+ case DISCONNECTED:
+ case ABORTED:
+ return false;
+ default:
+ return true;
+ }
+ }
+
/**
* @return True if the call is ringing, else logs the action name.
*/