Add new phone type (public API) DO NOT MERGE

This CL adds a new public API to allow services to implement calls.

Change-Id: I4d30eb4d91bd342506cad4ced059bd8446c2bec4
This commit is contained in:
Sailesh Nepal
2014-02-11 22:08:33 -08:00
parent d97a033ddc
commit aae9216320
10 changed files with 53 additions and 41 deletions

View File

@@ -24518,6 +24518,7 @@ package android.telephony {
method public java.lang.String iccTransmitApduLogicalChannel(int, int, int, int, int, int, java.lang.String);
method public boolean isNetworkRoaming();
method public void listen(android.telephony.PhoneStateListener, int);
method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String);
field public static final java.lang.String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE";
field public static final java.lang.String ACTION_RESPOND_VIA_MESSAGE = "android.intent.action.RESPOND_VIA_MESSAGE";
field public static final int CALL_STATE_IDLE = 0; // 0x0
@@ -24581,7 +24582,6 @@ package android.telephony {
method public void hangup();
method public void incomingCallAccept();
method public void mute(boolean);
method public void sendDtmf(char);
}
public class ThirdPartyCallService {
@@ -34080,7 +34080,6 @@ package com.android.internal.telephony {
method public abstract void hangup() throws android.os.RemoteException;
method public abstract void incomingCallAccept() throws android.os.RemoteException;
method public abstract void mute(boolean) throws android.os.RemoteException;
method public abstract void sendDtmf(char) throws android.os.RemoteException;
}
}

View File

@@ -18,6 +18,7 @@ package android.telephony;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
@@ -1421,6 +1422,21 @@ public class TelephonyManager {
}
}
/**
* Inform the phone about a new incoming third party call. The phone will bind to the service
* identified by component to handle the call.
* @param component the component that should handle the intent.
* @param callId the unique id of the call. This id is passed to the service via {@link
* ThirdPartyCallService#incomingCallAttach incomingCallAttach}.
*/
public void newIncomingThirdPartyCall(ComponentName component, String callId) {
try {
getITelephony().newIncomingThirdPartyCall(component, callId);
} catch (RemoteException ex) {
} catch (NullPointerException ex) {
}
}
/**
* Returns the MMS user agent.
*/

View File

@@ -16,6 +16,8 @@
package android.telephony;
import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import com.android.internal.telephony.IThirdPartyCallListener;
@@ -27,15 +29,12 @@ import com.android.internal.telephony.IThirdPartyCallListener;
public class ThirdPartyCallListener {
private final IThirdPartyCallListener mListener;
// Call end reason. TODO: rename this to DisconnectCause once they are public.
// Call end reason.
public static final int CALL_END_NORMAL = 1;
public static final int CALL_END_INCOMING_MISSED = 2;
public static final int CALL_END_OTHER = 3;
public ThirdPartyCallListener(IThirdPartyCallListener listener) {
if (listener == null) {
throw new IllegalArgumentException("Invalid listener");
}
mListener = listener;
}
@@ -45,7 +44,9 @@ public class ThirdPartyCallListener {
*/
public void onCallProviderAttached(ThirdPartyCallProvider callProvider) {
try {
mListener.onCallProviderAttached(callProvider.getCallback());
if (mListener != null) {
mListener.onCallProviderAttached(callProvider.callback);
}
} catch (RemoteException e) {
}
}
@@ -55,7 +56,9 @@ public class ThirdPartyCallListener {
*/
public void onRingingStarted() {
try {
mListener.onRingingStarted();
if (mListener != null) {
mListener.onRingingStarted();
}
} catch (RemoteException e) {
}
}
@@ -65,7 +68,9 @@ public class ThirdPartyCallListener {
*/
public void onCallEstablished() {
try {
mListener.onCallEstablished();
if (mListener != null) {
mListener.onCallEstablished();
}
} catch (RemoteException e) {
}
}
@@ -75,7 +80,9 @@ public class ThirdPartyCallListener {
*/
public void onCallEnded(int reason) {
try {
mListener.onCallEnded(reason);
if (mListener != null) {
mListener.onCallEnded(reason);
}
} catch (RemoteException e) {
}
}

View File

@@ -29,7 +29,6 @@ public class ThirdPartyCallProvider {
private static final int MSG_MUTE = 1;
private static final int MSG_HANGUP = 2;
private static final int MSG_INCOMING_CALL_ACCEPT = 3;
private static final int MSG_SEND_DTMF = 4;
/**
* Mutes or unmutes the call.
@@ -52,18 +51,7 @@ public class ThirdPartyCallProvider {
// default implementation empty
}
/**
* Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'.
*/
public void sendDtmf(char c) {
// default implementation empty
}
IThirdPartyCallProvider getCallback() {
return mCallback;
}
private final IThirdPartyCallProvider mCallback = new IThirdPartyCallProvider.Stub() {
final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() {
@Override
public void mute(boolean shouldMute) {
Message.obtain(mHandler, MSG_MUTE, shouldMute ? 1 : 0, 0).sendToTarget();
@@ -78,11 +66,6 @@ public class ThirdPartyCallProvider {
public void incomingCallAccept() {
Message.obtain(mHandler, MSG_INCOMING_CALL_ACCEPT).sendToTarget();
}
@Override
public void sendDtmf(char c) {
Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0).sendToTarget();
}
};
private final Handler mHandler = new Handler() {
@@ -98,9 +81,6 @@ public class ThirdPartyCallProvider {
case MSG_INCOMING_CALL_ACCEPT:
incomingCallAccept();
break;
case MSG_SEND_DTMF:
sendDtmf((char) msg.arg1);
break;
}
}
};

View File

@@ -19,6 +19,7 @@ package android.telephony;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.RemoteException;
import android.util.Pair;
import com.android.internal.telephony.IThirdPartyCallListener;
@@ -39,7 +40,8 @@ public class ThirdPartyCallService {
}
/**
* Call to attach to an incoming call.
* Call to attach to an incoming call. This is in response to a call to {@link
* android.telephony.TelephonyManager#newIncomingThirdPartyCall newIncomingThirdPartyCall}.
*/
public void incomingCallAttach(ThirdPartyCallListener listener, String callId) {
// default implementation empty
@@ -49,10 +51,10 @@ public class ThirdPartyCallService {
* Returns an IBinder instance that can returned from the service's onBind function.
*/
public IBinder getBinder() {
return mCallback;
return callback;
}
private final IThirdPartyCallService.Stub mCallback = new IThirdPartyCallService.Stub() {
private final IThirdPartyCallService.Stub callback = new IThirdPartyCallService.Stub() {
@Override
public void outgoingCallInitiate(IThirdPartyCallListener listener, String number) {
Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.out");

View File

@@ -17,10 +17,12 @@
package com.android.internal.telephony;
import android.os.Bundle;
import java.util.List;
import android.content.ComponentName;
import android.telephony.NeighboringCellInfo;
import android.telephony.CellInfo;
import java.util.List;
/**
* Interface used to interact with the phone. Mostly this is used by the
* TelephonyManager class. A few places are still using this directly.
@@ -412,4 +414,12 @@ interface ITelephony {
* @return true on success; false on any failure.
*/
boolean setRadioMode(int radioMode);
/**
* Inform the phone about a new incoming third party call. The phone will bind to the service
* identified by component to handle the call.
* @param component the component that should handle the intent.
* @param callId the unique id of the call.
*/
void newIncomingThirdPartyCall(in ComponentName component, String callId);
}

View File

@@ -38,9 +38,4 @@ oneway interface IThirdPartyCallProvider {
* Accepts the incoming call.
*/
void incomingCallAccept();
/**
* Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'.
*/
void sendDtmf(char c);
}

View File

@@ -28,7 +28,8 @@ oneway interface IThirdPartyCallService {
void outgoingCallInitiate(IThirdPartyCallListener listener, String number);
/**
* Call to attach to an incoming call.
* Call to attach to an incoming call. This is in response to a call to
* TelephonyManager.newIncomingThirdPartyCall.
*/
void incomingCallAttach(IThirdPartyCallListener listener, String callId);
}

View File

@@ -57,6 +57,7 @@ public class PhoneConstants {
public static final int PHONE_TYPE_GSM = RILConstants.GSM_PHONE;
public static final int PHONE_TYPE_CDMA = RILConstants.CDMA_PHONE;
public static final int PHONE_TYPE_SIP = RILConstants.SIP_PHONE;
public static final int PHONE_TYPE_THIRD_PARTY = RILConstants.THIRD_PARTY_PHONE;
// Modes for LTE_ON_CDMA
public static final int LTE_ON_CDMA_UNKNOWN = RILConstants.LTE_ON_CDMA_UNKNOWN;

View File

@@ -84,6 +84,7 @@ public interface RILConstants {
int GSM_PHONE = 1;
int CDMA_PHONE = 2;
int SIP_PHONE = 3;
int THIRD_PARTY_PHONE = 4;
int LTE_ON_CDMA_UNKNOWN = -1;
int LTE_ON_CDMA_FALSE = 0;