From 6621c917a09d5e20208d9e9a0065a77362df522e Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 24 Oct 2013 13:07:24 -0700 Subject: [PATCH 001/102] Add new phone type (public API) DO NOT MERGE This CL adds a new public API to allow services to implement calls. Change-Id: Ic57f39dfce070cce43c2b4e0f023b0e50ee60718 --- Android.mk | 3 + api/current.txt | 43 +++++++++ .../android/telephony/TelephonyManager.java | 16 ++++ .../telephony/ThirdPartyCallListener.java | 89 +++++++++++++++++ .../telephony/ThirdPartyCallProvider.java | 87 +++++++++++++++++ .../telephony/ThirdPartyCallService.java | 96 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 13 ++- .../telephony/IThirdPartyCallListener.aidl | 46 +++++++++ .../telephony/IThirdPartyCallProvider.aidl | 41 ++++++++ .../telephony/IThirdPartyCallService.aidl | 35 +++++++ .../internal/telephony/PhoneConstants.java | 1 + .../internal/telephony/RILConstants.java | 1 + 12 files changed, 469 insertions(+), 2 deletions(-) create mode 100644 telephony/java/android/telephony/ThirdPartyCallListener.java create mode 100644 telephony/java/android/telephony/ThirdPartyCallProvider.java create mode 100644 telephony/java/android/telephony/ThirdPartyCallService.java create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl diff --git a/Android.mk b/Android.mk index bcab2761dea1c..45639aba3776e 100644 --- a/Android.mk +++ b/Android.mk @@ -264,6 +264,9 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ diff --git a/api/current.txt b/api/current.txt index 9f80ef62a140c..d3fd7d43e4ed5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24085,6 +24085,7 @@ package android.telephony { method public boolean hasIccCard(); 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 @@ -24132,6 +24133,31 @@ package android.telephony { field public static final int SIM_STATE_UNKNOWN = 0; // 0x0 } + public class ThirdPartyCallListener { + ctor public ThirdPartyCallListener(com.android.internal.telephony.IThirdPartyCallListener); + method public void onCallEnded(int); + method public void onCallEstablished(); + method public void onCallProviderAttached(android.telephony.ThirdPartyCallProvider); + method public void onRingingStarted(); + field public static final int CALL_END_INCOMING_MISSED = 2; // 0x2 + field public static final int CALL_END_NORMAL = 1; // 0x1 + field public static final int CALL_END_OTHER = 3; // 0x3 + } + + public class ThirdPartyCallProvider { + ctor public ThirdPartyCallProvider(); + method public void hangup(); + method public void incomingCallAccept(); + method public void mute(boolean); + } + + public class ThirdPartyCallService { + ctor public ThirdPartyCallService(); + method public android.os.IBinder getBinder(); + method public void incomingCallAttach(android.telephony.ThirdPartyCallListener, java.lang.String); + method public void outgoingCallInitiate(android.telephony.ThirdPartyCallListener, java.lang.String); + } + } package android.telephony.cdma { @@ -33527,6 +33553,23 @@ package android.widget { } +package com.android.internal.telephony { + + public abstract interface IThirdPartyCallListener implements android.os.IInterface { + method public abstract void onCallEnded(int) throws android.os.RemoteException; + method public abstract void onCallEstablished() throws android.os.RemoteException; + method public abstract void onCallProviderAttached(com.android.internal.telephony.IThirdPartyCallProvider) throws android.os.RemoteException; + method public abstract void onRingingStarted() throws android.os.RemoteException; + } + + public abstract interface IThirdPartyCallProvider implements android.os.IInterface { + 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; + } + +} + package com.android.internal.util { public abstract interface Predicate { diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 8f17e72799245..b0f7dcfc90227 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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; @@ -1422,6 +1423,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. */ diff --git a/telephony/java/android/telephony/ThirdPartyCallListener.java b/telephony/java/android/telephony/ThirdPartyCallListener.java new file mode 100644 index 0000000000000..08f8d3aa13f4f --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallListener.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Handler; +import android.os.Message; +import android.os.RemoteException; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface provided to {@link android.telephony.ThirdPartyCallService}. The service can use this + * to notify the listener of changes to the call state. + */ +public class ThirdPartyCallListener { + private final IThirdPartyCallListener mListener; + + // 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) { + mListener = listener; + } + + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + public void onCallProviderAttached(ThirdPartyCallProvider callProvider) { + try { + if (mListener != null) { + mListener.onCallProviderAttached(callProvider.callback); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that ringing has started for this call. + */ + public void onRingingStarted() { + try { + if (mListener != null) { + mListener.onRingingStarted(); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that the call has been successfully established. + */ + public void onCallEstablished() { + try { + if (mListener != null) { + mListener.onCallEstablished(); + } + } catch (RemoteException e) { + } + } + + /** + * Notifies the listener that the call has ended. + */ + public void onCallEnded(int reason) { + try { + if (mListener != null) { + mListener.onCallEnded(reason); + } + } catch (RemoteException e) { + } + } +} diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java new file mode 100644 index 0000000000000..9d3f929a22bc7 --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.Handler; +import android.os.Message; + +import com.android.internal.telephony.IThirdPartyCallProvider; + +/** + * Interface sent to {@link android.telephony.ThirdPartyCallListener#onCallProviderAttached + * onCallProviderAttached}. This is used to control an outgoing or an incoming call. + */ +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; + + /** + * Mutes or unmutes the call. + */ + public void mute(boolean shouldMute) { + // default implementation empty + } + + /** + * Ends the current call. If this is an unanswered incoming call then the call is rejected. + */ + public void hangup() { + // default implementation empty + } + + /** + * Accepts the incoming call. + */ + public void incomingCallAccept() { + // default implementation empty + } + + final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { + @Override + public void mute(boolean shouldMute) { + Message.obtain(mHandler, MSG_MUTE, shouldMute ? 1 : 0, 0).sendToTarget(); + } + + @Override + public void hangup() { + Message.obtain(mHandler, MSG_HANGUP).sendToTarget(); + } + + @Override + public void incomingCallAccept() { + Message.obtain(mHandler, MSG_INCOMING_CALL_ACCEPT).sendToTarget(); + } + }; + + private final Handler mHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_MUTE: + mute(msg.arg1 != 0); + break; + case MSG_HANGUP: + hangup(); + break; + case MSG_INCOMING_CALL_ACCEPT: + incomingCallAccept(); + break; + } + } + }; +} diff --git a/telephony/java/android/telephony/ThirdPartyCallService.java b/telephony/java/android/telephony/ThirdPartyCallService.java new file mode 100644 index 0000000000000..de6c2903dcd6c --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallService.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +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; +import com.android.internal.telephony.IThirdPartyCallService; + +/** + * Interface provided by a service to start outgoing calls and attach to incoming calls. + */ +public class ThirdPartyCallService { + private static final int MSG_OUTGOING_CALL_INITIATE = 1; + private static final int MSG_INCOMING_CALL_ATTACH = 2; + + /** + * Call to start a new outgoing call. + */ + public void outgoingCallInitiate(ThirdPartyCallListener listener, String number) { + // default implementation empty + } + + /** + * 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 + } + + /** + * Returns an IBinder instance that can returned from the service's onBind function. + */ + public IBinder getBinder() { + return callback; + } + + private final IThirdPartyCallService.Stub callback = new IThirdPartyCallService.Stub() { + @Override + public void outgoingCallInitiate(IThirdPartyCallListener listener, String number) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.out"); + Message.obtain(mHandler, MSG_OUTGOING_CALL_INITIATE, + Pair.create(listener, number)).sendToTarget(); + } + + @Override + public void incomingCallAttach(IThirdPartyCallListener listener, String callId) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.in"); + Message.obtain(mHandler, MSG_INCOMING_CALL_ATTACH, + Pair.create(listener, callId)).sendToTarget(); + } + }; + + private final Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage: " + msg.what); + switch (msg.what) { + case MSG_OUTGOING_CALL_INITIATE: { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage out"); + Pair pair = + (Pair) msg.obj; + ThirdPartyCallListener listener = new ThirdPartyCallListener(pair.first); + outgoingCallInitiate(listener, pair.second); + break; + } + case MSG_INCOMING_CALL_ATTACH: { + Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.handleMessage in"); + Pair pair = + (Pair) msg.obj; + ThirdPartyCallListener listener = new ThirdPartyCallListener(pair.first); + incomingCallAttach(listener, pair.second); + break; + } + } + } + }; +} diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 7bd2c8412e979..69a44289f6cf7 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -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. @@ -324,5 +326,12 @@ interface ITelephony { * Sets minimum time in milli-seconds between onCellInfoChanged */ void setCellInfoListRate(int rateInMillis); -} + /** + * 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); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl new file mode 100644 index 0000000000000..bcf2d81d9b636 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallProvider; + +/** + * Interface provided to ThirdPartyCallService. The service can use this to notify the listener of + * changes to the call state. + */ +oneway interface IThirdPartyCallListener { + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + void onCallProviderAttached(IThirdPartyCallProvider callProvider); + + /** + * Notifies the listener that ringing has started for this call. + */ + void onRingingStarted(); + + /** + * Notifies the listener that the call has been successfully established. + */ + void onCallEstablished(); + + /** + * Notifies the listener that the call has ended. + */ + void onCallEnded(int reason); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl new file mode 100644 index 0000000000000..dcbf877a587ac --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface sent to ThirdPartyCallListener.onCallProviderAttached. This is used to control an + * outgoing or incoming call. + */ +oneway interface IThirdPartyCallProvider { + /** + * Mutes or unmutes the call. + */ + void mute(boolean shouldMute); + + /** + * Ends the current call. If this is an unanswered incoming call then the call is rejected (for + * example, a notification is sent to a server that the user declined the call). + */ + void hangup(); + + /** + * Accepts the incoming call. + */ + void incomingCallAccept(); +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl new file mode 100644 index 0000000000000..597567af02eae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.IThirdPartyCallListener; + +/** + * Interface provided by a service to start outgoing calls and attach to incoming calls. + */ +oneway interface IThirdPartyCallService { + /** + * Call to start a new outgoing call. + */ + void outgoingCallInitiate(IThirdPartyCallListener listener, String number); + + /** + * Call to attach to an incoming call. This is in response to a call to + * TelephonyManager.newIncomingThirdPartyCall. + */ + void incomingCallAttach(IThirdPartyCallListener listener, String callId); +} diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index 416325591352b..fe8f03181a112 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -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; diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 821a11cb3b0bf..71c3bec071112 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -82,6 +82,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; From 1dc5b4e87bdb7b9d9767aadd15ad25326fb28071 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 13 Nov 2013 09:14:49 -0800 Subject: [PATCH 002/102] ThirdPartyPhone: DTMF & callerDisplayName API DO NOT MERGE This CL extends the ThirdPartyCall API to support DTMF and callerDisplayname. Change-Id: I4bb43273243af6b41d63dde69c982891f160c035 --- api/current.txt | 4 +++- .../java/android/telephony/TelephonyManager.java | 7 +++++-- .../telephony/ThirdPartyCallProvider.java | 16 ++++++++++++++++ .../android/internal/telephony/ITelephony.aidl | 5 ++++- .../telephony/IThirdPartyCallProvider.aidl | 5 +++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index 964f1e8d68b00..88eec1af17a14 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24088,7 +24088,7 @@ package android.telephony { method public boolean hasIccCard(); method public boolean isNetworkRoaming(); method public void listen(android.telephony.PhoneStateListener, int); - method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String); + method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String, 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 @@ -24152,6 +24152,7 @@ package android.telephony { method public void hangup(); method public void incomingCallAccept(); method public void mute(boolean); + method public void sendDtmf(char); } public class ThirdPartyCallService { @@ -33574,6 +33575,7 @@ 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; } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index b0f7dcfc90227..42b2b8ccc4415 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1429,10 +1429,13 @@ public class TelephonyManager { * @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}. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - public void newIncomingThirdPartyCall(ComponentName component, String callId) { + public void newIncomingThirdPartyCall(ComponentName component, String callId, + String callerDisplayName) { try { - getITelephony().newIncomingThirdPartyCall(component, callId); + getITelephony().newIncomingThirdPartyCall(component, callId, callerDisplayName); } catch (RemoteException ex) { } catch (NullPointerException ex) { } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 9d3f929a22bc7..74b9ae373485f 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -29,6 +29,7 @@ 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. @@ -51,6 +52,13 @@ 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 + } + final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { @Override public void mute(boolean shouldMute) { @@ -66,6 +74,11 @@ 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() { @@ -81,6 +94,9 @@ public class ThirdPartyCallProvider { case MSG_INCOMING_CALL_ACCEPT: incomingCallAccept(); break; + case MSG_SEND_DTMF: + sendDtmf((char) msg.arg1); + break; } } }; diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 69a44289f6cf7..d81cab3069694 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -332,6 +332,9 @@ interface ITelephony { * identified by component to handle the call. * @param component the component that should handle the intent. * @param callId the unique id of the call. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - void newIncomingThirdPartyCall(in ComponentName component, String callId); + void newIncomingThirdPartyCall(in ComponentName component, String callId, + String callerDisplayName); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index dcbf877a587ac..a9d67a4e91f7d 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -38,4 +38,9 @@ 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); } From fc2a0a34d64baa9a9c793c68a06d75d8ca0e8e41 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Fri, 15 Nov 2013 13:23:45 -0800 Subject: [PATCH 003/102] DO NOT MERGE ThirdPartyCallSendDtmfCallBack API This API is needed to implement post dial. Change-Id: I013382a910948b3934ae128288f47bcf73c68f8c --- Android.mk | 1 + api/current.txt | 13 +++++- .../telephony/ThirdPartyCallProvider.java | 11 +++-- .../ThirdPartyCallSendDtmfCallback.java | 46 +++++++++++++++++++ .../telephony/IThirdPartyCallProvider.aidl | 3 +- .../IThirdPartyCallSendDtmfCallback.aidl | 27 +++++++++++ 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl diff --git a/Android.mk b/Android.mk index 8b137eaeb7ff2..8c4d5242f8bc0 100644 --- a/Android.mk +++ b/Android.mk @@ -270,6 +270,7 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ diff --git a/api/current.txt b/api/current.txt index 88eec1af17a14..e2a847d189a07 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24152,7 +24152,12 @@ package android.telephony { method public void hangup(); method public void incomingCallAccept(); method public void mute(boolean); - method public void sendDtmf(char); + method public void sendDtmf(char, android.telephony.ThirdPartyCallSendDtmfCallback); + } + + public class ThirdPartyCallSendDtmfCallback { + ctor public ThirdPartyCallSendDtmfCallback(com.android.internal.telephony.IThirdPartyCallSendDtmfCallback); + method public void onSendDtmfCompleted(); } public class ThirdPartyCallService { @@ -33575,7 +33580,11 @@ 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; + method public abstract void sendDtmf(char, com.android.internal.telephony.IThirdPartyCallSendDtmfCallback) throws android.os.RemoteException; + } + + public abstract interface IThirdPartyCallSendDtmfCallback implements android.os.IInterface { + method public abstract void onSendDtmfCompleted() throws android.os.RemoteException; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 74b9ae373485f..5054380f51343 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -20,6 +20,7 @@ import android.os.Handler; import android.os.Message; import com.android.internal.telephony.IThirdPartyCallProvider; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to {@link android.telephony.ThirdPartyCallListener#onCallProviderAttached @@ -55,7 +56,7 @@ public class ThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - public void sendDtmf(char c) { + public void sendDtmf(char c, ThirdPartyCallSendDtmfCallback callback) { // default implementation empty } @@ -76,8 +77,8 @@ public class ThirdPartyCallProvider { } @Override - public void sendDtmf(char c) { - Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0).sendToTarget(); + public void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback) { + Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0, callback).sendToTarget(); } }; @@ -95,7 +96,9 @@ public class ThirdPartyCallProvider { incomingCallAccept(); break; case MSG_SEND_DTMF: - sendDtmf((char) msg.arg1); + ThirdPartyCallSendDtmfCallback callback = new ThirdPartyCallSendDtmfCallback( + (IThirdPartyCallSendDtmfCallback) msg.obj); + sendDtmf((char) msg.arg1, callback); break; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java new file mode 100644 index 0000000000000..5a67cf76bf98d --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.RemoteException; + +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; + +/** + * Callback interface for when DTMF has been sent. + */ +public class ThirdPartyCallSendDtmfCallback { + private final IThirdPartyCallSendDtmfCallback mCallback; + + public ThirdPartyCallSendDtmfCallback(IThirdPartyCallSendDtmfCallback callback) { + if (callback == null) { + throw new IllegalArgumentException("Invalid callback"); + } + mCallback = callback; + } + + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + public void onSendDtmfCompleted() { + try { + mCallback.onSendDtmfCompleted(); + } catch (RemoteException e) { + } + } +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index a9d67a4e91f7d..9d595b0b1b5a1 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -17,6 +17,7 @@ package com.android.internal.telephony; import com.android.internal.telephony.IThirdPartyCallListener; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to ThirdPartyCallListener.onCallProviderAttached. This is used to control an @@ -42,5 +43,5 @@ oneway interface IThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - void sendDtmf(char c); + void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl new file mode 100644 index 0000000000000..3a02b06055d06 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +/** + * Callback interface for when DTMF has been sent. + */ +oneway interface IThirdPartyCallSendDtmfCallback { + /** + * Called when the DTMF code has been sent. + */ + void onSendDtmfCompleted(); +} From c62180949f3b1a39b2625b3381f998ff60537e46 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Mon, 25 Nov 2013 11:31:46 -0800 Subject: [PATCH 004/102] Add Wi-Fi calling state setting to telephony interfaces Change-Id: I73e643c00c7c00182cc4650053d098b6e40a8a5f --- core/java/android/provider/Settings.java | 8 ++++ .../android/telephony/TelephonyManager.java | 42 ++++++++++++++++++- .../internal/telephony/ITelephony.aidl | 14 +++++++ 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 0dffc17bda128..69ab166caef4b 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2483,6 +2483,14 @@ public final class Settings { NOTIFICATION_SOUND }; + /** + * When to use Wi-Fi calling + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + * @hide + */ + public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls"; + // Settings moved to Settings.Secure /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 42b2b8ccc4415..37cd4f8d3640c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.os.RemoteException; import android.os.ServiceManager; import android.os.SystemProperties; -import android.telephony.Rlog; import com.android.internal.telephony.IPhoneSubInfo; import com.android.internal.telephony.ITelephony; @@ -63,6 +62,20 @@ public class TelephonyManager { private static ITelephonyRegistry sRegistry; private final Context mContext; + /** + * The allowed states of Wi-Fi calling. + * + * @hide + */ + public interface WifiCallingChoices { + /** Always use Wi-Fi calling */ + static final int ALWAYS_USE = 0; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 1; + /** Ask the user whether to use Wi-Fi on every call */ + static final int ASK_EVERY_TIME = 2; + } + /** @hide */ public TelephonyManager(Context context) { Context appContext = context.getApplicationContext(); @@ -1458,4 +1471,31 @@ public class TelephonyManager { return mContext.getResources().getString( com.android.internal.R.string.config_mms_user_agent_profile_url); } + + /** + * Obtain the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public int getWhenToMakeWifiCalls() { + try { + return getITelephony().getWhenToMakeWifiCalls(); + } catch (RemoteException ex) { + return WifiCallingChoices.NEVER_USE; + } + } + + /** + * Set the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public void setWhenToMakeWifiCalls(int state) { + try { + getITelephony().setWhenToMakeWifiCalls(state); + } catch (RemoteException ex) { + } + } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index d81cab3069694..caa7ff40d448e 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -337,4 +337,18 @@ interface ITelephony { */ void newIncomingThirdPartyCall(in ComponentName component, String callId, String callerDisplayName); + + /** + * Obtain the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + int getWhenToMakeWifiCalls(); + + /** + * Set the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + void setWhenToMakeWifiCalls(int state); } From 7647f361b35f11e5a7a071b89f8cbf62fd793cf7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 20 Nov 2013 13:22:28 -0800 Subject: [PATCH 005/102] Add interface definitions for CallService/PhoneService Interfaces are meant to replace ThirdParty*.aidl/java files in same directory long term. The differences in methods are on purpose and reflect more recent design directions. Change-Id: Ia5ece7149b228a44758e659a4cabfc0676d1c499 --- Android.mk | 2 + .../android/internal/telephony/CallInfo.aidl | 19 +++++ .../android/internal/telephony/CallInfo.java | 77 +++++++++++++++++++ .../internal/telephony/ICallService.aidl | 61 +++++++++++++++ .../telephony/ICallServiceAdapter.aidl | 61 +++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.aidl create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.java create mode 100644 telephony/java/com/android/internal/telephony/ICallService.aidl create mode 100644 telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl diff --git a/Android.mk b/Android.mk index 8b137eaeb7ff2..216fcbf52fd94 100644 --- a/Android.mk +++ b/Android.mk @@ -265,6 +265,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRemoteDisplayProvider.aidl \ media/java/android/media/IRemoteVolumeObserver.aidl \ media/java/android/media/IRingtonePlayer.aidl \ + telephony/java/com/android/internal/telephony/ICallService.aidl \ + telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telephony/java/com/android/internal/telephony/CallInfo.aidl b/telephony/java/com/android/internal/telephony/CallInfo.aidl new file mode 100644 index 0000000000000..9140388587845 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.aidl @@ -0,0 +1,19 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +parcelable CallInfo; diff --git a/telephony/java/com/android/internal/telephony/CallInfo.java b/telephony/java/com/android/internal/telephony/CallInfo.java new file mode 100644 index 0000000000000..6bfc9d73e8c5c --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.java @@ -0,0 +1,77 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A parcelable holder class of Call information data. + */ +public class CallInfo implements Parcelable { + + /** + * Endpoint to which the call is connected. + * This could be the dialed value for outgoing calls or the caller id of incoming calls. + */ + private String handle; + + public CallInfo(String handle) { + this.handle = handle; + } + + public String getHandle() { + return handle; + } + + // + // Parcelling related code below here. + // + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator () { + + @Override + public CallInfo createFromParcel(Parcel source) { + return new CallInfo(source.readString()); + } + + @Override + public CallInfo[] newArray(int size) { + return new CallInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(handle); + } +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl new file mode 100644 index 0000000000000..a24c860d08cd6 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Service interface for services which would like to provide calls to be + * managed by the system in-call UI. + * + * This interface provides methods that the android framework can use to deliver commands + * for calls provided by this call service including making new calls and disconnecting + * existing ones. A binding to ICallService implementations exists for two conditions: + * 1) There exists one or more live calls for that call service, + * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + */ +oneway interface ICallService { + + /** + * Determines if the CallService can make calls to the handle. + * TODO(santoscordon): Move this method into its own service interface long term. + * TODO(santoscordon): Add response callback parameter. + */ + void isCompatibleWith(String handle); + + /** + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. + * TODO(santoscordon): Should this have a response attached to it to ensure that the call + * service actually plans to make the call? + */ + void call(String handle); + + /** + * Disconnects the call identified by callId. + */ + void disconnect(String callId); + + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); +} diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl new file mode 100644 index 0000000000000..bc900f00d71ae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.CallInfo; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + */ +oneway interface ICallServiceAdapter { + + /** + * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall. + */ + void getNextCallId(/* TODO(santoscordon): Needs response object */); + + /** + * Tells CallsManager of a new incoming call. + */ + void newIncomingCall(String callId, in CallInfo info); + + /** + * Tells CallsManager of a new outgoing call. + */ + void newOutgoingCall(String callId, in CallInfo info); + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + */ + void setActive(String callId); + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + */ + void setRinging(String callId); + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + */ + void setDialing(String callId); + + /** + * Sets a call's state to disconnected. + */ + void setDisconnected(String callId); +} From d16654f80e5ed5d71fb512ccaf6709e5247805f7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 26 Nov 2013 11:50:49 -0800 Subject: [PATCH 006/102] Add abstract base implementation of CallService. Base implementation takes care of a lot of boilerplate code. Change-Id: Ic7ee3325f694f7df06d23501d77172b4770551bc --- .../java/android/telephony/CallService.java | 165 ++++++++++++++++++ .../internal/telephony/ICallService.aidl | 2 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 telephony/java/android/telephony/CallService.java diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java new file mode 100644 index 0000000000000..0ea55b283e7c3 --- /dev/null +++ b/telephony/java/android/telephony/CallService.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import com.android.internal.telephony.ICallService; +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Base implementation of CallService which can be used to provide calls for the system + * in-call UI. CallService is a one-way service from the framework's CallsManager to any app + * that would like to provide calls managed by the default system in-call user interface. + * When the service is bound by the framework, CallsManager will call setCallServiceAdapter + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * for communicating back to CallsManager. Subsequently, more specific methods of the service + * will be called to perform various call actions including making an outgoing call and + * disconnected existing calls. + * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before + * we can unhide this API. + * + * Most public methods of this function are backed by a one-way AIDL interface which precludes + * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * response objects instead of return values. + * TODO(santoscordon): Improve paragraph above once the final design is in place. + * @hide + */ +public abstract class CallService extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_ADAPTER: + setCallServiceAdapter((ICallServiceAdapter) msg.obj); + break; + case MSG_IS_COMPATIBLE_WITH: + isCompatibleWith((String) msg.obj); + break; + case MSG_CALL: + call((String) msg.obj); + break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallService implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceWrapper extends ICallService.Stub { + @Override + public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) + .sendToTarget(); + } + + @Override + public void isCompatibleWith(String handle) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + } + + @Override + public void call(String handle) { + mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int + MSG_SET_CALL_SERVICE_ADAPTER = 1, + MSG_IS_COMPATIBLE_WITH = 2, + MSG_CALL = 3, + MSG_DISCONNECT = 4; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceMessageHandler}. + */ + private final CallServiceMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallService} interface. + */ + private final CallServiceWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallService() { + mMessageHandler = new CallServiceMessageHandler(); + mBinder = new CallServiceWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * changes of existing calls. + * @param callServiceAdapter Adapter object for communicating call to CallsManager + * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we + * wrap that in a wrapper like we do for CallService/ICallService? + * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. + */ + public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + + /** + * Determines if the CallService can make calls to the handle. + * @param handle The handle to test for compatibility. + * TODO(santoscordon): Need response parameter. + */ + public abstract void isCompatibleWith(String handle); + + /** + * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, + * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the + * same handle and this service is selected by the switchboard to handle the call. + * @param handle The handle to call. + */ + public abstract void call(String handle); + + /** + * Disconnects the specified call. + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl index a24c860d08cd6..cb9b2e838ddf9 100644 --- a/telephony/java/com/android/internal/telephony/ICallService.aidl +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -57,5 +57,5 @@ oneway interface ICallService { * and communicate state changes of existing calls. This is the first method that is called * after a the framework binds to the call service. */ - void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); } From c8712b6e2297f8b86045b885d3f8cdf28d7ec462 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Mon, 16 Dec 2013 16:27:43 -0800 Subject: [PATCH 007/102] Update TelephonyManager.WifiCallingChoices API This CL updates the order of the WifiCallingChoices values to match the wifi_calling_choice_values resource. Change-Id: Ib314bc44073fdc416b15926cec2aca91aedba08f --- telephony/java/android/telephony/TelephonyManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 37cd4f8d3640c..f1ed0a211c3b9 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -70,10 +70,10 @@ public class TelephonyManager { public interface WifiCallingChoices { /** Always use Wi-Fi calling */ static final int ALWAYS_USE = 0; - /** Never use Wi-Fi calling */ - static final int NEVER_USE = 1; /** Ask the user whether to use Wi-Fi on every call */ - static final int ASK_EVERY_TIME = 2; + static final int ASK_EVERY_TIME = 1; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 2; } /** @hide */ From 588f34a92d0b5c0313d7d455fd12624965b05c12 Mon Sep 17 00:00:00 2001 From: Qiwen Zhao Date: Mon, 10 Feb 2014 17:33:32 -0800 Subject: [PATCH 008/102] reset to master for rs/java/android/renderscript --- rs/java/android/renderscript/BaseObj.java | 2 +- rs/java/android/renderscript/Byte2.java | 356 +++++++++++- rs/java/android/renderscript/Byte3.java | 388 ++++++++++++- rs/java/android/renderscript/Byte4.java | 420 ++++++++++++++- rs/java/android/renderscript/Double2.java | 375 ++++++++++++- rs/java/android/renderscript/Double3.java | 413 +++++++++++++- rs/java/android/renderscript/Double4.java | 445 ++++++++++++++- rs/java/android/renderscript/FileA3D.java | 4 +- rs/java/android/renderscript/Float2.java | 381 ++++++++++++- rs/java/android/renderscript/Float3.java | 411 +++++++++++++- rs/java/android/renderscript/Float4.java | 444 ++++++++++++++- rs/java/android/renderscript/Font.java | 10 +- rs/java/android/renderscript/Int2.java | 429 ++++++++++++++- rs/java/android/renderscript/Int3.java | 472 +++++++++++++++- rs/java/android/renderscript/Int4.java | 508 +++++++++++++++++- rs/java/android/renderscript/Long2.java | 428 ++++++++++++++- rs/java/android/renderscript/Long3.java | 471 +++++++++++++++- rs/java/android/renderscript/Long4.java | 507 ++++++++++++++++- .../android/renderscript/ProgramStore.java | 4 +- .../android/renderscript/RenderScript.java | 36 +- rs/java/android/renderscript/Sampler.java | 4 +- rs/java/android/renderscript/ScriptC.java | 16 +- rs/java/android/renderscript/Short2.java | 426 ++++++++++++++- rs/java/android/renderscript/Short3.java | 472 +++++++++++++++- rs/java/android/renderscript/Short4.java | 508 +++++++++++++++++- 25 files changed, 7638 insertions(+), 292 deletions(-) diff --git a/rs/java/android/renderscript/BaseObj.java b/rs/java/android/renderscript/BaseObj.java index eee4936a96e33..842aa2337c45d 100644 --- a/rs/java/android/renderscript/BaseObj.java +++ b/rs/java/android/renderscript/BaseObj.java @@ -32,7 +32,7 @@ public class BaseObj { mDestroyed = false; } - void setID(int id) { + void setID(long id) { if (mID != 0) { throw new RSRuntimeException("Internal Error, reset of object ID."); } diff --git a/rs/java/android/renderscript/Byte2.java b/rs/java/android/renderscript/Byte2.java index ef7c770fbba08..3ad79e400c917 100644 --- a/rs/java/android/renderscript/Byte2.java +++ b/rs/java/android/renderscript/Byte2.java @@ -22,6 +22,9 @@ package android.renderscript; * **/ public class Byte2 { + public byte x; + public byte y; + public Byte2() { } @@ -30,8 +33,357 @@ public class Byte2 { y = initY; } - public byte x; - public byte y; + /** @hide */ + public Byte2(Byte2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte2 add(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte2 add(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte2 sub(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte2 sub(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte2 mul(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte2 mul(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte2 div(Byte2 a, Byte2 b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte2 div(Byte2 a, byte b) { + Byte2 result = new Byte2(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte2 a) { + return (byte)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte2 a, Byte2 b) { + return (byte)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte2 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Byte2 + * + * @param a + */ + public void set(Byte2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Char + * + * @param a + * @param b + */ + public void setValues(byte a, byte b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } + } diff --git a/rs/java/android/renderscript/Byte3.java b/rs/java/android/renderscript/Byte3.java index 025e8de80f753..a138313321d04 100644 --- a/rs/java/android/renderscript/Byte3.java +++ b/rs/java/android/renderscript/Byte3.java @@ -22,6 +22,10 @@ package android.renderscript; * **/ public class Byte3 { + public byte x; + public byte y; + public byte z; + public Byte3() { } @@ -31,9 +35,387 @@ public class Byte3 { z = initZ; } - public byte x; - public byte y; - public byte z; + /** @hide */ + public Byte3(Byte3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte3 add(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + result.z = (byte)(a.z + b.z); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte3 add(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + result.z = (byte)(a.z + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte3 sub(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + result.z = (byte)(a.z - b.z); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte3 sub(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + result.z = (byte)(a.z - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte3 mul(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + result.z = (byte)(a.z * b.z); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte3 mul(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + result.z = (byte)(a.z * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte3 div(Byte3 a, Byte3 b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + result.z = (byte)(a.z / b.z); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte3 div(Byte3 a, byte b) { + Byte3 result = new Byte3(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + result.z = (byte)(a.z / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + this.z = (byte)(-z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte3 a) { + return (byte)((byte)((byte)(x * a.x) + (byte)(y * a.y)) + (byte)(z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte3 a, Byte3 b) { + return (byte)((byte)((byte)(b.x * a.x) + (byte)(b.y * a.y)) + (byte)(b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte3 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Byte3 + * + * @param a + */ + public void set(Byte3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Char + * + * @param a + * @param b + * @param c + */ + public void setValues(byte a, byte b, byte c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } diff --git a/rs/java/android/renderscript/Byte4.java b/rs/java/android/renderscript/Byte4.java index 7df21049cdfd6..fa4c13d797140 100644 --- a/rs/java/android/renderscript/Byte4.java +++ b/rs/java/android/renderscript/Byte4.java @@ -22,6 +22,11 @@ package android.renderscript; * **/ public class Byte4 { + public byte x; + public byte y; + public byte z; + public byte w; + public Byte4() { } @@ -31,11 +36,418 @@ public class Byte4 { z = initZ; w = initW; } + /** @hide */ + public Byte4(Byte4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } - public byte x; - public byte y; - public byte z; - public byte w; + /** @hide + * Vector add + * + * @param a + */ + public void add(Byte4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte4 add(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x + b.x); + result.y = (byte)(a.y + b.y); + result.z = (byte)(a.z + b.z); + result.w = (byte)(a.w + b.w); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(byte value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Byte4 add(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x + b); + result.y = (byte)(a.y + b); + result.z = (byte)(a.z + b); + result.w = (byte)(a.w + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Byte4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte4 sub(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x - b.x); + result.y = (byte)(a.y - b.y); + result.z = (byte)(a.z - b.z); + result.w = (byte)(a.w - b.w); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(byte value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Byte4 sub(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x - b); + result.y = (byte)(a.y - b); + result.z = (byte)(a.z - b); + result.w = (byte)(a.w - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Byte4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte4 mul(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x * b.x); + result.y = (byte)(a.y * b.y); + result.z = (byte)(a.z * b.z); + result.w = (byte)(a.w * b.w); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(byte value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Byte4 mul(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x * b); + result.y = (byte)(a.y * b); + result.z = (byte)(a.z * b); + result.w = (byte)(a.w * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Byte4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte4 div(Byte4 a, Byte4 b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x / b.x); + result.y = (byte)(a.y / b.y); + result.z = (byte)(a.z / b.z); + result.w = (byte)(a.w / b.w); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(byte value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Byte4 div(Byte4 a, byte b) { + Byte4 result = new Byte4(); + result.x = (byte)(a.x / b); + result.y = (byte)(a.y / b); + result.z = (byte)(a.z / b); + result.w = (byte)(a.w / b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public byte length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (byte)(-x); + this.y = (byte)(-y); + this.z = (byte)(-z); + this.w = (byte)(-w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public byte dotProduct(Byte4 a) { + return (byte)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static byte dotProduct(Byte4 a, Byte4 b) { + return (byte)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Byte4 a, byte factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Byte4 + * + * @param a + */ + public void set(Byte4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field values + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(byte a, byte b, byte c, byte d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public byte elementSum() { + return (byte)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public byte get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, byte value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, byte value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to Char array + * + * @param data + * @param offset + */ + public void copyTo(byte[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } diff --git a/rs/java/android/renderscript/Double2.java b/rs/java/android/renderscript/Double2.java index 6e1afe6090116..4c7319d5a4b0f 100644 --- a/rs/java/android/renderscript/Double2.java +++ b/rs/java/android/renderscript/Double2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,25 +16,370 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double2 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides two double fields packed. + */ public class Double2 { + public double x; + public double y; + public Double2() { } - public Double2(double initX, double initY) { - x = initX; - y = initY; + /** @hide */ + public Double2(Double2 data) { + this.x = data.x; + this.y = data.y; } - public double x; - public double y; + public Double2(double x, double y) { + this.x = x; + this.y = y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double2 add(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x + b.x; + res.y = a.y + b.y; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double2 value) { + x += value.x; + y += value.y; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double2 add(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x + b; + res.y = a.y + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double2 value) { + x -= value.x; + y -= value.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double2 sub(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x - b.x; + res.y = a.y - b.y; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double2 sub(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x - b; + res.y = a.y - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double2 value) { + x *= value.x; + y *= value.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double2 mul(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x * b.x; + res.y = a.y * b.y; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double2 mul(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x * b; + res.y = a.y * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double2 value) { + x /= value.x; + y /= value.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double2 div(Double2 a, Double2 b) { + Double2 res = new Double2(); + res.x = a.x / b.x; + res.y = a.y / b.y; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double2 div(Double2 a, double b) { + Double2 res = new Double2(); + res.x = a.x / b; + res.y = a.y / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double2 a) { + return (x * a.x) + (y * a.y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static Double dotProduct(Double2 a, Double2 b) { + return (b.x * a.x) + (b.y * a.y); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double2 a, double factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * Set vector value by double2 + * + * @param a + */ + public void set(Double2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + */ + public void setValues(double x, double y) { + this.x = x; + this.y = y; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } } - - - - diff --git a/rs/java/android/renderscript/Double3.java b/rs/java/android/renderscript/Double3.java index 7c0979d32d16d..b819716017e9c 100644 --- a/rs/java/android/renderscript/Double3.java +++ b/rs/java/android/renderscript/Double3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,27 +16,402 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double3 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides three double fields packed. + */ public class Double3 { - public Double3() { - } - - public Double3(double initX, double initY, double initZ) { - x = initX; - y = initY; - z = initZ; - } - public double x; public double y; public double z; + + public Double3() { + } + /** @hide */ + public Double3(Double3 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + } + + public Double3(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double3 add(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double3 value) { + x += value.x; + y += value.y; + z += value.z; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double3 add(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double3 value) { + x -= value.x; + y -= value.y; + z -= value.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double3 sub(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double3 sub(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double3 value) { + x *= value.x; + y *= value.y; + z *= value.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double3 mul(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double3 mul(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double3 value) { + x /= value.x; + y /= value.y; + z /= value.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double3 div(Double3 a, Double3 b) { + Double3 res = new Double3(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double3 div(Double3 a, double b) { + Double3 res = new Double3(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double3 a) { + return (x * a.x) + (y * a.y) + (z * a.z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static double dotProduct(Double3 a, Double3 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double3 a, double factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * Set vector value by double3 + * + * @param a + */ + public void set(Double3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y + z; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + * @param z + */ + public void setValues(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } - - - - diff --git a/rs/java/android/renderscript/Double4.java b/rs/java/android/renderscript/Double4.java index 9e8261199d71d..e4829f7426aeb 100644 --- a/rs/java/android/renderscript/Double4.java +++ b/rs/java/android/renderscript/Double4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,28 +16,435 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript double4 type back - * to the Android system. - * - **/ + * Vector version of the basic double type. + * Provides four double fields packed. + */ public class Double4 { - public Double4() { - } - - public Double4(double initX, double initY, double initZ, double initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public double x; public double y; public double z; public double w; + + public Double4() { + } + /** @hide */ + public Double4(Double4 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + this.w = data.w; + } + + public Double4(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double4 add(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + res.w = a.w + b.w; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Double4 value) { + x += value.x; + y += value.y; + z += value.z; + w += value.w; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(double value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Double4 add(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + res.w = a.w + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Double4 value) { + x -= value.x; + y -= value.y; + z -= value.z; + w -= value.w; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(double value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double4 sub(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + res.w = a.w - b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Double4 sub(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + res.w = a.w - b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Double4 value) { + x *= value.x; + y *= value.y; + z *= value.z; + w *= value.w; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(double value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double4 mul(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + res.w = a.w * b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Double4 mul(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + res.w = a.w * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Double4 value) { + x /= value.x; + y /= value.y; + z /= value.z; + w /= value.w; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(double value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double4 div(Double4 a, double b) { + Double4 res = new Double4(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + res.w = a.w / b; + + return res; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Double4 div(Double4 a, Double4 b) { + Double4 res = new Double4(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + res.w = a.w / b.w; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public double dotProduct(Double4 a) { + return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static double dotProduct(Double4 a, Double4 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Double4 a, double factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * Set vector value by double4 + * + * @param a + */ + public void set(Double4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * Set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + w = -w; + } + + /** @hide + * Get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * Return the element sum of vector + * + * @return + */ + public double elementSum() { + return x + y + z + w; + } + + /** @hide + * Get the vector field value by index + * + * @param i + * @return + */ + public double get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, double value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, double value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * Set the vector field value + * + * @param x + * @param y + * @param z + * @param w + */ + public void setValues(double x, double y, double z, double w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Copy the vector to double array + * + * @param data + * @param offset + */ + public void copyTo(double[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } - - - diff --git a/rs/java/android/renderscript/FileA3D.java b/rs/java/android/renderscript/FileA3D.java index f0acb56b84adb..41648101cc885 100644 --- a/rs/java/android/renderscript/FileA3D.java +++ b/rs/java/android/renderscript/FileA3D.java @@ -136,7 +136,7 @@ public class FileA3D extends BaseObj { return null; } - int objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex); + long objectID = rs.nFileA3DGetEntryByIndex(entry.mID, entry.mIndex); if(objectID == 0) { return null; } @@ -292,7 +292,7 @@ public class FileA3D extends BaseObj { long fileId = 0; if (is instanceof AssetManager.AssetInputStream) { - int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); fileId = rs.nFileA3DCreateFromAssetStream(asset); } else { throw new RSRuntimeException("Unsupported asset stream"); diff --git a/rs/java/android/renderscript/Float2.java b/rs/java/android/renderscript/Float2.java index 427f038f8312a..e9f8ca7737ce1 100644 --- a/rs/java/android/renderscript/Float2.java +++ b/rs/java/android/renderscript/Float2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,24 +16,369 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ -public class Float2 { - public Float2() { - } - - public Float2(float initX, float initY) { - x = initX; - y = initY; - } - + * Vector version of the basic float type. + * Provides two float fields packed. + */ +public class Float2 { public float x; public float y; + + public Float2() { + } + /** @hide */ + public Float2(Float2 data) { + this.x = data.x; + this.y = data.y; + } + + public Float2(float x, float y) { + this.x = x; + this.y = y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float2 add(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x + b.x; + res.y = a.y + b.y; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float2 value) { + x += value.x; + y += value.y; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float2 add(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x + b; + res.y = a.y + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float2 value) { + x -= value.x; + y -= value.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float2 sub(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x - b.x; + res.y = a.y - b.y; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float2 sub(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x - b; + res.y = a.y - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float2 value) { + x *= value.x; + y *= value.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float2 mul(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x * b.x; + res.y = a.y * b.y; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float2 mul(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x * b; + res.y = a.y * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float2 value) { + x /= value.x; + y /= value.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float2 div(Float2 a, Float2 b) { + Float2 res = new Float2(); + res.x = a.x / b.x; + res.y = a.y / b.y; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float2 div(Float2 a, float b) { + Float2 res = new Float2(); + res.x = a.x / b; + res.y = a.y / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public float dotProduct(Float2 a) { + return (x * a.x) + (y * a.y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static float dotProduct(Float2 a, Float2 b) { + return (b.x * a.x) + (b.y * a.y); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float2 a, float factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by float2 + * + * @param a + */ + public void set(Float2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public float elementSum() { + return x + y; + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + */ + public void setValues(float x, float y) { + this.x = x; + this.y = y; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + } } - - - - diff --git a/rs/java/android/renderscript/Float3.java b/rs/java/android/renderscript/Float3.java index bfe143af60748..555bdf6d6e4eb 100644 --- a/rs/java/android/renderscript/Float3.java +++ b/rs/java/android/renderscript/Float3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,25 +16,402 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ + * Vector version of the basic float type. + * Provides three float fields packed. + */ public class Float3 { - public Float3() { - } - public Float3(float initX, float initY, float initZ) { - x = initX; - y = initY; - z = initZ; - } - public float x; public float y; public float z; + + public Float3() { + } + /** @hide */ + public Float3(Float3 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + } + + public Float3(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float3 add(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float3 value) { + x += value.x; + y += value.y; + z += value.z; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float3 add(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float3 value) { + x -= value.x; + y -= value.y; + z -= value.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float3 sub(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float3 sub(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float3 value) { + x *= value.x; + y *= value.y; + z *= value.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float3 mul(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float3 mul(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float3 value) { + x /= value.x; + y /= value.y; + z /= value.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float3 div(Float3 a, Float3 b) { + Float3 res = new Float3(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float3 div(Float3 a, float b) { + Float3 res = new Float3(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public Float dotProduct(Float3 a) { + return new Float((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static Float dotProduct(Float3 a, Float3 b) { + return new Float((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float3 a, float factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by float3 + * + * @param a + */ + public void set(Float3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public Float elementSum() { + return new Float(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + * @param z + */ + public void setValues(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + } } - - - - diff --git a/rs/java/android/renderscript/Float4.java b/rs/java/android/renderscript/Float4.java index 67c7afc2f743d..6541b2ec7264a 100644 --- a/rs/java/android/renderscript/Float4.java +++ b/rs/java/android/renderscript/Float4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,27 +16,435 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript float2 type back to the Android system. - * - **/ + * Vector version of the basic float type. + * Provides four float fields packed. + */ public class Float4 { - public Float4() { - } - - public Float4(float initX, float initY, float initZ, float initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public float x; public float y; public float z; public float w; + + public Float4() { + } + /** @hide */ + public Float4(Float4 data) { + this.x = data.x; + this.y = data.y; + this.z = data.z; + this.w = data.w; + } + + public Float4(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float4 add(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x + b.x; + res.y = a.y + b.y; + res.z = a.z + b.z; + res.w = a.w + b.w; + + return res; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(Float4 value) { + x += value.x; + y += value.y; + z += value.z; + w += value.w; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(float value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Float4 add(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x + b; + res.y = a.y + b; + res.z = a.z + b; + res.w = a.w + b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(Float4 value) { + x -= value.x; + y -= value.y; + z -= value.z; + w -= value.w; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(float value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float4 sub(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x - b; + res.y = a.y - b; + res.z = a.z - b; + res.w = a.w - b; + + return res; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Float4 sub(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x - b.x; + res.y = a.y - b.y; + res.z = a.z - b.z; + res.w = a.w - b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(Float4 value) { + x *= value.x; + y *= value.y; + z *= value.z; + w *= value.w; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(float value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float4 mul(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x * b.x; + res.y = a.y * b.y; + res.z = a.z * b.z; + res.w = a.w * b.w; + + return res; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Float4 mul(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x * b; + res.y = a.y * b; + res.z = a.z * b; + res.w = a.w * b; + + return res; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(Float4 value) { + x /= value.x; + y /= value.y; + z /= value.z; + w /= value.w; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(float value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float4 div(Float4 a, float b) { + Float4 res = new Float4(); + res.x = a.x / b; + res.y = a.y / b; + res.z = a.z / b; + res.w = a.w / b; + + return res; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Float4 div(Float4 a, Float4 b) { + Float4 res = new Float4(); + res.x = a.x / b.x; + res.y = a.y / b.y; + res.z = a.z / b.z; + res.w = a.w / b.w; + + return res; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public float dotProduct(Float4 a) { + return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static float dotProduct(Float4 a, Float4 b) { + return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Float4 a, float factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by float4 + * + * @param a + */ + public void set(Float4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set vector negate + */ + public void negate() { + x = -x; + y = -y; + z = -z; + w = -w; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public float elementSum() { + return x + y + z + w; + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public float get(int i) { + switch (i) { + case 0: + return x; + case 1: + return y; + case 2: + return z; + case 3: + return w; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, float value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, float value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value + * + * @param x + * @param y + * @param z + * @param w + */ + public void setValues(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide + * copy the vector to float array + * + * @param data + * @param offset + */ + public void copyTo(float[] data, int offset) { + data[offset] = x; + data[offset + 1] = y; + data[offset + 2] = z; + data[offset + 3] = w; + } } - - - diff --git a/rs/java/android/renderscript/Font.java b/rs/java/android/renderscript/Font.java index 4cd89db28e932..b22aeb7c04b71 100644 --- a/rs/java/android/renderscript/Font.java +++ b/rs/java/android/renderscript/Font.java @@ -148,7 +148,7 @@ public class Font extends BaseObj { return "DroidSans.ttf"; } - Font(int id, RenderScript rs) { + Font(long id, RenderScript rs) { super(id, rs); } @@ -159,7 +159,7 @@ public class Font extends BaseObj { static public Font createFromFile(RenderScript rs, Resources res, String path, float pointSize) { rs.validate(); int dpi = res.getDisplayMetrics().densityDpi; - int fontId = rs.nFontCreateFromFile(path, pointSize, dpi); + long fontId = rs.nFontCreateFromFile(path, pointSize, dpi); if(fontId == 0) { throw new RSRuntimeException("Unable to create font from file " + path); @@ -184,7 +184,7 @@ public class Font extends BaseObj { AssetManager mgr = res.getAssets(); int dpi = res.getDisplayMetrics().densityDpi; - int fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi); + long fontId = rs.nFontCreateFromAsset(mgr, path, pointSize, dpi); if(fontId == 0) { throw new RSRuntimeException("Unable to create font from asset " + path); } @@ -208,9 +208,9 @@ public class Font extends BaseObj { int dpi = res.getDisplayMetrics().densityDpi; - int fontId = 0; + long fontId = 0; if (is instanceof AssetManager.AssetInputStream) { - int asset = ((AssetManager.AssetInputStream) is).getAssetInt(); + long asset = ((AssetManager.AssetInputStream) is).getNativeAsset(); fontId = rs.nFontCreateFromAssetStream(name, pointSize, dpi, asset); } else { throw new RSRuntimeException("Unsupported asset stream created"); diff --git a/rs/java/android/renderscript/Int2.java b/rs/java/android/renderscript/Int2.java index 524e36185ffec..120957bcd726d 100644 --- a/rs/java/android/renderscript/Int2.java +++ b/rs/java/android/renderscript/Int2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,24 +16,425 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int2 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides two int fields packed. + */ public class Int2 { + public int x; + public int y; + public Int2() { } - public Int2(int initX, int initY) { - x = initX; - y = initY; + /** @hide */ + public Int2(int i) { + this.x = this.y = i; } - public int x; - public int y; + public Int2(int x, int y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Int2(Int2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int2 add(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x + b.x; + result.y = a.y + b.y; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int2 add(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x + b; + result.y = a.y + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int2 sub(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x - b.x; + result.y = a.y - b.y; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int2 sub(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x - b; + result.y = a.y - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int2 mul(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x * b.x; + result.y = a.y * b.y; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int2 mul(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x * b; + result.y = a.y * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int2 div(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x / b.x; + result.y = a.y / b.y; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int2 div(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x / b; + result.y = a.y / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int2 mod(Int2 a, Int2 b) { + Int2 result = new Int2(); + result.x = a.x % b.x; + result.y = a.y % b.y; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int2 mod(Int2 a, int b) { + Int2 result = new Int2(); + result.x = a.x % b; + result.y = a.y % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int2 a) { + return (int)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int2 a, Int2 b) { + return (int)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int2 a, int factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Int2 + * + * @param a + */ + public void set(Int2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + */ + public void setValues(int a, int b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Int3.java b/rs/java/android/renderscript/Int3.java index df42e28e52ca7..5431b9a75ba75 100644 --- a/rs/java/android/renderscript/Int3.java +++ b/rs/java/android/renderscript/Int3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,26 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int3 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides three int fields packed. + */ public class Int3 { - public Int3() { - } - - public Int3(int initX, int initY, int initZ) { - x = initX; - y = initY; - z = initZ; - } - public int x; public int y; public int z; + + public Int3() { + } + + /** @hide */ + public Int3(int i) { + this.x = this.y = this.z = i; + } + + public Int3(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Int3(Int3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int3 add(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int3 add(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int3 sub(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int3 sub(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int3 mul(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int3 mul(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int3 div(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int3 div(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int3 mod(Int3 a, Int3 b) { + Int3 result = new Int3(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int3 mod(Int3 a, int b) { + Int3 result = new Int3(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int3 a) { + return (int)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int3 a, Int3 b) { + return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int3 a, int factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Int3 + * + * @param a + */ + public void set(Int3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + * @param c + */ + public void setValues(int a, int b, int c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + case 2: + return (int)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + data[offset + 2] = (int)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Int4.java b/rs/java/android/renderscript/Int4.java index 408fb0ddd6fdb..1c0e2e2621aa9 100644 --- a/rs/java/android/renderscript/Int4.java +++ b/rs/java/android/renderscript/Int4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,27 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript int4 type back to the Android system. - * - **/ + * Vector version of the basic int type. + * Provides four int fields packed. + */ public class Int4 { - public Int4() { - } - - public Int4(int initX, int initY, int initZ, int initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public int x; public int y; public int z; public int w; + + public Int4() { + } + + /** @hide */ + public Int4(int i) { + this.x = this.y = this.z = this.w = i; + } + + public Int4(int x, int y, int z, int w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Int4(Int4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Int4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int4 add(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(int value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Int4 add(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + result.w = a.w + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Int4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int4 sub(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(int value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Int4 sub(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + result.w = a.w - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Int4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int4 mul(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + result.w = a.w * b.w; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(int value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Int4 mul(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + result.w = a.w * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Int4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int4 div(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + result.w = a.w / b.w; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(int value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Int4 div(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + result.w = a.w / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Int4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int4 mod(Int4 a, Int4 b) { + Int4 result = new Int4(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + result.w = a.w % b.w; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(int value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Int4 mod(Int4 a, int b) { + Int4 result = new Int4(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + result.w = a.w % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public int length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + this.w = -w; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public int dotProduct(Int4 a) { + return (int)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static int dotProduct(Int4 a, Int4 b) { + return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Int4 a, int factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Int4 + * + * @param a + */ + public void set(Int4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Int + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(int a, int b, int c, int d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public int elementSum() { + return (int)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public int get(int i) { + switch (i) { + case 0: + return (int)(x); + case 1: + return (int)(y); + case 2: + return (int)(z); + case 3: + return (int)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, int value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, int value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to int array + * + * @param data + * @param offset + */ + public void copyTo(int[] data, int offset) { + data[offset] = (int)(x); + data[offset + 1] = (int)(y); + data[offset + 2] = (int)(z); + data[offset + 3] = (int)(w); + } } - - - diff --git a/rs/java/android/renderscript/Long2.java b/rs/java/android/renderscript/Long2.java index 70fc374b57ea8..fabf2046a48ce 100644 --- a/rs/java/android/renderscript/Long2.java +++ b/rs/java/android/renderscript/Long2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,23 +16,425 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long2 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides two long fields packed. + */ public class Long2 { + public long x; + public long y; + public Long2() { } - public Long2(long initX, long initY) { - x = initX; - y = initY; + /** @hide */ + public Long2(long i) { + this.x = this.y = i; } - public long x; - public long y; + public Long2(long x, long y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Long2(Long2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long2 add(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x + b.x; + result.y = a.y + b.y; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long2 add(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x + b; + result.y = a.y + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long2 sub(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x - b.x; + result.y = a.y - b.y; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long2 sub(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x - b; + result.y = a.y - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long2 mul(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x * b.x; + result.y = a.y * b.y; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long2 mul(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x * b; + result.y = a.y * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long2 div(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x / b.x; + result.y = a.y / b.y; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long2 div(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x / b; + result.y = a.y / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long2 mod(Long2 a, Long2 b) { + Long2 result = new Long2(); + result.x = a.x % b.x; + result.y = a.y % b.y; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long2 mod(Long2 a, long b) { + Long2 result = new Long2(); + result.x = a.x % b; + result.y = a.y % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long2 a) { + return (long)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long2 a, Long2 b) { + return (long)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long2 a, long factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Long2 + * + * @param a + */ + public void set(Long2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + */ + public void setValues(long a, long b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Long3.java b/rs/java/android/renderscript/Long3.java index d81826b0529a9..8e243cce647f5 100644 --- a/rs/java/android/renderscript/Long3.java +++ b/rs/java/android/renderscript/Long3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,25 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long3 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides three long fields packed. + */ public class Long3 { - public Long3() { - } - - public Long3(long initX, long initY, long initZ) { - x = initX; - y = initY; - z = initZ; - } - public long x; public long y; public long z; + + public Long3() { + } + + /** @hide */ + public Long3(long i) { + this.x = this.y = this.z = i; + } + + public Long3(long x, long y, long z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Long3(Long3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long3 add(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long3 add(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long3 sub(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long3 sub(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long3 mul(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long3 mul(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long3 div(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long3 div(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long3 mod(Long3 a, Long3 b) { + Long3 result = new Long3(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long3 mod(Long3 a, long b) { + Long3 result = new Long3(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long3 a) { + return (long)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long3 a, Long3 b) { + return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long3 a, long factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Long3 + * + * @param a + */ + public void set(Long3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + * @param c + */ + public void setValues(long a, long b, long c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + case 2: + return (long)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + data[offset + 2] = (long)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Long4.java b/rs/java/android/renderscript/Long4.java index 47ef43726c782..1a1ad748e462e 100644 --- a/rs/java/android/renderscript/Long4.java +++ b/rs/java/android/renderscript/Long4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,26 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript long4 type back to the Android system. - **/ + * Vector version of the basic long type. + * Provides four long fields packed. + */ public class Long4 { - public Long4() { - } - - public Long4(long initX, long initY, long initZ, long initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public long x; public long y; public long z; public long w; + + public Long4() { + } + + /** @hide */ + public Long4(long i) { + this.x = this.y = this.z = this.w = i; + } + + public Long4(long x, long y, long z, long w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Long4(Long4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Long4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long4 add(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x + b.x; + result.y = a.y + b.y; + result.z = a.z + b.z; + result.w = a.w + b.w; + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(long value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Long4 add(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x + b; + result.y = a.y + b; + result.z = a.z + b; + result.w = a.w + b; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Long4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long4 sub(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x - b.x; + result.y = a.y - b.y; + result.z = a.z - b.z; + result.w = a.w - b.w; + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(long value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Long4 sub(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x - b; + result.y = a.y - b; + result.z = a.z - b; + result.w = a.w - b; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Long4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long4 mul(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x * b.x; + result.y = a.y * b.y; + result.z = a.z * b.z; + result.w = a.w * b.w; + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(long value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Long4 mul(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x * b; + result.y = a.y * b; + result.z = a.z * b; + result.w = a.w * b; + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Long4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long4 div(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x / b.x; + result.y = a.y / b.y; + result.z = a.z / b.z; + result.w = a.w / b.w; + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(long value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Long4 div(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x / b; + result.y = a.y / b; + result.z = a.z / b; + result.w = a.w / b; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Long4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long4 mod(Long4 a, Long4 b) { + Long4 result = new Long4(); + result.x = a.x % b.x; + result.y = a.y % b.y; + result.z = a.z % b.z; + result.w = a.w % b.w; + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(long value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Long4 mod(Long4 a, long b) { + Long4 result = new Long4(); + result.x = a.x % b; + result.y = a.y % b; + result.z = a.z % b; + result.w = a.w % b; + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public long length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = -x; + this.y = -y; + this.z = -z; + this.w = -w; + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public long dotProduct(Long4 a) { + return (long)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static long dotProduct(Long4 a, Long4 b) { + return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Long4 a, long factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Long4 + * + * @param a + */ + public void set(Long4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Long + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(long a, long b, long c, long d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public long elementSum() { + return (long)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public long get(int i) { + switch (i) { + case 0: + return (long)(x); + case 1: + return (long)(y); + case 2: + return (long)(z); + case 3: + return (long)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, long value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, long value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to long array + * + * @param data + * @param offset + */ + public void copyTo(long[] data, int offset) { + data[offset] = (long)(x); + data[offset + 1] = (long)(y); + data[offset + 2] = (long)(z); + data[offset + 3] = (long)(w); + } } - - - diff --git a/rs/java/android/renderscript/ProgramStore.java b/rs/java/android/renderscript/ProgramStore.java index 730c51bc2d15e..c0fa9c45fb53f 100644 --- a/rs/java/android/renderscript/ProgramStore.java +++ b/rs/java/android/renderscript/ProgramStore.java @@ -143,7 +143,7 @@ public class ProgramStore extends BaseObj { BlendDstFunc mBlendDst; boolean mDither; - ProgramStore(int id, RenderScript rs) { + ProgramStore(long id, RenderScript rs) { super(id, rs); } @@ -418,7 +418,7 @@ public class ProgramStore extends BaseObj { */ public ProgramStore create() { mRS.validate(); - int id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, + long id = mRS.nProgramStoreCreate(mColorMaskR, mColorMaskG, mColorMaskB, mColorMaskA, mDepthMask, mDither, mBlendSrc.mID, mBlendDst.mID, mDepthFunc.mID); ProgramStore programStore = new ProgramStore(id, mRS); diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java index b0ef156e0934f..a4a9070a800d1 100644 --- a/rs/java/android/renderscript/RenderScript.java +++ b/rs/java/android/renderscript/RenderScript.java @@ -502,8 +502,8 @@ public class RenderScript { rsnAllocationResize1D(mContext, id, dimX); } - native long rsnFileA3DCreateFromAssetStream(long con, int assetStream); - synchronized long nFileA3DCreateFromAssetStream(int assetStream) { + native long rsnFileA3DCreateFromAssetStream(long con, long assetStream); + synchronized long nFileA3DCreateFromAssetStream(long assetStream) { validate(); return rsnFileA3DCreateFromAssetStream(mContext, assetStream); } @@ -527,24 +527,24 @@ public class RenderScript { validate(); rsnFileA3DGetIndexEntries(mContext, fileA3D, numEntries, IDs, names); } - native int rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index); - synchronized int nFileA3DGetEntryByIndex(long fileA3D, int index) { + native long rsnFileA3DGetEntryByIndex(long con, long fileA3D, int index); + synchronized long nFileA3DGetEntryByIndex(long fileA3D, int index) { validate(); return rsnFileA3DGetEntryByIndex(mContext, fileA3D, index); } - native int rsnFontCreateFromFile(long con, String fileName, float size, int dpi); - synchronized int nFontCreateFromFile(String fileName, float size, int dpi) { + native long rsnFontCreateFromFile(long con, String fileName, float size, int dpi); + synchronized long nFontCreateFromFile(String fileName, float size, int dpi) { validate(); return rsnFontCreateFromFile(mContext, fileName, size, dpi); } - native int rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, int assetStream); - synchronized int nFontCreateFromAssetStream(String name, float size, int dpi, int assetStream) { + native long rsnFontCreateFromAssetStream(long con, String name, float size, int dpi, long assetStream); + synchronized long nFontCreateFromAssetStream(String name, float size, int dpi, long assetStream) { validate(); return rsnFontCreateFromAssetStream(mContext, name, size, dpi, assetStream); } - native int rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi); - synchronized int nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { + native long rsnFontCreateFromAsset(long con, AssetManager mgr, String path, float size, int dpi); + synchronized long nFontCreateFromAsset(AssetManager mgr, String path, float size, int dpi) { validate(); return rsnFontCreateFromAsset(mContext, mgr, path, size, dpi); } @@ -661,9 +661,9 @@ public class RenderScript { rsnScriptSetVarObj(mContext, id, slot, val); } - native int rsnScriptCCreate(long con, String resName, String cacheDir, + native long rsnScriptCCreate(long con, String resName, String cacheDir, byte[] script, int length); - synchronized int nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { + synchronized long nScriptCCreate(String resName, String cacheDir, byte[] script, int length) { validate(); return rsnScriptCCreate(mContext, resName, cacheDir, script, length); } @@ -710,18 +710,18 @@ public class RenderScript { rsnScriptGroupExecute(mContext, group); } - native int rsnSamplerCreate(long con, int magFilter, int minFilter, + native long rsnSamplerCreate(long con, int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso); - synchronized int nSamplerCreate(int magFilter, int minFilter, + synchronized long nSamplerCreate(int magFilter, int minFilter, int wrapS, int wrapT, int wrapR, float aniso) { validate(); return rsnSamplerCreate(mContext, magFilter, minFilter, wrapS, wrapT, wrapR, aniso); } - native int rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a, + native long rsnProgramStoreCreate(long con, boolean r, boolean g, boolean b, boolean a, boolean depthMask, boolean dither, int srcMode, int dstMode, int depthFunc); - synchronized int nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, + synchronized long nProgramStoreCreate(boolean r, boolean g, boolean b, boolean a, boolean depthMask, boolean dither, int srcMode, int dstMode, int depthFunc) { validate(); @@ -787,8 +787,8 @@ public class RenderScript { rsnMeshGetIndices(mContext, id, idxIds, primitives, vtxIdCount); } - native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, int loop, float q); - synchronized long nPathCreate(int prim, boolean isStatic, long vtx, int loop, float q) { + native long rsnPathCreate(long con, int prim, boolean isStatic, long vtx, long loop, float q); + synchronized long nPathCreate(int prim, boolean isStatic, long vtx, long loop, float q) { validate(); return rsnPathCreate(mContext, prim, isStatic, vtx, loop, q); } diff --git a/rs/java/android/renderscript/Sampler.java b/rs/java/android/renderscript/Sampler.java index 39b867b7b039e..a4edbb50ac109 100644 --- a/rs/java/android/renderscript/Sampler.java +++ b/rs/java/android/renderscript/Sampler.java @@ -49,7 +49,7 @@ public class Sampler extends BaseObj { Value mWrapR; float mAniso; - Sampler(int id, RenderScript rs) { + Sampler(long id, RenderScript rs) { super(id, rs); } @@ -336,7 +336,7 @@ public class Sampler extends BaseObj { public Sampler create() { mRS.validate(); - int id = mRS.nSamplerCreate(mMag.mID, mMin.mID, + long id = mRS.nSamplerCreate(mMag.mID, mMin.mID, mWrapS.mID, mWrapT.mID, mWrapR.mID, mAniso); Sampler sampler = new Sampler(id, mRS); sampler.mMin = mMin; diff --git a/rs/java/android/renderscript/ScriptC.java b/rs/java/android/renderscript/ScriptC.java index c7979f6fa2bc1..9e76f5293bd06 100644 --- a/rs/java/android/renderscript/ScriptC.java +++ b/rs/java/android/renderscript/ScriptC.java @@ -38,7 +38,17 @@ public class ScriptC extends Script { protected ScriptC(int id, RenderScript rs) { super(id, rs); } - + /** + * Only intended for use by the generated derived classes. + * + * @param id + * @param rs + * + * @hide + */ + protected ScriptC(long id, RenderScript rs) { + super(id, rs); + } /** * Only intended for use by the generated derived classes. * @@ -49,7 +59,7 @@ public class ScriptC extends Script { */ protected ScriptC(RenderScript rs, Resources resources, int resourceID) { super(0, rs); - int id = internalCreate(rs, resources, resourceID); + long id = internalCreate(rs, resources, resourceID); if (id == 0) { throw new RSRuntimeException("Loading of ScriptC script failed."); } @@ -63,7 +73,7 @@ public class ScriptC extends Script { static String mCachePath; - private static synchronized int internalCreate(RenderScript rs, Resources resources, int resourceID) { + private static synchronized long internalCreate(RenderScript rs, Resources resources, int resourceID) { byte[] pgm; int pgmLength; InputStream is = resources.openRawResource(resourceID); diff --git a/rs/java/android/renderscript/Short2.java b/rs/java/android/renderscript/Short2.java index 2c6c334a53b24..24809f7391598 100644 --- a/rs/java/android/renderscript/Short2.java +++ b/rs/java/android/renderscript/Short2.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +20,424 @@ package android.renderscript; /** * Class for exposing the native RenderScript Short2 type back to the Android system. * - **/ + * Vector version of the basic short type. + * Provides two short fields packed. + */ public class Short2 { + public short x; + public short y; + public Short2() { } - public Short2(short initX, short initY) { - x = initX; - y = initY; + /** @hide */ + public Short2(short i) { + this.x = this.y = i; } - public short x; - public short y; + public Short2(short x, short y) { + this.x = x; + this.y = y; + } + + /** @hide */ + public Short2(Short2 source) { + this.x = source.x; + this.y = source.y; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short2 a) { + this.x += a.x; + this.y += a.y; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short2 add(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short2 add(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short2 a) { + this.x -= a.x; + this.y -= a.y; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short2 sub(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short2 sub(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short2 a) { + this.x *= a.x; + this.y *= a.y; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short2 mul(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short2 mul(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short2 a) { + this.x /= a.x; + this.y /= a.y; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short2 div(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short2 div(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short2 a) { + this.x %= a.x; + this.y %= a.y; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short2 mod(Short2 a, Short2 b) { + Short2 result = new Short2(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short2 mod(Short2 a, short b) { + Short2 result = new Short2(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 2; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short2 a) { + return (short)((x * a.x) + (y * a.y)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short2 a, Short2 b) { + return (short)((b.x * a.x) + (b.y * a.y)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short2 a, short factor) { + x += a.x * factor; + y += a.y * factor; + } + + /** @hide + * set vector value by Short2 + * + * @param a + */ + public void set(Short2 a) { + this.x = a.x; + this.y = a.y; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + */ + public void setValues(short a, short b) { + this.x = a; + this.y = b; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + } } - - - - diff --git a/rs/java/android/renderscript/Short3.java b/rs/java/android/renderscript/Short3.java index aafd27b15326e..661db0a89f3d8 100644 --- a/rs/java/android/renderscript/Short3.java +++ b/rs/java/android/renderscript/Short3.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,26 +16,462 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript short3 type back to the Android system. - * - **/ + * Vector version of the basic short type. + * Provides three short fields packed. + */ public class Short3 { - public Short3() { - } - - public Short3(short initX, short initY, short initZ) { - x = initX; - y = initY; - z = initZ; - } - public short x; public short y; public short z; + + public Short3() { + } + + /** @hide */ + public Short3(short i) { + this.x = this.y = this.z = i; + } + + public Short3(short x, short y, short z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** @hide */ + public Short3(Short3 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short3 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short3 add(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + result.z = (short)(a.z + b.z); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + z += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short3 add(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + result.z = (short)(a.z + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short3 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short3 sub(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + result.z = (short)(a.z - b.z); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + z -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short3 sub(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + result.z = (short)(a.z - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short3 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short3 mul(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + result.z = (short)(a.z * b.z); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + z *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short3 mul(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + result.z = (short)(a.z * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short3 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short3 div(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + result.z = (short)(a.z / b.z); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + z /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short3 div(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + result.z = (short)(a.z / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short3 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short3 mod(Short3 a, Short3 b) { + Short3 result = new Short3(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + result.z = (short)(a.z % b.z); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + z %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short3 mod(Short3 a, short b) { + Short3 result = new Short3(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + result.z = (short)(a.z % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 3; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + this.z = (short)(-z); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short3 a) { + return (short)((x * a.x) + (y * a.y) + (z * a.z)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short3 a, Short3 b) { + return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short3 a, short factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + } + + /** @hide + * set vector value by Short3 + * + * @param a + */ + public void set(Short3 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + * @param c + */ + public void setValues(short a, short b, short c) { + this.x = a; + this.y = b; + this.z = c; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y + z); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + case 2: + return (short)(z); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + data[offset + 2] = (short)(z); + } } - - - - diff --git a/rs/java/android/renderscript/Short4.java b/rs/java/android/renderscript/Short4.java index 176bde91c9262..a2d74f2ccf94b 100644 --- a/rs/java/android/renderscript/Short4.java +++ b/rs/java/android/renderscript/Short4.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 The Android Open Source Project + * Copyright (C) 2013 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,27 +16,499 @@ package android.renderscript; - /** - * Class for exposing the native RenderScript short4 type back to the Android system. - * - **/ + * Vector version of the basic short type. + * Provides four short fields packed. + */ public class Short4 { - public Short4() { - } - - public Short4(short initX, short initY, short initZ, short initW) { - x = initX; - y = initY; - z = initZ; - w = initW; - } - public short x; public short y; public short z; public short w; + + public Short4() { + } + + /** @hide */ + public Short4(short i) { + this.x = this.y = this.z = this.w = i; + } + + public Short4(short x, short y, short z, short w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + /** @hide */ + public Short4(Short4 source) { + this.x = source.x; + this.y = source.y; + this.z = source.z; + this.w = source.w; + } + + /** @hide + * Vector add + * + * @param a + */ + public void add(Short4 a) { + this.x += a.x; + this.y += a.y; + this.z += a.z; + this.w += a.w; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short4 add(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x + b.x); + result.y = (short)(a.y + b.y); + result.z = (short)(a.z + b.z); + result.w = (short)(a.w + b.w); + + return result; + } + + /** @hide + * Vector add + * + * @param value + */ + public void add(short value) { + x += value; + y += value; + z += value; + w += value; + } + + /** @hide + * Vector add + * + * @param a + * @param b + * @return + */ + public static Short4 add(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x + b); + result.y = (short)(a.y + b); + result.z = (short)(a.z + b); + result.w = (short)(a.w + b); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param a + */ + public void sub(Short4 a) { + this.x -= a.x; + this.y -= a.y; + this.z -= a.z; + this.w -= a.w; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short4 sub(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x - b.x); + result.y = (short)(a.y - b.y); + result.z = (short)(a.z - b.z); + result.w = (short)(a.w - b.w); + + return result; + } + + /** @hide + * Vector subtraction + * + * @param value + */ + public void sub(short value) { + x -= value; + y -= value; + z -= value; + w -= value; + } + + /** @hide + * Vector subtraction + * + * @param a + * @param b + * @return + */ + public static Short4 sub(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x - b); + result.y = (short)(a.y - b); + result.z = (short)(a.z - b); + result.w = (short)(a.w - b); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param a + */ + public void mul(Short4 a) { + this.x *= a.x; + this.y *= a.y; + this.z *= a.z; + this.w *= a.w; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short4 mul(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x * b.x); + result.y = (short)(a.y * b.y); + result.z = (short)(a.z * b.z); + result.w = (short)(a.w * b.w); + + return result; + } + + /** @hide + * Vector multiplication + * + * @param value + */ + public void mul(short value) { + x *= value; + y *= value; + z *= value; + w *= value; + } + + /** @hide + * Vector multiplication + * + * @param a + * @param b + * @return + */ + public static Short4 mul(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x * b); + result.y = (short)(a.y * b); + result.z = (short)(a.z * b); + result.w = (short)(a.w * b); + + return result; + } + + /** @hide + * Vector division + * + * @param a + */ + public void div(Short4 a) { + this.x /= a.x; + this.y /= a.y; + this.z /= a.z; + this.w /= a.w; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short4 div(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x / b.x); + result.y = (short)(a.y / b.y); + result.z = (short)(a.z / b.z); + result.w = (short)(a.w / b.w); + + return result; + } + + /** @hide + * Vector division + * + * @param value + */ + public void div(short value) { + x /= value; + y /= value; + z /= value; + w /= value; + } + + /** @hide + * Vector division + * + * @param a + * @param b + * @return + */ + public static Short4 div(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x / b); + result.y = (short)(a.y / b); + result.z = (short)(a.z / b); + result.w = (short)(a.w / b); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param a + */ + public void mod(Short4 a) { + this.x %= a.x; + this.y %= a.y; + this.z %= a.z; + this.w %= a.w; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short4 mod(Short4 a, Short4 b) { + Short4 result = new Short4(); + result.x = (short)(a.x % b.x); + result.y = (short)(a.y % b.y); + result.z = (short)(a.z % b.z); + result.w = (short)(a.w % b.w); + + return result; + } + + /** @hide + * Vector Modulo + * + * @param value + */ + public void mod(short value) { + x %= value; + y %= value; + z %= value; + w %= value; + } + + /** @hide + * Vector Modulo + * + * @param a + * @param b + * @return + */ + public static Short4 mod(Short4 a, short b) { + Short4 result = new Short4(); + result.x = (short)(a.x % b); + result.y = (short)(a.y % b); + result.z = (short)(a.z % b); + result.w = (short)(a.w % b); + + return result; + } + + /** @hide + * get vector length + * + * @return + */ + public short length() { + return 4; + } + + /** @hide + * set vector negate + */ + public void negate() { + this.x = (short)(-x); + this.y = (short)(-y); + this.z = (short)(-z); + this.w = (short)(-w); + } + + /** @hide + * Vector dot Product + * + * @param a + * @return + */ + public short dotProduct(Short4 a) { + return (short)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w)); + } + + /** @hide + * Vector dot Product + * + * @param a + * @param b + * @return + */ + public static short dotProduct(Short4 a, Short4 b) { + return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w)); + } + + /** @hide + * Vector add Multiple + * + * @param a + * @param factor + */ + public void addMultiple(Short4 a, short factor) { + x += a.x * factor; + y += a.y * factor; + z += a.z * factor; + w += a.w * factor; + } + + /** @hide + * set vector value by Short4 + * + * @param a + */ + public void set(Short4 a) { + this.x = a.x; + this.y = a.y; + this.z = a.z; + this.w = a.w; + } + + /** @hide + * set the vector field value by Short + * + * @param a + * @param b + * @param c + * @param d + */ + public void setValues(short a, short b, short c, short d) { + this.x = a; + this.y = b; + this.z = c; + this.w = d; + } + + /** @hide + * return the element sum of vector + * + * @return + */ + public short elementSum() { + return (short)(x + y + z + w); + } + + /** @hide + * get the vector field value by index + * + * @param i + * @return + */ + public short get(int i) { + switch (i) { + case 0: + return (short)(x); + case 1: + return (short)(y); + case 2: + return (short)(z); + case 3: + return (short)(w); + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * set the vector field value by index + * + * @param i + * @param value + */ + public void setAt(int i, short value) { + switch (i) { + case 0: + x = value; + return; + case 1: + y = value; + return; + case 2: + z = value; + return; + case 3: + w = value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * add the vector field value by index + * + * @param i + * @param value + */ + public void addAt(int i, short value) { + switch (i) { + case 0: + x += value; + return; + case 1: + y += value; + return; + case 2: + z += value; + return; + case 3: + w += value; + return; + default: + throw new IndexOutOfBoundsException("Index: i"); + } + } + + /** @hide + * copy the vector to short array + * + * @param data + * @param offset + */ + public void copyTo(short[] data, int offset) { + data[offset] = (short)(x); + data[offset + 1] = (short)(y); + data[offset + 2] = (short)(z); + data[offset + 3] = (short)(w); + } } - - - From cc69d4c778738500b1ddbc0e08ac55bb322e3889 Mon Sep 17 00:00:00 2001 From: Craig Mautner Date: Fri, 7 Feb 2014 13:11:47 -0800 Subject: [PATCH 009/102] Don't remove Activities and Tasks until animation done Just like stacks and displays, activities and tasks need to stick around until animations have completed. Change-Id: I54fe8f6855d60cbc3a25cbc6e762defd5ac50bf5 --- .../server/am/ActivityStackSupervisor.java | 10 ++-- .../com/android/server/wm/AppWindowToken.java | 2 + .../core/java/com/android/server/wm/Task.java | 1 + .../java/com/android/server/wm/TaskStack.java | 17 ++++++- .../server/wm/WindowManagerService.java | 48 +++++++++++++++---- .../server/wm/WindowStateAnimator.java | 2 +- 6 files changed, 63 insertions(+), 17 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index a33b0e5078ea4..8f8b2a27ad6ac 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -1151,7 +1151,11 @@ public final class ActivityStackSupervisor implements DisplayListener { if (err == ActivityManager.START_SUCCESS) { final int userId = aInfo != null ? UserHandle.getUserId(aInfo.applicationInfo.uid) : 0; Slog.i(TAG, "START u" + userId + " {" + intent.toShortString(true, true, true, false) - + "} from pid " + (callerApp != null ? callerApp.pid : callingPid)); + + "} from pid " + (callerApp != null ? callerApp.pid : callingPid) + + " on display " + (container == null ? (mFocusedStack == null ? + Display.DEFAULT_DISPLAY : mFocusedStack.mDisplayId) : + (container.mActivityDisplay == null ? Display.DEFAULT_DISPLAY : + container.mActivityDisplay.mDisplayId))); } ActivityRecord sourceRecord = null; @@ -3069,10 +3073,6 @@ public final class ActivityStackSupervisor implements DisplayListener { init(mDisplayManager.getDisplay(displayId)); } - ActivityDisplay(Display display) { - init(display); - } - ActivityDisplay(Surface surface, int width, int height, int density) { DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance(); long ident = Binder.clearCallingIdentity(); diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index e98014bdea3e9..ca4ad8a32e0d8 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -105,6 +105,8 @@ class AppWindowToken extends WindowToken { // Input application handle used by the input dispatcher. final InputApplicationHandle mInputApplicationHandle; + boolean mDeferRemoval; + AppWindowToken(WindowManagerService _service, IApplicationToken _token) { super(_service, _token.asBinder(), WindowManager.LayoutParams.TYPE_APPLICATION, true); diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 44f2596eb92be..c301ffed1a4b1 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -24,6 +24,7 @@ class Task { final AppTokenList mAppTokens = new AppTokenList(); final int taskId; final int mUserId; + boolean mDeferRemoval = false; Task(AppWindowToken wtoken, TaskStack stack, int userId) { taskId = wtoken.groupId; diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 0941c76855021..7d8cff4a8040c 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -366,7 +366,7 @@ public class TaskStack { mAnimationBackgroundSurface.mDimSurface.destroy(); } - void checkForDeferredDetach() { + void checkForDeferredActions() { if (mDisplayContent != null && (mDisplayContent.mDeferredActions & DisplayContent.DEFER_DETACH) != 0 && !isAnimating()) { @@ -377,6 +377,21 @@ public class TaskStack { mService.onDisplayRemoved(mDisplayContent.getDisplayId()); } } + for (int taskNdx = mTasks.size() - 1; taskNdx >= 0; --taskNdx) { + final Task task = mTasks.get(taskNdx); + AppTokenList tokens = task.mAppTokens; + for (int tokenNdx = tokens.size() - 1; tokenNdx >= 0; --tokenNdx) { + AppWindowToken wtoken = tokens.get(tokenNdx); + if (wtoken.mDeferRemoval) { + wtoken.mDeferRemoval = false; + mService.removeAppFromTaskLocked(wtoken); + } + } + if (task.mDeferRemoval) { + task.mDeferRemoval = false; + mService.removeTaskLocked(task); + } + } } public void dump(String prefix, PrintWriter pw) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b76ec4bb67263..7293d6f1c0e95 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -21,6 +21,7 @@ import static android.view.WindowManager.LayoutParams.*; import static android.view.WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER; import android.app.AppOpsManager; +import android.util.ArraySet; import android.util.TimeUtils; import android.view.IWindowId; @@ -362,6 +363,11 @@ public class WindowManagerService extends IWindowManager.Stub */ final ArrayList mPendingRemove = new ArrayList(); + /** + * Stacks whose animations have ended and whose tasks, apps, selves may now be removed. + */ + final ArraySet mPendingStacksRemove = new ArraySet(); + /** * Used when processing mPendingRemove to avoid working on the original array. */ @@ -3425,6 +3431,8 @@ public class WindowManagerService extends IWindowManager.Stub } private Task createTask(int taskId, int stackId, int userId, AppWindowToken atoken) { + if (DEBUG_STACK) Slog.i(TAG, "createTask: taskId=" + taskId + " stackId=" + stackId + + " atoken=" + atoken); final TaskStack stack = mStackIdToStack.get(stackId); if (stack == null) { throw new IllegalArgumentException("addAppToken: invalid stackId=" + stackId); @@ -3507,7 +3515,7 @@ public class WindowManagerService extends IWindowManager.Stub return; } final Task oldTask = mTaskIdToTask.get(atoken.groupId); - removeAppFromTask(atoken); + removeAppFromTaskLocked(atoken); atoken.groupId = groupId; Task newTask = mTaskIdToTask.get(groupId); @@ -4525,11 +4533,10 @@ public class WindowManagerService extends IWindowManager.Stub } } - void removeAppFromTask(AppWindowToken wtoken) { + void removeAppFromTaskLocked(AppWindowToken wtoken) { final Task task = mTaskIdToTask.get(wtoken.groupId); - if (task != null && task.removeAppToken(wtoken)) { - task.mStack.removeTask(task); - mTaskIdToTask.delete(wtoken.groupId); + if (!wtoken.mDeferRemoval && task != null && task.removeAppToken(wtoken)) { + removeTaskLocked(task); } } @@ -4571,17 +4578,18 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "removeAppToken make exiting: " + wtoken); stack.mExitingAppTokens.add(wtoken); + wtoken.mDeferRemoval = true; } else { // Make sure there is no animation running on this token, // so any windows associated with it will be removed as // soon as their animations are complete wtoken.mAppAnimator.clearAnimation(); wtoken.mAppAnimator.animating = false; + removeAppFromTaskLocked(wtoken); } if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "removeAppToken: " + wtoken); - removeAppFromTask(wtoken); wtoken.removed = true; if (wtoken.startingData != null) { @@ -4926,6 +4934,21 @@ public class WindowManagerService extends IWindowManager.Stub } } + void removeTaskLocked(Task task) { + final int taskId = task.taskId; + final TaskStack stack = task.mStack; + if (stack.isAnimating()) { + if (DEBUG_STACK) Slog.i(TAG, "removeTask: deferring removing taskId=" + taskId); + task.mDeferRemoval = true; + return; + } + if (DEBUG_STACK) Slog.i(TAG, "removeTask: removing taskId=" + taskId); + EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask"); + task.mDeferRemoval = false; + task.mStack.removeTask(task); + mTaskIdToTask.delete(task.taskId); + } + public void removeTask(int taskId) { synchronized (mWindowMap) { Task task = mTaskIdToTask.get(taskId); @@ -4933,14 +4956,14 @@ public class WindowManagerService extends IWindowManager.Stub if (DEBUG_STACK) Slog.i(TAG, "removeTask: could not find taskId=" + taskId); return; } - final TaskStack stack = task.mStack; - EventLog.writeEvent(EventLogTags.WM_TASK_REMOVED, taskId, "removeTask"); - stack.removeTask(task); + removeTaskLocked(task); } } public void addTask(int taskId, int stackId, boolean toTop) { synchronized (mWindowMap) { + if (DEBUG_STACK) Slog.i(TAG, "addTask: adding taskId=" + taskId + + " to " + (toTop ? "top" : "bottom")); Task task = mTaskIdToTask.get(taskId); if (task == null) { return; @@ -9365,7 +9388,7 @@ public class WindowManagerService extends IWindowManager.Stub token.mAppAnimator.animating = false; if (DEBUG_ADD_REMOVE || DEBUG_TOKEN_MOVEMENT) Slog.v(TAG, "performLayout: App token exiting now removed" + token); - removeAppFromTask(token); + removeAppFromTaskLocked(token); exitingAppTokens.remove(i); } } @@ -9458,6 +9481,11 @@ public class WindowManagerService extends IWindowManager.Stub } } + // Remove all deferred Stacks, tasks, and activities. + for (int stackNdx = mPendingStacksRemove.size() - 1; stackNdx >= 0; --stackNdx) { + mPendingStacksRemove.removeAt(stackNdx).checkForDeferredActions(); + } + setFocusedStackFrame(); // Check to see if we are now in a state where the screen should diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 5cff3197a336b..ffb17f1fb3745 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -416,7 +416,7 @@ class WindowStateAnimator { mService.mPendingRemove.add(mWin); mWin.mRemoveOnExit = false; } - mWin.getStack().checkForDeferredDetach(); + mService.mPendingStacksRemove.add(mWin.getStack()); mAnimator.hideWallpapersLocked(mWin); } From 13f0a3a43dcebcd949932782a86f57bad8b03956 Mon Sep 17 00:00:00 2001 From: Qiwen Zhao Date: Tue, 11 Feb 2014 10:56:43 -0800 Subject: [PATCH 010/102] reset to master for this file since it is missing an older change. --- core/jni/android_view_GLES20Canvas.cpp | 152 ------------------------- 1 file changed, 152 deletions(-) diff --git a/core/jni/android_view_GLES20Canvas.cpp b/core/jni/android_view_GLES20Canvas.cpp index 3e140efc61f53..dd089f2eeea08 100644 --- a/core/jni/android_view_GLES20Canvas.cpp +++ b/core/jni/android_view_GLES20Canvas.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include @@ -81,7 +80,6 @@ using namespace uirenderer; #define MODIFIER_SHADOW 1 #define MODIFIER_SHADER 2 -#define MODIFIER_COLOR_FILTER 4 // ---------------------------------------------------------------------------- @@ -638,7 +636,6 @@ static void android_view_GLES20Canvas_resetModifiers(JNIEnv* env, jobject clazz, OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); if (modifiers & MODIFIER_SHADOW) renderer->resetShadow(); if (modifiers & MODIFIER_SHADER) renderer->resetShader(); - if (modifiers & MODIFIER_COLOR_FILTER) renderer->resetColorFilter(); } static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz, @@ -648,12 +645,6 @@ static void android_view_GLES20Canvas_setupShader(JNIEnv* env, jobject clazz, renderer->setupShader(shader); } -static void android_view_GLES20Canvas_setupColorFilter(JNIEnv* env, jobject clazz, - jlong rendererPtr, jlong colorFilterPtr) { - OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); - SkiaColorFilter* colorFilter = reinterpret_cast(colorFilterPtr); - renderer->setupColorFilter(colorFilter); -} static void android_view_GLES20Canvas_setupShadow(JNIEnv* env, jobject clazz, jlong rendererPtr, jfloat radius, jfloat dx, jfloat dy, jint color) { @@ -923,148 +914,6 @@ static void android_view_GLES20Canvas_resume(JNIEnv* env, jobject clazz, renderer->resume(); } -<<<<<<< HEAD -static jint android_view_GLES20Canvas_createLayerRenderer(JNIEnv* env, - jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - OpenGLRenderer* renderer = new LayerRenderer(layer); - renderer->initProperties(); - return reinterpret_cast(renderer); - } - return NULL; -} - -static jlong android_view_GLES20Canvas_createTextureLayer(JNIEnv* env, jobject clazz, - jboolean isOpaque, jintArray layerInfo) { - Layer* layer = LayerRenderer::createTextureLayer(isOpaque); - - if (layer) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getTexture(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - } - - return reinterpret_cast(layer); -} - -static jlong android_view_GLES20Canvas_createLayer(JNIEnv* env, jobject clazz, - jint width, jint height, jboolean isOpaque, jintArray layerInfo) { - Layer* layer = LayerRenderer::createLayer(width, height, isOpaque); - - if (layer) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getWidth(); - storage[1] = layer->getHeight(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - } - - return reinterpret_cast(layer); -} - -static jboolean android_view_GLES20Canvas_resizeLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jint width, jint height, jintArray layerInfo) { - Layer* layer = reinterpret_cast(layerPtr); - if (LayerRenderer::resizeLayer(layer, width, height)) { - jint* storage = env->GetIntArrayElements(layerInfo, NULL); - storage[0] = layer->getWidth(); - storage[1] = layer->getHeight(); - env->ReleaseIntArrayElements(layerInfo, storage, 0); - return JNI_TRUE; - } - return JNI_FALSE; -} - -static void android_view_GLES20Canvas_setLayerPaint(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong paintPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - SkPaint* paint = reinterpret_cast(paintPtr); - layer->setPaint(paint); - } -} - -static void android_view_GLES20Canvas_setLayerColorFilter(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong colorFilterPtr) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - SkiaColorFilter* colorFilter = reinterpret_cast(colorFilterPtr); - layer->setColorFilter(colorFilter); - } -} - -static void android_view_GLES20Canvas_setOpaqueLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jboolean isOpaque) { - Layer* layer = reinterpret_cast(layerPtr); - if (layer) { - layer->setBlend(!isOpaque); - } -} - -static void android_view_GLES20Canvas_updateTextureLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jint width, jint height, jboolean isOpaque, jobject surface) { - float transform[16]; - sp surfaceTexture(SurfaceTexture_getSurfaceTexture(env, surface)); - - if (surfaceTexture->updateTexImage() == NO_ERROR) { - int64_t frameNumber = surfaceTexture->getFrameNumber(); - // If the GLConsumer queue is in synchronous mode, need to discard all - // but latest frame, using the frame number to tell when we no longer - // have newer frames to target. Since we can't tell which mode it is in, - // do this unconditionally. - int dropCounter = 0; - while (surfaceTexture->updateTexImage() == NO_ERROR) { - int64_t newFrameNumber = surfaceTexture->getFrameNumber(); - if (newFrameNumber == frameNumber) break; - frameNumber = newFrameNumber; - dropCounter++; - } - #if DEBUG_RENDERER - if (dropCounter > 0) { - RENDERER_LOGD("Dropped %d frames on texture layer update", dropCounter); - } - #endif - surfaceTexture->getTransformMatrix(transform); - GLenum renderTarget = surfaceTexture->getCurrentTextureTarget(); - - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::updateTextureLayer(layer, width, height, isOpaque, renderTarget, transform); - } -} - -static void android_view_GLES20Canvas_updateRenderLayer(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong rendererPtr, jlong displayListPtr, - jint left, jint top, jint right, jint bottom) { - Layer* layer = reinterpret_cast(layerPtr); - OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); - DisplayList* displayList = reinterpret_cast(displayListPtr); - layer->updateDeferred(renderer, displayList, left, top, right, bottom); -} - -static void android_view_GLES20Canvas_clearLayerTexture(JNIEnv* env, jobject clazz, - jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - layer->clearTexture(); -} - -static void android_view_GLES20Canvas_setTextureLayerTransform(JNIEnv* env, jobject clazz, - jlong layerPtr, jlong matrixPtr) { - Layer* layer = reinterpret_cast(layerPtr); - SkMatrix* matrix = reinterpret_cast(matrixPtr); - layer->getTransform().load(*matrix); -} - -static void android_view_GLES20Canvas_destroyLayer(JNIEnv* env, jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::destroyLayer(layer); -} - -static void android_view_GLES20Canvas_destroyLayerDeferred(JNIEnv* env, - jobject clazz, jlong layerPtr) { - Layer* layer = reinterpret_cast(layerPtr); - LayerRenderer::destroyLayerDeferred(layer); -} - static void android_view_GLES20Canvas_drawLayer(JNIEnv* env, jobject clazz, jlong rendererPtr, jlong layerPtr, jfloat x, jfloat y) { OpenGLRenderer* renderer = reinterpret_cast(rendererPtr); @@ -1223,7 +1072,6 @@ static JNINativeMethod gMethods[] = { { "nResetModifiers", "(JI)V", (void*) android_view_GLES20Canvas_resetModifiers }, { "nSetupShader", "(JJ)V", (void*) android_view_GLES20Canvas_setupShader }, - { "nSetupColorFilter", "(JJ)V", (void*) android_view_GLES20Canvas_setupColorFilter }, { "nSetupShadow", "(JFFFI)V", (void*) android_view_GLES20Canvas_setupShadow }, { "nSetupPaintFilter", "(JII)V", (void*) android_view_GLES20Canvas_setupPaintFilter }, From 0590ac70a93c713c6cf28c3bcbce287d9864f037 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 21:27:13 -0800 Subject: [PATCH 011/102] Add new phone type (public API) DO NOT MERGE This CL adds a new public API to allow services to implement calls. Change-Id: If6fef93aebc8b199880ad44d35b7d8ae69f71f9e --- .../android/telephony/TelephonyManager.java | 16 +++++++++++++ .../telephony/ThirdPartyCallListener.java | 23 ++++++++++++------- .../telephony/ThirdPartyCallProvider.java | 22 +----------------- .../telephony/ThirdPartyCallService.java | 8 ++++--- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3d416fbe3b33f..27231187ec2ae 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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. */ diff --git a/telephony/java/android/telephony/ThirdPartyCallListener.java b/telephony/java/android/telephony/ThirdPartyCallListener.java index 00265f8665dd0..08f8d3aa13f4f 100644 --- a/telephony/java/android/telephony/ThirdPartyCallListener.java +++ b/telephony/java/android/telephony/ThirdPartyCallListener.java @@ -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) { } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index bd8a1ead7e6c2..9d3f929a22bc7 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -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; } } }; diff --git a/telephony/java/android/telephony/ThirdPartyCallService.java b/telephony/java/android/telephony/ThirdPartyCallService.java index 6eddb4360ffd0..de6c2903dcd6c 100644 --- a/telephony/java/android/telephony/ThirdPartyCallService.java +++ b/telephony/java/android/telephony/ThirdPartyCallService.java @@ -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"); From b47ed4f44a8ef802143fbc68d24384b4847ad834 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 12 Feb 2014 06:02:26 +0000 Subject: [PATCH 012/102] Revert "Add new phone type (public API) DO NOT MERGE" This reverts commit 0590ac70a93c713c6cf28c3bcbce287d9864f037. Change-Id: I1f4b34c0f8246bb601e2ba5f14eabe9c36d33d94 --- .../android/telephony/TelephonyManager.java | 16 ------------- .../telephony/ThirdPartyCallListener.java | 23 +++++++------------ .../telephony/ThirdPartyCallProvider.java | 22 +++++++++++++++++- .../telephony/ThirdPartyCallService.java | 8 +++---- 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 27231187ec2ae..3d416fbe3b33f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -18,7 +18,6 @@ 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; @@ -1422,21 +1421,6 @@ 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. */ diff --git a/telephony/java/android/telephony/ThirdPartyCallListener.java b/telephony/java/android/telephony/ThirdPartyCallListener.java index 08f8d3aa13f4f..00265f8665dd0 100644 --- a/telephony/java/android/telephony/ThirdPartyCallListener.java +++ b/telephony/java/android/telephony/ThirdPartyCallListener.java @@ -16,8 +16,6 @@ package android.telephony; -import android.os.Handler; -import android.os.Message; import android.os.RemoteException; import com.android.internal.telephony.IThirdPartyCallListener; @@ -29,12 +27,15 @@ import com.android.internal.telephony.IThirdPartyCallListener; public class ThirdPartyCallListener { private final IThirdPartyCallListener mListener; - // Call end reason. + // Call end reason. TODO: rename this to DisconnectCause once they are public. 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; } @@ -44,9 +45,7 @@ public class ThirdPartyCallListener { */ public void onCallProviderAttached(ThirdPartyCallProvider callProvider) { try { - if (mListener != null) { - mListener.onCallProviderAttached(callProvider.callback); - } + mListener.onCallProviderAttached(callProvider.getCallback()); } catch (RemoteException e) { } } @@ -56,9 +55,7 @@ public class ThirdPartyCallListener { */ public void onRingingStarted() { try { - if (mListener != null) { - mListener.onRingingStarted(); - } + mListener.onRingingStarted(); } catch (RemoteException e) { } } @@ -68,9 +65,7 @@ public class ThirdPartyCallListener { */ public void onCallEstablished() { try { - if (mListener != null) { - mListener.onCallEstablished(); - } + mListener.onCallEstablished(); } catch (RemoteException e) { } } @@ -80,9 +75,7 @@ public class ThirdPartyCallListener { */ public void onCallEnded(int reason) { try { - if (mListener != null) { - mListener.onCallEnded(reason); - } + mListener.onCallEnded(reason); } catch (RemoteException e) { } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 9d3f929a22bc7..bd8a1ead7e6c2 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -29,6 +29,7 @@ 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. @@ -51,7 +52,18 @@ public class ThirdPartyCallProvider { // default implementation empty } - final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { + /** + * 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() { @Override public void mute(boolean shouldMute) { Message.obtain(mHandler, MSG_MUTE, shouldMute ? 1 : 0, 0).sendToTarget(); @@ -66,6 +78,11 @@ 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() { @@ -81,6 +98,9 @@ public class ThirdPartyCallProvider { case MSG_INCOMING_CALL_ACCEPT: incomingCallAccept(); break; + case MSG_SEND_DTMF: + sendDtmf((char) msg.arg1); + break; } } }; diff --git a/telephony/java/android/telephony/ThirdPartyCallService.java b/telephony/java/android/telephony/ThirdPartyCallService.java index de6c2903dcd6c..6eddb4360ffd0 100644 --- a/telephony/java/android/telephony/ThirdPartyCallService.java +++ b/telephony/java/android/telephony/ThirdPartyCallService.java @@ -19,7 +19,6 @@ 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; @@ -40,8 +39,7 @@ public class ThirdPartyCallService { } /** - * Call to attach to an incoming call. This is in response to a call to {@link - * android.telephony.TelephonyManager#newIncomingThirdPartyCall newIncomingThirdPartyCall}. + * Call to attach to an incoming call. */ public void incomingCallAttach(ThirdPartyCallListener listener, String callId) { // default implementation empty @@ -51,10 +49,10 @@ public class ThirdPartyCallService { * Returns an IBinder instance that can returned from the service's onBind function. */ public IBinder getBinder() { - return callback; + return mCallback; } - private final IThirdPartyCallService.Stub callback = new IThirdPartyCallService.Stub() { + private final IThirdPartyCallService.Stub mCallback = new IThirdPartyCallService.Stub() { @Override public void outgoingCallInitiate(IThirdPartyCallListener listener, String number) { Rlog.w("ThirdPartyPhone", "ThirdPartyCallService.IThirdPartyCallService.out"); From aae9216320328e6b865725219a31a029ea46c1b0 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:08:33 -0800 Subject: [PATCH 013/102] 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 --- api/current.txt | 3 +-- .../android/telephony/TelephonyManager.java | 16 +++++++++++++ .../telephony/ThirdPartyCallListener.java | 23 ++++++++++++------- .../telephony/ThirdPartyCallProvider.java | 22 +----------------- .../telephony/ThirdPartyCallService.java | 8 ++++--- .../internal/telephony/ITelephony.aidl | 12 +++++++++- .../telephony/IThirdPartyCallProvider.aidl | 5 ---- .../telephony/IThirdPartyCallService.aidl | 3 ++- .../internal/telephony/PhoneConstants.java | 1 + .../internal/telephony/RILConstants.java | 1 + 10 files changed, 53 insertions(+), 41 deletions(-) diff --git a/api/current.txt b/api/current.txt index 3ebd522cc0c98..f454a8f8e3fdc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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; } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 3d416fbe3b33f..27231187ec2ae 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -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. */ diff --git a/telephony/java/android/telephony/ThirdPartyCallListener.java b/telephony/java/android/telephony/ThirdPartyCallListener.java index 00265f8665dd0..08f8d3aa13f4f 100644 --- a/telephony/java/android/telephony/ThirdPartyCallListener.java +++ b/telephony/java/android/telephony/ThirdPartyCallListener.java @@ -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) { } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index bd8a1ead7e6c2..9d3f929a22bc7 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -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; } } }; diff --git a/telephony/java/android/telephony/ThirdPartyCallService.java b/telephony/java/android/telephony/ThirdPartyCallService.java index 6eddb4360ffd0..de6c2903dcd6c 100644 --- a/telephony/java/android/telephony/ThirdPartyCallService.java +++ b/telephony/java/android/telephony/ThirdPartyCallService.java @@ -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"); diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 370e27a415883..eb6c66fce74fc 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -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); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index a9d67a4e91f7d..dcbf877a587ac 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -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); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl index c9ee4ed46ef89..597567af02eae 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl @@ -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); } diff --git a/telephony/java/com/android/internal/telephony/PhoneConstants.java b/telephony/java/com/android/internal/telephony/PhoneConstants.java index fc6c99722351f..ade024fa471f4 100644 --- a/telephony/java/com/android/internal/telephony/PhoneConstants.java +++ b/telephony/java/com/android/internal/telephony/PhoneConstants.java @@ -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; diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java index 6015df0dcfd51..b8b90ee0183ec 100644 --- a/telephony/java/com/android/internal/telephony/RILConstants.java +++ b/telephony/java/com/android/internal/telephony/RILConstants.java @@ -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; From 960fe9a5ff2a629d62e3252a37e4ec598af54b6a Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:18:35 -0800 Subject: [PATCH 014/102] ThirdPartyPhone: DTMF & callerDisplayName API DO NOT MERGE This CL extends the ThirdPartyCall API to support DTMF and callerDisplayname. Change-Id: Ia3b4730e852a95d0c11fbddfbe1b780aec39dbb5 --- api/current.txt | 4 +++- .../java/android/telephony/TelephonyManager.java | 7 +++++-- .../telephony/ThirdPartyCallProvider.java | 16 ++++++++++++++++ .../android/internal/telephony/ITelephony.aidl | 5 ++++- .../telephony/IThirdPartyCallProvider.aidl | 5 +++++ 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index f454a8f8e3fdc..d5b976b483474 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24518,7 +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); + method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String, 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 @@ -24582,6 +24582,7 @@ 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,6 +34081,7 @@ 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; } } diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 27231187ec2ae..0e54d0f9afd24 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1428,10 +1428,13 @@ public class TelephonyManager { * @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}. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - public void newIncomingThirdPartyCall(ComponentName component, String callId) { + public void newIncomingThirdPartyCall(ComponentName component, String callId, + String callerDisplayName) { try { - getITelephony().newIncomingThirdPartyCall(component, callId); + getITelephony().newIncomingThirdPartyCall(component, callId, callerDisplayName); } catch (RemoteException ex) { } catch (NullPointerException ex) { } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 9d3f929a22bc7..74b9ae373485f 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -29,6 +29,7 @@ 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. @@ -51,6 +52,13 @@ 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 + } + final IThirdPartyCallProvider callback = new IThirdPartyCallProvider.Stub() { @Override public void mute(boolean shouldMute) { @@ -66,6 +74,11 @@ 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() { @@ -81,6 +94,9 @@ public class ThirdPartyCallProvider { case MSG_INCOMING_CALL_ACCEPT: incomingCallAccept(); break; + case MSG_SEND_DTMF: + sendDtmf((char) msg.arg1); + break; } } }; diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index eb6c66fce74fc..a22e6b6d7b839 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -420,6 +420,9 @@ interface ITelephony { * identified by component to handle the call. * @param component the component that should handle the intent. * @param callId the unique id of the call. + * @param callerDisplayName the name shown to the user. Normally this will be the caller's phone + * number. */ - void newIncomingThirdPartyCall(in ComponentName component, String callId); + void newIncomingThirdPartyCall(in ComponentName component, String callId, + String callerDisplayName); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index dcbf877a587ac..a9d67a4e91f7d 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -38,4 +38,9 @@ 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); } From 512b28309d3ee5dd506e62fb14913047b6049236 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:22:42 -0800 Subject: [PATCH 015/102] DO NOT MERGE ThirdPartyCallSendDtmfCallBack API This API is needed to implement post dial. Change-Id: Iefdeae81d0eae6be86e7ee1e8ab0251ae43ed079 --- Android.mk | 1 + api/current.txt | 13 +++++- .../telephony/ThirdPartyCallProvider.java | 11 +++-- .../ThirdPartyCallSendDtmfCallback.java | 46 +++++++++++++++++++ .../telephony/IThirdPartyCallProvider.aidl | 3 +- .../IThirdPartyCallSendDtmfCallback.aidl | 27 +++++++++++ 6 files changed, 94 insertions(+), 7 deletions(-) create mode 100644 telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java create mode 100644 telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl diff --git a/Android.mk b/Android.mk index d478a59773c70..1868dcbe1e377 100644 --- a/Android.mk +++ b/Android.mk @@ -277,6 +277,7 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallListener.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl \ + telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl \ telephony/java/com/android/internal/telephony/IThirdPartyCallService.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ diff --git a/api/current.txt b/api/current.txt index d5b976b483474..414169f134e19 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24582,7 +24582,12 @@ package android.telephony { method public void hangup(); method public void incomingCallAccept(); method public void mute(boolean); - method public void sendDtmf(char); + method public void sendDtmf(char, android.telephony.ThirdPartyCallSendDtmfCallback); + } + + public class ThirdPartyCallSendDtmfCallback { + ctor public ThirdPartyCallSendDtmfCallback(com.android.internal.telephony.IThirdPartyCallSendDtmfCallback); + method public void onSendDtmfCompleted(); } public class ThirdPartyCallService { @@ -34081,7 +34086,11 @@ 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; + method public abstract void sendDtmf(char, com.android.internal.telephony.IThirdPartyCallSendDtmfCallback) throws android.os.RemoteException; + } + + public abstract interface IThirdPartyCallSendDtmfCallback implements android.os.IInterface { + method public abstract void onSendDtmfCompleted() throws android.os.RemoteException; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallProvider.java b/telephony/java/android/telephony/ThirdPartyCallProvider.java index 74b9ae373485f..5054380f51343 100644 --- a/telephony/java/android/telephony/ThirdPartyCallProvider.java +++ b/telephony/java/android/telephony/ThirdPartyCallProvider.java @@ -20,6 +20,7 @@ import android.os.Handler; import android.os.Message; import com.android.internal.telephony.IThirdPartyCallProvider; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to {@link android.telephony.ThirdPartyCallListener#onCallProviderAttached @@ -55,7 +56,7 @@ public class ThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - public void sendDtmf(char c) { + public void sendDtmf(char c, ThirdPartyCallSendDtmfCallback callback) { // default implementation empty } @@ -76,8 +77,8 @@ public class ThirdPartyCallProvider { } @Override - public void sendDtmf(char c) { - Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0).sendToTarget(); + public void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback) { + Message.obtain(mHandler, MSG_SEND_DTMF, (int) c, 0, callback).sendToTarget(); } }; @@ -95,7 +96,9 @@ public class ThirdPartyCallProvider { incomingCallAccept(); break; case MSG_SEND_DTMF: - sendDtmf((char) msg.arg1); + ThirdPartyCallSendDtmfCallback callback = new ThirdPartyCallSendDtmfCallback( + (IThirdPartyCallSendDtmfCallback) msg.obj); + sendDtmf((char) msg.arg1, callback); break; } } diff --git a/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java new file mode 100644 index 0000000000000..5a67cf76bf98d --- /dev/null +++ b/telephony/java/android/telephony/ThirdPartyCallSendDtmfCallback.java @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.os.RemoteException; + +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; + +/** + * Callback interface for when DTMF has been sent. + */ +public class ThirdPartyCallSendDtmfCallback { + private final IThirdPartyCallSendDtmfCallback mCallback; + + public ThirdPartyCallSendDtmfCallback(IThirdPartyCallSendDtmfCallback callback) { + if (callback == null) { + throw new IllegalArgumentException("Invalid callback"); + } + mCallback = callback; + } + + /** + * Called by the service when a call provider is available to perform the outgoing or incoming + * call. + */ + public void onSendDtmfCompleted() { + try { + mCallback.onSendDtmfCompleted(); + } catch (RemoteException e) { + } + } +} diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl index a9d67a4e91f7d..9d595b0b1b5a1 100644 --- a/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallProvider.aidl @@ -17,6 +17,7 @@ package com.android.internal.telephony; import com.android.internal.telephony.IThirdPartyCallListener; +import com.android.internal.telephony.IThirdPartyCallSendDtmfCallback; /** * Interface sent to ThirdPartyCallListener.onCallProviderAttached. This is used to control an @@ -42,5 +43,5 @@ oneway interface IThirdPartyCallProvider { /** * Sends the given DTMF code. The code can be '0'-'9', 'A'-'D', '#', or '*'. */ - void sendDtmf(char c); + void sendDtmf(char c, IThirdPartyCallSendDtmfCallback callback); } diff --git a/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl new file mode 100644 index 0000000000000..3a02b06055d06 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/IThirdPartyCallSendDtmfCallback.aidl @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +/** + * Callback interface for when DTMF has been sent. + */ +oneway interface IThirdPartyCallSendDtmfCallback { + /** + * Called when the DTMF code has been sent. + */ + void onSendDtmfCompleted(); +} From 1bd7876d76167922f38d78747c5696c82020c1ea Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:32:21 -0800 Subject: [PATCH 016/102] Add Wi-Fi calling state setting to telephony interfaces Change-Id: I01029ade0eb1ff981cb92a536d042a02129a053f --- core/java/android/provider/Settings.java | 8 ++++ .../android/telephony/TelephonyManager.java | 40 +++++++++++++++++++ .../internal/telephony/ITelephony.aidl | 14 +++++++ 3 files changed, 62 insertions(+) diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index 9332578b62422..d7f6a0bc56a9c 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -2483,6 +2483,14 @@ public final class Settings { NOTIFICATION_SOUND }; + /** + * When to use Wi-Fi calling + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + * @hide + */ + public static final String WHEN_TO_MAKE_WIFI_CALLS = "when_to_make_wifi_calls"; + // Settings moved to Settings.Secure /** diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 0e54d0f9afd24..5902b9c17411f 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -62,6 +62,20 @@ public class TelephonyManager { private static ITelephonyRegistry sRegistry; private final Context mContext; + /** + * The allowed states of Wi-Fi calling. + * + * @hide + */ + public interface WifiCallingChoices { + /** Always use Wi-Fi calling */ + static final int ALWAYS_USE = 0; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 1; + /** Ask the user whether to use Wi-Fi on every call */ + static final int ASK_EVERY_TIME = 2; + } + /** @hide */ public TelephonyManager(Context context) { Context appContext = context.getApplicationContext(); @@ -1617,5 +1631,31 @@ public class TelephonyManager { Rlog.e(TAG, "setRadioMode NPE", ex); } return false; + + /* + * Obtain the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public int getWhenToMakeWifiCalls() { + try { + return getITelephony().getWhenToMakeWifiCalls(); + } catch (RemoteException ex) { + return WifiCallingChoices.NEVER_USE; + } + } + + /** + * Set the current state of Wi-Fi calling. + * + * @hide + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + public void setWhenToMakeWifiCalls(int state) { + try { + getITelephony().setWhenToMakeWifiCalls(state); + } catch (RemoteException ex) { + } } } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index a22e6b6d7b839..3ff5a52180364 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -425,4 +425,18 @@ interface ITelephony { */ void newIncomingThirdPartyCall(in ComponentName component, String callId, String callerDisplayName); + + /** + * Obtain the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + int getWhenToMakeWifiCalls(); + + /** + * Set the current state of Wi-Fi calling. + * + * @see android.telephony.TelephonyManager.WifiCallingChoices + */ + void setWhenToMakeWifiCalls(int state); } From eaeb071a1751c9813612a1e3e2ec2450ea0d7a73 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:36:26 -0800 Subject: [PATCH 017/102] Add interface definitions for CallService/PhoneService Interfaces are meant to replace ThirdParty*.aidl/java files in same directory long term. The differences in methods are on purpose and reflect more recent design directions. Change-Id: Ia98603a1d0b6d07a3393c5f7c5aa040f9e3916e4 --- Android.mk | 2 + .../android/internal/telephony/CallInfo.aidl | 19 +++++ .../android/internal/telephony/CallInfo.java | 77 +++++++++++++++++++ .../internal/telephony/ICallService.aidl | 61 +++++++++++++++ .../telephony/ICallServiceAdapter.aidl | 61 +++++++++++++++ 5 files changed, 220 insertions(+) create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.aidl create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.java create mode 100644 telephony/java/com/android/internal/telephony/ICallService.aidl create mode 100644 telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl diff --git a/Android.mk b/Android.mk index 1868dcbe1e377..26e1b56f5e065 100644 --- a/Android.mk +++ b/Android.mk @@ -272,6 +272,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRemoteDisplayProvider.aidl \ media/java/android/media/IRemoteVolumeObserver.aidl \ media/java/android/media/IRingtonePlayer.aidl \ + telephony/java/com/android/internal/telephony/ICallService.aidl \ + telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telephony/java/com/android/internal/telephony/CallInfo.aidl b/telephony/java/com/android/internal/telephony/CallInfo.aidl new file mode 100644 index 0000000000000..9140388587845 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.aidl @@ -0,0 +1,19 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +parcelable CallInfo; diff --git a/telephony/java/com/android/internal/telephony/CallInfo.java b/telephony/java/com/android/internal/telephony/CallInfo.java new file mode 100644 index 0000000000000..6bfc9d73e8c5c --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.java @@ -0,0 +1,77 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A parcelable holder class of Call information data. + */ +public class CallInfo implements Parcelable { + + /** + * Endpoint to which the call is connected. + * This could be the dialed value for outgoing calls or the caller id of incoming calls. + */ + private String handle; + + public CallInfo(String handle) { + this.handle = handle; + } + + public String getHandle() { + return handle; + } + + // + // Parcelling related code below here. + // + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator () { + + @Override + public CallInfo createFromParcel(Parcel source) { + return new CallInfo(source.readString()); + } + + @Override + public CallInfo[] newArray(int size) { + return new CallInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(handle); + } +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl new file mode 100644 index 0000000000000..a24c860d08cd6 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Service interface for services which would like to provide calls to be + * managed by the system in-call UI. + * + * This interface provides methods that the android framework can use to deliver commands + * for calls provided by this call service including making new calls and disconnecting + * existing ones. A binding to ICallService implementations exists for two conditions: + * 1) There exists one or more live calls for that call service, + * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + */ +oneway interface ICallService { + + /** + * Determines if the CallService can make calls to the handle. + * TODO(santoscordon): Move this method into its own service interface long term. + * TODO(santoscordon): Add response callback parameter. + */ + void isCompatibleWith(String handle); + + /** + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. + * TODO(santoscordon): Should this have a response attached to it to ensure that the call + * service actually plans to make the call? + */ + void call(String handle); + + /** + * Disconnects the call identified by callId. + */ + void disconnect(String callId); + + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); +} diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl new file mode 100644 index 0000000000000..bc900f00d71ae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.CallInfo; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + */ +oneway interface ICallServiceAdapter { + + /** + * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall. + */ + void getNextCallId(/* TODO(santoscordon): Needs response object */); + + /** + * Tells CallsManager of a new incoming call. + */ + void newIncomingCall(String callId, in CallInfo info); + + /** + * Tells CallsManager of a new outgoing call. + */ + void newOutgoingCall(String callId, in CallInfo info); + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + */ + void setActive(String callId); + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + */ + void setRinging(String callId); + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + */ + void setDialing(String callId); + + /** + * Sets a call's state to disconnected. + */ + void setDisconnected(String callId); +} From bdd484f6f263f44f31709b71c4d2843442fd830a Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:51:32 -0800 Subject: [PATCH 018/102] Add abstract base implementation of CallService. Base implementation takes care of a lot of boilerplate code. Change-Id: Iaf5a16f5718727cee0f7efb4af53a021536f50d8 --- .../java/android/telephony/CallService.java | 165 ++++++++++++++++++ .../internal/telephony/ICallService.aidl | 2 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 telephony/java/android/telephony/CallService.java diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java new file mode 100644 index 0000000000000..0ea55b283e7c3 --- /dev/null +++ b/telephony/java/android/telephony/CallService.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import com.android.internal.telephony.ICallService; +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Base implementation of CallService which can be used to provide calls for the system + * in-call UI. CallService is a one-way service from the framework's CallsManager to any app + * that would like to provide calls managed by the default system in-call user interface. + * When the service is bound by the framework, CallsManager will call setCallServiceAdapter + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * for communicating back to CallsManager. Subsequently, more specific methods of the service + * will be called to perform various call actions including making an outgoing call and + * disconnected existing calls. + * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before + * we can unhide this API. + * + * Most public methods of this function are backed by a one-way AIDL interface which precludes + * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * response objects instead of return values. + * TODO(santoscordon): Improve paragraph above once the final design is in place. + * @hide + */ +public abstract class CallService extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_ADAPTER: + setCallServiceAdapter((ICallServiceAdapter) msg.obj); + break; + case MSG_IS_COMPATIBLE_WITH: + isCompatibleWith((String) msg.obj); + break; + case MSG_CALL: + call((String) msg.obj); + break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallService implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceWrapper extends ICallService.Stub { + @Override + public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) + .sendToTarget(); + } + + @Override + public void isCompatibleWith(String handle) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + } + + @Override + public void call(String handle) { + mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int + MSG_SET_CALL_SERVICE_ADAPTER = 1, + MSG_IS_COMPATIBLE_WITH = 2, + MSG_CALL = 3, + MSG_DISCONNECT = 4; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceMessageHandler}. + */ + private final CallServiceMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallService} interface. + */ + private final CallServiceWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallService() { + mMessageHandler = new CallServiceMessageHandler(); + mBinder = new CallServiceWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * changes of existing calls. + * @param callServiceAdapter Adapter object for communicating call to CallsManager + * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we + * wrap that in a wrapper like we do for CallService/ICallService? + * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. + */ + public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + + /** + * Determines if the CallService can make calls to the handle. + * @param handle The handle to test for compatibility. + * TODO(santoscordon): Need response parameter. + */ + public abstract void isCompatibleWith(String handle); + + /** + * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, + * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the + * same handle and this service is selected by the switchboard to handle the call. + * @param handle The handle to call. + */ + public abstract void call(String handle); + + /** + * Disconnects the specified call. + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl index a24c860d08cd6..cb9b2e838ddf9 100644 --- a/telephony/java/com/android/internal/telephony/ICallService.aidl +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -57,5 +57,5 @@ oneway interface ICallService { * and communicate state changes of existing calls. This is the first method that is called * after a the framework binds to the call service. */ - void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); } From 2cde710fe42b706b368aec9b85f134f2d2452f7f Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:54:58 -0800 Subject: [PATCH 019/102] Update TelephonyManager.WifiCallingChoices API This CL updates the order of the WifiCallingChoices values to match the wifi_calling_choice_values resource. Change-Id: Iaa643d7a70938877c760ff4a65f737a4c1c750da --- api/current.txt | 1 + telephony/java/android/telephony/TelephonyManager.java | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index 414169f134e19..a47267b3883d0 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24512,6 +24512,7 @@ package android.telephony { method public java.lang.String getSubscriberId(); method public java.lang.String getVoiceMailAlphaTag(); method public java.lang.String getVoiceMailNumber(); + method public int getWhenToMakeWifiCalls(); method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); method public int iccOpenLogicalChannel(java.lang.String); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 5902b9c17411f..ec1f1df49174a 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -70,10 +70,10 @@ public class TelephonyManager { public interface WifiCallingChoices { /** Always use Wi-Fi calling */ static final int ALWAYS_USE = 0; - /** Never use Wi-Fi calling */ - static final int NEVER_USE = 1; /** Ask the user whether to use Wi-Fi on every call */ - static final int ASK_EVERY_TIME = 2; + static final int ASK_EVERY_TIME = 1; + /** Never use Wi-Fi calling */ + static final int NEVER_USE = 2; } /** @hide */ @@ -1631,6 +1631,7 @@ public class TelephonyManager { Rlog.e(TAG, "setRadioMode NPE", ex); } return false; + } /* * Obtain the current state of Wi-Fi calling. From 6eac2ee0fc8a652c4cb1e7ca6602a080d4f82dbd Mon Sep 17 00:00:00 2001 From: Derek Tan Date: Tue, 4 Feb 2014 12:05:05 -0800 Subject: [PATCH 020/102] Expose sendEnvelope. Change-Id: I21565fae9ba8f163aed9104db355aecf9bae1796 --- api/current.txt | 1 + .../android/telephony/TelephonyManager.java | 38 +++++++++++++++++-- .../internal/telephony/ITelephony.aidl | 11 ++++++ 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index a47267b3883d0..62b2262463c0d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24516,6 +24516,7 @@ package android.telephony { method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); method public int iccOpenLogicalChannel(java.lang.String); + method public java.lang.String sendEnvelope(java.lang.String); 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); diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index ec1f1df49174a..c8efcea88e40c 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1477,12 +1477,15 @@ public class TelephonyManager { * * Input parameters equivalent to TS 27.007 AT+CCHO command. * + *

Requires Permission: + * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} + * * @param AID Application id. See ETSI 102.221 and 101.220. * @return The logical channel id which is negative on error. */ public int iccOpenLogicalChannel(String AID) { try { - return getITelephony().iccOpenLogicalChannel(AID); + return getITelephony().iccOpenLogicalChannel(AID); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1494,13 +1497,16 @@ public class TelephonyManager { * * Input parameters equivalent to TS 27.007 AT+CCHC command. * + *

Requires Permission: + * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} + * * @param channel is the channel id to be closed as retruned by a successful * iccOpenLogicalChannel. * @return true if the channel was closed successfully. */ public boolean iccCloseLogicalChannel(int channel) { try { - return getITelephony().iccCloseLogicalChannel(channel); + return getITelephony().iccCloseLogicalChannel(channel); } catch (RemoteException ex) { } catch (NullPointerException ex) { } @@ -1512,6 +1518,9 @@ public class TelephonyManager { * * Input parameters equivalent to TS 27.007 AT+CGLA command. * + *

Requires Permission: + * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} + * * @param channel is the channel id to be closed as returned by a successful * iccOpenLogicalChannel. * @param cla Class of the APDU command. @@ -1527,8 +1536,29 @@ public class TelephonyManager { public String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data) { try { - return getITelephony().iccTransmitApduLogicalChannel(channel, cla, - instruction, p1, p2, p3, data); + return getITelephony().iccTransmitApduLogicalChannel(channel, cla, + instruction, p1, p2, p3, data); + } catch (RemoteException ex) { + } catch (NullPointerException ex) { + } + return ""; + } + + /** + * Send ENVELOPE to the SIM, after processing a proactive command sent by + * the SIM. + * + *

Requires Permission: + * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} + * + * @param contents String containing SAT/USAT response in hexadecimal + * format starting with command tag. See TS 102 223 for + * details. + * @return The APDU response from the ICC card. + */ + public String sendEnvelope(String content) { + try { + return getITelephony().sendEnvelope(content); } catch (RemoteException ex) { } catch (NullPointerException ex) { } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 3ff5a52180364..5f490af7fd48a 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -368,6 +368,17 @@ interface ITelephony { String iccTransmitApduLogicalChannel(int channel, int cla, int instruction, int p1, int p2, int p3, String data); + /** + * Send ENVELOPE to the SIM, after processing a proactive command sent by + * the SIM. + * + * @param contents String containing SAT/USAT response in hexadecimal + * format starting with command tag. See TS 102 223 for + * details. + * @return The APDU response from the ICC card. + */ + String sendEnvelope(String content); + /** * Read one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. * Used for device configuration by some CDMA operators. From ded7d1871d702ce628bb8041f28677c801179a38 Mon Sep 17 00:00:00 2001 From: Derek Tan Date: Thu, 13 Feb 2014 14:49:26 -0800 Subject: [PATCH 021/102] Fix the inconsistent name on @param and the real param. Change-Id: If9853e91f55c0be89cdf77ae7c4369f274a45bb6 --- telephony/java/android/telephony/TelephonyManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index e5f9a5502ca31..108310e7eb7f5 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1812,9 +1812,9 @@ public class TelephonyManager { *

Requires Permission: * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} * - * @param contents String containing SAT/USAT response in hexadecimal - * format starting with command tag. See TS 102 223 for - * details. + * @param content String containing SAT/USAT response in hexadecimal + * format starting with command tag. See TS 102 223 for + * details. * @return The APDU response from the ICC card. */ public String sendEnvelope(String content) { From 7d855704ad5c60ce27d10d912d6d1da55499fa8e Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 20 Nov 2013 13:22:28 -0800 Subject: [PATCH 022/102] Add interface definitions for CallService/PhoneService Interfaces are meant to replace ThirdParty*.aidl/java files in same directory long term. The differences in methods are on purpose and reflect more recent design directions. Change-Id: Ia5ece7149b228a44758e659a4cabfc0676d1c499 From bbc743607ad2c7e2cd848410e3e37a91a51f474a Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 26 Nov 2013 11:50:49 -0800 Subject: [PATCH 023/102] Add abstract base implementation of CallService. Base implementation takes care of a lot of boilerplate code. Change-Id: Ic7ee3325f694f7df06d23501d77172b4770551bc From 09538ebd04b83abad2fac8ccc9845aa0c2a4f62c Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Wed, 11 Dec 2013 13:44:44 -0800 Subject: [PATCH 024/102] Initial frameworks/base/telecomm check in. Change-Id: Idd2bb597c4066f7f0c14da8fe277e969e52c0f00 --- telecomm/java/android/telecomm/README | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 telecomm/java/android/telecomm/README diff --git a/telecomm/java/android/telecomm/README b/telecomm/java/android/telecomm/README new file mode 100644 index 0000000000000..defca73548654 --- /dev/null +++ b/telecomm/java/android/telecomm/README @@ -0,0 +1,2 @@ +Mostly AIDL files to interface between the rest of the system and code under +/packages/services/Telecomm/src/com/android/telecomm. \ No newline at end of file From d13e1d2babf9e3d14d3fe661c7c701b3b18b3eca Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Thu, 12 Dec 2013 18:40:03 -0800 Subject: [PATCH 025/102] Remove the telecomm entries now that we have https://googleplex-android-review.git.corp.google.com/#/c/398927 DO NOT SUBMIT until the above CL is uploaded. Change-Id: I4e4f19175b502ba81c882d1379d1d225b0e6ba67 --- Android.mk | 2 - .../java/android/telephony/CallService.java | 165 ------------------ .../android/internal/telephony/CallInfo.aidl | 19 -- .../android/internal/telephony/CallInfo.java | 77 -------- .../internal/telephony/ICallService.aidl | 61 ------- .../telephony/ICallServiceAdapter.aidl | 61 ------- 6 files changed, 385 deletions(-) delete mode 100644 telephony/java/android/telephony/CallService.java delete mode 100644 telephony/java/com/android/internal/telephony/CallInfo.aidl delete mode 100644 telephony/java/com/android/internal/telephony/CallInfo.java delete mode 100644 telephony/java/com/android/internal/telephony/ICallService.aidl delete mode 100644 telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl diff --git a/Android.mk b/Android.mk index a6f1205a94675..9867b5b9ee58e 100644 --- a/Android.mk +++ b/Android.mk @@ -277,8 +277,6 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRemoteDisplayProvider.aidl \ media/java/android/media/IRemoteVolumeObserver.aidl \ media/java/android/media/IRingtonePlayer.aidl \ - telephony/java/com/android/internal/telephony/ICallService.aidl \ - telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java deleted file mode 100644 index 0ea55b283e7c3..0000000000000 --- a/telephony/java/android/telephony/CallService.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telephony; - -import android.app.Service; -import android.content.Intent; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; - -import com.android.internal.telephony.ICallService; -import com.android.internal.telephony.ICallServiceAdapter; - -/** - * Base implementation of CallService which can be used to provide calls for the system - * in-call UI. CallService is a one-way service from the framework's CallsManager to any app - * that would like to provide calls managed by the default system in-call user interface. - * When the service is bound by the framework, CallsManager will call setCallServiceAdapter - * which will provide CallService with an instance of {@link CallServiceAdapter} to be used - * for communicating back to CallsManager. Subsequently, more specific methods of the service - * will be called to perform various call actions including making an outgoing call and - * disconnected existing calls. - * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before - * we can unhide this API. - * - * Most public methods of this function are backed by a one-way AIDL interface which precludes - * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) - * response objects instead of return values. - * TODO(santoscordon): Improve paragraph above once the final design is in place. - * @hide - */ -public abstract class CallService extends Service { - - /** - * Default Handler used to consolidate binder method calls onto a single thread. - */ - private final class CallServiceMessageHandler extends Handler { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_SET_CALL_SERVICE_ADAPTER: - setCallServiceAdapter((ICallServiceAdapter) msg.obj); - break; - case MSG_IS_COMPATIBLE_WITH: - isCompatibleWith((String) msg.obj); - break; - case MSG_CALL: - call((String) msg.obj); - break; - case MSG_DISCONNECT: - disconnect((String) msg.obj); - break; - default: - break; - } - } - } - - /** - * Default ICallService implementation provided to CallsManager via {@link #onBind}. - */ - private final class CallServiceWrapper extends ICallService.Stub { - @Override - public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { - mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) - .sendToTarget(); - } - - @Override - public void isCompatibleWith(String handle) { - mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); - } - - @Override - public void call(String handle) { - mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); - } - - @Override - public void disconnect(String callId) { - mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); - } - } - - // Only used internally by this class. - // Binder method calls on this service can occur on multiple threads. These messages are used - // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a - // single thread. Keeping it on a single thread allows CallService implementations to avoid - // needing multi-threaded code in their own callback routines. - private static final int - MSG_SET_CALL_SERVICE_ADAPTER = 1, - MSG_IS_COMPATIBLE_WITH = 2, - MSG_CALL = 3, - MSG_DISCONNECT = 4; - - /** - * Message handler for consolidating binder callbacks onto a single thread. - * See {@link #CallServiceMessageHandler}. - */ - private final CallServiceMessageHandler mMessageHandler; - - /** - * Default binder implementation of {@link ICallService} interface. - */ - private final CallServiceWrapper mBinder; - - /** - * Protected constructor called only by subclasses creates the binder interface and - * single-threaded message handler. - */ - protected CallService() { - mMessageHandler = new CallServiceMessageHandler(); - mBinder = new CallServiceWrapper(); - } - - /** {@inheritDoc} */ - public IBinder onBind(Intent intent) { - return mBinder; - } - - /** - * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state - * changes of existing calls. - * @param callServiceAdapter Adapter object for communicating call to CallsManager - * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we - * wrap that in a wrapper like we do for CallService/ICallService? - * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. - */ - public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); - - /** - * Determines if the CallService can make calls to the handle. - * @param handle The handle to test for compatibility. - * TODO(santoscordon): Need response parameter. - */ - public abstract void isCompatibleWith(String handle); - - /** - * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, - * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the - * same handle and this service is selected by the switchboard to handle the call. - * @param handle The handle to call. - */ - public abstract void call(String handle); - - /** - * Disconnects the specified call. - * @param callId The ID of the call to disconnect. - */ - public abstract void disconnect(String callId); -} diff --git a/telephony/java/com/android/internal/telephony/CallInfo.aidl b/telephony/java/com/android/internal/telephony/CallInfo.aidl deleted file mode 100644 index 9140388587845..0000000000000 --- a/telephony/java/com/android/internal/telephony/CallInfo.aidl +++ /dev/null @@ -1,19 +0,0 @@ -/* -** Copyright 2013, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -package com.android.internal.telephony; - -parcelable CallInfo; diff --git a/telephony/java/com/android/internal/telephony/CallInfo.java b/telephony/java/com/android/internal/telephony/CallInfo.java deleted file mode 100644 index 6bfc9d73e8c5c..0000000000000 --- a/telephony/java/com/android/internal/telephony/CallInfo.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Copyright 2013, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -package com.android.internal.telephony; - -import android.os.Parcel; -import android.os.Parcelable; - -/** - * A parcelable holder class of Call information data. - */ -public class CallInfo implements Parcelable { - - /** - * Endpoint to which the call is connected. - * This could be the dialed value for outgoing calls or the caller id of incoming calls. - */ - private String handle; - - public CallInfo(String handle) { - this.handle = handle; - } - - public String getHandle() { - return handle; - } - - // - // Parcelling related code below here. - // - - /** - * Responsible for creating CallInfo objects for deserialized Parcels. - */ - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator () { - - @Override - public CallInfo createFromParcel(Parcel source) { - return new CallInfo(source.readString()); - } - - @Override - public CallInfo[] newArray(int size) { - return new CallInfo[size]; - } - }; - - /** - * {@inheritDoc} - */ - @Override - public int describeContents() { - return 0; - } - - /** - * Writes CallInfo object into a serializeable Parcel. - */ - @Override - public void writeToParcel(Parcel destination, int flags) { - destination.writeString(handle); - } -} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl deleted file mode 100644 index cb9b2e838ddf9..0000000000000 --- a/telephony/java/com/android/internal/telephony/ICallService.aidl +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.internal.telephony; - -import com.android.internal.telephony.ICallServiceAdapter; - -/** - * Service interface for services which would like to provide calls to be - * managed by the system in-call UI. - * - * This interface provides methods that the android framework can use to deliver commands - * for calls provided by this call service including making new calls and disconnecting - * existing ones. A binding to ICallService implementations exists for two conditions: - * 1) There exists one or more live calls for that call service, - * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. - */ -oneway interface ICallService { - - /** - * Determines if the CallService can make calls to the handle. - * TODO(santoscordon): Move this method into its own service interface long term. - * TODO(santoscordon): Add response callback parameter. - */ - void isCompatibleWith(String handle); - - /** - * Attempts to call the relevant party using the specified handle, be it a phone number, - * SIP address, or some other kind of user ID. Note that the set of handle types is - * dynamically extensible since call providers should be able to implement arbitrary - * handle-calling systems. See {@link #isCompatibleWith}. - * TODO(santoscordon): Should this have a response attached to it to ensure that the call - * service actually plans to make the call? - */ - void call(String handle); - - /** - * Disconnects the call identified by callId. - */ - void disconnect(String callId); - - /** - * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls - * and communicate state changes of existing calls. This is the first method that is called - * after a the framework binds to the call service. - */ - void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); -} diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl deleted file mode 100644 index bc900f00d71ae..0000000000000 --- a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.internal.telephony; - -import com.android.internal.telephony.CallInfo; - -/** - * Provides methods for ICallService implementations to interact with the system phone app. - */ -oneway interface ICallServiceAdapter { - - /** - * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall. - */ - void getNextCallId(/* TODO(santoscordon): Needs response object */); - - /** - * Tells CallsManager of a new incoming call. - */ - void newIncomingCall(String callId, in CallInfo info); - - /** - * Tells CallsManager of a new outgoing call. - */ - void newOutgoingCall(String callId, in CallInfo info); - - /** - * Sets a call's state to active (e.g., an ongoing call where two parties can actively - * communicate). - */ - void setActive(String callId); - - /** - * Sets a call's state to ringing (e.g., an inbound ringing call). - */ - void setRinging(String callId); - - /** - * Sets a call's state to dialing (e.g., dialing an outbound call). - */ - void setDialing(String callId); - - /** - * Sets a call's state to disconnected. - */ - void setDisconnected(String callId); -} From bb69b0c2d821a9806fb00037284c399cbc78277d Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Thu, 12 Dec 2013 18:32:02 -0800 Subject: [PATCH 026/102] Adding the frameworks/base code from https://googleplex-android-review.git.corp.google.com/#/c/391028 Change-Id: I6fe7aae52a7ff52da1a1e009e8361810fcaddd1e --- Android.mk | 3 + telecomm/java/android/telecomm/CallInfo.aidl | 19 +++++ telecomm/java/android/telecomm/CallInfo.java | 79 +++++++++++++++++++ .../java/android/telecomm/ICallService.aidl | 64 +++++++++++++++ .../android/telecomm/ICallServiceAdapter.aidl | 63 +++++++++++++++ 5 files changed, 228 insertions(+) create mode 100644 telecomm/java/android/telecomm/CallInfo.aidl create mode 100644 telecomm/java/android/telecomm/CallInfo.java create mode 100644 telecomm/java/android/telecomm/ICallService.aidl create mode 100644 telecomm/java/android/telecomm/ICallServiceAdapter.aidl diff --git a/Android.mk b/Android.mk index 9867b5b9ee58e..3c5a291d0d28d 100644 --- a/Android.mk +++ b/Android.mk @@ -426,6 +426,9 @@ aidl_files := \ frameworks/base/location/java/android/location/FusedBatchOptions.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderProperties.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \ + telecomm/java/android/telecomm/CallInfo.aidl \ + telecomm/java/android/telecomm/ICallService.aidl \ + telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ frameworks/base/telephony/java/android/telephony/ServiceState.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallInfo.aidl b/telecomm/java/android/telecomm/CallInfo.aidl new file mode 100644 index 0000000000000..bc5ef96394d8c --- /dev/null +++ b/telecomm/java/android/telecomm/CallInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright 2013, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +parcelable CallInfo; diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java new file mode 100644 index 0000000000000..8fe67a02d866d --- /dev/null +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -0,0 +1,79 @@ +/* + * Copyright 2013, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A parcelable holder class of Call information data. + * TODO(santoscordon): Need final public-facing comments in this file. + * @hide + */ +public final class CallInfo implements Parcelable { + + /** + * Endpoint to which the call is connected. + * This could be the dialed value for outgoing calls or the caller id of incoming calls. + */ + private String handle; + + public CallInfo(String handle) { + this.handle = handle; + } + + public String getHandle() { + return handle; + } + + // + // Parceling related code below here. + // + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator () { + + @Override + public CallInfo createFromParcel(Parcel source) { + return new CallInfo(source.readString()); + } + + @Override + public CallInfo[] newArray(int size) { + return new CallInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(handle); + } +} diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl new file mode 100644 index 0000000000000..09edadccc4620 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.ICallServiceAdapter; + +/** + * Service interface for services which would like to provide calls to be + * managed by the system in-call UI. + * + * This interface provides methods that the android framework can use to deliver commands + * for calls provided by this call service including making new calls and disconnecting + * existing ones. A binding to ICallService implementations exists for two conditions: + * 1) There exists one or more live calls for that call service, + * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + * + * TODO(santoscordon): Need final public-facing comments in this file. + * @hide + */ +oneway interface ICallService { + + /** + * Determines if the CallService can make calls to the handle. + * TODO(santoscordon): Move this method into its own service interface long term. + * TODO(santoscordon): Add response callback parameter. + */ + void isCompatibleWith(String handle); + + /** + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. + * TODO(santoscordon): Should this have a response attached to it to ensure that the call + * service actually plans to make the call? + */ + void call(String handle); + + /** + * Disconnects the call identified by callId. + */ + void disconnect(String callId); + + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); +} diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl new file mode 100644 index 0000000000000..af80e2a51425e --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.CallInfo; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + * TODO(santoscordon): Need final public-facing comments in this file. + * @hide + */ +oneway interface ICallServiceAdapter { + + /** + * Retrieves a new unique call ID for use with newOutgoingCall and newIncomingCall. + */ + void getNextCallId(/* TODO(santoscordon): Needs response object */); + + /** + * Tells CallsManager of a new incoming call. + */ + void newIncomingCall(String callId, CallInfo info); + + /** + * Tells CallsManager of a new outgoing call. + */ + void newOutgoingCall(String callId, CallInfo info); + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + */ + void setActive(String callId); + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + */ + void setRinging(String callId); + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + */ + void setDialing(String callId); + + /** + * Sets a call's state to disconnected. + */ + void setDisconnected(String callId); +} From e57944dd55f72aa1b9fc04c6b6bc48992076fdf6 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Mon, 16 Dec 2013 16:39:52 -0800 Subject: [PATCH 027/102] Add the CallService base class and the necessary call-service-provider AIDL interfaces. Change-Id: Ic0aab1245d259f1148d403033647d795e07ab015 --- Android.mk | 2 + .../java/android/telecomm/CallService.java | 164 ++++++++++++++++++ .../java/android/telecomm/ICallService.aidl | 14 +- .../telecomm/ICallServiceProvider.aidl | 47 +++++ .../telecomm/ICallServiceProviderAdapter.aidl | 32 ++++ 5 files changed, 252 insertions(+), 7 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallService.java create mode 100644 telecomm/java/android/telecomm/ICallServiceProvider.aidl create mode 100644 telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl diff --git a/Android.mk b/Android.mk index 3c5a291d0d28d..11db9853ecd2b 100644 --- a/Android.mk +++ b/Android.mk @@ -429,6 +429,8 @@ aidl_files := \ telecomm/java/android/telecomm/CallInfo.aidl \ telecomm/java/android/telecomm/ICallService.aidl \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/android/telecomm/ICallServiceProvider.aidl \ + telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ frameworks/base/telephony/java/android/telephony/ServiceState.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java new file mode 100644 index 0000000000000..e0d7dbc19d487 --- /dev/null +++ b/telecomm/java/android/telecomm/CallService.java @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import android.ICallService; +import android.ICallServiceAdapter; + +/** + * Base implementation of CallService which can be used to provide calls for the system + * in-call UI. CallService is a one-way service from the framework's CallsManager to any app + * that would like to provide calls managed by the default system in-call user interface. + * When the service is bound by the framework, CallsManager will call setCallServiceAdapter + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * for communicating back to CallsManager. Subsequently, more specific methods of the service + * will be called to perform various call actions including making an outgoing call and + * disconnected existing calls. + * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before + * we can unhide this API. + * + * Most public methods of this function are backed by a one-way AIDL interface which precludes + * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * response objects instead of return values. + * TODO(santoscordon): Improve paragraph above once the final design is in place. + * @hide + */ +public abstract class CallService extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_ADAPTER: + setCallServiceAdapter((ICallServiceAdapter) msg.obj); + break; + case MSG_IS_COMPATIBLE_WITH: + isCompatibleWith((String) msg.obj); + break; + case MSG_CALL: + call((String) msg.obj); + break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallService implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceWrapper extends ICallService.Stub { + @Override + public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) + .sendToTarget(); + } + + @Override + public void isCompatibleWith(String handle) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + } + + @Override + public void call(String handle) { + mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int + MSG_SET_CALL_SERVICE_ADAPTER = 1, + MSG_IS_COMPATIBLE_WITH = 2, + MSG_CALL = 3, + MSG_DISCONNECT = 4; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceMessageHandler}. + */ + private final CallServiceMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallService} interface. + */ + private final CallServiceWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallService() { + mMessageHandler = new CallServiceMessageHandler(); + mBinder = new CallServiceWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * changes of existing calls. + * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we + * wrap that in a wrapper like we do for CallService/ICallService? + * @param callServiceAdapter Adapter object for communicating call to CallsManager + */ + public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + + /** + * Determines if the CallService can make calls to the handle. + * @param handle The handle to test for compatibility. + * TODO(santoscordon): Need response parameter. + */ + public abstract void isCompatibleWith(String handle); + + /** + * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, + * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the + * same handle and this service is selected by the switchboard to handle the call. + * @param handle The handle to call. + */ + public abstract void call(String handle); + + /** + * Disconnects the specified call. + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); +} diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 09edadccc4620..0ff42fdbbae4e 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -33,6 +33,13 @@ import android.telecomm.ICallServiceAdapter; */ oneway interface ICallService { + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + /** * Determines if the CallService can make calls to the handle. * TODO(santoscordon): Move this method into its own service interface long term. @@ -54,11 +61,4 @@ oneway interface ICallService { * Disconnects the call identified by callId. */ void disconnect(String callId); - - /** - * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls - * and communicate state changes of existing calls. This is the first method that is called - * after a the framework binds to the call service. - */ - void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); } diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl new file mode 100644 index 0000000000000..0803cbc1fee49 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** + * Interface for applications interested in providing call-service implementations. Only used in + * outgoing-call scenarios where the best-candidate service to issue the call over may need to be + * decided dynamically (unlike incoming call scenario where the call-service is known). + * + * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn + * gathers and binds all ICallServiceProvider implementations (using the framework). The actual + * bind is between each CallServiceProvider and the CallServiceProviderAdapter. Once bound, the + * CallsManager invokes the initiateDiscoveryProtocol API of each bound provider and waits until + * either all providers reply (asynchronously) or some timeout is met. The resulted list is then + * processed by the CallsManager and its helpers (potentially requesting input from the user) to + * identify the best CallService. The user should obviously be notified upon zero candidates as + * well as all (one or more) candidates failing to issue the call. + * @hide + */ +oneway interface ICallServiceProvider { + + /** + * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to + * communicate with the CallsManager. + */ + void setCallServiceProviderAdapter(ICallServiceProviderAdapter callServiceProviderAdapter); + + /** + * Provides the application with the opportunity to "register" ICallServiceProvider + * implementations with the CallsManager for the purpose of issuing outgoing calls. + */ + void initiateDiscoveryProtocol(); +} diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl new file mode 100644 index 0000000000000..6c43d16a53803 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.CallService; + +/** + * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. + * @hide + */ +oneway interface ICallServiceProviderAdapter { + + /** + * Provides the CallsManager with the services made available by this application. + * @param callServices the relevant services to make the CallManager aware of. + */ + void registerCallServices(List callServices); +} From b3e51b791873b2ca6da6694964a48e0f2f49305a Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 17 Dec 2013 13:30:53 -0800 Subject: [PATCH 028/102] Fixing typos and a build break. Change-Id: I74ac6da8a9943b3b2cc76a4fc75027b7717b1bb3 --- Android.mk | 10 +++++----- telecomm/java/android/telecomm/CallService.java | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Android.mk b/Android.mk index 11db9853ecd2b..8813a99b573a3 100644 --- a/Android.mk +++ b/Android.mk @@ -426,11 +426,11 @@ aidl_files := \ frameworks/base/location/java/android/location/FusedBatchOptions.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderProperties.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \ - telecomm/java/android/telecomm/CallInfo.aidl \ - telecomm/java/android/telecomm/ICallService.aidl \ - telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ - telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ + frameworks/base/telecomm/java/android/telecomm/CallInfo.aidl \ + frameworks/base/telecomm/java/android/telecomm/ICallService.aidl \ + frameworks/base/telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + frameworks/base/telecomm/java/android/telecomm/ICallServiceProvider.aidl \ + frameworks/base/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ frameworks/base/telephony/java/android/telephony/ServiceState.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index e0d7dbc19d487..35989583b491f 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -38,7 +38,7 @@ import android.ICallServiceAdapter; * we can unhide this API. * * Most public methods of this function are backed by a one-way AIDL interface which precludes - * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * synchronous responses. As a result, most responses are handled by (or have TODOs to handle) * response objects instead of return values. * TODO(santoscordon): Improve paragraph above once the final design is in place. * @hide From 3784133b95f1206c0c6bbbddb5921ef396b5b941 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 17 Dec 2013 13:30:53 -0800 Subject: [PATCH 029/102] Additional fixes to aidl files. Change-Id: I24e5ae0ff65c3049d735cd4c6e1d79a0c406d92b --- Android.mk | 9 +++---- .../java/android/telecomm/CallService.java | 4 +-- .../java/android/telecomm/ICallService.aidl | 11 +++++++- .../android/telecomm/ICallServiceAdapter.aidl | 25 ++++++++++++++++--- .../telecomm/ICallServiceProvider.aidl | 7 +++++- .../telecomm/ICallServiceProviderAdapter.aidl | 9 ++++--- 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Android.mk b/Android.mk index 8813a99b573a3..dd7d5bcf0042d 100644 --- a/Android.mk +++ b/Android.mk @@ -277,6 +277,10 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRemoteDisplayProvider.aidl \ media/java/android/media/IRemoteVolumeObserver.aidl \ media/java/android/media/IRingtonePlayer.aidl \ + telecomm/java/android/telecomm/ICallService.aidl \ + telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/android/telecomm/ICallServiceProvider.aidl \ + telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ @@ -426,11 +430,6 @@ aidl_files := \ frameworks/base/location/java/android/location/FusedBatchOptions.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderProperties.aidl \ frameworks/base/location/java/com/android/internal/location/ProviderRequest.aidl \ - frameworks/base/telecomm/java/android/telecomm/CallInfo.aidl \ - frameworks/base/telecomm/java/android/telecomm/ICallService.aidl \ - frameworks/base/telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ - frameworks/base/telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - frameworks/base/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ frameworks/base/telephony/java/android/telephony/ServiceState.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ frameworks/base/telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 35989583b491f..9c5af3d4dc6b8 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -22,8 +22,8 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.ICallService; -import android.ICallServiceAdapter; +import android.telecomm.ICallService; +import android.telecomm.ICallServiceAdapter; /** * Base implementation of CallService which can be used to provide calls for the system diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 0ff42fdbbae4e..6764e4e56ce99 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -37,13 +37,18 @@ oneway interface ICallService { * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls * and communicate state changes of existing calls. This is the first method that is called * after a the framework binds to the call service. + * + * @param callServiceAdapter Interface to CallsManager for adding and updating calls. */ - void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); /** * Determines if the CallService can make calls to the handle. * TODO(santoscordon): Move this method into its own service interface long term. * TODO(santoscordon): Add response callback parameter. + * + * @param handle The destination handle to test against. Method should return true via the + * response callback if it can make a call to this handle. */ void isCompatibleWith(String handle); @@ -54,11 +59,15 @@ oneway interface ICallService { * handle-calling systems. See {@link #isCompatibleWith}. * TODO(santoscordon): Should this have a response attached to it to ensure that the call * service actually plans to make the call? + * + * @param handle The destination handle to call. */ void call(String handle); /** * Disconnects the call identified by callId. + * + * @param callId The identifier of the call to disconnect. */ void disconnect(String callId); } diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index af80e2a51425e..01f785cd40ea4 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -32,32 +32,51 @@ oneway interface ICallServiceAdapter { /** * Tells CallsManager of a new incoming call. + * + * @param callId The unique ID (via {@link #getNextCallId}) of the new incoming call. + * @param info Information about the new call including but not limited to the start time of the + * call and information about the caller's handle. */ - void newIncomingCall(String callId, CallInfo info); + void newIncomingCall(String callId, in CallInfo info); /** - * Tells CallsManager of a new outgoing call. + * Tells CallsManager of a new outgoing call. Use of this method should always follow + * {@link ICallService#call}. + * + * @param callId The unique ID (via {@link #getNextCallId}) of the new outgoing call. + * TODO(santoscordon): May be easier to have ICallService#call provide an ID instead of + * requiring a separate call to getNextCallId(). + * @param info Information about the new call including but not limited to the start time of the + * call and information about the caller's handle. */ - void newOutgoingCall(String callId, CallInfo info); + void newOutgoingCall(String callId, in CallInfo info); /** * Sets a call's state to active (e.g., an ongoing call where two parties can actively * communicate). + * + * @param callId The unique ID of the call whose state is changing to active. */ void setActive(String callId); /** * Sets a call's state to ringing (e.g., an inbound ringing call). + * + * @param callId The unique ID of the call whose state is changing to ringing. */ void setRinging(String callId); /** * Sets a call's state to dialing (e.g., dialing an outbound call). + * + * @param callId The unique ID of the call whose state is changing to dialing. */ void setDialing(String callId); /** * Sets a call's state to disconnected. + * + * @param callId The unique ID of the call whose state is changing to disconnected. */ void setDisconnected(String callId); } diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 0803cbc1fee49..1bd8d1fde376a 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -16,6 +16,8 @@ package android.telecomm; +import android.telecomm.ICallServiceProviderAdapter; + /** * Interface for applications interested in providing call-service implementations. Only used in * outgoing-call scenarios where the best-candidate service to issue the call over may need to be @@ -36,8 +38,11 @@ oneway interface ICallServiceProvider { /** * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to * communicate with the CallsManager. + * + * @param callServiceProviderAdapter The interface through which {@link ICallService} + * implementations are passed to CallsManager. */ - void setCallServiceProviderAdapter(ICallServiceProviderAdapter callServiceProviderAdapter); + void setCallServiceProviderAdapter(in ICallServiceProviderAdapter callServiceProviderAdapter); /** * Provides the application with the opportunity to "register" ICallServiceProvider diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl index 6c43d16a53803..ec88a06e44717 100644 --- a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl @@ -16,7 +16,7 @@ package android.telecomm; -import android.telecomm.CallService; +import android.telecomm.ICallService; /** * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. @@ -26,7 +26,10 @@ oneway interface ICallServiceProviderAdapter { /** * Provides the CallsManager with the services made available by this application. - * @param callServices the relevant services to make the CallManager aware of. + * + * @param callServices The relevant services to make the CallsManager aware of. Parameter is + * a list of IBinder which can be cast to ICallService. + * NOTE: IBinder is required by AIDL processor when passing a list of interfaces. */ - void registerCallServices(List callServices); + void registerCallServices(in List callServices); } From 6734a173f027b9f298366317b95fb353a040fc5b Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Mon, 30 Dec 2013 16:43:01 -0800 Subject: [PATCH 030/102] Add a default CallServiceProvider implementation. Change-Id: Ib9afcaac2e971fc8cd9d1fdef2d6ae97cbb79757 --- .../android/telecomm/CallServiceProvider.java | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 telecomm/java/android/telecomm/CallServiceProvider.java diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java new file mode 100644 index 0000000000000..01e1271b1ff5d --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import android.telecomm.ICallServiceProvider; + +/** + * Base implementation of CallServiceProvider service which implements ICallServiceProvider. + * Its primary function is to provide implementations of {@link ICallService} which itself + * can be used to provide calls for the framework's telecomm component. + * + * TODO(santoscordon): Improve paragraph above once the final design is in place. Needs more + * about how this can be used. + * @hide + */ +public abstract class CallServiceProvider extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceProviderMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER: + setCallServiceProviderAdapter((ICallServiceProviderAdapter) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { + @Override + public void setCallServiceProviderAdapter( + ICallServiceProviderAdapter CallServiceProviderAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER, + CallServiceProviderAdapter).sendToTarget(); + } + + @Override + public void initiateDiscoveryProtocol() {} + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER = 1; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceProviderMessageHandler}. + */ + private final CallServiceProviderMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallServiceProvider} interface. + */ + private final CallServiceProviderWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallServiceProvider() { + mMessageHandler = new CallServiceProviderMessageHandler(); + mBinder = new CallServiceProviderWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceProviderAdapter for adding providing instances of + * ICallService. + * TODO(santoscordon): Should we not reference ICallServiceProviderAdapter directly from here? + * Should we wrap that in a wrapper like we do for CallServiceProvider/ICallServiceProvider? + * @param callServiceAdapter Adapter object for communicating call to CallsManager + */ + public abstract void setCallServiceProviderAdapter( + ICallServiceProviderAdapter CallServiceProviderAdapter); +} From 6fbb1b73f82da0e7fe1244e4a44dea3c3c163997 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 8 Jan 2014 13:52:54 -0800 Subject: [PATCH 031/102] Remove CallServiceProviderAdapter and replace with CallServiceLookupResponse. Change-Id: I4d1c007bd46b804ecbb80163fc26de199cdbb2eb --- Android.mk | 2 +- .../android/telecomm/CallServiceProvider.java | 39 ++++++++--------- .../telecomm/ICallServiceLookupResponse.aidl | 42 +++++++++++++++++++ .../telecomm/ICallServiceProvider.aidl | 24 ++++------- .../telecomm/ICallServiceProviderAdapter.aidl | 35 ---------------- 5 files changed, 70 insertions(+), 72 deletions(-) create mode 100644 telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl delete mode 100644 telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl diff --git a/Android.mk b/Android.mk index dd7d5bcf0042d..f614d848d7443 100644 --- a/Android.mk +++ b/Android.mk @@ -279,8 +279,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRingtonePlayer.aidl \ telecomm/java/android/telecomm/ICallService.aidl \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 01e1271b1ff5d..f5fa1d19ef5a2 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -21,8 +21,11 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.os.RemoteException; import android.telecomm.ICallServiceProvider; +import android.telecomm.ICallServiceLookupResponse; +import android.util.Log; /** * Base implementation of CallServiceProvider service which implements ICallServiceProvider. @@ -33,7 +36,9 @@ import android.telecomm.ICallServiceProvider; * about how this can be used. * @hide */ -public abstract class CallServiceProvider extends Service { +public abstract class CallServiceProvider extends Service implements ICallServiceProvider { + /** Used to identify log entries by this class. */ + private static final String TAG = CallServiceProvider.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -42,8 +47,12 @@ public abstract class CallServiceProvider extends Service { @Override public void handleMessage(Message msg) { switch (msg.what) { - case MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER: - setCallServiceProviderAdapter((ICallServiceProviderAdapter) msg.obj); + case MSG_GET_CALL_SERVICES: + try { + lookupCallServices((ICallServiceLookupResponse) msg.obj); + } catch (RemoteException e) { + Log.e(TAG, "Remote exception on lookupCallServices().", e); + } break; default: break; @@ -55,15 +64,13 @@ public abstract class CallServiceProvider extends Service { * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. */ private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { - @Override - public void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter) { - mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER, - CallServiceProviderAdapter).sendToTarget(); - } + /** {@inheritDoc} */ @Override - public void initiateDiscoveryProtocol() {} + public void lookupCallServices(ICallServiceLookupResponse callServiceLookupResponse) { + mMessageHandler.obtainMessage(MSG_GET_CALL_SERVICES, callServiceLookupResponse) + .sendToTarget(); + } } // Only used internally by this class. @@ -71,7 +78,7 @@ public abstract class CallServiceProvider extends Service { // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a // single thread. Keeping it on a single thread allows CallService implementations to avoid // needing multi-threaded code in their own callback routines. - private static final int MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER = 1; + private static final int MSG_GET_CALL_SERVICES = 1; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -97,14 +104,4 @@ public abstract class CallServiceProvider extends Service { public IBinder onBind(Intent intent) { return mBinder; } - - /** - * Sets an implementation of ICallServiceProviderAdapter for adding providing instances of - * ICallService. - * TODO(santoscordon): Should we not reference ICallServiceProviderAdapter directly from here? - * Should we wrap that in a wrapper like we do for CallServiceProvider/ICallServiceProvider? - * @param callServiceAdapter Adapter object for communicating call to CallsManager - */ - public abstract void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter); } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl new file mode 100644 index 0000000000000..2327c645764e9 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.Bundle; + +/** + * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations or + * an errorCode in case of error. + */ +oneway interface ICallServiceLookupResponse { + /** + * Receives the list of {@link ICallServices} as a data value in the bundle parameter. + * TODO(santoscordon): Needs more specifics about the data key used for the list. + * + * @param bundle Container for the list of call services. + */ + void onResult(in Bundle bundle); + + /** + * Receives error code upon failure in retrieving the list of call services. + * TODO(santoscordon): Needs list of potential error codes. Also, do we really need this + * method or can we return codes as part of onResult? + * + * @param errorCode Error code describing the error condition. + */ + void onError(int errorCode); +} diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 1bd8d1fde376a..2e2610c68af60 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -16,7 +16,7 @@ package android.telecomm; -import android.telecomm.ICallServiceProviderAdapter; +import android.telecomm.ICallServiceLookupResponse; /** * Interface for applications interested in providing call-service implementations. Only used in @@ -24,9 +24,8 @@ import android.telecomm.ICallServiceProviderAdapter; * decided dynamically (unlike incoming call scenario where the call-service is known). * * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). The actual - * bind is between each CallServiceProvider and the CallServiceProviderAdapter. Once bound, the - * CallsManager invokes the initiateDiscoveryProtocol API of each bound provider and waits until + * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the + * CallsManager invokes the lookupCallServices API of each bound provider and waits until * either all providers reply (asynchronously) or some timeout is met. The resulted list is then * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as @@ -36,17 +35,12 @@ import android.telecomm.ICallServiceProviderAdapter; oneway interface ICallServiceProvider { /** - * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to - * communicate with the CallsManager. + * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * this provider. + * TODO(santoscordon): Needs comments on how to populate the list within + * ICallServiceLookupResponse and how to handle error conditions. * - * @param callServiceProviderAdapter The interface through which {@link ICallService} - * implementations are passed to CallsManager. + * @param response The response object through which the list of call services is sent. */ - void setCallServiceProviderAdapter(in ICallServiceProviderAdapter callServiceProviderAdapter); - - /** - * Provides the application with the opportunity to "register" ICallServiceProvider - * implementations with the CallsManager for the purpose of issuing outgoing calls. - */ - void initiateDiscoveryProtocol(); + void lookupCallServices(in ICallServiceLookupResponse response); } diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl deleted file mode 100644 index ec88a06e44717..0000000000000 --- a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.telecomm.ICallService; - -/** - * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. - * @hide - */ -oneway interface ICallServiceProviderAdapter { - - /** - * Provides the CallsManager with the services made available by this application. - * - * @param callServices The relevant services to make the CallsManager aware of. Parameter is - * a list of IBinder which can be cast to ICallService. - * NOTE: IBinder is required by AIDL processor when passing a list of interfaces. - */ - void registerCallServices(in List callServices); -} From 6fee2ea8f887e32d4c4a8c35b0ff00ea7eeb2bb3 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 10 Jan 2014 04:20:34 +0000 Subject: [PATCH 032/102] Revert "Remove CallServiceProviderAdapter and replace with CallServiceLookupResponse." This reverts commit 753fc58932e976086069bacb3e5252332960644b. Change-Id: Ie17b4918fa404eb768c0f3ce5109d6cc8b2d1da8 --- Android.mk | 2 +- .../android/telecomm/CallServiceProvider.java | 39 +++++++++-------- .../telecomm/ICallServiceLookupResponse.aidl | 42 ------------------- .../telecomm/ICallServiceProvider.aidl | 24 +++++++---- .../telecomm/ICallServiceProviderAdapter.aidl | 35 ++++++++++++++++ 5 files changed, 72 insertions(+), 70 deletions(-) delete mode 100644 telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl create mode 100644 telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl diff --git a/Android.mk b/Android.mk index f614d848d7443..dd7d5bcf0042d 100644 --- a/Android.mk +++ b/Android.mk @@ -279,8 +279,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRingtonePlayer.aidl \ telecomm/java/android/telecomm/ICallService.aidl \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ - telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ + telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index f5fa1d19ef5a2..01e1271b1ff5d 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -21,11 +21,8 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.os.RemoteException; import android.telecomm.ICallServiceProvider; -import android.telecomm.ICallServiceLookupResponse; -import android.util.Log; /** * Base implementation of CallServiceProvider service which implements ICallServiceProvider. @@ -36,9 +33,7 @@ import android.util.Log; * about how this can be used. * @hide */ -public abstract class CallServiceProvider extends Service implements ICallServiceProvider { - /** Used to identify log entries by this class. */ - private static final String TAG = CallServiceProvider.class.getSimpleName(); +public abstract class CallServiceProvider extends Service { /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -47,12 +42,8 @@ public abstract class CallServiceProvider extends Service implements ICallServic @Override public void handleMessage(Message msg) { switch (msg.what) { - case MSG_GET_CALL_SERVICES: - try { - lookupCallServices((ICallServiceLookupResponse) msg.obj); - } catch (RemoteException e) { - Log.e(TAG, "Remote exception on lookupCallServices().", e); - } + case MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER: + setCallServiceProviderAdapter((ICallServiceProviderAdapter) msg.obj); break; default: break; @@ -64,13 +55,15 @@ public abstract class CallServiceProvider extends Service implements ICallServic * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. */ private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { - - /** {@inheritDoc} */ @Override - public void lookupCallServices(ICallServiceLookupResponse callServiceLookupResponse) { - mMessageHandler.obtainMessage(MSG_GET_CALL_SERVICES, callServiceLookupResponse) - .sendToTarget(); + public void setCallServiceProviderAdapter( + ICallServiceProviderAdapter CallServiceProviderAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER, + CallServiceProviderAdapter).sendToTarget(); } + + @Override + public void initiateDiscoveryProtocol() {} } // Only used internally by this class. @@ -78,7 +71,7 @@ public abstract class CallServiceProvider extends Service implements ICallServic // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a // single thread. Keeping it on a single thread allows CallService implementations to avoid // needing multi-threaded code in their own callback routines. - private static final int MSG_GET_CALL_SERVICES = 1; + private static final int MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER = 1; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -104,4 +97,14 @@ public abstract class CallServiceProvider extends Service implements ICallServic public IBinder onBind(Intent intent) { return mBinder; } + + /** + * Sets an implementation of ICallServiceProviderAdapter for adding providing instances of + * ICallService. + * TODO(santoscordon): Should we not reference ICallServiceProviderAdapter directly from here? + * Should we wrap that in a wrapper like we do for CallServiceProvider/ICallServiceProvider? + * @param callServiceAdapter Adapter object for communicating call to CallsManager + */ + public abstract void setCallServiceProviderAdapter( + ICallServiceProviderAdapter CallServiceProviderAdapter); } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl deleted file mode 100644 index 2327c645764e9..0000000000000 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telecomm; - -import android.os.Bundle; - -/** - * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations or - * an errorCode in case of error. - */ -oneway interface ICallServiceLookupResponse { - /** - * Receives the list of {@link ICallServices} as a data value in the bundle parameter. - * TODO(santoscordon): Needs more specifics about the data key used for the list. - * - * @param bundle Container for the list of call services. - */ - void onResult(in Bundle bundle); - - /** - * Receives error code upon failure in retrieving the list of call services. - * TODO(santoscordon): Needs list of potential error codes. Also, do we really need this - * method or can we return codes as part of onResult? - * - * @param errorCode Error code describing the error condition. - */ - void onError(int errorCode); -} diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 2e2610c68af60..1bd8d1fde376a 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -16,7 +16,7 @@ package android.telecomm; -import android.telecomm.ICallServiceLookupResponse; +import android.telecomm.ICallServiceProviderAdapter; /** * Interface for applications interested in providing call-service implementations. Only used in @@ -24,8 +24,9 @@ import android.telecomm.ICallServiceLookupResponse; * decided dynamically (unlike incoming call scenario where the call-service is known). * * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the - * CallsManager invokes the lookupCallServices API of each bound provider and waits until + * gathers and binds all ICallServiceProvider implementations (using the framework). The actual + * bind is between each CallServiceProvider and the CallServiceProviderAdapter. Once bound, the + * CallsManager invokes the initiateDiscoveryProtocol API of each bound provider and waits until * either all providers reply (asynchronously) or some timeout is met. The resulted list is then * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as @@ -35,12 +36,17 @@ import android.telecomm.ICallServiceLookupResponse; oneway interface ICallServiceProvider { /** - * Initiates the process to retrieve the list of {@link ICallService}s implemented by - * this provider. - * TODO(santoscordon): Needs comments on how to populate the list within - * ICallServiceLookupResponse and how to handle error conditions. + * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to + * communicate with the CallsManager. * - * @param response The response object through which the list of call services is sent. + * @param callServiceProviderAdapter The interface through which {@link ICallService} + * implementations are passed to CallsManager. */ - void lookupCallServices(in ICallServiceLookupResponse response); + void setCallServiceProviderAdapter(in ICallServiceProviderAdapter callServiceProviderAdapter); + + /** + * Provides the application with the opportunity to "register" ICallServiceProvider + * implementations with the CallsManager for the purpose of issuing outgoing calls. + */ + void initiateDiscoveryProtocol(); } diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl new file mode 100644 index 0000000000000..ec88a06e44717 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.ICallService; + +/** + * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. + * @hide + */ +oneway interface ICallServiceProviderAdapter { + + /** + * Provides the CallsManager with the services made available by this application. + * + * @param callServices The relevant services to make the CallsManager aware of. Parameter is + * a list of IBinder which can be cast to ICallService. + * NOTE: IBinder is required by AIDL processor when passing a list of interfaces. + */ + void registerCallServices(in List callServices); +} From 4939ccf7864b3b5664c6cdbe124e49e68030cfa9 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 8 Jan 2014 13:52:54 -0800 Subject: [PATCH 033/102] Remove CallServiceProviderAdapter and replace with CallServiceLookupResponse. Change-Id: I55a574784162e3cc4a88b2889f1d14a07116f937 --- Android.mk | 2 +- .../android/telecomm/CallServiceProvider.java | 43 ++++++++++--------- ...r.aidl => ICallServiceLookupResponse.aidl} | 18 ++++---- .../telecomm/ICallServiceProvider.aidl | 24 ++++------- 4 files changed, 41 insertions(+), 46 deletions(-) rename telecomm/java/android/telecomm/{ICallServiceProviderAdapter.aidl => ICallServiceLookupResponse.aidl} (50%) diff --git a/Android.mk b/Android.mk index dd7d5bcf0042d..f614d848d7443 100644 --- a/Android.mk +++ b/Android.mk @@ -279,8 +279,8 @@ LOCAL_SRC_FILES += \ media/java/android/media/IRingtonePlayer.aidl \ telecomm/java/android/telecomm/ICallService.aidl \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 01e1271b1ff5d..998f0013120b4 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -21,19 +21,26 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; +import android.os.RemoteException; import android.telecomm.ICallServiceProvider; +import android.telecomm.ICallServiceLookupResponse; +import android.util.Log; /** - * Base implementation of CallServiceProvider service which implements ICallServiceProvider. - * Its primary function is to provide implementations of {@link ICallService} which itself - * can be used to provide calls for the framework's telecomm component. + * Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class + * should be extended by an app that wants to supply phone calls to be handled and managed by + * the device's in-call interface. All method-calls from the framework to + * {@link ICallServiceProvider} are passed through to the main thread for before executing the + * overriden methods of CallServiceProvider. * * TODO(santoscordon): Improve paragraph above once the final design is in place. Needs more * about how this can be used. * @hide */ public abstract class CallServiceProvider extends Service { + /** Used to identify log entries by this class. */ + private static final String TAG = CallServiceProvider.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -42,8 +49,8 @@ public abstract class CallServiceProvider extends Service { @Override public void handleMessage(Message msg) { switch (msg.what) { - case MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER: - setCallServiceProviderAdapter((ICallServiceProviderAdapter) msg.obj); + case MSG_LOOKUP_CALL_SERVICES: + lookupCallServices((ICallServiceLookupResponse) msg.obj); break; default: break; @@ -55,15 +62,13 @@ public abstract class CallServiceProvider extends Service { * Default ICallServiceProvider implementation provided to CallsManager via {@link #onBind}. */ private final class CallServiceProviderWrapper extends ICallServiceProvider.Stub { + /** {@inheritDoc} */ @Override - public void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter) { - mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER, - CallServiceProviderAdapter).sendToTarget(); + public void lookupCallServices(ICallServiceLookupResponse callServiceLookupResponse) { + Message message = mMessageHandler.obtainMessage( + MSG_LOOKUP_CALL_SERVICES, callServiceLookupResponse); + message.sendToTarget(); } - - @Override - public void initiateDiscoveryProtocol() {} } // Only used internally by this class. @@ -71,7 +76,7 @@ public abstract class CallServiceProvider extends Service { // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a // single thread. Keeping it on a single thread allows CallService implementations to avoid // needing multi-threaded code in their own callback routines. - private static final int MSG_SET_CALL_SERVICE_PROVIDER_ADAPTER = 1; + private static final int MSG_LOOKUP_CALL_SERVICES = 1; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -99,12 +104,10 @@ public abstract class CallServiceProvider extends Service { } /** - * Sets an implementation of ICallServiceProviderAdapter for adding providing instances of - * ICallService. - * TODO(santoscordon): Should we not reference ICallServiceProviderAdapter directly from here? - * Should we wrap that in a wrapper like we do for CallServiceProvider/ICallServiceProvider? - * @param callServiceAdapter Adapter object for communicating call to CallsManager + * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * this provider. + * + * @param response The response object through which the list of call services is sent. */ - public abstract void setCallServiceProviderAdapter( - ICallServiceProviderAdapter CallServiceProviderAdapter); + public abstract void lookupCallServices(ICallServiceLookupResponse response); } diff --git a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl similarity index 50% rename from telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl rename to telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index ec88a06e44717..4b59121eb07de 100644 --- a/telecomm/java/android/telecomm/ICallServiceProviderAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,20 +16,18 @@ package android.telecomm; -import android.telecomm.ICallService; +import android.os.IBinder; +import java.util.List; /** - * Provides ICallServiceProvider implementations with the relevant CallsManager APIs. + * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations. * @hide */ -oneway interface ICallServiceProviderAdapter { - +oneway interface ICallServiceLookupResponse { /** - * Provides the CallsManager with the services made available by this application. + * Receives the list of {@link ICallService}s as a list of {@link IBinder}s. * - * @param callServices The relevant services to make the CallsManager aware of. Parameter is - * a list of IBinder which can be cast to ICallService. - * NOTE: IBinder is required by AIDL processor when passing a list of interfaces. + * @param bundle Container for the list of call services. */ - void registerCallServices(in List callServices); + void onResult(in List callServices); } diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 1bd8d1fde376a..2e2610c68af60 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -16,7 +16,7 @@ package android.telecomm; -import android.telecomm.ICallServiceProviderAdapter; +import android.telecomm.ICallServiceLookupResponse; /** * Interface for applications interested in providing call-service implementations. Only used in @@ -24,9 +24,8 @@ import android.telecomm.ICallServiceProviderAdapter; * decided dynamically (unlike incoming call scenario where the call-service is known). * * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). The actual - * bind is between each CallServiceProvider and the CallServiceProviderAdapter. Once bound, the - * CallsManager invokes the initiateDiscoveryProtocol API of each bound provider and waits until + * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the + * CallsManager invokes the lookupCallServices API of each bound provider and waits until * either all providers reply (asynchronously) or some timeout is met. The resulted list is then * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as @@ -36,17 +35,12 @@ import android.telecomm.ICallServiceProviderAdapter; oneway interface ICallServiceProvider { /** - * Sets an implementation of ICallServiceProviderAdapter to allow call-service providers to - * communicate with the CallsManager. + * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * this provider. + * TODO(santoscordon): Needs comments on how to populate the list within + * ICallServiceLookupResponse and how to handle error conditions. * - * @param callServiceProviderAdapter The interface through which {@link ICallService} - * implementations are passed to CallsManager. + * @param response The response object through which the list of call services is sent. */ - void setCallServiceProviderAdapter(in ICallServiceProviderAdapter callServiceProviderAdapter); - - /** - * Provides the application with the opportunity to "register" ICallServiceProvider - * implementations with the CallsManager for the purpose of issuing outgoing calls. - */ - void initiateDiscoveryProtocol(); + void lookupCallServices(in ICallServiceLookupResponse response); } From 73e64fe81a75e25008c46107e4dfa8507c5e73a2 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 14 Jan 2014 17:48:45 -0800 Subject: [PATCH 034/102] clean up javadoc. Change-Id: I64b20065fffbcd5a53ab9d2b5d424e3cea2db3b3 --- telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index 4b59121eb07de..f3c827e5b1d88 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -27,7 +27,7 @@ oneway interface ICallServiceLookupResponse { /** * Receives the list of {@link ICallService}s as a list of {@link IBinder}s. * - * @param bundle Container for the list of call services. + * @param callServices List of call services from {@link ICallServiceProvider}. */ void onResult(in List callServices); } From 0f7dac1741dd4e2c56f8f6d441fdbef1533577b1 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 14 Jan 2014 17:53:37 -0800 Subject: [PATCH 035/102] Adding the CallServiceSelector skeleton (AIDL) files. Change-Id: I55ca3bed6e1b964602a9291bd388a10c99729da7 --- Android.mk | 2 + .../telecomm/ICallServiceLookupResponse.aidl | 1 + .../ICallServiceSelectionResponse.aidl | 38 ++++++++ .../telecomm/ICallServiceSelector.aidl | 95 +++++++++++++++++++ 4 files changed, 136 insertions(+) create mode 100644 telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl create mode 100644 telecomm/java/android/telecomm/ICallServiceSelector.aidl diff --git a/Android.mk b/Android.mk index f614d848d7443..f6ed4dadbebbe 100644 --- a/Android.mk +++ b/Android.mk @@ -281,6 +281,8 @@ LOCAL_SRC_FILES += \ telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ + telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl \ + telecomm/java/android/telecomm/ICallServiceSelector.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index f3c827e5b1d88..7384d1b9caf56 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -28,6 +28,7 @@ oneway interface ICallServiceLookupResponse { * Receives the list of {@link ICallService}s as a list of {@link IBinder}s. * * @param callServices List of call services from {@link ICallServiceProvider}. + * TODO(gilad): Rename to callServiceBinders. */ void onResult(in List callServices); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl new file mode 100644 index 0000000000000..143d17130f26c --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.IBinder; +import java.util.List; + +/** + * Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService} + * implementations with which to connect the corresponding outgoing call. + * @hide + */ +oneway interface ICallServiceSelectionResponse { + /** + * Records the sorted set of call services that are preferred by the corresponding + * call-service selector. + * + * @param callServiceBinders The relevant call-service binders ordered by priority (most + * desired first). + * TODO(gilad): Move to use call-service IDs or (reduced-visibility) call-service wrappers + * instead, see isSwitchable/callId in ICallServiceSelector.aidl for more details. + */ + void setPreferredCallServices(in List callServiceBinders); +} diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl new file mode 100644 index 0000000000000..db742ac8af48b --- /dev/null +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.ICallService; +import android.telecomm.ICallServiceSelectionResponse; + +import java.util.List; + +/** + * Interface for call-service selector implementations. + * + * Call-service selectors are ultimately responsible for deciding which of the available call + * service implementations should be used to place an outgoing call, as well as which service + * to switch the call to upon system-provided opportunities to switch call services. + * + * Outgoing call scenario: + * + * Telecomm maintains a prioritized list of call-service selectors. Upon attempting to issue + * outgoing calls, the switchboard iterates through these (starting with the highest-priority + * selector). It then invokes the "select" API below passing -- among other parameters -- the + * list of available call services, excluding fully-utilized services that temporarily aren't + * capable of accommodating additional calls. Once invoked, selectors return a sorted subset + * from the specified list, containing the preferred services through which to place the call. + * Upon empty selection the switchboard continues to the next selector. Otherwise, upon non- + * empty selection, the returned call services are attempted in the specified order. The flow + * is concluded either when the call is placed by one of the specified services (e.g. ringing) + * or upon failure to connect by the time the set of selectors is exhausted. Failed calls are + * essentially abandoned by this flow and then picked up by the switchboard's monitor. + * + * Note that attempted-yet-failed call services within one outgoing-call cycle may be omitted + * from the set passed to the next selector. As for selector priority, at the time of writing + * this is intended to be a blend of built-in priorities (e.g. to handle emergency calls) and + * user-specified preferences (via settings, e.g. electing to use a particular selector prior + * to attempting the system-default call-service selector). + * + * Call-services switching scenario (applying to both incoming and outgoing calls): + * + * The switchboard may invoke any active selector (a selector associated with one or more on- + * going calls) up to once per ongoing call at its discretion (e.g. periodically), once again + * passing the available call services to the "select" API. As in the outgoing-call scenario + * above, returning the empty list means "pass" -- basically indicating that the current call + * service for this call need not be switched at this time. In cases where switching isn't at + * all supported (either for a given call or globally across a given selector) , isSwitchable + * below can return false blindly to suppress all "select" calls beyond the initial one (that + * is used to establish outgoing calls). + * + * @hide + */ +oneway interface ICallServiceSelector { + + /** + * Initiates the process to retrieve the sorted set of call services that are preferred + * by this call-service selector. + * TODO(gilad): Pass reduced-visibility call-service objects, see isSwitchable/callId below. + * TODO(gilad): Consider passing a Call object encapsulating the relevant call details (e.g. + * handle, contactInfo, etc). + * + * @param handle The handle to dial. + * @param callServiceBinders The list of binders to select call services from. + * @param response The response object through which the selected services are passed back + * to the switchboard. + */ + void select( + String handle, + in List callServiceBinders, + in ICallServiceSelectionResponse response); + + /** + * Determines if the specified ongoing call can/should be switched from the currently-used + * call service to another. + * TODO(gilad): Do we want to add a dedicated response type, introduce a generic one (and use + * it across the board), or eliminate this altogether (i.e. relying on "select" to return the + * empty set in the cases this would have returned false)? + * + * @param callId The identifier of the call to disconnect. + * TODO(gilad): Consider passing a reduced-visibility call object, e.g. using Call externally + * and PackagePrivateCall within Telecomm (where the latter can be wrapped by the former). + */ + void isSwitchable(String callId); +} From 2e412075baaac8066265618e1a0d5186aced74c4 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Wed, 15 Jan 2014 11:22:27 -0800 Subject: [PATCH 036/102] Remove unused code/comments and adding missing tags etc. Change-Id: I6ec7eda46a2b61bee26b4edca1bede5c00177712 --- telecomm/java/android/telecomm/CallServiceProvider.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 998f0013120b4..a24521a181d26 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -21,11 +21,9 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.os.RemoteException; import android.telecomm.ICallServiceProvider; import android.telecomm.ICallServiceLookupResponse; -import android.util.Log; /** * Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class @@ -39,8 +37,6 @@ import android.util.Log; * @hide */ public abstract class CallServiceProvider extends Service { - /** Used to identify log entries by this class. */ - private static final String TAG = CallServiceProvider.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -80,7 +76,7 @@ public abstract class CallServiceProvider extends Service { /** * Message handler for consolidating binder callbacks onto a single thread. - * See {@link #CallServiceProviderMessageHandler}. + * See {@link CallServiceProviderMessageHandler}. */ private final CallServiceProviderMessageHandler mMessageHandler; @@ -99,6 +95,7 @@ public abstract class CallServiceProvider extends Service { } /** {@inheritDoc} */ + @Override public IBinder onBind(Intent intent) { return mBinder; } From f042a3f067b47a92c67d994ba3e24bf41636e4f9 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Wed, 15 Jan 2014 13:58:57 -0800 Subject: [PATCH 037/102] Following up on our discussion offline to introduce response objects for isSwitchable. Change-Id: Ic1385d9b67ed0a859128845574d48ad90d6152a2 --- Android.mk | 1 + .../telecomm/ICallServiceSelector.aidl | 10 +++--- .../telecomm/ICallSwitchabilityResponse.aidl | 36 +++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl diff --git a/Android.mk b/Android.mk index f6ed4dadbebbe..091061e28328c 100644 --- a/Android.mk +++ b/Android.mk @@ -283,6 +283,7 @@ LOCAL_SRC_FILES += \ telecomm/java/android/telecomm/ICallServiceProvider.aidl \ telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl \ telecomm/java/android/telecomm/ICallServiceSelector.aidl \ + telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index db742ac8af48b..13a3f4cf60159 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -18,6 +18,7 @@ package android.telecomm; import android.telecomm.ICallService; import android.telecomm.ICallServiceSelectionResponse; +import android.telecomm.ICallSwitchabilityResponse; import java.util.List; @@ -83,13 +84,10 @@ oneway interface ICallServiceSelector { /** * Determines if the specified ongoing call can/should be switched from the currently-used * call service to another. - * TODO(gilad): Do we want to add a dedicated response type, introduce a generic one (and use - * it across the board), or eliminate this altogether (i.e. relying on "select" to return the - * empty set in the cases this would have returned false)? + * TODO(gilad): Pass a CallInfo instead that contains (among other fields) the callId. * * @param callId The identifier of the call to disconnect. - * TODO(gilad): Consider passing a reduced-visibility call object, e.g. using Call externally - * and PackagePrivateCall within Telecomm (where the latter can be wrapped by the former). + * @param response The response object to be populated and returned to switchboard. */ - void isSwitchable(String callId); + void isSwitchable(String callId, in ICallSwitchabilityResponse response); } diff --git a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl new file mode 100644 index 0000000000000..628ad6b499a75 --- /dev/null +++ b/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** + * Used by {@link ICallServiceSelector}s to return whether or not the relevant + * call is switchable. + * @hide + */ +oneway interface ICallSwitchabilityResponse { + /** + * Records whether or not the corresponding call can potentially be switched to another + * call service. + * + * @param isSwitchable True if the associated call-service selector may be interested + * in switching call services. Setting isSwitchable to true should generally + * guarantee the "select" API of the associated selector to be invoked, hence + * allowing the selector to return either the empty list (meaning pass, don't + * switch) or the prioritized list of call-services to attempt switching to. + */ + void setIsSwitchable(boolean isSwitchable); +} From 8986ef460188805a1af21ee5d8cd49a57d725d5e Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 14 Jan 2014 14:43:35 -0800 Subject: [PATCH 038/102] Updates CallService API. Adds additional parameters and a response method for isCompatibleWith on ICallServiceAdapter. Adds connectionStartTime to CallInfo. Change-Id: I27a8d14c5c63d3f6a70a290ffb39d9f623d40a60 --- telecomm/java/android/telecomm/CallInfo.java | 36 +++++++--- .../java/android/telecomm/CallService.java | 67 ++++++++++++++----- .../java/android/telecomm/ICallService.aidl | 28 +++++--- .../android/telecomm/ICallServiceAdapter.aidl | 25 ++++--- .../telecomm/ICallServiceLookupResponse.aidl | 5 +- 5 files changed, 115 insertions(+), 46 deletions(-) diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index 8fe67a02d866d..d964944ed2a12 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -19,10 +19,13 @@ package android.telecomm; import android.os.Parcel; import android.os.Parcelable; +import java.util.Date; + /** - * A parcelable holder class of Call information data. - * TODO(santoscordon): Need final public-facing comments in this file. - * @hide + * A parcelable holder class of Call information data. This class is intended for transfering call + * information from Telecomm to call services and thus is read-only. + * TODO(santoscordon): Need final public-facing comments in this file. + * @hide */ public final class CallInfo implements Parcelable { @@ -30,14 +33,29 @@ public final class CallInfo implements Parcelable { * Endpoint to which the call is connected. * This could be the dialed value for outgoing calls or the caller id of incoming calls. */ - private String handle; + private final String mHandle; + // There are 4 timestamps that are important to a call: + // 1) Created timestamp - The time at which the user explicitly chose to make the call. + // 2) Connected timestamp - The time at which a call service confirms that it has connected + // this call. This happens through a method-call to either newOutgoingCall or newIncomingCall + // on CallServiceAdapter. Generally this should coincide roughly to the user physically + // hearing/seeing a ring. + // TODO(santoscordon): Consider renaming Call-active to better match the others. + // 3) Call-active timestamp - The time at which the call switches to the active state. This + // happens when the user answers an incoming call or an outgoing call was answered by the + // other party. + // 4) Disconnected timestamp - The time at which the call was disconnected. + + /** + * Persists handle of the other party of this call. + */ public CallInfo(String handle) { - this.handle = handle; + mHandle = handle; } public String getHandle() { - return handle; + return mHandle; } // @@ -47,8 +65,8 @@ public final class CallInfo implements Parcelable { /** * Responsible for creating CallInfo objects for deserialized Parcels. */ - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator () { + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator () { @Override public CallInfo createFromParcel(Parcel source) { @@ -74,6 +92,6 @@ public final class CallInfo implements Parcelable { */ @Override public void writeToParcel(Parcel destination, int flags) { - destination.writeString(handle); + destination.writeString(mHandle); } } diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 9c5af3d4dc6b8..1f47a0ad1728d 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -24,6 +24,8 @@ import android.os.Message; import android.telecomm.ICallService; import android.telecomm.ICallServiceAdapter; +import android.util.Log; +import android.util.Pair; /** * Base implementation of CallService which can be used to provide calls for the system @@ -44,6 +46,7 @@ import android.telecomm.ICallServiceAdapter; * @hide */ public abstract class CallService extends Service { + private static final String TAG = CallService.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -56,10 +59,25 @@ public abstract class CallService extends Service { setCallServiceAdapter((ICallServiceAdapter) msg.obj); break; case MSG_IS_COMPATIBLE_WITH: - isCompatibleWith((String) msg.obj); + // See {@link CallServiceWrapper#isCompatibleWith} for dataObject definition. + try { + // TODO(santoscordon): Switch to using a custom class here instead. When we + // switch to using Call objects instead of handles directly, this may not even be + // necessary. + Pair dataObject = (Pair) msg.obj; + isCompatibleWith(dataObject.first, dataObject.second); + } catch (ClassCastException e) { + Log.e(TAG, "Unexpected object type for MSG_IS_COMPATIBLE_WITH.", e); + } break; case MSG_CALL: - call((String) msg.obj); + // See {@link CallServiceWrapper#call} for dataObject definition. + try { + Pair dataObject = (Pair) msg.obj; + call(dataObject.first, dataObject.second); + } catch (ClassCastException e) { + Log.e(TAG, "Unexpected object type for MSG_CALL.", e); + } break; case MSG_DISCONNECT: disconnect((String) msg.obj); @@ -81,13 +99,15 @@ public abstract class CallService extends Service { } @Override - public void isCompatibleWith(String handle) { - mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + public void isCompatibleWith(String handle, String callId) { + Pair dataObject = new Pair(handle, callId); + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, dataObject).sendToTarget(); } @Override - public void call(String handle) { - mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + public void call(String handle, String callId) { + Pair dataObject = new Pair(handle, callId); + mMessageHandler.obtainMessage(MSG_CALL, dataObject).sendToTarget(); } @Override @@ -129,6 +149,13 @@ public abstract class CallService extends Service { /** {@inheritDoc} */ public IBinder onBind(Intent intent) { + return getBinder(); + } + + /** + * Returns binder object which can be used across IPC methods. + */ + public IBinder getBinder() { return mBinder; } @@ -137,27 +164,37 @@ public abstract class CallService extends Service { * changes of existing calls. * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we * wrap that in a wrapper like we do for CallService/ICallService? + * * @param callServiceAdapter Adapter object for communicating call to CallsManager */ public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); /** - * Determines if the CallService can make calls to the handle. - * @param handle The handle to test for compatibility. - * TODO(santoscordon): Need response parameter. + * Determines if the CallService can make calls to the handle. Response is sent via + * ICallServiceAdapter. When responding, the correct call ID must be specified along with + * the handle. + * + * @param handle The destination handle to test against. + * @param callId The call identifier associated with this compatibility request. */ - public abstract void isCompatibleWith(String handle); + public abstract void isCompatibleWith(String handle, String callId); /** - * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, - * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the - * same handle and this service is selected by the switchboard to handle the call. - * @param handle The handle to call. + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the + * call service respond via {@link ICallServiceAdapter#newOutgoingCall} if it can successfully + * make the call. + * + * @param handle The destination handle to call. + * @param callId Unique identifier for the call. */ - public abstract void call(String handle); + public abstract void call(String handle, String callId); /** * Disconnects the specified call. + * * @param callId The ID of the call to disconnect. */ public abstract void disconnect(String callId); diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 6764e4e56ce99..9d0223464355b 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -43,26 +43,34 @@ oneway interface ICallService { void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); /** - * Determines if the CallService can make calls to the handle. - * TODO(santoscordon): Move this method into its own service interface long term. - * TODO(santoscordon): Add response callback parameter. + * Determines if the ICallService can make calls to the handle. Response is sent via + * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be + * specified along with the handle. It is expected that the call service respond within 500 + * milliseconds. Any response that takes longer than 500 milliseconds will be treated as being + * incompatible. + * TODO(santoscordon): 500 ms was arbitrarily chosen and must be confirmed before this + * API is made public. + * TODO(santoscordon): Switch from specific parameters to CallInfo/Call. * - * @param handle The destination handle to test against. Method should return true via the - * response callback if it can make a call to this handle. + * @param handle The destination handle to test against. + * @param callId The call identifier associated with this compatibility request. */ - void isCompatibleWith(String handle); + void isCompatibleWith(String handle, String callId); /** * Attempts to call the relevant party using the specified handle, be it a phone number, * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary - * handle-calling systems. See {@link #isCompatibleWith}. - * TODO(santoscordon): Should this have a response attached to it to ensure that the call - * service actually plans to make the call? + * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the + * call service respond via {@link ICallServiceAdapter#newOutgoingCall} if it can successfully + * make the call. + * TODO(santoscordon): Figure out how a calls service can short-circuit a failure to + * the adapter. * * @param handle The destination handle to call. + * @param callId Unique identifier for the call. */ - void call(String handle); + void call(String handle, String callId); /** * Disconnects the call identified by callId. diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 01f785cd40ea4..71c5006ed5ec9 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -26,30 +26,35 @@ import android.telecomm.CallInfo; oneway interface ICallServiceAdapter { /** - * Retrieves a new unique call ID for use with newOutgoingCall and newIncomingCall. + * Retrieves a new unique call ID for use with newIncomingCall. */ void getNextCallId(/* TODO(santoscordon): Needs response object */); + /** + * Receives confirmation of the call service's ability to make a call to the specified handle. + * + * @param handle The handle to call. + * @param callId The identifier of the call for which compatibility is being received. + * @param isCompatible True if the call service can place a call to the handle. + */ + void setCompatibleWith(String handle, String callId, boolean isCompatible); + /** * Tells CallsManager of a new incoming call. * + * @param handle The handle to the other party or null if no such handle is available (as with + * blocked caller ID). * @param callId The unique ID (via {@link #getNextCallId}) of the new incoming call. - * @param info Information about the new call including but not limited to the start time of the - * call and information about the caller's handle. */ - void newIncomingCall(String callId, in CallInfo info); + void newIncomingCall(String handle, String callId); /** * Tells CallsManager of a new outgoing call. Use of this method should always follow * {@link ICallService#call}. * - * @param callId The unique ID (via {@link #getNextCallId}) of the new outgoing call. - * TODO(santoscordon): May be easier to have ICallService#call provide an ID instead of - * requiring a separate call to getNextCallId(). - * @param info Information about the new call including but not limited to the start time of the - * call and information about the caller's handle. + * @param callId The unique ID (via {@link ICallService#call}) of the new outgoing call. */ - void newOutgoingCall(String callId, in CallInfo info); + void newOutgoingCall(String callId); /** * Sets a call's state to active (e.g., an ongoing call where two parties can actively diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index 7384d1b9caf56..91c5724a1dc94 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -25,10 +25,11 @@ import java.util.List; */ oneway interface ICallServiceLookupResponse { /** - * Receives the list of {@link ICallService}s as a list of {@link IBinder}s. + * Forwards the list of {@link ICallService}s as a list of {@link IBinder}s to be processed by + * Telecomm which will choose which call service, among potentially many, to place a call. * * @param callServices List of call services from {@link ICallServiceProvider}. * TODO(gilad): Rename to callServiceBinders. */ - void onResult(in List callServices); + void setCallServices(in List callServices); } From 658c0cf6c3140b5cafc4e8880e08a7dead39d24a Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 16 Jan 2014 19:53:05 -0800 Subject: [PATCH 039/102] Update the Telecomm APIs to use CallInfo. Replace uses of callId and/or handle with a single, extensible CallInfo object. Change-Id: I4b7b86ccb7153e5dc49f4d3fa31f485fd06a960a --- telecomm/java/android/telecomm/CallInfo.java | 22 ++++++++- .../java/android/telecomm/CallService.java | 47 ++++++------------- .../java/android/telecomm/ICallService.aidl | 21 ++++----- .../android/telecomm/ICallServiceAdapter.aidl | 13 +++-- .../telecomm/ICallServiceSelector.aidl | 13 ++--- 5 files changed, 56 insertions(+), 60 deletions(-) diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index d964944ed2a12..e96f3b4b84ab0 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -20,6 +20,7 @@ import android.os.Parcel; import android.os.Parcelable; import java.util.Date; +import java.util.UUID; /** * A parcelable holder class of Call information data. This class is intended for transfering call @@ -35,6 +36,11 @@ public final class CallInfo implements Parcelable { */ private final String mHandle; + /** + * Unique identifier for the call as a UUID string. + */ + private String mId; + // There are 4 timestamps that are important to a call: // 1) Created timestamp - The time at which the user explicitly chose to make the call. // 2) Connected timestamp - The time at which a call service confirms that it has connected @@ -49,8 +55,12 @@ public final class CallInfo implements Parcelable { /** * Persists handle of the other party of this call. + * + * @param id The unique ID of the call. + * @param handle The handle to the other party in this call. */ - public CallInfo(String handle) { + public CallInfo(String id, String handle) { + mId = id; mHandle = handle; } @@ -58,6 +68,10 @@ public final class CallInfo implements Parcelable { return mHandle; } + public String getId() { + return mId; + } + // // Parceling related code below here. // @@ -70,7 +84,10 @@ public final class CallInfo implements Parcelable { @Override public CallInfo createFromParcel(Parcel source) { - return new CallInfo(source.readString()); + String id = source.readString(); + String handle = source.readString(); + + return new CallInfo(id, handle); } @Override @@ -92,6 +109,7 @@ public final class CallInfo implements Parcelable { */ @Override public void writeToParcel(Parcel destination, int flags) { + destination.writeString(mId); destination.writeString(mHandle); } } diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 1f47a0ad1728d..148a136b3f508 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -59,25 +59,10 @@ public abstract class CallService extends Service { setCallServiceAdapter((ICallServiceAdapter) msg.obj); break; case MSG_IS_COMPATIBLE_WITH: - // See {@link CallServiceWrapper#isCompatibleWith} for dataObject definition. - try { - // TODO(santoscordon): Switch to using a custom class here instead. When we - // switch to using Call objects instead of handles directly, this may not even be - // necessary. - Pair dataObject = (Pair) msg.obj; - isCompatibleWith(dataObject.first, dataObject.second); - } catch (ClassCastException e) { - Log.e(TAG, "Unexpected object type for MSG_IS_COMPATIBLE_WITH.", e); - } + isCompatibleWith((CallInfo) msg.obj); break; case MSG_CALL: - // See {@link CallServiceWrapper#call} for dataObject definition. - try { - Pair dataObject = (Pair) msg.obj; - call(dataObject.first, dataObject.second); - } catch (ClassCastException e) { - Log.e(TAG, "Unexpected object type for MSG_CALL.", e); - } + call((CallInfo) msg.obj); break; case MSG_DISCONNECT: disconnect((String) msg.obj); @@ -99,15 +84,13 @@ public abstract class CallService extends Service { } @Override - public void isCompatibleWith(String handle, String callId) { - Pair dataObject = new Pair(handle, callId); - mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, dataObject).sendToTarget(); + public void isCompatibleWith(CallInfo callInfo) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, callInfo).sendToTarget(); } @Override - public void call(String handle, String callId) { - Pair dataObject = new Pair(handle, callId); - mMessageHandler.obtainMessage(MSG_CALL, dataObject).sendToTarget(); + public void call(CallInfo callInfo) { + mMessageHandler.obtainMessage(MSG_CALL, callInfo).sendToTarget(); } @Override @@ -170,27 +153,25 @@ public abstract class CallService extends Service { public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); /** - * Determines if the CallService can make calls to the handle. Response is sent via - * ICallServiceAdapter. When responding, the correct call ID must be specified along with - * the handle. + * Determines if the CallService can place the specified call. Response is sent via + * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be + * specified. * - * @param handle The destination handle to test against. - * @param callId The call identifier associated with this compatibility request. + * @param callInfo The details of the relevant call. */ - public abstract void isCompatibleWith(String handle, String callId); + public abstract void isCompatibleWith(CallInfo callInfo); /** - * Attempts to call the relevant party using the specified handle, be it a phone number, + * Attempts to call the relevant party using the specified call's handle, be it a phone number, * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the * call service respond via {@link ICallServiceAdapter#newOutgoingCall} if it can successfully * make the call. * - * @param handle The destination handle to call. - * @param callId Unique identifier for the call. + * @param callInfo The details of the relevant call. */ - public abstract void call(String handle, String callId); + public abstract void call(CallInfo callInfo); /** * Disconnects the specified call. diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 9d0223464355b..d82e2f5914d03 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -16,6 +16,7 @@ package android.telecomm; +import android.telecomm.CallInfo; import android.telecomm.ICallServiceAdapter; /** @@ -43,22 +44,19 @@ oneway interface ICallService { void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); /** - * Determines if the ICallService can make calls to the handle. Response is sent via + * Determines if the ICallService can place the specified call. Response is sent via * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be - * specified along with the handle. It is expected that the call service respond within 500 - * milliseconds. Any response that takes longer than 500 milliseconds will be treated as being - * incompatible. + * specified. It is expected that the call service respond within 500 milliseconds. Any response + * that takes longer than 500 milliseconds will be treated as being incompatible. * TODO(santoscordon): 500 ms was arbitrarily chosen and must be confirmed before this * API is made public. - * TODO(santoscordon): Switch from specific parameters to CallInfo/Call. * - * @param handle The destination handle to test against. - * @param callId The call identifier associated with this compatibility request. + * @param callInfo The details of the relevant call. */ - void isCompatibleWith(String handle, String callId); + void isCompatibleWith(in CallInfo callInfo); /** - * Attempts to call the relevant party using the specified handle, be it a phone number, + * Attempts to call the relevant party using the specified call's handle, be it a phone number, * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the @@ -67,10 +65,9 @@ oneway interface ICallService { * TODO(santoscordon): Figure out how a calls service can short-circuit a failure to * the adapter. * - * @param handle The destination handle to call. - * @param callId Unique identifier for the call. + * @param callInfo The details of the relevant call. */ - void call(String handle, String callId); + void call(in CallInfo callInfo); /** * Disconnects the call identified by callId. diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 71c5006ed5ec9..526351e69652e 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -31,13 +31,16 @@ oneway interface ICallServiceAdapter { void getNextCallId(/* TODO(santoscordon): Needs response object */); /** - * Receives confirmation of the call service's ability to make a call to the specified handle. + * Receives confirmation of a call service's ability to place a call. This method is used in + * response to {@link ICallService#isCompatibleWith}. + * TODO(santoscordon): rename to setIsCompatibleWith(). * - * @param handle The handle to call. - * @param callId The identifier of the call for which compatibility is being received. - * @param isCompatible True if the call service can place a call to the handle. + * @param callId The identifier of the call for which compatibility is being received. This ID + * should correspond to the ID given as part of the call information in + * {@link ICallService#isCompatibleWith}. + * @param isCompatible True if the call service can place the call. */ - void setCompatibleWith(String handle, String callId, boolean isCompatible); + void setCompatibleWith(String callId, boolean isCompatible); /** * Tells CallsManager of a new incoming call. diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index 13a3f4cf60159..58cbf6c3d967f 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -16,6 +16,7 @@ package android.telecomm; +import android.telecomm.CallInfo; import android.telecomm.ICallService; import android.telecomm.ICallServiceSelectionResponse; import android.telecomm.ICallSwitchabilityResponse; @@ -67,27 +68,23 @@ oneway interface ICallServiceSelector { /** * Initiates the process to retrieve the sorted set of call services that are preferred * by this call-service selector. - * TODO(gilad): Pass reduced-visibility call-service objects, see isSwitchable/callId below. - * TODO(gilad): Consider passing a Call object encapsulating the relevant call details (e.g. - * handle, contactInfo, etc). * - * @param handle The handle to dial. + * @param callInfo The details of the relevant call. * @param callServiceBinders The list of binders to select call services from. * @param response The response object through which the selected services are passed back * to the switchboard. */ void select( - String handle, + in CallInfo callInfo, in List callServiceBinders, in ICallServiceSelectionResponse response); /** * Determines if the specified ongoing call can/should be switched from the currently-used * call service to another. - * TODO(gilad): Pass a CallInfo instead that contains (among other fields) the callId. * - * @param callId The identifier of the call to disconnect. + * @param callInfo The details of the relevant call. * @param response The response object to be populated and returned to switchboard. */ - void isSwitchable(String callId, in ICallSwitchabilityResponse response); + void isSwitchable(in CallInfo callInfo, in ICallSwitchabilityResponse response); } From 8f3fd30a60d4a5b6e9c94d463681b0c0ac3f119e Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Mon, 27 Jan 2014 08:46:21 -0800 Subject: [PATCH 040/102] Add interfaces between Telecomm and InCall. Change-Id: Ie0e8c5e6626e1db33eb1142b302bf415785cfe47 --- Android.mk | 2 + .../java/android/telecomm/IInCallAdapter.aidl | 55 +++++++++++++++ .../java/android/telecomm/IInCallService.aidl | 68 +++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 telecomm/java/android/telecomm/IInCallAdapter.aidl create mode 100644 telecomm/java/android/telecomm/IInCallService.aidl diff --git a/Android.mk b/Android.mk index 091061e28328c..78a3495bfc8a5 100644 --- a/Android.mk +++ b/Android.mk @@ -284,6 +284,8 @@ LOCAL_SRC_FILES += \ telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl \ telecomm/java/android/telecomm/ICallServiceSelector.aidl \ telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl \ + telecomm/java/android/telecomm/IInCallAdapter.aidl \ + telecomm/java/android/telecomm/IInCallService.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/telecomm/java/android/telecomm/IInCallAdapter.aidl b/telecomm/java/android/telecomm/IInCallAdapter.aidl new file mode 100644 index 0000000000000..9fb7d4db91f10 --- /dev/null +++ b/telecomm/java/android/telecomm/IInCallAdapter.aidl @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** + * Receives commands from {@link IInCallService} implementations which should be executed by + * Telecomm. When Telecomm binds to a {@link IInCallService}, an instance of this class is given to + * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When + * the in-call service is notified of new calls ({@link IInCallService#addCall}), it can use the + * given call IDs to execute commands such as {@link #answerCall} for incoming calls or + * {@link #disconnectCall} for active calls the user would like to end. Some commands are only + * appropriate for calls in certain states; please consult each method for such limitations. + * TODO(santoscordon): Needs more/better comments once the API is finalized. + * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. + * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording + * the javadoc to reference those states precisely. + */ +oneway interface IInCallAdapter { + /** + * Instructs Telecomm to answer the specified call. + * + * @param callId The identifier of the call to answer. + */ + void answerCall(String callId); + + /** + * Instructs Telecomm to reject the specified call. + * TODO(santoscordon): Add reject-with-text-message parameter when that feature + * is ported over. + * + * @param callId The identifier of the call to reject. + */ + void rejectCall(String callId); + + /** + * Instructs Telecomm to disconnect the specified call. + * + * @param callId The identifier of the call to disconnect. + */ + void disconnectCall(String callId); +} diff --git a/telecomm/java/android/telecomm/IInCallService.aidl b/telecomm/java/android/telecomm/IInCallService.aidl new file mode 100644 index 0000000000000..bc3a6b6cf5aae --- /dev/null +++ b/telecomm/java/android/telecomm/IInCallService.aidl @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.telecomm.CallInfo; +import android.telecomm.IInCallAdapter; + +/** + * This service is implemented by any app that wishes to provide the user-interface for managing + * phone calls. Telecomm binds to this service while there exists a live (active or incoming) + * call, and uses it to notify the in-call app of any live and and recently disconnected calls. + * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better + * defined. + * TODO(santoscordon): What happens if two or more apps on a given decide implement this interface? + */ +oneway interface IInCallService { + + /** + * Provides the in-call app an adapter object through which to send call-commands such as + * answering and rejecting incoming calls, disconnecting active calls, and putting calls in + * special states (mute, hold, etc). + * + * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. + */ + void setInCallAdapter(in IInCallAdapter inCallAdapter); + + /** + * Indicates to the in-call app that a new call has been created and an appropriate + * user-interface should be built and shown to notify the user. Information about the call + * including its current state is passed in through the callInfo object. + * + * @param callInfo Information about the new call. + */ + void addCall(in CallInfo callInfo); + + /** + * Indicates to the in-call app that a call has moved to the active state. + * TODO(santoscordon): link javadoc to "active" constant once CallState is defined. + * + * @param callId The identifier of the call that became active. + */ + void setActive(String callId); + + /** + * Indicates to the in-call app that a call has been disconnected and the user should be + * notified. + * TODO(santoscordon): link javadoc to "disconnected" constant once CallState is defined. + * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both + * depending on what is ultimately needed to support all scenarios. + * + * @param callId The identifier of the call that was disconnected. + */ + void setDisconnected(String callId); +} From 9cf80ed2b454a881cc11c6dc83b78206bb5cb9a9 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 28 Jan 2014 01:25:43 -0800 Subject: [PATCH 041/102] Add @hide to InCall APIs (fixes build break). Change-Id: I2911d1e96466e26891c5a6f1edb2440114eb3b4e --- telecomm/java/android/telecomm/IInCallAdapter.aidl | 1 + telecomm/java/android/telecomm/IInCallService.aidl | 1 + 2 files changed, 2 insertions(+) diff --git a/telecomm/java/android/telecomm/IInCallAdapter.aidl b/telecomm/java/android/telecomm/IInCallAdapter.aidl index 9fb7d4db91f10..594b046fd232b 100644 --- a/telecomm/java/android/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/android/telecomm/IInCallAdapter.aidl @@ -28,6 +28,7 @@ package android.telecomm; * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording * the javadoc to reference those states precisely. + * @hide */ oneway interface IInCallAdapter { /** diff --git a/telecomm/java/android/telecomm/IInCallService.aidl b/telecomm/java/android/telecomm/IInCallService.aidl index bc3a6b6cf5aae..1418b0340e336 100644 --- a/telecomm/java/android/telecomm/IInCallService.aidl +++ b/telecomm/java/android/telecomm/IInCallService.aidl @@ -26,6 +26,7 @@ import android.telecomm.IInCallAdapter; * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better * defined. * TODO(santoscordon): What happens if two or more apps on a given decide implement this interface? + * @hide */ oneway interface IInCallService { From 805afaaf23afef78b9053dad432378142eba8c12 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 29 Jan 2014 11:58:36 -0800 Subject: [PATCH 042/102] CallInfo usage everywhere; selector using call-service Id strings. Change-Id: Ide81dc869d6e025a83685b7247ee4179ec7097ab --- .../java/android/telecomm/ICallServiceAdapter.aidl | 9 ++++----- .../telecomm/ICallServiceSelectionResponse.aidl | 8 +++----- .../java/android/telecomm/ICallServiceSelector.aidl | 12 ++++++------ 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 526351e69652e..48622d310f928 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -43,13 +43,12 @@ oneway interface ICallServiceAdapter { void setCompatibleWith(String callId, boolean isCompatible); /** - * Tells CallsManager of a new incoming call. + * Tells CallsManager of a new incoming call. CallInfo should be populated using a new call ID + * retrieved via {@link #getNextCallId}. * - * @param handle The handle to the other party or null if no such handle is available (as with - * blocked caller ID). - * @param callId The unique ID (via {@link #getNextCallId}) of the new incoming call. + * @param callInfo The details of the relevant call. */ - void newIncomingCall(String handle, String callId); + void newIncomingCall(in CallInfo callInfo); /** * Tells CallsManager of a new outgoing call. Use of this method should always follow diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl index 143d17130f26c..710f5f6627751 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -29,10 +29,8 @@ oneway interface ICallServiceSelectionResponse { * Records the sorted set of call services that are preferred by the corresponding * call-service selector. * - * @param callServiceBinders The relevant call-service binders ordered by priority (most - * desired first). - * TODO(gilad): Move to use call-service IDs or (reduced-visibility) call-service wrappers - * instead, see isSwitchable/callId in ICallServiceSelector.aidl for more details. + * @param selectedCallServiceIds The relevant call-service IDs ordered by priority (most desired + * first). */ - void setPreferredCallServices(in List callServiceBinders); + void setSelectedCallServiceIds(in List selectedCallServiceIds); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index 58cbf6c3d967f..8841f5e3a0fd6 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -66,17 +66,17 @@ import java.util.List; oneway interface ICallServiceSelector { /** - * Initiates the process to retrieve the sorted set of call services that are preferred - * by this call-service selector. + * Initiates the process to retrieve the sorted set of call service IDs that are preferred by + * this call-service selector. * * @param callInfo The details of the relevant call. - * @param callServiceBinders The list of binders to select call services from. - * @param response The response object through which the selected services are passed back - * to the switchboard. + * @param callServiceIds The list of call-service IDs. + * @param response The response object through which the selected service IDs are passed back + * to Telecomm. */ void select( in CallInfo callInfo, - in List callServiceBinders, + in List callServiceIds, in ICallServiceSelectionResponse response); /** From 3d3735e3d307c309f778d4976fc7316c785c1789 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 29 Jan 2014 14:10:10 -0800 Subject: [PATCH 043/102] Adding call state constants to Telecomm. Change-Id: I40675477a96c9a74a17782870c5824702466e6cc --- telecomm/java/android/telecomm/CallState.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 telecomm/java/android/telecomm/CallState.java diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java new file mode 100644 index 0000000000000..5216c85b47c3a --- /dev/null +++ b/telecomm/java/android/telecomm/CallState.java @@ -0,0 +1,64 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** + * Defines call-state constants of the different states in which a call can exist. Although states + * have the notion of normal transitions, due to the volatile nature of telephony systems, code + * that uses these states should be resilient to unexpected state changes outside of what is + * considered traditional. + */ +public final class CallState { + /** + * Indicates that a call is new and not connected. This is used as the default state internally + * within Telecomm and should not be used between Telecomm and call services. + * @hide + */ + static final int NEW = 1; + + /** + * Indicates that a call is outgoing and in the dialing state. A call transitions to this state + * once an outgoing call has begun (e.g., user presses the dial button in Dialer). Calls in this + * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED} + * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user). + */ + static final int DIALING = 2; + + /** + * Indicates that a call is incoming and the user still has the option of answering, rejecting, + * or doing nothing with the call. This state is usually associated with some type of audible + * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED} + * otherwise. + */ + static final int RINGING = 3; + + /** + * Indicates that a call is currently connected to another party and a communication channel is + * open between them. The normal transition to this state is by the user answering a + * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party. + */ + static final int ACTIVE = 4; + + /** + * Indicates that a call is currently disconnected. All states can transition to this state + * by the call service giving notice that the connection has been severed. When the user + * explicitly ends a call, it will not transition to this state until the call service confirms + * the disconnection or communication was lost to the call service currently responsible for + * this call (e.g., call service crashes). + */ + static final int DISCONNECTED = 5; +} From 04c9f556c060e591e6502d2b0c65bf2c89f92398 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 29 Jan 2014 20:15:15 -0800 Subject: [PATCH 044/102] fix build break. Change-Id: I3e9ab82fb4afb87aaa09259dba269146fe858e72 --- api/current.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/current.txt b/api/current.txt index 0cacfe21f4f73..030d45cf49850 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24171,6 +24171,14 @@ package android.speech.tts { } +package android.telecomm { + + public final class CallState { + ctor public CallState(); + } + +} + package android.telephony { public final class CellIdentityCdma implements android.os.Parcelable { From 713f1d7f213aece78a260b5b0bdee4c99205e75f Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 29 Jan 2014 19:56:10 -0800 Subject: [PATCH 045/102] Change call state to enum and add it to CallInfo. Change-Id: Ic88096aa6680245913e4d50da1ff7797813f8abc --- api/current.txt | 9 +++-- telecomm/java/android/telecomm/CallInfo.java | 35 +++++++++++++------ telecomm/java/android/telecomm/CallState.java | 16 +++++---- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/api/current.txt b/api/current.txt index 030d45cf49850..355fb39e29ad8 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24173,8 +24173,13 @@ package android.speech.tts { package android.telecomm { - public final class CallState { - ctor public CallState(); + public final class CallState extends java.lang.Enum { + method public static android.telecomm.CallState valueOf(java.lang.String); + method public static final android.telecomm.CallState[] values(); + enum_constant public static final android.telecomm.CallState ACTIVE; + enum_constant public static final android.telecomm.CallState DIALING; + enum_constant public static final android.telecomm.CallState DISCONNECTED; + enum_constant public static final android.telecomm.CallState RINGING; } } diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index e96f3b4b84ab0..236206189e460 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -30,17 +30,22 @@ import java.util.UUID; */ public final class CallInfo implements Parcelable { + /** + * Unique identifier for the call as a UUID string. + */ + private final String mId; + + /** + * The state of the call. + */ + private final CallState mState; + /** * Endpoint to which the call is connected. * This could be the dialed value for outgoing calls or the caller id of incoming calls. */ private final String mHandle; - /** - * Unique identifier for the call as a UUID string. - */ - private String mId; - // There are 4 timestamps that are important to a call: // 1) Created timestamp - The time at which the user explicitly chose to make the call. // 2) Connected timestamp - The time at which a call service confirms that it has connected @@ -57,21 +62,27 @@ public final class CallInfo implements Parcelable { * Persists handle of the other party of this call. * * @param id The unique ID of the call. + * @param state The state of the call. * @param handle The handle to the other party in this call. */ - public CallInfo(String id, String handle) { + public CallInfo(String id, CallState state, String handle) { mId = id; + mState = state; mHandle = handle; } - public String getHandle() { - return mHandle; - } - public String getId() { return mId; } + public CallState getState() { + return mState; + } + + public String getHandle() { + return mHandle; + } + // // Parceling related code below here. // @@ -85,9 +96,10 @@ public final class CallInfo implements Parcelable { @Override public CallInfo createFromParcel(Parcel source) { String id = source.readString(); + CallState state = CallState.valueOf(source.readString()); String handle = source.readString(); - return new CallInfo(id, handle); + return new CallInfo(id, state, handle); } @Override @@ -110,6 +122,7 @@ public final class CallInfo implements Parcelable { @Override public void writeToParcel(Parcel destination, int flags) { destination.writeString(mId); + destination.writeString(mState.name()); destination.writeString(mHandle); } } diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index 5216c85b47c3a..4f774cbcdd33d 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -22,13 +22,15 @@ package android.telecomm; * that uses these states should be resilient to unexpected state changes outside of what is * considered traditional. */ -public final class CallState { +public enum CallState { /** * Indicates that a call is new and not connected. This is used as the default state internally - * within Telecomm and should not be used between Telecomm and call services. + * within Telecomm and should not be used between Telecomm and call services. Call services are + * not expected to ever interact with NEW calls so we keep this value hidden as a Telecomm + * internal-only value. * @hide */ - static final int NEW = 1; + NEW, /** * Indicates that a call is outgoing and in the dialing state. A call transitions to this state @@ -36,7 +38,7 @@ public final class CallState { * state usually transition to {@link #ACTIVE} if the call was answered or {@link #DISCONNECTED} * if the call was disconnected somehow (e.g., failure or cancellation of the call by the user). */ - static final int DIALING = 2; + DIALING, /** * Indicates that a call is incoming and the user still has the option of answering, rejecting, @@ -44,14 +46,14 @@ public final class CallState { * ringtone. Normal transitions are to {@link #ACTIVE} if answered or {@link #DISCONNECTED} * otherwise. */ - static final int RINGING = 3; + RINGING, /** * Indicates that a call is currently connected to another party and a communication channel is * open between them. The normal transition to this state is by the user answering a * {@link #DIALING} call or a {@link #RINGING} call being answered by the other party. */ - static final int ACTIVE = 4; + ACTIVE, /** * Indicates that a call is currently disconnected. All states can transition to this state @@ -60,5 +62,5 @@ public final class CallState { * the disconnection or communication was lost to the call service currently responsible for * this call (e.g., call service crashes). */ - static final int DISCONNECTED = 5; + DISCONNECTED; } From f6d868bd543b5178b6f35757141807273e53eca8 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 5 Feb 2014 13:04:15 -0800 Subject: [PATCH 046/102] Adds methods for a call service respond to a call(). Change-Id: Ib597037b8fafcfa54f3bd1ee21b91285ea595fd4 --- .../android/telecomm/ICallServiceAdapter.aidl | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 48622d310f928..112a1dd5367b8 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -51,12 +51,21 @@ oneway interface ICallServiceAdapter { void newIncomingCall(in CallInfo callInfo); /** - * Tells CallsManager of a new outgoing call. Use of this method should always follow - * {@link ICallService#call}. + * Tells Telecomm that an attempt to place the specified outgoing call succeeded. + * TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is + * somehow no longer in the DIALING state. * - * @param callId The unique ID (via {@link ICallService#call}) of the new outgoing call. + * @param callId The ID of the outgoing call. */ - void newOutgoingCall(String callId); + void handleSuccessfulOutgoingCall(String callId); + + /** + * Tells Telecomm that an attempt to place the specified outgoing call failed. + * + * @param callId The ID of the outgoing call. + * @param errorMessage The error associated with the failed call attempt. + */ + void handleFailedOutgoingCall(String callId, String errorMessage); /** * Sets a call's state to active (e.g., an ongoing call where two parties can actively From 5f66e8819f4b1e74be0959e7ea5916e2d2c9e9f3 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 4 Feb 2014 12:54:35 -0800 Subject: [PATCH 047/102] Adding ACTION_INCOMING_CALL intents to new TelecommConstants.java class. Change-Id: I468156fa9499ff904678b5ed57f4fa3cec2f7229 --- .../android/telecomm/TelecommConstants.java | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 telecomm/java/android/telecomm/TelecommConstants.java diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java new file mode 100644 index 0000000000000..ebb855cd7042c --- /dev/null +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** + * Defines constants for use with the Telecomm system. + */ +public final class TelecommConstants { + /** + *

Activity action: Starts the UI for handing an incoming call. This intent starts the + * in-call UI by notifying the Telecomm system that an incoming call exists for a specific call + * service (see {@link android.telecomm.ICallService}). Telecomm reads the Intent extras to find + * and bind to the appropriate {@link android.telecomm.ICallServiceProvider} and + * {@link android.telecomm.ICallService} implementations which Telecomm will ultimately use to + * control and get information about the call.

+ * + *

Input: get*Extra field {@link #EXTRA_CALL_SERVICE_PROVIDER} contains the component name + * of the {@link android.telecomm.ICallServiceProvider} service Telecomm should bind to. + * {@link #EXTRA_CALL_SERVICE_ID} contains a string-based identifier that Telecomm will pass to + * {@link ICallServiceProvider#getCallService} to get the appropriate {@link ICallService}.

+ * + * TODO(santoscordon): Needs permissions. + * TODO(santoscordon): Consider moving this into a simple method call on a system service. + */ + public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + + /** + * Extra for {@link #ACTION_INCOMING_CALL} that contains the component name of the call-service + * provider used by Telecomm to obtain the correct call service for the incoming call. + */ + public static final String EXTRA_CALL_SERVICE_PROVIDER = + "android.intent.extra.CALL_SERVICE_PROVIDER"; + + /** + * Extra for {@link #ACTION_INCOMING_CALL} that contains the String-based ID that Telecomm will + * use to obtain the correct call service for the incoming call via + * {@link android.telecomm.ICallServiceProvider#getCallService}. + */ + public static final String EXTRA_CALL_SERVICE_ID = "android.intent.extra.CALL_SERVICE_ID"; +} From 8bc8228f73b62fb906969c70f5182edf44460311 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 6 Feb 2014 18:36:10 -0800 Subject: [PATCH 048/102] Update API Change-Id: I0bd0fe32900de6288ef1c19d1ecf85868d467085 --- api/current.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/current.txt b/api/current.txt index 355fb39e29ad8..ef155fe9bce06 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24182,6 +24182,13 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState RINGING; } + public final class TelecommConstants { + ctor public TelecommConstants(); + field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + field public static final java.lang.String EXTRA_CALL_SERVICE_ID = "android.intent.extra.CALL_SERVICE_ID"; + field public static final java.lang.String EXTRA_CALL_SERVICE_PROVIDER = "android.intent.extra.CALL_SERVICE_PROVIDER"; + } + } package android.telephony { From 222f1290ba3d5eab8ddc7b93afc01c12662ac963 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Sun, 2 Feb 2014 19:51:34 -0800 Subject: [PATCH 049/102] Make telecomm APIs public Change-Id: Ie7243be369e55df9696b544d8b286c978ceb4b39 --- api/current.txt | 142 ++++++++++++++++++ telecomm/java/android/telecomm/CallInfo.java | 1 - .../java/android/telecomm/CallService.java | 1 - .../android/telecomm/CallServiceProvider.java | 1 - .../java/android/telecomm/ICallService.aidl | 1 - .../android/telecomm/ICallServiceAdapter.aidl | 1 - .../telecomm/ICallServiceLookupResponse.aidl | 1 - .../telecomm/ICallServiceProvider.aidl | 1 - .../ICallServiceSelectionResponse.aidl | 1 - .../telecomm/ICallServiceSelector.aidl | 2 - .../telecomm/ICallSwitchabilityResponse.aidl | 1 - .../java/android/telecomm/IInCallAdapter.aidl | 1 - .../java/android/telecomm/IInCallService.aidl | 1 - 13 files changed, 142 insertions(+), 13 deletions(-) diff --git a/api/current.txt b/api/current.txt index ef155fe9bce06..35ffe51072dc7 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24173,6 +24173,32 @@ package android.speech.tts { package android.telecomm { + public final class CallInfo implements android.os.Parcelable { + ctor public CallInfo(java.lang.String, android.telecomm.CallState, java.lang.String); + method public int describeContents(); + method public java.lang.String getHandle(); + method public java.lang.String getId(); + method public android.telecomm.CallState getState(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; + } + + public abstract class CallService extends android.app.Service { + ctor protected CallService(); + method public abstract void call(android.telecomm.CallInfo); + method public abstract void disconnect(java.lang.String); + method public android.os.IBinder getBinder(); + method public abstract void isCompatibleWith(android.telecomm.CallInfo); + method public android.os.IBinder onBind(android.content.Intent); + method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); + } + + public abstract class CallServiceProvider extends android.app.Service { + ctor protected CallServiceProvider(); + method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse); + method public android.os.IBinder onBind(android.content.Intent); + } + public final class CallState extends java.lang.Enum { method public static android.telecomm.CallState valueOf(java.lang.String); method public static final android.telecomm.CallState[] values(); @@ -24182,6 +24208,122 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState RINGING; } + public abstract interface ICallService implements android.os.IInterface { + method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void disconnect(java.lang.String) throws android.os.RemoteException; + method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException; + } + + public static abstract class ICallService.Stub extends android.os.Binder implements android.telecomm.ICallService { + ctor public ICallService.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallService asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallServiceAdapter implements android.os.IInterface { + method public abstract void getNextCallId() throws android.os.RemoteException; + method public abstract void handleFailedOutgoingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; + method public abstract void handleSuccessfulOutgoingCall(java.lang.String) throws android.os.RemoteException; + method public abstract void newIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void setActive(java.lang.String) throws android.os.RemoteException; + method public abstract void setCompatibleWith(java.lang.String, boolean) throws android.os.RemoteException; + method public abstract void setDialing(java.lang.String) throws android.os.RemoteException; + method public abstract void setDisconnected(java.lang.String) throws android.os.RemoteException; + method public abstract void setRinging(java.lang.String) throws android.os.RemoteException; + } + + public static abstract class ICallServiceAdapter.Stub extends android.os.Binder implements android.telecomm.ICallServiceAdapter { + ctor public ICallServiceAdapter.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallServiceAdapter asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallServiceLookupResponse implements android.os.IInterface { + method public abstract void setCallServices(java.util.List) throws android.os.RemoteException; + } + + public static abstract class ICallServiceLookupResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceLookupResponse { + ctor public ICallServiceLookupResponse.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallServiceLookupResponse asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallServiceProvider implements android.os.IInterface { + method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse) throws android.os.RemoteException; + } + + public static abstract class ICallServiceProvider.Stub extends android.os.Binder implements android.telecomm.ICallServiceProvider { + ctor public ICallServiceProvider.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallServiceProvider asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallServiceSelectionResponse implements android.os.IInterface { + method public abstract void setSelectedCallServiceIds(java.util.List) throws android.os.RemoteException; + } + + public static abstract class ICallServiceSelectionResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelectionResponse { + ctor public ICallServiceSelectionResponse.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallServiceSelectionResponse asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallServiceSelector implements android.os.IInterface { + method public abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.ICallSwitchabilityResponse) throws android.os.RemoteException; + method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; + } + + public static abstract class ICallServiceSelector.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelector { + ctor public ICallServiceSelector.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallServiceSelector asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface ICallSwitchabilityResponse implements android.os.IInterface { + method public abstract void setIsSwitchable(boolean) throws android.os.RemoteException; + } + + public static abstract class ICallSwitchabilityResponse.Stub extends android.os.Binder implements android.telecomm.ICallSwitchabilityResponse { + ctor public ICallSwitchabilityResponse.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.ICallSwitchabilityResponse asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface IInCallAdapter implements android.os.IInterface { + method public abstract void answerCall(java.lang.String) throws android.os.RemoteException; + method public abstract void disconnectCall(java.lang.String) throws android.os.RemoteException; + method public abstract void rejectCall(java.lang.String) throws android.os.RemoteException; + } + + public static abstract class IInCallAdapter.Stub extends android.os.Binder implements android.telecomm.IInCallAdapter { + ctor public IInCallAdapter.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.IInCallAdapter asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + + public abstract interface IInCallService implements android.os.IInterface { + method public abstract void addCall(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void setActive(java.lang.String) throws android.os.RemoteException; + method public abstract void setDisconnected(java.lang.String) throws android.os.RemoteException; + method public abstract void setInCallAdapter(android.telecomm.IInCallAdapter) throws android.os.RemoteException; + } + + public static abstract class IInCallService.Stub extends android.os.Binder implements android.telecomm.IInCallService { + ctor public IInCallService.Stub(); + method public android.os.IBinder asBinder(); + method public static android.telecomm.IInCallService asInterface(android.os.IBinder); + method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; + } + public final class TelecommConstants { ctor public TelecommConstants(); field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index 236206189e460..b818e6dcf9f6d 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -26,7 +26,6 @@ import java.util.UUID; * A parcelable holder class of Call information data. This class is intended for transfering call * information from Telecomm to call services and thus is read-only. * TODO(santoscordon): Need final public-facing comments in this file. - * @hide */ public final class CallInfo implements Parcelable { diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 148a136b3f508..d0c4f198e28af 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -43,7 +43,6 @@ import android.util.Pair; * synchronous responses. As a result, most responses are handled by (or have TODOs to handle) * response objects instead of return values. * TODO(santoscordon): Improve paragraph above once the final design is in place. - * @hide */ public abstract class CallService extends Service { private static final String TAG = CallService.class.getSimpleName(); diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index a24521a181d26..64294d8072ac9 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -34,7 +34,6 @@ import android.telecomm.ICallServiceLookupResponse; * * TODO(santoscordon): Improve paragraph above once the final design is in place. Needs more * about how this can be used. - * @hide */ public abstract class CallServiceProvider extends Service { diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index d82e2f5914d03..d9716b5be6295 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -30,7 +30,6 @@ import android.telecomm.ICallServiceAdapter; * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. * * TODO(santoscordon): Need final public-facing comments in this file. - * @hide */ oneway interface ICallService { diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 112a1dd5367b8..72f9fdb4fa75a 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -21,7 +21,6 @@ import android.telecomm.CallInfo; /** * Provides methods for ICallService implementations to interact with the system phone app. * TODO(santoscordon): Need final public-facing comments in this file. - * @hide */ oneway interface ICallServiceAdapter { diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index 91c5724a1dc94..a3153f200ff26 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -21,7 +21,6 @@ import java.util.List; /** * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations. - * @hide */ oneway interface ICallServiceLookupResponse { /** diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/android/telecomm/ICallServiceProvider.aidl index 2e2610c68af60..8b0a736cfb446 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/android/telecomm/ICallServiceProvider.aidl @@ -30,7 +30,6 @@ import android.telecomm.ICallServiceLookupResponse; * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as * well as all (one or more) candidates failing to issue the call. - * @hide */ oneway interface ICallServiceProvider { diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl index 710f5f6627751..d3032eac4159c 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -22,7 +22,6 @@ import java.util.List; /** * Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService} * implementations with which to connect the corresponding outgoing call. - * @hide */ oneway interface ICallServiceSelectionResponse { /** diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index 8841f5e3a0fd6..ffdfd91ea6221 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -60,8 +60,6 @@ import java.util.List; * all supported (either for a given call or globally across a given selector) , isSwitchable * below can return false blindly to suppress all "select" calls beyond the initial one (that * is used to establish outgoing calls). - * - * @hide */ oneway interface ICallServiceSelector { diff --git a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl index 628ad6b499a75..afb4122f40b71 100644 --- a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl +++ b/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl @@ -19,7 +19,6 @@ package android.telecomm; /** * Used by {@link ICallServiceSelector}s to return whether or not the relevant * call is switchable. - * @hide */ oneway interface ICallSwitchabilityResponse { /** diff --git a/telecomm/java/android/telecomm/IInCallAdapter.aidl b/telecomm/java/android/telecomm/IInCallAdapter.aidl index 594b046fd232b..9fb7d4db91f10 100644 --- a/telecomm/java/android/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/android/telecomm/IInCallAdapter.aidl @@ -28,7 +28,6 @@ package android.telecomm; * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording * the javadoc to reference those states precisely. - * @hide */ oneway interface IInCallAdapter { /** diff --git a/telecomm/java/android/telecomm/IInCallService.aidl b/telecomm/java/android/telecomm/IInCallService.aidl index 1418b0340e336..bc3a6b6cf5aae 100644 --- a/telecomm/java/android/telecomm/IInCallService.aidl +++ b/telecomm/java/android/telecomm/IInCallService.aidl @@ -26,7 +26,6 @@ import android.telecomm.IInCallAdapter; * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better * defined. * TODO(santoscordon): What happens if two or more apps on a given decide implement this interface? - * @hide */ oneway interface IInCallService { From 9a23a55df21f79b0830a5c3fec3b3cf2f5b829da Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Mon, 3 Feb 2014 11:44:06 -0800 Subject: [PATCH 050/102] Add CallServiceInfo descriptor object CallServiceInfo allows CallServiceProviders to describe the CallServices' requirements (e.g. network requirements) and info (e.g. ComponentName). Change-Id: Iff694b998d18e7ce424ec976e9134e3c70f8b6f4 --- api/current.txt | 24 ++- .../android/telecomm/CallServiceInfo.aidl | 19 ++ .../android/telecomm/CallServiceInfo.java | 203 ++++++++++++++++++ .../telecomm/ICallServiceLookupResponse.aidl | 11 +- .../ICallServiceSelectionResponse.aidl | 7 +- .../telecomm/ICallServiceSelector.aidl | 3 +- 6 files changed, 255 insertions(+), 12 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallServiceInfo.aidl create mode 100644 telecomm/java/android/telecomm/CallServiceInfo.java diff --git a/api/current.txt b/api/current.txt index 35ffe51072dc7..0d75264791fe3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24193,6 +24193,24 @@ package android.telecomm { method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); } + public final class CallServiceInfo implements android.os.Parcelable { + method public int describeContents(); + method public java.lang.String getCallServiceId(); + method public int getNetworkType(); + method public android.content.ComponentName getServiceComponent(); + method public static android.telecomm.CallServiceInfo.Builder newBuilder(android.content.Context); + method public void writeToParcel(android.os.Parcel, int); + field public static final int FLAG_MOBILE = 4; // 0x4 + field public static final int FLAG_PSTN = 2; // 0x2 + field public static final int FLAG_WIFI = 1; // 0x1 + } + + public static class CallServiceInfo.Builder { + method public android.telecomm.CallServiceInfo build(); + method public android.telecomm.CallServiceInfo.Builder setCallService(java.lang.Class); + method public android.telecomm.CallServiceInfo.Builder setNetworkType(int); + } + public abstract class CallServiceProvider extends android.app.Service { ctor protected CallServiceProvider(); method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse); @@ -24242,7 +24260,7 @@ package android.telecomm { } public abstract interface ICallServiceLookupResponse implements android.os.IInterface { - method public abstract void setCallServices(java.util.List) throws android.os.RemoteException; + method public abstract void setCallServices(java.util.List) throws android.os.RemoteException; } public static abstract class ICallServiceLookupResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceLookupResponse { @@ -24264,7 +24282,7 @@ package android.telecomm { } public abstract interface ICallServiceSelectionResponse implements android.os.IInterface { - method public abstract void setSelectedCallServiceIds(java.util.List) throws android.os.RemoteException; + method public abstract void setSelectedCallServiceInfos(java.util.List) throws android.os.RemoteException; } public static abstract class ICallServiceSelectionResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelectionResponse { @@ -24276,7 +24294,7 @@ package android.telecomm { public abstract interface ICallServiceSelector implements android.os.IInterface { method public abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.ICallSwitchabilityResponse) throws android.os.RemoteException; - method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; + method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; } public static abstract class ICallServiceSelector.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelector { diff --git a/telecomm/java/android/telecomm/CallServiceInfo.aidl b/telecomm/java/android/telecomm/CallServiceInfo.aidl new file mode 100644 index 0000000000000..fa6dea01c9f43 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +parcelable CallServiceInfo; diff --git a/telecomm/java/android/telecomm/CallServiceInfo.java b/telecomm/java/android/telecomm/CallServiceInfo.java new file mode 100644 index 0000000000000..f6d0827e1eb42 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceInfo.java @@ -0,0 +1,203 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.content.ComponentName; +import android.content.Context; +import android.os.Parcel; +import android.os.Parcelable; +import android.util.Log; + +import java.util.UUID; + +/** + * An immutable object containing information about a given {@link CallService}. Instances are + * created using the enclosed {@link Builder}. + */ +public final class CallServiceInfo implements Parcelable { + private static final String TAG = CallServiceInfo.class.getSimpleName(); + + /** + * A placeholder value indicating an invalid network type. + * @hide + */ + private static final int FLAG_INVALID = 0; + + /** + * Indicates that the device must be connected to a Wi-Fi network in order for the backing + * {@link CallService} to be used. + */ + public static final int FLAG_WIFI = 0x01; + + /** + * Indicates that the device must be connected to a cellular PSTN network in order for the + * backing {@link CallService} to be used. + */ + public static final int FLAG_PSTN = 0x02; + + /** + * Indicates that the device must be connected to a cellular data network in order for the + * backing {@link CallService} to be used. + */ + public static final int FLAG_MOBILE = 0x04; + + /** + * Represents all of the defined FLAG_ constants so validity can be easily checked. + * @hide + */ + public static final int FLAG_ALL = FLAG_WIFI | FLAG_PSTN | FLAG_MOBILE; + + /** + * A unique ID used to identify a given instance. + */ + private final String mCallServiceId; + + /** + * The {@link ComponentName} of the {@link CallService} implementation which this is describing. + */ + private final ComponentName mComponentName; + + /** + * The type of connection that the {@link CallService} requires; will be one of the FLAG_* + * constants defined in this class. + */ + private final int mNetworkType; + + private CallServiceInfo(String callServiceId, ComponentName componentName, int networkType) { + mCallServiceId = callServiceId; + mComponentName = componentName; + mNetworkType = networkType; + } + + /** + * @return The ID used to identify this {@link CallService}. + */ + public String getCallServiceId() { + return mCallServiceId; + } + + /** + * @return The {@link ComponentName} of the {@link CallService}. + */ + public ComponentName getServiceComponent() { + return mComponentName; + } + + /** + * @return The network type required by the {@link CallService} to place a call. + */ + public int getNetworkType() { + return mNetworkType; + } + + /** + * @param context {@link Context} to use for the construction of the {@link Builder}. + * @return A new {@link Builder} instance. + */ + public static Builder newBuilder(Context context) { + return new Builder(context); + } + + /** + * Creates {@link CallServiceInfo} instances. Builders should be created with the + * {@link CallServiceInfo#newBuilder(Context)} method. + */ + public static class Builder { + /** The {@link Context} to use to verify {@link ComponentName} ownership. */ + private Context mContext; + + /** The {@link ComponentName} pointing to the backing {@link CallService}. */ + private ComponentName mComponentName; + + /** The required network type that the {@link CallService} needs. */ + private int mNetworkType = FLAG_INVALID; + + private Builder(Context context) { + mContext = context; + } + + /** + * Set which {@link CallService} this {@link CallServiceInfo} is describing. + * + * @param callServiceClass The {@link CallService} class + * @return This {@link Builder} for method chaining. + */ + public Builder setCallService(Class callServiceClass) { + mComponentName = new ComponentName(mContext, callServiceClass); + return this; + } + + /** + * Which network type the backing {@link CallService} requires. This must be one of the + * {@link CallServiceInfo}.TYPE_* fields. + * + * @param networkType Which network type the backing {@link CallService} requires. + * @return This {@link Builder} for method chaining. + */ + public Builder setNetworkType(int networkType) { + mNetworkType = networkType; + return this; + } + + /** + * @return A constructed {@link CallServiceInfo} object. + */ + public CallServiceInfo build() { + // STOPSHIP: Verify validity of ComponentName (permissions, intents, etc) + + // Make sure that they passed in a valid network flag combination + if (mNetworkType == FLAG_INVALID || ((mNetworkType & FLAG_ALL) == 0)) { + + Log.wtf(TAG, "Invalid network type for " + mComponentName); + // Revert them back to TYPE_INVALID so it won't be considered. + mNetworkType = FLAG_INVALID; + } + + // TODO: Should we use a sha1 of the ComponentName? Would prevent duplicates. + return new CallServiceInfo(UUID.randomUUID().toString(), mComponentName, mNetworkType); + } + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeString(mCallServiceId); + dest.writeParcelable(mComponentName, 0); + dest.writeInt(mNetworkType); + } + + static final Creator CREATOR = new Creator() { + @Override + public CallServiceInfo createFromParcel(Parcel source) { + String id = source.readString(); + ComponentName componentName = source.readParcelable( + CallServiceInfo.class.getClassLoader()); + int networkType = source.readInt(); + + return new CallServiceInfo(id, componentName, networkType); + } + + @Override + public CallServiceInfo[] newArray(int size) { + return new CallServiceInfo[size]; + } + }; +} diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index a3153f200ff26..146d5f6492388 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -17,6 +17,7 @@ package android.telecomm; import android.os.IBinder; +import android.telecomm.CallServiceInfo; import java.util.List; /** @@ -24,11 +25,11 @@ import java.util.List; */ oneway interface ICallServiceLookupResponse { /** - * Forwards the list of {@link ICallService}s as a list of {@link IBinder}s to be processed by - * Telecomm which will choose which call service, among potentially many, to place a call. + * Forwards the list of {@link ICallService}s as a list of {@link CallServiceInfo}s to be + * processed by Telecomm which will choose which call service, among potentially many, to + * place a call. * - * @param callServices List of call services from {@link ICallServiceProvider}. - * TODO(gilad): Rename to callServiceBinders. + * @param callServices The set of call service descriptors from {@link ICallServiceProvider}. */ - void setCallServices(in List callServices); + void setCallServices(in List callServices); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl index d3032eac4159c..137676316502b 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -17,6 +17,7 @@ package android.telecomm; import android.os.IBinder; +import android.telecomm.CallServiceInfo; import java.util.List; /** @@ -28,8 +29,8 @@ oneway interface ICallServiceSelectionResponse { * Records the sorted set of call services that are preferred by the corresponding * call-service selector. * - * @param selectedCallServiceIds The relevant call-service IDs ordered by priority (most desired - * first). + * @param selectedCallServiceInfos The prioritized list of preferred CallServices to use for + * completing the call. */ - void setSelectedCallServiceIds(in List selectedCallServiceIds); + void setSelectedCallServiceInfos(in List selectedCallServiceInfos); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index ffdfd91ea6221..9652dec32439e 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -17,6 +17,7 @@ package android.telecomm; import android.telecomm.CallInfo; +import android.telecomm.CallServiceInfo; import android.telecomm.ICallService; import android.telecomm.ICallServiceSelectionResponse; import android.telecomm.ICallSwitchabilityResponse; @@ -74,7 +75,7 @@ oneway interface ICallServiceSelector { */ void select( in CallInfo callInfo, - in List callServiceIds, + in List callServiceInfos, in ICallServiceSelectionResponse response); /** From 35699a295a67b48d840f3e4326a9efefa116cfcf Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 11 Feb 2014 17:36:30 -0800 Subject: [PATCH 051/102] Following up on the TODO to rename newIncomingCall, see ag/417776 for the corresponding services/telecomm change. Change-Id: I8296856c2b8d89aa7962c9ccd231463b9b5e8079 --- telecomm/java/android/telecomm/ICallServiceAdapter.aidl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 72f9fdb4fa75a..2faf30d8df0a0 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -47,7 +47,7 @@ oneway interface ICallServiceAdapter { * * @param callInfo The details of the relevant call. */ - void newIncomingCall(in CallInfo callInfo); + void handleIncomingCall(in CallInfo callInfo); /** * Tells Telecomm that an attempt to place the specified outgoing call succeeded. From 77e0d606f63c8526931018a3ae86f8b9d722c0bd Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:36:26 -0800 Subject: [PATCH 052/102] Add interface definitions for CallService/PhoneService Interfaces are meant to replace ThirdParty*.aidl/java files in same directory long term. The differences in methods are on purpose and reflect more recent design directions. Change-Id: Ia98603a1d0b6d07a3393c5f7c5aa040f9e3916e4 --- .../android/internal/telephony/CallInfo.aidl | 19 +++++ .../android/internal/telephony/CallInfo.java | 77 +++++++++++++++++++ .../internal/telephony/ICallService.aidl | 61 +++++++++++++++ .../telephony/ICallServiceAdapter.aidl | 61 +++++++++++++++ 4 files changed, 218 insertions(+) create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.aidl create mode 100644 telephony/java/com/android/internal/telephony/CallInfo.java create mode 100644 telephony/java/com/android/internal/telephony/ICallService.aidl create mode 100644 telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl diff --git a/telephony/java/com/android/internal/telephony/CallInfo.aidl b/telephony/java/com/android/internal/telephony/CallInfo.aidl new file mode 100644 index 0000000000000..9140388587845 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.aidl @@ -0,0 +1,19 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +parcelable CallInfo; diff --git a/telephony/java/com/android/internal/telephony/CallInfo.java b/telephony/java/com/android/internal/telephony/CallInfo.java new file mode 100644 index 0000000000000..6bfc9d73e8c5c --- /dev/null +++ b/telephony/java/com/android/internal/telephony/CallInfo.java @@ -0,0 +1,77 @@ +/* +** Copyright 2013, The Android Open Source Project +** +** Licensed under the Apache License, Version 2.0 (the "License"); +** you may not use this file except in compliance with the License. +** You may obtain a copy of the License at +** +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, +** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** See the License for the specific language governing permissions and +** limitations under the License. +*/ + +package com.android.internal.telephony; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * A parcelable holder class of Call information data. + */ +public class CallInfo implements Parcelable { + + /** + * Endpoint to which the call is connected. + * This could be the dialed value for outgoing calls or the caller id of incoming calls. + */ + private String handle; + + public CallInfo(String handle) { + this.handle = handle; + } + + public String getHandle() { + return handle; + } + + // + // Parcelling related code below here. + // + + /** + * Responsible for creating CallInfo objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator () { + + @Override + public CallInfo createFromParcel(Parcel source) { + return new CallInfo(source.readString()); + } + + @Override + public CallInfo[] newArray(int size) { + return new CallInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallInfo object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(handle); + } +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl new file mode 100644 index 0000000000000..a24c860d08cd6 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Service interface for services which would like to provide calls to be + * managed by the system in-call UI. + * + * This interface provides methods that the android framework can use to deliver commands + * for calls provided by this call service including making new calls and disconnecting + * existing ones. A binding to ICallService implementations exists for two conditions: + * 1) There exists one or more live calls for that call service, + * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + */ +oneway interface ICallService { + + /** + * Determines if the CallService can make calls to the handle. + * TODO(santoscordon): Move this method into its own service interface long term. + * TODO(santoscordon): Add response callback parameter. + */ + void isCompatibleWith(String handle); + + /** + * Attempts to call the relevant party using the specified handle, be it a phone number, + * SIP address, or some other kind of user ID. Note that the set of handle types is + * dynamically extensible since call providers should be able to implement arbitrary + * handle-calling systems. See {@link #isCompatibleWith}. + * TODO(santoscordon): Should this have a response attached to it to ensure that the call + * service actually plans to make the call? + */ + void call(String handle); + + /** + * Disconnects the call identified by callId. + */ + void disconnect(String callId); + + /** + * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls + * and communicate state changes of existing calls. This is the first method that is called + * after a the framework binds to the call service. + */ + void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); +} diff --git a/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl new file mode 100644 index 0000000000000..bc900f00d71ae --- /dev/null +++ b/telephony/java/com/android/internal/telephony/ICallServiceAdapter.aidl @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.internal.telephony; + +import com.android.internal.telephony.CallInfo; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + */ +oneway interface ICallServiceAdapter { + + /** + * Retrieves a new unique call id for use with newOutgoingCall and newIncomingCall. + */ + void getNextCallId(/* TODO(santoscordon): Needs response object */); + + /** + * Tells CallsManager of a new incoming call. + */ + void newIncomingCall(String callId, in CallInfo info); + + /** + * Tells CallsManager of a new outgoing call. + */ + void newOutgoingCall(String callId, in CallInfo info); + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + */ + void setActive(String callId); + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + */ + void setRinging(String callId); + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + */ + void setDialing(String callId); + + /** + * Sets a call's state to disconnected. + */ + void setDisconnected(String callId); +} From 968740b5f574fee11d71a35c321f4e9e13d13570 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Feb 2014 22:51:32 -0800 Subject: [PATCH 053/102] Add abstract base implementation of CallService. Base implementation takes care of a lot of boilerplate code. Change-Id: Iaf5a16f5718727cee0f7efb4af53a021536f50d8 --- .../java/android/telephony/CallService.java | 165 ++++++++++++++++++ .../internal/telephony/ICallService.aidl | 2 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 telephony/java/android/telephony/CallService.java diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java new file mode 100644 index 0000000000000..0ea55b283e7c3 --- /dev/null +++ b/telephony/java/android/telephony/CallService.java @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telephony; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Message; + +import com.android.internal.telephony.ICallService; +import com.android.internal.telephony.ICallServiceAdapter; + +/** + * Base implementation of CallService which can be used to provide calls for the system + * in-call UI. CallService is a one-way service from the framework's CallsManager to any app + * that would like to provide calls managed by the default system in-call user interface. + * When the service is bound by the framework, CallsManager will call setCallServiceAdapter + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * for communicating back to CallsManager. Subsequently, more specific methods of the service + * will be called to perform various call actions including making an outgoing call and + * disconnected existing calls. + * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before + * we can unhide this API. + * + * Most public methods of this function are backed by a one-way AIDL interface which precludes + * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) + * response objects instead of return values. + * TODO(santoscordon): Improve paragraph above once the final design is in place. + * @hide + */ +public abstract class CallService extends Service { + + /** + * Default Handler used to consolidate binder method calls onto a single thread. + */ + private final class CallServiceMessageHandler extends Handler { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_CALL_SERVICE_ADAPTER: + setCallServiceAdapter((ICallServiceAdapter) msg.obj); + break; + case MSG_IS_COMPATIBLE_WITH: + isCompatibleWith((String) msg.obj); + break; + case MSG_CALL: + call((String) msg.obj); + break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; + default: + break; + } + } + } + + /** + * Default ICallService implementation provided to CallsManager via {@link #onBind}. + */ + private final class CallServiceWrapper extends ICallService.Stub { + @Override + public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { + mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) + .sendToTarget(); + } + + @Override + public void isCompatibleWith(String handle) { + mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); + } + + @Override + public void call(String handle) { + mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); + } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } + } + + // Only used internally by this class. + // Binder method calls on this service can occur on multiple threads. These messages are used + // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a + // single thread. Keeping it on a single thread allows CallService implementations to avoid + // needing multi-threaded code in their own callback routines. + private static final int + MSG_SET_CALL_SERVICE_ADAPTER = 1, + MSG_IS_COMPATIBLE_WITH = 2, + MSG_CALL = 3, + MSG_DISCONNECT = 4; + + /** + * Message handler for consolidating binder callbacks onto a single thread. + * See {@link #CallServiceMessageHandler}. + */ + private final CallServiceMessageHandler mMessageHandler; + + /** + * Default binder implementation of {@link ICallService} interface. + */ + private final CallServiceWrapper mBinder; + + /** + * Protected constructor called only by subclasses creates the binder interface and + * single-threaded message handler. + */ + protected CallService() { + mMessageHandler = new CallServiceMessageHandler(); + mBinder = new CallServiceWrapper(); + } + + /** {@inheritDoc} */ + public IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * changes of existing calls. + * @param callServiceAdapter Adapter object for communicating call to CallsManager + * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we + * wrap that in a wrapper like we do for CallService/ICallService? + * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. + */ + public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + + /** + * Determines if the CallService can make calls to the handle. + * @param handle The handle to test for compatibility. + * TODO(santoscordon): Need response parameter. + */ + public abstract void isCompatibleWith(String handle); + + /** + * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, + * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the + * same handle and this service is selected by the switchboard to handle the call. + * @param handle The handle to call. + */ + public abstract void call(String handle); + + /** + * Disconnects the specified call. + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); +} diff --git a/telephony/java/com/android/internal/telephony/ICallService.aidl b/telephony/java/com/android/internal/telephony/ICallService.aidl index a24c860d08cd6..cb9b2e838ddf9 100644 --- a/telephony/java/com/android/internal/telephony/ICallService.aidl +++ b/telephony/java/com/android/internal/telephony/ICallService.aidl @@ -57,5 +57,5 @@ oneway interface ICallService { * and communicate state changes of existing calls. This is the first method that is called * after a the framework binds to the call service. */ - void setCallServiceAdapter(ICallServiceAdapter CallServiceAdapter); + void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); } From 7692be41290faccf3f38ab7ccf8844a7014cc6c1 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 12 Feb 2014 13:28:33 -0800 Subject: [PATCH 054/102] Delete telephony's CallService This moved to telecomm; kill it again. Change-Id: I6ae581ac3fe5417f3a17f10f8615caacc69a21ad --- .../java/android/telephony/CallService.java | 165 ------------------ 1 file changed, 165 deletions(-) delete mode 100644 telephony/java/android/telephony/CallService.java diff --git a/telephony/java/android/telephony/CallService.java b/telephony/java/android/telephony/CallService.java deleted file mode 100644 index 0ea55b283e7c3..0000000000000 --- a/telephony/java/android/telephony/CallService.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.telephony; - -import android.app.Service; -import android.content.Intent; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; - -import com.android.internal.telephony.ICallService; -import com.android.internal.telephony.ICallServiceAdapter; - -/** - * Base implementation of CallService which can be used to provide calls for the system - * in-call UI. CallService is a one-way service from the framework's CallsManager to any app - * that would like to provide calls managed by the default system in-call user interface. - * When the service is bound by the framework, CallsManager will call setCallServiceAdapter - * which will provide CallService with an instance of {@link CallServiceAdapter} to be used - * for communicating back to CallsManager. Subsequently, more specific methods of the service - * will be called to perform various call actions including making an outgoing call and - * disconnected existing calls. - * TODO(santoscordon): Needs more about AndroidManifest.xml service registrations before - * we can unhide this API. - * - * Most public methods of this function are backed by a one-way AIDL interface which precludes - * syncronous responses. As a result, most responses are handled by (or have TODOs to handle) - * response objects instead of return values. - * TODO(santoscordon): Improve paragraph above once the final design is in place. - * @hide - */ -public abstract class CallService extends Service { - - /** - * Default Handler used to consolidate binder method calls onto a single thread. - */ - private final class CallServiceMessageHandler extends Handler { - @Override - public void handleMessage(Message msg) { - switch (msg.what) { - case MSG_SET_CALL_SERVICE_ADAPTER: - setCallServiceAdapter((ICallServiceAdapter) msg.obj); - break; - case MSG_IS_COMPATIBLE_WITH: - isCompatibleWith((String) msg.obj); - break; - case MSG_CALL: - call((String) msg.obj); - break; - case MSG_DISCONNECT: - disconnect((String) msg.obj); - break; - default: - break; - } - } - } - - /** - * Default ICallService implementation provided to CallsManager via {@link #onBind}. - */ - private final class CallServiceWrapper extends ICallService.Stub { - @Override - public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { - mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) - .sendToTarget(); - } - - @Override - public void isCompatibleWith(String handle) { - mMessageHandler.obtainMessage(MSG_IS_COMPATIBLE_WITH, handle).sendToTarget(); - } - - @Override - public void call(String handle) { - mMessageHandler.obtainMessage(MSG_CALL, handle).sendToTarget(); - } - - @Override - public void disconnect(String callId) { - mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); - } - } - - // Only used internally by this class. - // Binder method calls on this service can occur on multiple threads. These messages are used - // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a - // single thread. Keeping it on a single thread allows CallService implementations to avoid - // needing multi-threaded code in their own callback routines. - private static final int - MSG_SET_CALL_SERVICE_ADAPTER = 1, - MSG_IS_COMPATIBLE_WITH = 2, - MSG_CALL = 3, - MSG_DISCONNECT = 4; - - /** - * Message handler for consolidating binder callbacks onto a single thread. - * See {@link #CallServiceMessageHandler}. - */ - private final CallServiceMessageHandler mMessageHandler; - - /** - * Default binder implementation of {@link ICallService} interface. - */ - private final CallServiceWrapper mBinder; - - /** - * Protected constructor called only by subclasses creates the binder interface and - * single-threaded message handler. - */ - protected CallService() { - mMessageHandler = new CallServiceMessageHandler(); - mBinder = new CallServiceWrapper(); - } - - /** {@inheritDoc} */ - public IBinder onBind(Intent intent) { - return mBinder; - } - - /** - * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state - * changes of existing calls. - * @param callServiceAdapter Adapter object for communicating call to CallsManager - * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we - * wrap that in a wrapper like we do for CallService/ICallService? - * TODO(santoscordon): Consider rename of CallServiceAdapter to CallsManager. - */ - public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); - - /** - * Determines if the CallService can make calls to the handle. - * @param handle The handle to test for compatibility. - * TODO(santoscordon): Need response parameter. - */ - public abstract void isCompatibleWith(String handle); - - /** - * Calls the specified handle. Handle type is dynamically extensible and can be a phone number, - * a SIP address, or other types. Only called if {@link #isCompatibleWith} returns true for the - * same handle and this service is selected by the switchboard to handle the call. - * @param handle The handle to call. - */ - public abstract void call(String handle); - - /** - * Disconnects the specified call. - * @param callId The ID of the call to disconnect. - */ - public abstract void disconnect(String callId); -} From a69403224d62153cee843cd9697e8924faa8eb89 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 12 Feb 2014 13:55:51 -0800 Subject: [PATCH 055/102] Remove some duplicate methods Merge conflicts resulted in some duplicated methods. Change-Id: Id7336f7441a7ded2088f01c3d76110c7860686cd From f4c06145af8961f4280c17b67db1ca19a2729a3a Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 12 Feb 2014 14:53:32 -0800 Subject: [PATCH 056/102] Delete GLES20Layer DO NOT MERGE Looks like this was dropped by the automerger. Change-Id: I59d85ee47c6b3478e6ded89b61a95d45df781068 From 07823df111220090805653b49d89505a87f2ce9e Mon Sep 17 00:00:00 2001 From: Derek Tan Date: Tue, 4 Feb 2014 12:05:05 -0800 Subject: [PATCH 057/102] Expose sendEnvelope. Change-Id: I21565fae9ba8f163aed9104db355aecf9bae1796 From 120eb5b2a2080390fed10c97b70f289781bdeab7 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 12 Feb 2014 16:22:23 -0800 Subject: [PATCH 058/102] Update api Change-Id: I77a6f2c906b0df61cfdd64298c1cfe3f213a98d7 --- api/current.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 0d75264791fe3..cf1621e0a85af 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24243,8 +24243,8 @@ package android.telecomm { public abstract interface ICallServiceAdapter implements android.os.IInterface { method public abstract void getNextCallId() throws android.os.RemoteException; method public abstract void handleFailedOutgoingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; + method public abstract void handleIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void handleSuccessfulOutgoingCall(java.lang.String) throws android.os.RemoteException; - method public abstract void newIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void setActive(java.lang.String) throws android.os.RemoteException; method public abstract void setCompatibleWith(java.lang.String, boolean) throws android.os.RemoteException; method public abstract void setDialing(java.lang.String) throws android.os.RemoteException; From 0e4430721157ae0affc2f1ba8b5517dcaabb13e7 Mon Sep 17 00:00:00 2001 From: Derek Tan Date: Thu, 13 Feb 2014 14:49:26 -0800 Subject: [PATCH 059/102] Fix the inconsistent name on @param and the real param. Change-Id: If9853e91f55c0be89cdf77ae7c4369f274a45bb6 From c3010b39c98e2b136c38d68172dbf2dfcbe58c12 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Sat, 8 Feb 2014 19:12:38 -0800 Subject: [PATCH 060/102] Add a CallServiceSelector base implementation Add the base class for implementing CallServiceSelectors. Change-Id: I292d962f1b73d0966af0c484ebddc724f8e6c925 --- .../android/telecomm/CallServiceSelector.java | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 telecomm/java/android/telecomm/CallServiceSelector.java diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java new file mode 100644 index 0000000000000..cfa8eb3afa65e --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.app.Service; +import android.content.Intent; +import android.os.Binder; +import android.os.IBinder; +import android.os.RemoteException; + +import java.util.List; + +/** + * Allows for the organization of {@link CallService}s for outbound calls. Given a call and list of + * {@link CallService} IDs, order the list in terms of priority and return it using + * {@link #select(CallInfo, List)}.
+ *
+ * Also determine whether a call is switchable (can be moved between {@link CallService}s) or not + * using {@link #isSwitchable(CallInfo)}. + */ +public abstract class CallServiceSelector extends Service { + + /** Manages the binder calls so that the implementor does not need to deal it. */ + private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub { + @Override + public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response) + throws RemoteException { + // Ensure that we're running with the app's normal permission level + long ident = Binder.clearCallingIdentity(); + try { + response.setIsSwitchable(CallServiceSelector.this.isSwitchable(callInfo)); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + + @Override + public void select(CallInfo callInfo, List callServiceIds, + ICallServiceSelectionResponse response) throws RemoteException { + // Ensure that we're running with the app's normal permission level + long ident = Binder.clearCallingIdentity(); + try { + response.setSelectedCallServiceIds( + CallServiceSelector.this.select(callInfo, callServiceIds)); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + private final CallServiceSelectorBinder mBinder; + + protected CallServiceSelector() { + mBinder = new CallServiceSelectorBinder(); + } + + @Override + public final IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Determines (and returns) whether the given call is switchable. That is, whether the call can + * be moved to another {@link CallService} seamlessly.
+ *
+ * This method is not called on the UI thread and is safe to block. + * + * @param callInfo The call being potentially switched between {@link CallService}s. + * @return Whether the given call is switchable or not. + */ + protected abstract boolean isSwitchable(CallInfo callInfo); + + /** + * Return a list of prioritized {@link CallService}s which should be used to complete the given + * call.
+ *
+ * This method is not called on the UI thread and is safe to block. + * + * @param callInfo The call being placed using the {@link CallService}s. + * @param callServiceIds The IDs of the {@link CallService}s to organize for the call. + * + * @return A list of prioritized {@link CallService} IDs to use to complete the given call. + */ + protected abstract List select(CallInfo callInfo, List callServiceIds); +} From bd63f90a789bfb608dbd036d60c4d08f9fd1f2d9 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 14 Feb 2014 01:59:01 -0800 Subject: [PATCH 061/102] New call service methods for incoming calls. Adds a method that allows Telecomm to request confirmation of an incoming call and another method on the adapter through which the confirmation is sent. Change-Id: Ib5d0a71f40ea3d09a42f31c479c22aed1dbc5ce8 --- api/current.txt | 7 +-- .../java/android/telecomm/CallService.java | 46 +++++++++++++------ .../java/android/telecomm/ICallService.aidl | 12 +++++ .../android/telecomm/ICallServiceAdapter.aidl | 14 +++--- 4 files changed, 55 insertions(+), 24 deletions(-) diff --git a/api/current.txt b/api/current.txt index cf1621e0a85af..18dde9f08559c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24186,6 +24186,7 @@ package android.telecomm { public abstract class CallService extends android.app.Service { ctor protected CallService(); method public abstract void call(android.telecomm.CallInfo); + method public abstract void confirmIncomingCall(java.lang.String, java.lang.String); method public abstract void disconnect(java.lang.String); method public android.os.IBinder getBinder(); method public abstract void isCompatibleWith(android.telecomm.CallInfo); @@ -24228,6 +24229,7 @@ package android.telecomm { public abstract interface ICallService implements android.os.IInterface { method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void confirmIncomingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; method public abstract void disconnect(java.lang.String) throws android.os.RemoteException; method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException; @@ -24241,9 +24243,8 @@ package android.telecomm { } public abstract interface ICallServiceAdapter implements android.os.IInterface { - method public abstract void getNextCallId() throws android.os.RemoteException; + method public abstract void handleConfirmedIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void handleFailedOutgoingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; - method public abstract void handleIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void handleSuccessfulOutgoingCall(java.lang.String) throws android.os.RemoteException; method public abstract void setActive(java.lang.String) throws android.os.RemoteException; method public abstract void setCompatibleWith(java.lang.String, boolean) throws android.os.RemoteException; @@ -24745,11 +24746,11 @@ package android.telephony { method public boolean hasIccCard(); method public boolean iccCloseLogicalChannel(int); method public int iccOpenLogicalChannel(java.lang.String); - method public java.lang.String sendEnvelope(java.lang.String); 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, java.lang.String); + method public java.lang.String sendEnvelope(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 diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index d0c4f198e28af..a2fb7eb3b741d 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -27,6 +27,8 @@ import android.telecomm.ICallServiceAdapter; import android.util.Log; import android.util.Pair; +import com.android.internal.os.SomeArgs; + /** * Base implementation of CallService which can be used to provide calls for the system * in-call UI. CallService is a one-way service from the framework's CallsManager to any app @@ -66,6 +68,12 @@ public abstract class CallService extends Service { case MSG_DISCONNECT: disconnect((String) msg.obj); break; + case MSG_CONFIRM_INCOMING_CALL: + SomeArgs args = (SomeArgs) msg.obj; + String callId = (String) args.arg1; + String callToken = (String) args.arg2; + confirmIncomingCall(callId, callToken); + break; default: break; } @@ -75,7 +83,7 @@ public abstract class CallService extends Service { /** * Default ICallService implementation provided to CallsManager via {@link #onBind}. */ - private final class CallServiceWrapper extends ICallService.Stub { + private final class CallServiceBinder extends ICallService.Stub { @Override public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) { mMessageHandler.obtainMessage(MSG_SET_CALL_SERVICE_ADAPTER, callServiceAdapter) @@ -96,6 +104,14 @@ public abstract class CallService extends Service { public void disconnect(String callId) { mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); } + + @Override + public void confirmIncomingCall(String callId, String callToken) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = callToken; + mMessageHandler.obtainMessage(MSG_CONFIRM_INCOMING_CALL, args).sendToTarget(); + } } // Only used internally by this class. @@ -107,27 +123,19 @@ public abstract class CallService extends Service { MSG_SET_CALL_SERVICE_ADAPTER = 1, MSG_IS_COMPATIBLE_WITH = 2, MSG_CALL = 3, - MSG_DISCONNECT = 4; + MSG_DISCONNECT = 4, + MSG_CONFIRM_INCOMING_CALL = 5; /** * Message handler for consolidating binder callbacks onto a single thread. * See {@link #CallServiceMessageHandler}. */ - private final CallServiceMessageHandler mMessageHandler; + private final CallServiceMessageHandler mMessageHandler = new CallServiceMessageHandler(); /** * Default binder implementation of {@link ICallService} interface. */ - private final CallServiceWrapper mBinder; - - /** - * Protected constructor called only by subclasses creates the binder interface and - * single-threaded message handler. - */ - protected CallService() { - mMessageHandler = new CallServiceMessageHandler(); - mBinder = new CallServiceWrapper(); - } + private final CallServiceBinder mBinder = new CallServiceBinder(); /** {@inheritDoc} */ public IBinder onBind(Intent intent) { @@ -178,4 +186,16 @@ public abstract class CallService extends Service { * @param callId The ID of the call to disconnect. */ public abstract void disconnect(String callId); + + /** + * Confirms that the specified incoming call is connecting through this call service. Telecomm + * receives all incoming calls initially as intents that include information about a call + * and a token identifying the call. Before displaying any UI to the user, Telecomm confirms + * the existence of the incoming call by binding to the specified call service and calling + * this method. Confirmation responses are received through {@link ICallServiceAdapter}. + * + * @param callId The ID of the call. + * @param callToken The call token received through the incoming call intent. + */ + public abstract void confirmIncomingCall(String callId, String callToken); } diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index d9716b5be6295..cfd09c8c9c1b3 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -74,4 +74,16 @@ oneway interface ICallService { * @param callId The identifier of the call to disconnect. */ void disconnect(String callId); + + /** + * Confirms that the specified incoming call is connecting through this call service. Telecomm + * receives all incoming calls initially as intents that include information about a call + * and a token identifying the call. Before displaying any UI to the user, Telecomm confirms + * the existence of the incoming call by binding to the specified call service and calling + * this method. Confirmation responses are received through {@link ICallServiceAdapter}. + * + * @param callId The ID of the call. + * @param callToken The call token received through the incoming call intent. + */ + void confirmIncomingCall(String callId, String callToken); } diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index 2faf30d8df0a0..c1ffa68341265 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -24,11 +24,6 @@ import android.telecomm.CallInfo; */ oneway interface ICallServiceAdapter { - /** - * Retrieves a new unique call ID for use with newIncomingCall. - */ - void getNextCallId(/* TODO(santoscordon): Needs response object */); - /** * Receives confirmation of a call service's ability to place a call. This method is used in * response to {@link ICallService#isCompatibleWith}. @@ -42,12 +37,15 @@ oneway interface ICallServiceAdapter { void setCompatibleWith(String callId, boolean isCompatible); /** - * Tells CallsManager of a new incoming call. CallInfo should be populated using a new call ID - * retrieved via {@link #getNextCallId}. + * Receives confirmation of the existence of an incoming call connected through the call + * service. Invoked by the call service after it receives a confirmation request from Telecomm + * through {@link ICallService#confirmIncomingCall}. The call info object must contain all the + * updated status of the call and use the same call ID as was passed into + * {@link ICallService#confirmIncomingCall}. * * @param callInfo The details of the relevant call. */ - void handleIncomingCall(in CallInfo callInfo); + void handleConfirmedIncomingCall(in CallInfo callInfo); /** * Tells Telecomm that an attempt to place the specified outgoing call succeeded. From 591ef664d85c1f6e3c8e6a2bf8d94b9e60fcabb7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 18 Feb 2014 20:56:59 -0800 Subject: [PATCH 062/102] Fix build. Change-Id: I4633e4ab3753f0de328bbe0ef59e87dac1d58d54 --- .../android/telecomm/CallServiceSelector.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index cfa8eb3afa65e..74f05fee49ee8 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -49,13 +49,13 @@ public abstract class CallServiceSelector extends Service { } @Override - public void select(CallInfo callInfo, List callServiceIds, + public void select(CallInfo callInfo, List callServiceInfos, ICallServiceSelectionResponse response) throws RemoteException { // Ensure that we're running with the app's normal permission level long ident = Binder.clearCallingIdentity(); try { - response.setSelectedCallServiceIds( - CallServiceSelector.this.select(callInfo, callServiceIds)); + response.setSelectedCallServiceInfos( + CallServiceSelector.this.select(callInfo, callServiceInfos)); } finally { Binder.restoreCallingIdentity(ident); } @@ -91,9 +91,10 @@ public abstract class CallServiceSelector extends Service { * This method is not called on the UI thread and is safe to block. * * @param callInfo The call being placed using the {@link CallService}s. - * @param callServiceIds The IDs of the {@link CallService}s to organize for the call. - * - * @return A list of prioritized {@link CallService} IDs to use to complete the given call. + * @param callServiceInfos The details of the available {@link CallService}s with which to place + * the call. + * @return A list of prioritized {@link CallServiceInfo}s to use to complete the given call. */ - protected abstract List select(CallInfo callInfo, List callServiceIds); + protected abstract List select( + CallInfo callInfo, List callServiceInfos); } From 3342e77ec908ac55125b6dff6ae2545b862caece Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Tue, 18 Feb 2014 22:04:46 -0800 Subject: [PATCH 063/102] Update current.txt to fix build. Change-Id: Ie0a8e5749e1aad3fbe0098294cfe192de419ad25 --- api/current.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/current.txt b/api/current.txt index 18dde9f08559c..d6dc94c99c665 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24184,7 +24184,7 @@ package android.telecomm { } public abstract class CallService extends android.app.Service { - ctor protected CallService(); + ctor public CallService(); method public abstract void call(android.telecomm.CallInfo); method public abstract void confirmIncomingCall(java.lang.String, java.lang.String); method public abstract void disconnect(java.lang.String); @@ -24218,6 +24218,13 @@ package android.telecomm { method public android.os.IBinder onBind(android.content.Intent); } + public abstract class CallServiceSelector extends android.app.Service { + ctor protected CallServiceSelector(); + method protected abstract boolean isSwitchable(android.telecomm.CallInfo); + method public final android.os.IBinder onBind(android.content.Intent); + method protected abstract java.util.List select(android.telecomm.CallInfo, java.util.List); + } + public final class CallState extends java.lang.Enum { method public static android.telecomm.CallState valueOf(java.lang.String); method public static final android.telecomm.CallState[] values(); From 6adbaf70f31e29c52fd0bb8849774f58224df6f9 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 18 Feb 2014 19:48:48 -0800 Subject: [PATCH 064/102] Addressing the TODO to rename CallServiceInfo. Also removing some unused imports etc. Change-Id: I48176d5394aee0110f3b7a081a1a616b72b574b9 --- api/current.txt | 18 ++++----- .../java/android/telecomm/CallService.java | 11 ++---- ...ceInfo.aidl => CallServiceDescriptor.aidl} | 2 +- ...ceInfo.java => CallServiceDescriptor.java} | 37 +++++++++++-------- .../android/telecomm/CallServiceSelector.java | 15 ++++---- .../telecomm/ICallServiceLookupResponse.aidl | 14 +++---- .../ICallServiceSelectionResponse.aidl | 9 +++-- .../telecomm/ICallServiceSelector.aidl | 8 ++-- 8 files changed, 59 insertions(+), 55 deletions(-) rename telecomm/java/android/telecomm/{CallServiceInfo.aidl => CallServiceDescriptor.aidl} (94%) rename telecomm/java/android/telecomm/{CallServiceInfo.java => CallServiceDescriptor.java} (82%) diff --git a/api/current.txt b/api/current.txt index d6dc94c99c665..1db070d45852a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24194,22 +24194,22 @@ package android.telecomm { method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); } - public final class CallServiceInfo implements android.os.Parcelable { + public final class CallServiceDescriptor implements android.os.Parcelable { method public int describeContents(); method public java.lang.String getCallServiceId(); method public int getNetworkType(); method public android.content.ComponentName getServiceComponent(); - method public static android.telecomm.CallServiceInfo.Builder newBuilder(android.content.Context); + method public static android.telecomm.CallServiceDescriptor.Builder newBuilder(android.content.Context); method public void writeToParcel(android.os.Parcel, int); field public static final int FLAG_MOBILE = 4; // 0x4 field public static final int FLAG_PSTN = 2; // 0x2 field public static final int FLAG_WIFI = 1; // 0x1 } - public static class CallServiceInfo.Builder { - method public android.telecomm.CallServiceInfo build(); - method public android.telecomm.CallServiceInfo.Builder setCallService(java.lang.Class); - method public android.telecomm.CallServiceInfo.Builder setNetworkType(int); + public static class CallServiceDescriptor.Builder { + method public android.telecomm.CallServiceDescriptor build(); + method public android.telecomm.CallServiceDescriptor.Builder setCallService(java.lang.Class); + method public android.telecomm.CallServiceDescriptor.Builder setNetworkType(int); } public abstract class CallServiceProvider extends android.app.Service { @@ -24268,7 +24268,7 @@ package android.telecomm { } public abstract interface ICallServiceLookupResponse implements android.os.IInterface { - method public abstract void setCallServices(java.util.List) throws android.os.RemoteException; + method public abstract void setCallServiceDescriptors(java.util.List) throws android.os.RemoteException; } public static abstract class ICallServiceLookupResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceLookupResponse { @@ -24290,7 +24290,7 @@ package android.telecomm { } public abstract interface ICallServiceSelectionResponse implements android.os.IInterface { - method public abstract void setSelectedCallServiceInfos(java.util.List) throws android.os.RemoteException; + method public abstract void setSelectedCallServiceDescriptors(java.util.List) throws android.os.RemoteException; } public static abstract class ICallServiceSelectionResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelectionResponse { @@ -24302,7 +24302,7 @@ package android.telecomm { public abstract interface ICallServiceSelector implements android.os.IInterface { method public abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.ICallSwitchabilityResponse) throws android.os.RemoteException; - method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; + method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; } public static abstract class ICallServiceSelector.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelector { diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index a2fb7eb3b741d..7d1e32a34a384 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -21,11 +21,8 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; - import android.telecomm.ICallService; import android.telecomm.ICallServiceAdapter; -import android.util.Log; -import android.util.Pair; import com.android.internal.os.SomeArgs; @@ -47,7 +44,6 @@ import com.android.internal.os.SomeArgs; * TODO(santoscordon): Improve paragraph above once the final design is in place. */ public abstract class CallService extends Service { - private static final String TAG = CallService.class.getSimpleName(); /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -128,7 +124,7 @@ public abstract class CallService extends Service { /** * Message handler for consolidating binder callbacks onto a single thread. - * See {@link #CallServiceMessageHandler}. + * See {@link CallServiceMessageHandler}. */ private final CallServiceMessageHandler mMessageHandler = new CallServiceMessageHandler(); @@ -138,6 +134,7 @@ public abstract class CallService extends Service { private final CallServiceBinder mBinder = new CallServiceBinder(); /** {@inheritDoc} */ + @Override public IBinder onBind(Intent intent) { return getBinder(); } @@ -173,8 +170,8 @@ public abstract class CallService extends Service { * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link ICallServiceAdapter#newOutgoingCall} if it can successfully - * make the call. + * call service respond via {@link ICallServiceAdapter#handleIncomingCall} if it can + * successfully make the call. * * @param callInfo The details of the relevant call. */ diff --git a/telecomm/java/android/telecomm/CallServiceInfo.aidl b/telecomm/java/android/telecomm/CallServiceDescriptor.aidl similarity index 94% rename from telecomm/java/android/telecomm/CallServiceInfo.aidl rename to telecomm/java/android/telecomm/CallServiceDescriptor.aidl index fa6dea01c9f43..f517c731dacfa 100644 --- a/telecomm/java/android/telecomm/CallServiceInfo.aidl +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.aidl @@ -16,4 +16,4 @@ package android.telecomm; -parcelable CallServiceInfo; +parcelable CallServiceDescriptor; diff --git a/telecomm/java/android/telecomm/CallServiceInfo.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java similarity index 82% rename from telecomm/java/android/telecomm/CallServiceInfo.java rename to telecomm/java/android/telecomm/CallServiceDescriptor.java index f6d0827e1eb42..256b5589ec371 100644 --- a/telecomm/java/android/telecomm/CallServiceInfo.java +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java @@ -28,8 +28,8 @@ import java.util.UUID; * An immutable object containing information about a given {@link CallService}. Instances are * created using the enclosed {@link Builder}. */ -public final class CallServiceInfo implements Parcelable { - private static final String TAG = CallServiceInfo.class.getSimpleName(); +public final class CallServiceDescriptor implements Parcelable { + private static final String TAG = CallServiceDescriptor.class.getSimpleName(); /** * A placeholder value indicating an invalid network type. @@ -77,7 +77,11 @@ public final class CallServiceInfo implements Parcelable { */ private final int mNetworkType; - private CallServiceInfo(String callServiceId, ComponentName componentName, int networkType) { + private CallServiceDescriptor( + String callServiceId, + ComponentName componentName, + int networkType) { + mCallServiceId = callServiceId; mComponentName = componentName; mNetworkType = networkType; @@ -113,8 +117,8 @@ public final class CallServiceInfo implements Parcelable { } /** - * Creates {@link CallServiceInfo} instances. Builders should be created with the - * {@link CallServiceInfo#newBuilder(Context)} method. + * Creates {@link CallServiceDescriptor} instances. Builders should be created with the + * {@link CallServiceDescriptor#newBuilder(Context)} method. */ public static class Builder { /** The {@link Context} to use to verify {@link ComponentName} ownership. */ @@ -131,7 +135,7 @@ public final class CallServiceInfo implements Parcelable { } /** - * Set which {@link CallService} this {@link CallServiceInfo} is describing. + * Set which {@link CallService} this {@link CallServiceDescriptor} is describing. * * @param callServiceClass The {@link CallService} class * @return This {@link Builder} for method chaining. @@ -143,7 +147,7 @@ public final class CallServiceInfo implements Parcelable { /** * Which network type the backing {@link CallService} requires. This must be one of the - * {@link CallServiceInfo}.TYPE_* fields. + * {@link CallServiceDescriptor}.TYPE_* fields. * * @param networkType Which network type the backing {@link CallService} requires. * @return This {@link Builder} for method chaining. @@ -154,9 +158,9 @@ public final class CallServiceInfo implements Parcelable { } /** - * @return A constructed {@link CallServiceInfo} object. + * @return A constructed {@link CallServiceDescriptor} object. */ - public CallServiceInfo build() { + public CallServiceDescriptor build() { // STOPSHIP: Verify validity of ComponentName (permissions, intents, etc) // Make sure that they passed in a valid network flag combination @@ -168,7 +172,8 @@ public final class CallServiceInfo implements Parcelable { } // TODO: Should we use a sha1 of the ComponentName? Would prevent duplicates. - return new CallServiceInfo(UUID.randomUUID().toString(), mComponentName, mNetworkType); + return new CallServiceDescriptor( + UUID.randomUUID().toString(), mComponentName, mNetworkType); } } @@ -184,20 +189,20 @@ public final class CallServiceInfo implements Parcelable { dest.writeInt(mNetworkType); } - static final Creator CREATOR = new Creator() { + static final Creator CREATOR = new Creator() { @Override - public CallServiceInfo createFromParcel(Parcel source) { + public CallServiceDescriptor createFromParcel(Parcel source) { String id = source.readString(); ComponentName componentName = source.readParcelable( - CallServiceInfo.class.getClassLoader()); + CallServiceDescriptor.class.getClassLoader()); int networkType = source.readInt(); - return new CallServiceInfo(id, componentName, networkType); + return new CallServiceDescriptor(id, componentName, networkType); } @Override - public CallServiceInfo[] newArray(int size) { - return new CallServiceInfo[size]; + public CallServiceDescriptor[] newArray(int size) { + return new CallServiceDescriptor[size]; } }; } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 74f05fee49ee8..cef9987021d25 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -49,13 +49,14 @@ public abstract class CallServiceSelector extends Service { } @Override - public void select(CallInfo callInfo, List callServiceInfos, + public void select(CallInfo callInfo, List descriptors, ICallServiceSelectionResponse response) throws RemoteException { + // Ensure that we're running with the app's normal permission level long ident = Binder.clearCallingIdentity(); try { - response.setSelectedCallServiceInfos( - CallServiceSelector.this.select(callInfo, callServiceInfos)); + response.setSelectedCallServiceDescriptors( + CallServiceSelector.this.select(callInfo, descriptors)); } finally { Binder.restoreCallingIdentity(ident); } @@ -91,10 +92,10 @@ public abstract class CallServiceSelector extends Service { * This method is not called on the UI thread and is safe to block. * * @param callInfo The call being placed using the {@link CallService}s. - * @param callServiceInfos The details of the available {@link CallService}s with which to place + * @param descriptors The descriptors of the available {@link CallService}s with which to place * the call. - * @return A list of prioritized {@link CallServiceInfo}s to use to complete the given call. + * @return A list of prioritized call-service descriptors to use to complete the given call. */ - protected abstract List select( - CallInfo callInfo, List callServiceInfos); + protected abstract List select( + CallInfo callInfo, List descriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl index 146d5f6492388..2f2725799bdb9 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl @@ -17,19 +17,19 @@ package android.telecomm; import android.os.IBinder; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import java.util.List; /** - * Used by {@link ICallServiceProvider} to return a list of {@link ICallService} implementations. + * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s. */ oneway interface ICallServiceLookupResponse { /** - * Forwards the list of {@link ICallService}s as a list of {@link CallServiceInfo}s to be - * processed by Telecomm which will choose which call service, among potentially many, to - * place a call. + * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used + * in the context of attempting to place a pending outgoing call. * - * @param callServices The set of call service descriptors from {@link ICallServiceProvider}. + * @param callServiceDescriptors The set of call-service descriptors from + * {@link ICallServiceProvider}. */ - void setCallServices(in List callServices); + void setCallServiceDescriptors(in List callServiceDescriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl index 137676316502b..51efb8e3af83f 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl @@ -17,7 +17,7 @@ package android.telecomm; import android.os.IBinder; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import java.util.List; /** @@ -29,8 +29,9 @@ oneway interface ICallServiceSelectionResponse { * Records the sorted set of call services that are preferred by the corresponding * call-service selector. * - * @param selectedCallServiceInfos The prioritized list of preferred CallServices to use for - * completing the call. + * @param selectedCallServiceDescriptors The prioritized list of preferred call-service + * descriptors to use for completing the call. */ - void setSelectedCallServiceInfos(in List selectedCallServiceInfos); + void setSelectedCallServiceDescriptors( + in List selectedCallServiceDescriptors); } diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/android/telecomm/ICallServiceSelector.aidl index 9652dec32439e..8ca4c0cd4afcf 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/android/telecomm/ICallServiceSelector.aidl @@ -17,7 +17,7 @@ package android.telecomm; import android.telecomm.CallInfo; -import android.telecomm.CallServiceInfo; +import android.telecomm.CallServiceDescriptor; import android.telecomm.ICallService; import android.telecomm.ICallServiceSelectionResponse; import android.telecomm.ICallSwitchabilityResponse; @@ -65,17 +65,17 @@ import java.util.List; oneway interface ICallServiceSelector { /** - * Initiates the process to retrieve the sorted set of call service IDs that are preferred by + * Initiates the process to retrieve the sorted set of call services that are preferred by * this call-service selector. * * @param callInfo The details of the relevant call. - * @param callServiceIds The list of call-service IDs. + * @param callServiceDescriptors The list of call-service descriptors to select from. * @param response The response object through which the selected service IDs are passed back * to Telecomm. */ void select( in CallInfo callInfo, - in List callServiceInfos, + in List callServiceDescriptors, in ICallServiceSelectionResponse response); /** From 64a44a876b08f4a49238becb90bf1788b840a103 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 19 Feb 2014 16:39:53 -0800 Subject: [PATCH 065/102] Update CallServiceSelector API Move the consumer methods to the main thread and use response objects to return the results back to the caller. Change-Id: Ifc062cf49421079686d925406c823000232fa728 --- api/current.txt | 13 +- .../java/android/telecomm/CallService.java | 6 +- .../android/telecomm/CallServiceSelector.java | 163 ++++++++++++++---- 3 files changed, 144 insertions(+), 38 deletions(-) diff --git a/api/current.txt b/api/current.txt index 1db070d45852a..656dffc27f5d5 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24188,9 +24188,9 @@ package android.telecomm { method public abstract void call(android.telecomm.CallInfo); method public abstract void confirmIncomingCall(java.lang.String, java.lang.String); method public abstract void disconnect(java.lang.String); - method public android.os.IBinder getBinder(); + method public final android.os.IBinder getBinder(); method public abstract void isCompatibleWith(android.telecomm.CallInfo); - method public android.os.IBinder onBind(android.content.Intent); + method public final android.os.IBinder onBind(android.content.Intent); method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); } @@ -24220,9 +24220,14 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); - method protected abstract boolean isSwitchable(android.telecomm.CallInfo); + method protected abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.CallServiceSelector.Response); method public final android.os.IBinder onBind(android.content.Intent); - method protected abstract java.util.List select(android.telecomm.CallInfo, java.util.List); + method protected abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.CallServiceSelector.Response); + } + + public static abstract interface CallServiceSelector.Response { + method public abstract void setSelectedCallServices(java.util.List); + method public abstract void setSwitchable(boolean); } public final class CallState extends java.lang.Enum { diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 7d1e32a34a384..7144653f3d1d9 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -21,8 +21,6 @@ import android.content.Intent; import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.telecomm.ICallService; -import android.telecomm.ICallServiceAdapter; import com.android.internal.os.SomeArgs; @@ -135,14 +133,14 @@ public abstract class CallService extends Service { /** {@inheritDoc} */ @Override - public IBinder onBind(Intent intent) { + public final IBinder onBind(Intent intent) { return getBinder(); } /** * Returns binder object which can be used across IPC methods. */ - public IBinder getBinder() { + public final IBinder getBinder() { return mBinder; } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index cef9987021d25..6937bdfc081cc 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -18,47 +18,146 @@ package android.telecomm; import android.app.Service; import android.content.Intent; -import android.os.Binder; +import android.os.Handler; import android.os.IBinder; +import android.os.Looper; +import android.os.Message; import android.os.RemoteException; +import android.util.Log; + +import com.android.internal.os.SomeArgs; import java.util.List; /** * Allows for the organization of {@link CallService}s for outbound calls. Given a call and list of * {@link CallService} IDs, order the list in terms of priority and return it using - * {@link #select(CallInfo, List)}.
+ * {@link #select(CallInfo, List, CallServiceSelectionResponse)}.
*
* Also determine whether a call is switchable (can be moved between {@link CallService}s) or not - * using {@link #isSwitchable(CallInfo)}. + * using {@link #isSwitchable(CallInfo, CallSwitchabilityResponse)}. */ public abstract class CallServiceSelector extends Service { + private static final String TAG = CallServiceSelector.class.getSimpleName(); + + /** + * Used to tell {@link #mHandler} to move the call to + * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)} to the main + * thread. + */ + private static final int MSG_IS_SWITCHABLE = 1; + + /** + * Used to tell {@link #mHandler} to move the call to + * {@link #select(CallInfo, List, CallServiceSelectionResponse)} to the main thread. + */ + private static final int MSG_SELECT_CALL_SERVICES = 2; + + /** + * Listens for responses from the {@link CallServiceSelector} and passes them back through the + * Binder interface. This must be called from + * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}. + */ + public interface CallSwitchabilityResponse { + /** + * Mark a call as switchable (or not). This must be called by + * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}. + * + * @param isSwitchable Whether the call was switchable or not. + */ + void setSwitchable(boolean isSwitchable); + } + + /** + * Listens for responses from the {@link CallServiceSelector} and passes them back through the + * Binder interface. This must be called from + * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}. + */ + public interface CallServiceSelectionResponse { + /** + * Sets the prioritized {@link CallServiceDescriptor}s for the given {@link CallInfo}. This + * must be called by + * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}. + * + * @param callServices The prioritized {@link CallServiceDescriptor}s. + */ + void setSelectedCallServices(List callServices); + } + + /** Handler to move client-bound method calls to the main thread. */ + private final Handler mHandler = new Handler(Looper.getMainLooper()) { + @SuppressWarnings("unchecked") + @Override + public void handleMessage(Message msg) { + final SomeArgs args = (SomeArgs) msg.obj; + try { + switch (msg.what) { + case MSG_IS_SWITCHABLE: + isSwitchable((CallInfo) args.arg1, (CallSwitchabilityResponse) args.arg2); + break; + case MSG_SELECT_CALL_SERVICES: + select((CallInfo) args.arg1, (List) args.arg2, + (CallServiceSelectionResponse) args.arg3); + break; + } + } finally { + if (args != null) { + args.recycle(); + } + } + } + }; /** Manages the binder calls so that the implementor does not need to deal it. */ - private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub { + private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub + implements CallSwitchabilityResponse, CallServiceSelectionResponse { + private ICallSwitchabilityResponse mSwitchabilityResponse; + private ICallServiceSelectionResponse mSelectionResponse; + @Override public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response) throws RemoteException { - // Ensure that we're running with the app's normal permission level - long ident = Binder.clearCallingIdentity(); - try { - response.setIsSwitchable(CallServiceSelector.this.isSwitchable(callInfo)); - } finally { - Binder.restoreCallingIdentity(ident); - } + mSwitchabilityResponse = response; + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callInfo; + args.arg2 = this; + mHandler.obtainMessage(MSG_IS_SWITCHABLE, args).sendToTarget(); } @Override public void select(CallInfo callInfo, List descriptors, ICallServiceSelectionResponse response) throws RemoteException { + mSelectionResponse = response; + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callInfo; + args.arg2 = descriptors; + args.arg3 = this; + mHandler.obtainMessage(MSG_SELECT_CALL_SERVICES, args).sendToTarget(); + } - // Ensure that we're running with the app's normal permission level - long ident = Binder.clearCallingIdentity(); - try { - response.setSelectedCallServiceDescriptors( - CallServiceSelector.this.select(callInfo, descriptors)); - } finally { - Binder.restoreCallingIdentity(ident); + @Override + public void setSwitchable(boolean isSwitchable) { + if (mSwitchabilityResponse != null) { + try { + mSwitchabilityResponse.setIsSwitchable(isSwitchable); + } catch (RemoteException e) { + Log.d(TAG, "Failed to set switchability", e); + } + } else { + Log.wtf(TAG, "Switchability response object not set"); + } + } + + @Override + public void setSelectedCallServices(List callServices) { + if (mSelectionResponse != null) { + try { + mSelectionResponse.setSelectedCallServiceDescriptors(callServices); + } catch (RemoteException e) { + Log.d(TAG, "Failed to set call services", e); + } + } else { + Log.wtf(TAG, "Selector response object not set"); } } } @@ -75,27 +174,31 @@ public abstract class CallServiceSelector extends Service { } /** - * Determines (and returns) whether the given call is switchable. That is, whether the call can - * be moved to another {@link CallService} seamlessly.
+ * Determines whether the given call is switchable. That is, whether the call can be moved to + * another {@link CallService} seamlessly. Once this is determined, the result is passed to the + * given {@link CallSwitchabilityResponse} listener.
*
- * This method is not called on the UI thread and is safe to block. + * This method is called on the main thread and is not safe to block. * * @param callInfo The call being potentially switched between {@link CallService}s. - * @return Whether the given call is switchable or not. + * @param response The {@link CallSwitchabilityResponse} listener to call back with the result. */ - protected abstract boolean isSwitchable(CallInfo callInfo); + protected abstract void isSwitchable(CallInfo callInfo, CallSwitchabilityResponse response); /** - * Return a list of prioritized {@link CallService}s which should be used to complete the given - * call.
+ * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return + * them through the given {@link CallServiceSelectionResponse} listener.
*
- * This method is not called on the UI thread and is safe to block. + * This method is called on the UI thread and is not safe to block. * * @param callInfo The call being placed using the {@link CallService}s. * @param descriptors The descriptors of the available {@link CallService}s with which to place - * the call. - * @return A list of prioritized call-service descriptors to use to complete the given call. + * the call. + * @param response The {@link CallServiceSelectionResponse} listener to call back with the + * result. */ - protected abstract List select( - CallInfo callInfo, List descriptors); + protected abstract void select( + CallInfo callInfo, + List descriptors, + CallServiceSelectionResponse response); } From cad4b973564d89321c2e644e11d37c4d7cc97fee Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Fri, 21 Feb 2014 09:58:18 -0800 Subject: [PATCH 066/102] Update API Forgot to run update-api after 64a44a876b08f4a49238becb90bf1788b840a103 Change-Id: Id9e623b7acadb7b2d8fe5c805cf828f21833f7b9 --- api/current.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index acc77f7b8a660..61c7add9c2531 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24230,13 +24230,16 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); - method protected abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.CallServiceSelector.Response); + method protected abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.CallServiceSelector.CallSwitchabilityResponse); method public final android.os.IBinder onBind(android.content.Intent); - method protected abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.CallServiceSelector.Response); + method protected abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.CallServiceSelector.CallServiceSelectionResponse); } - public static abstract interface CallServiceSelector.Response { + public static abstract interface CallServiceSelector.CallServiceSelectionResponse { method public abstract void setSelectedCallServices(java.util.List); + } + + public static abstract interface CallServiceSelector.CallSwitchabilityResponse { method public abstract void setSwitchable(boolean); } From 1fe964d11e4446437f2688648f2ffe45617b82d6 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 20 Feb 2014 17:13:15 -0800 Subject: [PATCH 067/102] Renaming intent to INCOMING_CALL. Change-Id: I90ac30be5d8503f100deedf44f8d3bd18de3fa83 --- api/current.txt | 3 +- .../android/telecomm/TelecommConstants.java | 29 +++++++------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/api/current.txt b/api/current.txt index b7e58ae6adbbb..26bcf7e3a8226 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24392,8 +24392,7 @@ package android.telecomm { public final class TelecommConstants { ctor public TelecommConstants(); field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; - field public static final java.lang.String EXTRA_CALL_SERVICE_ID = "android.intent.extra.CALL_SERVICE_ID"; - field public static final java.lang.String EXTRA_CALL_SERVICE_PROVIDER = "android.intent.extra.CALL_SERVICE_PROVIDER"; + field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; } } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index ebb855cd7042c..a5ef34490de46 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -23,15 +23,13 @@ public final class TelecommConstants { /** *

Activity action: Starts the UI for handing an incoming call. This intent starts the * in-call UI by notifying the Telecomm system that an incoming call exists for a specific call - * service (see {@link android.telecomm.ICallService}). Telecomm reads the Intent extras to find - * and bind to the appropriate {@link android.telecomm.ICallServiceProvider} and - * {@link android.telecomm.ICallService} implementations which Telecomm will ultimately use to - * control and get information about the call.

+ * service (see {@link android.telecomm.CallService}). Telecomm reads the Intent extras to find + * and bind to the appropriate {@link android.telecomm.CallService} which Telecomm will + * ultimately use to control and get information about the call.

* - *

Input: get*Extra field {@link #EXTRA_CALL_SERVICE_PROVIDER} contains the component name - * of the {@link android.telecomm.ICallServiceProvider} service Telecomm should bind to. - * {@link #EXTRA_CALL_SERVICE_ID} contains a string-based identifier that Telecomm will pass to - * {@link ICallServiceProvider#getCallService} to get the appropriate {@link ICallService}.

+ *

Input: get*Extra field {@link #EXTRA_CALL_SERVICE} contains the component name + * of the {@link android.telecomm.CallService} that Telecomm should bind to. Telecomm will then + * ask the call service for more information about the call prior to showing any UI. * * TODO(santoscordon): Needs permissions. * TODO(santoscordon): Consider moving this into a simple method call on a system service. @@ -39,16 +37,9 @@ public final class TelecommConstants { public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; /** - * Extra for {@link #ACTION_INCOMING_CALL} that contains the component name of the call-service - * provider used by Telecomm to obtain the correct call service for the incoming call. + * Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that + * describes the call service to use for the incoming call. */ - public static final String EXTRA_CALL_SERVICE_PROVIDER = - "android.intent.extra.CALL_SERVICE_PROVIDER"; - - /** - * Extra for {@link #ACTION_INCOMING_CALL} that contains the String-based ID that Telecomm will - * use to obtain the correct call service for the incoming call via - * {@link android.telecomm.ICallServiceProvider#getCallService}. - */ - public static final String EXTRA_CALL_SERVICE_ID = "android.intent.extra.CALL_SERVICE_ID"; + public static final String EXTRA_CALL_SERVICE_DESCRIPTOR = + "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; } From 832ddb3fe66a73cdf383ea2700ae48f88ad9ded0 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Fri, 21 Feb 2014 13:53:01 -0800 Subject: [PATCH 068/102] Fix some javadocs Fix some bad {@link ..} tags in the javadocs. Change-Id: Id64b901218878e9996a390fee9eb72e4b5cd9d93 --- telecomm/java/android/telecomm/CallService.java | 6 +++--- telecomm/java/android/telecomm/ICallService.aidl | 4 ++-- telecomm/java/android/telecomm/TelecommConstants.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 7144653f3d1d9..9bad3ad9e9c59 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -29,7 +29,7 @@ import com.android.internal.os.SomeArgs; * in-call UI. CallService is a one-way service from the framework's CallsManager to any app * that would like to provide calls managed by the default system in-call user interface. * When the service is bound by the framework, CallsManager will call setCallServiceAdapter - * which will provide CallService with an instance of {@link CallServiceAdapter} to be used + * which will provide CallService with an instance of {@link ICallServiceAdapter} to be used * for communicating back to CallsManager. Subsequently, more specific methods of the service * will be called to perform various call actions including making an outgoing call and * disconnected existing calls. @@ -168,8 +168,8 @@ public abstract class CallService extends Service { * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link ICallServiceAdapter#handleIncomingCall} if it can - * successfully make the call. + * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall(String)} + * if it can successfully make the call. * * @param callInfo The details of the relevant call. */ diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index cfd09c8c9c1b3..393a1bec0c652 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -59,8 +59,8 @@ oneway interface ICallService { * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link ICallServiceAdapter#newOutgoingCall} if it can successfully - * make the call. + * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall} if it can + * successfully make the call. * TODO(santoscordon): Figure out how a calls service can short-circuit a failure to * the adapter. * diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index a5ef34490de46..b0651c8f7b62f 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -27,7 +27,7 @@ public final class TelecommConstants { * and bind to the appropriate {@link android.telecomm.CallService} which Telecomm will * ultimately use to control and get information about the call.

* - *

Input: get*Extra field {@link #EXTRA_CALL_SERVICE} contains the component name + *

Input: get*Extra field {@link #EXTRA_CALL_SERVICE_DESCRIPTOR} contains the component name * of the {@link android.telecomm.CallService} that Telecomm should bind to. Telecomm will then * ask the call service for more information about the call prior to showing any UI. * From b340c331bca330e9cb60ce6e398b3c014e1a14c7 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Wed, 19 Feb 2014 01:59:32 -0800 Subject: [PATCH 069/102] Adding API support for incoming calls. Change-Id: I7b1530d13e5adac530c4f451aa2cd97f275f9cae --- api/current.txt | 11 +++- .../java/android/telecomm/CallService.java | 63 +++++++++++++------ .../telecomm/CallServiceDescriptor.java | 3 +- .../java/android/telecomm/ICallService.aidl | 32 +++++++--- .../android/telecomm/ICallServiceAdapter.aidl | 12 ++-- 5 files changed, 84 insertions(+), 37 deletions(-) diff --git a/api/current.txt b/api/current.txt index 62288482f0b49..3fa628fcdd5fa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24216,13 +24216,15 @@ package android.telecomm { public abstract class CallService extends android.app.Service { ctor public CallService(); + method public abstract void answer(java.lang.String); method public abstract void call(android.telecomm.CallInfo); - method public abstract void confirmIncomingCall(java.lang.String, java.lang.String); method public abstract void disconnect(java.lang.String); method public final android.os.IBinder getBinder(); method public abstract void isCompatibleWith(android.telecomm.CallInfo); method public final android.os.IBinder onBind(android.content.Intent); + method public abstract void reject(java.lang.String); method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); + method public abstract void setIncomingCallId(java.lang.String); } public final class CallServiceDescriptor implements android.os.Parcelable { @@ -24232,6 +24234,7 @@ package android.telecomm { method public android.content.ComponentName getServiceComponent(); method public static android.telecomm.CallServiceDescriptor.Builder newBuilder(android.content.Context); method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; field public static final int FLAG_MOBILE = 4; // 0x4 field public static final int FLAG_PSTN = 2; // 0x2 field public static final int FLAG_WIFI = 1; // 0x1 @@ -24274,11 +24277,13 @@ package android.telecomm { } public abstract interface ICallService implements android.os.IInterface { + method public abstract void answer(java.lang.String) throws android.os.RemoteException; method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException; - method public abstract void confirmIncomingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; method public abstract void disconnect(java.lang.String) throws android.os.RemoteException; method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException; + method public abstract void reject(java.lang.String) throws android.os.RemoteException; method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException; + method public abstract void setIncomingCallId(java.lang.String) throws android.os.RemoteException; } public static abstract class ICallService.Stub extends android.os.Binder implements android.telecomm.ICallService { @@ -24289,8 +24294,8 @@ package android.telecomm { } public abstract interface ICallServiceAdapter implements android.os.IInterface { - method public abstract void handleConfirmedIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void handleFailedOutgoingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; + method public abstract void handleIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void handleSuccessfulOutgoingCall(java.lang.String) throws android.os.RemoteException; method public abstract void setActive(java.lang.String) throws android.os.RemoteException; method public abstract void setCompatibleWith(java.lang.String, boolean) throws android.os.RemoteException; diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 9bad3ad9e9c59..0eb96cc2848d9 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -62,11 +62,14 @@ public abstract class CallService extends Service { case MSG_DISCONNECT: disconnect((String) msg.obj); break; - case MSG_CONFIRM_INCOMING_CALL: - SomeArgs args = (SomeArgs) msg.obj; - String callId = (String) args.arg1; - String callToken = (String) args.arg2; - confirmIncomingCall(callId, callToken); + case MSG_SET_INCOMING_CALL_ID: + setIncomingCallId((String) msg.obj); + break; + case MSG_ANSWER: + answer((String) msg.obj); + break; + case MSG_REJECT: + reject((String) msg.obj); break; default: break; @@ -100,11 +103,18 @@ public abstract class CallService extends Service { } @Override - public void confirmIncomingCall(String callId, String callToken) { - SomeArgs args = SomeArgs.obtain(); - args.arg1 = callId; - args.arg2 = callToken; - mMessageHandler.obtainMessage(MSG_CONFIRM_INCOMING_CALL, args).sendToTarget(); + public void setIncomingCallId(String callId) { + mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, callId).sendToTarget(); + } + + @Override + public void answer(String callId) { + mMessageHandler.obtainMessage(MSG_ANSWER, callId).sendToTarget(); + } + + @Override + public void reject(String callId) { + mMessageHandler.obtainMessage(MSG_REJECT, callId).sendToTarget(); } } @@ -118,7 +128,9 @@ public abstract class CallService extends Service { MSG_IS_COMPATIBLE_WITH = 2, MSG_CALL = 3, MSG_DISCONNECT = 4, - MSG_CONFIRM_INCOMING_CALL = 5; + MSG_SET_INCOMING_CALL_ID = 5, + MSG_ANSWER = 6, + MSG_REJECT = 7; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -183,14 +195,29 @@ public abstract class CallService extends Service { public abstract void disconnect(String callId); /** - * Confirms that the specified incoming call is connecting through this call service. Telecomm - * receives all incoming calls initially as intents that include information about a call - * and a token identifying the call. Before displaying any UI to the user, Telecomm confirms - * the existence of the incoming call by binding to the specified call service and calling - * this method. Confirmation responses are received through {@link ICallServiceAdapter}. + * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified + * that this call service has a pending incoming call, see + * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm + * additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}. + * Following that, the call service can update the call at will using the specified call ID. * * @param callId The ID of the call. - * @param callToken The call token received through the incoming call intent. */ - public abstract void confirmIncomingCall(String callId, String callToken); + public abstract void setIncomingCallId(String callId); + + /** + * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the + * user hitting the "answer" button in the incoming call screen. + * + * @param callId The ID of the call. + */ + public abstract void answer(String callId); + + /** + * Rejects a ringing call identified by callId. Telecomm invokes this method as a result of the + * user hitting the "reject" button in the incoming call screen. + * + * @param callId The ID of the call. + */ + public abstract void reject(String callId); } diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java index 256b5589ec371..40f6ab9fce784 100644 --- a/telecomm/java/android/telecomm/CallServiceDescriptor.java +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java @@ -189,7 +189,8 @@ public final class CallServiceDescriptor implements Parcelable { dest.writeInt(mNetworkType); } - static final Creator CREATOR = new Creator() { + public static final Creator CREATOR = + new Creator() { @Override public CallServiceDescriptor createFromParcel(Parcel source) { String id = source.readString(); diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 393a1bec0c652..6f3c4d4627ade 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -61,8 +61,7 @@ oneway interface ICallService { * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall} if it can * successfully make the call. - * TODO(santoscordon): Figure out how a calls service can short-circuit a failure to - * the adapter. + * TODO(santoscordon): Figure out how a call service can short-circuit a failure to the adapter. * * @param callInfo The details of the relevant call. */ @@ -76,14 +75,29 @@ oneway interface ICallService { void disconnect(String callId); /** - * Confirms that the specified incoming call is connecting through this call service. Telecomm - * receives all incoming calls initially as intents that include information about a call - * and a token identifying the call. Before displaying any UI to the user, Telecomm confirms - * the existence of the incoming call by binding to the specified call service and calling - * this method. Confirmation responses are received through {@link ICallServiceAdapter}. + * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified + * that this call service has a pending incoming call, see + * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm + * additional information of the call through {@link ICallServiceAdapter#handleIncomingCall}. + * Following that, the call service can update the call at will using the specified call ID. * * @param callId The ID of the call. - * @param callToken The call token received through the incoming call intent. */ - void confirmIncomingCall(String callId, String callToken); + void setIncomingCallId(String callId); + + /** + * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the + * user hitting the "answer" button in the incoming call screen. + * + * @param callId The ID of the call. + */ + void answer(String callId); + + /** + * Rejects a ringing call identified by callId. Telecomm invokes this method as a result of the + * user hitting the "reject" button in the incoming call screen. + * + * @param callId The ID of the call. + */ + void reject(String callId); } diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl index c1ffa68341265..2e03d391e7553 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/android/telecomm/ICallServiceAdapter.aidl @@ -37,15 +37,15 @@ oneway interface ICallServiceAdapter { void setCompatibleWith(String callId, boolean isCompatible); /** - * Receives confirmation of the existence of an incoming call connected through the call - * service. Invoked by the call service after it receives a confirmation request from Telecomm - * through {@link ICallService#confirmIncomingCall}. The call info object must contain all the - * updated status of the call and use the same call ID as was passed into - * {@link ICallService#confirmIncomingCall}. + * Provides Telecomm with the details of an incoming call. An invocation of this method must + * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon + * the invocation of this method, Telecomm will bring up the incoming-call interface where the + * user can elect to answer or reject a call. + * TODO(santoscordon): Consider renaming from handle* to notify*. * * @param callInfo The details of the relevant call. */ - void handleConfirmedIncomingCall(in CallInfo callInfo); + void handleIncomingCall(in CallInfo callInfo); /** * Tells Telecomm that an attempt to place the specified outgoing call succeeded. From 6c874e3d786eea52f3488dce7c9d56a869e5ee23 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 4 Mar 2014 16:01:22 -0800 Subject: [PATCH 070/102] Adding the aborted call state. Change-Id: I26c1e2bc180a2be2d2374143546c666faeea2705 --- telecomm/java/android/telecomm/CallState.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index 4f774cbcdd33d..d4a45f9ca753a 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -62,5 +62,11 @@ public enum CallState { * the disconnection or communication was lost to the call service currently responsible for * this call (e.g., call service crashes). */ - DISCONNECTED; + DISCONNECTED, + + /** + * Indicates that the call was attempted (mostly in the context of outgoing, at least at the + * time of writing) but cancelled before it was successfully connected. + */ + ABORTED; } From a50f45405d4937b86db4c482309cbebdd857e348 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 5 Mar 2014 09:54:15 -0800 Subject: [PATCH 071/102] Fix the build Add CallState.ABORTED Change-Id: Id7139069f5e3346548785d351df2962457b15299 --- api/current.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/api/current.txt b/api/current.txt index af5260c57c7ab..dff51710ea2fc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24310,6 +24310,7 @@ package android.telecomm { public final class CallState extends java.lang.Enum { method public static android.telecomm.CallState valueOf(java.lang.String); method public static final android.telecomm.CallState[] values(); + enum_constant public static final android.telecomm.CallState ABORTED; enum_constant public static final android.telecomm.CallState ACTIVE; enum_constant public static final android.telecomm.CallState DIALING; enum_constant public static final android.telecomm.CallState DISCONNECTED; From 74f6bf88eb0247b25caa8be9d170be6ba4cf5d28 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 5 Mar 2014 08:21:52 -0800 Subject: [PATCH 072/102] Add optional data to incoming calls When a CallService creates an incoming call, allow it to pass a Bundle of arbitrary data along with the intent. This data will be returned to the CallService via setIncomingCallId. This makes it easier for CallServices to match up incoming calls with their IDs. Change-Id: I52e7e1d0788ecd01aa427e76de7ccf4d9b75f1f0 --- api/current.txt | 5 ++-- .../java/android/telecomm/CallService.java | 24 +++++++++++++++---- .../java/android/telecomm/ICallService.aidl | 9 ++++++- .../android/telecomm/TelecommConstants.java | 10 ++++++++ 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/api/current.txt b/api/current.txt index dff51710ea2fc..b6905c0725fd3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24264,7 +24264,7 @@ package android.telecomm { method public final android.os.IBinder onBind(android.content.Intent); method public abstract void reject(java.lang.String); method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); - method public abstract void setIncomingCallId(java.lang.String); + method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); } public final class CallServiceDescriptor implements android.os.Parcelable { @@ -24324,7 +24324,7 @@ package android.telecomm { method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void reject(java.lang.String) throws android.os.RemoteException; method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException; - method public abstract void setIncomingCallId(java.lang.String) throws android.os.RemoteException; + method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle) throws android.os.RemoteException; } public static abstract class ICallService.Stub extends android.os.Binder implements android.telecomm.ICallService { @@ -24439,6 +24439,7 @@ package android.telecomm { ctor public TelecommConstants(); field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; + field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; } } diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 0eb96cc2848d9..8767ffa3598fd 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -18,6 +18,7 @@ package android.telecomm; import android.app.Service; import android.content.Intent; +import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; @@ -63,7 +64,14 @@ public abstract class CallService extends Service { disconnect((String) msg.obj); break; case MSG_SET_INCOMING_CALL_ID: - setIncomingCallId((String) msg.obj); + SomeArgs args = (SomeArgs) msg.obj; + try { + String callId = (String) args.arg1; + Bundle extras = (Bundle) args.arg2; + setIncomingCallId(callId, extras); + } finally { + args.recycle(); + } break; case MSG_ANSWER: answer((String) msg.obj); @@ -103,8 +111,11 @@ public abstract class CallService extends Service { } @Override - public void setIncomingCallId(String callId) { - mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, callId).sendToTarget(); + public void setIncomingCallId(String callId, Bundle extras) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = extras; + mMessageHandler.obtainMessage(MSG_SET_INCOMING_CALL_ID, args).sendToTarget(); } @Override @@ -201,9 +212,14 @@ public abstract class CallService extends Service { * additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}. * Following that, the call service can update the call at will using the specified call ID. * + * If a {@link Bundle} was passed (via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}) in + * with the {@link TelecommConstants#ACTION_INCOMING_CALL} intent, extras will be + * populated with this {@link Bundle}. Otherwise, an empty Bundle will be returned. + * * @param callId The ID of the call. + * @param extras The optional extras which were passed in with the intent, or an empty Bundle. */ - public abstract void setIncomingCallId(String callId); + public abstract void setIncomingCallId(String callId, Bundle extras); /** * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 6f3c4d4627ade..382bdd58a3b5d 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -16,6 +16,7 @@ package android.telecomm; +import android.os.Bundle; import android.telecomm.CallInfo; import android.telecomm.ICallServiceAdapter; @@ -81,9 +82,15 @@ oneway interface ICallService { * additional information of the call through {@link ICallServiceAdapter#handleIncomingCall}. * Following that, the call service can update the call at will using the specified call ID. * + * As part of the {@link TelecommConstants#ACTION_INCOMING_CALL} Intent, a Bundle of extra + * data could be sent via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}, which is + * returned through this method. If no data was given, an empty Bundle will be returned. + * * @param callId The ID of the call. + * @param extras The Bundle of extra information passed via + * {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}. */ - void setIncomingCallId(String callId); + void setIncomingCallId(String callId, in Bundle extras); /** * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index b0651c8f7b62f..564f0cb89372c 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -16,6 +16,8 @@ package android.telecomm; +import android.os.Bundle; + /** * Defines constants for use with the Telecomm system. */ @@ -42,4 +44,12 @@ public final class TelecommConstants { */ public static final String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; + + /** + * Optional extra for {@link #ACTION_INCOMING_CALL} containing a {@link Bundle} which contains + * metadata about the call. This {@link Bundle} will be returned to the {@link CallService} as + * part of {@link CallService#setIncomingCallId(String,Bundle)}. + */ + public static final String EXTRA_INCOMING_CALL_EXTRAS = + "android.intent.extra.INCOMING_CALL_EXTRAS"; } From 3fadaa923272675d841eda3d46b3e1d9dc08c819 Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Tue, 4 Mar 2014 16:40:58 -0800 Subject: [PATCH 073/102] Add the abort API to ICallService implementations. Change-Id: Ie9b996b4d23184034811ef5667403ff4e47ae2d9 --- api/current.txt | 3 +- .../java/android/telecomm/CallService.java | 42 ++++++++++++++----- telecomm/java/android/telecomm/CallState.java | 1 + .../java/android/telecomm/ICallService.aidl | 21 +++++++--- 4 files changed, 50 insertions(+), 17 deletions(-) diff --git a/api/current.txt b/api/current.txt index dff51710ea2fc..0c8b87201391d 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24256,6 +24256,7 @@ package android.telecomm { public abstract class CallService extends android.app.Service { ctor public CallService(); + method public abstract void abort(java.lang.String); method public abstract void answer(java.lang.String); method public abstract void call(android.telecomm.CallInfo); method public abstract void disconnect(java.lang.String); @@ -24310,7 +24311,6 @@ package android.telecomm { public final class CallState extends java.lang.Enum { method public static android.telecomm.CallState valueOf(java.lang.String); method public static final android.telecomm.CallState[] values(); - enum_constant public static final android.telecomm.CallState ABORTED; enum_constant public static final android.telecomm.CallState ACTIVE; enum_constant public static final android.telecomm.CallState DIALING; enum_constant public static final android.telecomm.CallState DISCONNECTED; @@ -24318,6 +24318,7 @@ package android.telecomm { } public abstract interface ICallService implements android.os.IInterface { + method public abstract void abort(java.lang.String) throws android.os.RemoteException; method public abstract void answer(java.lang.String) throws android.os.RemoteException; method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException; method public abstract void disconnect(java.lang.String) throws android.os.RemoteException; diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 0eb96cc2848d9..f90ce972921a5 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -59,8 +59,8 @@ public abstract class CallService extends Service { case MSG_CALL: call((CallInfo) msg.obj); break; - case MSG_DISCONNECT: - disconnect((String) msg.obj); + case MSG_ABORT: + abort((String) msg.obj); break; case MSG_SET_INCOMING_CALL_ID: setIncomingCallId((String) msg.obj); @@ -71,6 +71,9 @@ public abstract class CallService extends Service { case MSG_REJECT: reject((String) msg.obj); break; + case MSG_DISCONNECT: + disconnect((String) msg.obj); + break; default: break; } @@ -98,8 +101,8 @@ public abstract class CallService extends Service { } @Override - public void disconnect(String callId) { - mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + public void abort(String callId) { + mMessageHandler.obtainMessage(MSG_ABORT, callId).sendToTarget(); } @Override @@ -116,6 +119,11 @@ public abstract class CallService extends Service { public void reject(String callId) { mMessageHandler.obtainMessage(MSG_REJECT, callId).sendToTarget(); } + + @Override + public void disconnect(String callId) { + mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); + } } // Only used internally by this class. @@ -127,10 +135,11 @@ public abstract class CallService extends Service { MSG_SET_CALL_SERVICE_ADAPTER = 1, MSG_IS_COMPATIBLE_WITH = 2, MSG_CALL = 3, - MSG_DISCONNECT = 4, + MSG_ABORT = 4, MSG_SET_INCOMING_CALL_ID = 5, MSG_ANSWER = 6, - MSG_REJECT = 7; + MSG_REJECT = 7, + MSG_DISCONNECT = 8; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -169,7 +178,7 @@ public abstract class CallService extends Service { /** * Determines if the CallService can place the specified call. Response is sent via * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be - * specified. + * specified. Only used in the context of outgoing calls and call switching (handoff). * * @param callInfo The details of the relevant call. */ @@ -181,18 +190,22 @@ public abstract class CallService extends Service { * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall(String)} - * if it can successfully make the call. + * if it can successfully make the call. Only used in the context of outgoing calls. * * @param callInfo The details of the relevant call. */ public abstract void call(CallInfo callInfo); /** - * Disconnects the specified call. + * Aborts the outgoing call attempt. Invoked in the unlikely event that Telecomm decides to + * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. + * After this is invoked, Telecomm does not expect any more updates about the call and will + * actively ignore any such update. This is different from {@link #disconnect} where Telecomm + * expects confirmation via {@link #markCallAsDisconnected}. * - * @param callId The ID of the call to disconnect. + * @param callId The identifier of the call to abort. */ - public abstract void disconnect(String callId); + public abstract void abort(String callId); /** * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified @@ -220,4 +233,11 @@ public abstract class CallService extends Service { * @param callId The ID of the call. */ public abstract void reject(String callId); + + /** + * Disconnects the specified call. + * + * @param callId The ID of the call to disconnect. + */ + public abstract void disconnect(String callId); } diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index d4a45f9ca753a..d699fbd23baab 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -67,6 +67,7 @@ public enum CallState { /** * Indicates that the call was attempted (mostly in the context of outgoing, at least at the * time of writing) but cancelled before it was successfully connected. + * @hide */ ABORTED; } diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index 6f3c4d4627ade..a4c2599d25349 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -48,7 +48,7 @@ oneway interface ICallService { * specified. It is expected that the call service respond within 500 milliseconds. Any response * that takes longer than 500 milliseconds will be treated as being incompatible. * TODO(santoscordon): 500 ms was arbitrarily chosen and must be confirmed before this - * API is made public. + * API is made public. Only used in the context of outgoing calls and call switching (handoff). * * @param callInfo The details of the relevant call. */ @@ -60,7 +60,7 @@ oneway interface ICallService { * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall} if it can - * successfully make the call. + * successfully make the call. Only used in the context of outgoing calls. * TODO(santoscordon): Figure out how a call service can short-circuit a failure to the adapter. * * @param callInfo The details of the relevant call. @@ -68,11 +68,15 @@ oneway interface ICallService { void call(in CallInfo callInfo); /** - * Disconnects the call identified by callId. + * Aborts the outgoing call attempt. Invoked in the unlikely event that Telecomm decides to + * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. + * After this is invoked, Telecomm does not expect any more updates about the call and will + * actively ignore any such update. This is different from {@link #disconnect} where Telecomm + * expects confirmation via {@link #markCallAsDisconnected}. * - * @param callId The identifier of the call to disconnect. + * @param callId The identifier of the call to abort. */ - void disconnect(String callId); + void abort(String callId); /** * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified @@ -100,4 +104,11 @@ oneway interface ICallService { * @param callId The ID of the call. */ void reject(String callId); + + /** + * Disconnects the call identified by callId. Used for outgoing and incoming calls. + * + * @param callId The identifier of the call to disconnect. + */ + void disconnect(String callId); } From 971e9a40a97eee7b6b0aa230034c04d2fb4fef8f Mon Sep 17 00:00:00 2001 From: Ben Gilad Date: Thu, 6 Mar 2014 14:46:49 -0800 Subject: [PATCH 074/102] Fix broken build due to ag/428341. Change-Id: I84945e8ce1b5c8b1be0785f71c7eae77699687fe --- telecomm/java/android/telecomm/CallService.java | 2 +- telecomm/java/android/telecomm/ICallService.aidl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 261de4c735203..d1d0977a18146 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -212,7 +212,7 @@ public abstract class CallService extends Service { * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. * After this is invoked, Telecomm does not expect any more updates about the call and will * actively ignore any such update. This is different from {@link #disconnect} where Telecomm - * expects confirmation via {@link #markCallAsDisconnected}. + * expects confirmation via ICallServiceAdapter.markCallAsDisconnected. * * @param callId The identifier of the call to abort. */ diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/android/telecomm/ICallService.aidl index c035262c163a3..28f19ca805fae 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/android/telecomm/ICallService.aidl @@ -73,7 +73,7 @@ oneway interface ICallService { * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. * After this is invoked, Telecomm does not expect any more updates about the call and will * actively ignore any such update. This is different from {@link #disconnect} where Telecomm - * expects confirmation via {@link #markCallAsDisconnected}. + * expects confirmation via ICallServiceAdapter.markCallAsDisconnected. * * @param callId The identifier of the call to abort. */ From e9d85a07aac0360d59ab9bcfd5bdb2f674094840 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Mon, 10 Mar 2014 19:12:37 -0700 Subject: [PATCH 075/102] Add constant for Call Id extra The extra will be used to include the call ID on phone state changes. Change-Id: I9edd0b6e017f8414fa3e148fd4d57958e2072184 --- api/current.txt | 1 + telecomm/java/android/telecomm/TelecommConstants.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/api/current.txt b/api/current.txt index 31d0c6c36402c..a02db742d43d6 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24441,6 +24441,7 @@ package android.telecomm { public final class TelecommConstants { ctor public TelecommConstants(); field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + field public static final java.lang.String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 564f0cb89372c..08f39e38d3391 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -52,4 +52,10 @@ public final class TelecommConstants { */ public static final String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; + + /** + * Optional extra for {@link TelephonyManager.ACTION_PHONE_STATE_CHANGED} containing the unique + * ID of the call. + */ + public static final String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; } From ab5d282dd6f487578ae86b2d53d0d8edc9b71747 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Sat, 8 Mar 2014 18:01:06 -0800 Subject: [PATCH 076/102] Add wrappers around telecomm interfaces This CL adds wrappers for: CallServiceLookupResponse CallServiceAdapter IInCallAdapter IInCallService This CL also moves all the aidl files into com.android.internal.telecomm. Change-Id: I840f023bc545643e8bb719825e7bc78344ee46ee --- Android.mk | 18 +-- api/current.txt | 37 ++++- .../java/android/telecomm/CallService.java | 22 +-- .../android/telecomm/CallServiceAdapter.java | 143 ++++++++++++++++++ .../telecomm/CallServiceLookupResponse.java | 51 +++++++ .../android/telecomm/CallServiceProvider.java | 14 +- .../android/telecomm/CallServiceSelector.java | 5 +- .../java/android/telecomm/InCallAdapter.java | 81 ++++++++++ .../java/android/telecomm/InCallService.java | 139 +++++++++++++++++ .../android/telecomm/TelecommConstants.java | 15 ++ .../internal}/telecomm/ICallService.aidl | 6 +- .../telecomm/ICallServiceAdapter.aidl | 9 +- .../telecomm/ICallServiceLookupResponse.aidl | 3 +- .../telecomm/ICallServiceProvider.aidl | 9 +- .../ICallServiceSelectionResponse.aidl | 3 +- .../telecomm/ICallServiceSelector.aidl | 10 +- .../telecomm/ICallSwitchabilityResponse.aidl | 3 +- .../internal}/telecomm/IInCallAdapter.aidl | 3 +- .../internal}/telecomm/IInCallService.aidl | 17 ++- 19 files changed, 533 insertions(+), 55 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallServiceAdapter.java create mode 100644 telecomm/java/android/telecomm/CallServiceLookupResponse.java create mode 100644 telecomm/java/android/telecomm/InCallAdapter.java create mode 100644 telecomm/java/android/telecomm/InCallService.java rename telecomm/java/{android => com/android/internal}/telecomm/ICallService.aidl (98%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallServiceAdapter.aidl (92%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallServiceLookupResponse.aidl (96%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallServiceProvider.aidl (88%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallServiceSelectionResponse.aidl (96%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallServiceSelector.aidl (94%) rename telecomm/java/{android => com/android/internal}/telecomm/ICallSwitchabilityResponse.aidl (96%) rename telecomm/java/{android => com/android/internal}/telecomm/IInCallAdapter.aidl (97%) rename telecomm/java/{android => com/android/internal}/telecomm/IInCallService.aidl (85%) diff --git a/Android.mk b/Android.mk index 51635cb4b7818..1d42528ef2d98 100644 --- a/Android.mk +++ b/Android.mk @@ -279,15 +279,15 @@ LOCAL_SRC_FILES += \ media/java/android/media/session/IMediaSession.aidl \ media/java/android/media/session/IMediaSessionCallback.aidl \ media/java/android/media/session/IMediaSessionManager.aidl \ - telecomm/java/android/telecomm/ICallService.aidl \ - telecomm/java/android/telecomm/ICallServiceAdapter.aidl \ - telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl \ - telecomm/java/android/telecomm/ICallServiceProvider.aidl \ - telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl \ - telecomm/java/android/telecomm/ICallServiceSelector.aidl \ - telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl \ - telecomm/java/android/telecomm/IInCallAdapter.aidl \ - telecomm/java/android/telecomm/IInCallService.aidl \ + telecomm/java/com/android/internal/telecomm/ICallService.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl \ + telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl \ + telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \ + telecomm/java/com/android/internal/telecomm/IInCallService.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ diff --git a/api/current.txt b/api/current.txt index 31d0c6c36402c..b219bc9230fd3 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24266,10 +24266,21 @@ package android.telecomm { method public abstract void isCompatibleWith(android.telecomm.CallInfo); method public final android.os.IBinder onBind(android.content.Intent); method public abstract void reject(java.lang.String); - method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter); + method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); } + public final class CallServiceAdapter { + method public void handleFailedOutgoingCall(java.lang.String, java.lang.String); + method public void handleSuccessfulOutgoingCall(java.lang.String); + method public void notifyIncomingCall(android.telecomm.CallInfo); + method public void setActive(java.lang.String); + method public void setDialing(java.lang.String); + method public void setDisconnected(java.lang.String); + method public void setIsCompatibleWith(java.lang.String, boolean); + method public void setRinging(java.lang.String); + } + public final class CallServiceDescriptor implements android.os.Parcelable { method public int describeContents(); method public java.lang.String getCallServiceId(); @@ -24289,9 +24300,13 @@ package android.telecomm { method public android.telecomm.CallServiceDescriptor.Builder setNetworkType(int); } + public final class CallServiceLookupResponse { + method public void setCallServiceDescriptors(java.util.List); + } + public abstract class CallServiceProvider extends android.app.Service { ctor protected CallServiceProvider(); - method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse); + method public abstract void lookupCallServices(android.telecomm.CallServiceLookupResponse); method public android.os.IBinder onBind(android.content.Intent); } @@ -24438,9 +24453,27 @@ package android.telecomm { method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; } + public final class InCallAdapter { + method public void answerCall(java.lang.String); + method public void disconnectCall(java.lang.String); + method public void rejectCall(java.lang.String); + } + + public abstract class InCallService extends android.app.Service { + ctor protected InCallService(); + method protected abstract void addCall(android.telecomm.CallInfo); + method public final android.os.IBinder onBind(android.content.Intent); + method protected abstract void setActive(java.lang.String); + method protected abstract void setDisconnected(java.lang.String); + method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); + } + public final class TelecommConstants { ctor public TelecommConstants(); field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + field public static final java.lang.String CALL_SERVICE_ACTION; + field public static final java.lang.String CALL_SERVICE_PROVIDER_ACTION; + field public static final java.lang.String CALL_SERVICE_SELECTOR_ACTION; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; } diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index d1d0977a18146..87a5372b64653 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -24,13 +24,15 @@ import android.os.IBinder; import android.os.Message; import com.android.internal.os.SomeArgs; +import com.android.internal.telecomm.ICallService; +import com.android.internal.telecomm.ICallServiceAdapter; /** * Base implementation of CallService which can be used to provide calls for the system * in-call UI. CallService is a one-way service from the framework's CallsManager to any app * that would like to provide calls managed by the default system in-call user interface. * When the service is bound by the framework, CallsManager will call setCallServiceAdapter - * which will provide CallService with an instance of {@link ICallServiceAdapter} to be used + * which will provide CallService with an instance of {@link CallServiceAdapter} to be used * for communicating back to CallsManager. Subsequently, more specific methods of the service * will be called to perform various call actions including making an outgoing call and * disconnected existing calls. @@ -52,7 +54,9 @@ public abstract class CallService extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_SET_CALL_SERVICE_ADAPTER: - setCallServiceAdapter((ICallServiceAdapter) msg.obj); + CallServiceAdapter adapter = + new CallServiceAdapter((ICallServiceAdapter) msg.obj); + setCallServiceAdapter(adapter); break; case MSG_IS_COMPATIBLE_WITH: isCompatibleWith((CallInfo) msg.obj); @@ -177,18 +181,16 @@ public abstract class CallService extends Service { } /** - * Sets an implementation of ICallServiceAdapter for adding new calls and communicating state + * Sets an implementation of CallServiceAdapter for adding new calls and communicating state * changes of existing calls. - * TODO(santoscordon): Should we not reference ICallServiceAdapter directly from here? Should we - * wrap that in a wrapper like we do for CallService/ICallService? * * @param callServiceAdapter Adapter object for communicating call to CallsManager */ - public abstract void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter); + public abstract void setCallServiceAdapter(CallServiceAdapter callServiceAdapter); /** * Determines if the CallService can place the specified call. Response is sent via - * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be + * {@link CallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be * specified. Only used in the context of outgoing calls and call switching (handoff). * * @param callInfo The details of the relevant call. @@ -200,7 +202,7 @@ public abstract class CallService extends Service { * SIP address, or some other kind of user ID. Note that the set of handle types is * dynamically extensible since call providers should be able to implement arbitrary * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall(String)} + * call service respond via {@link CallServiceAdapter#handleSuccessfulOutgoingCall(String)} * if it can successfully make the call. Only used in the context of outgoing calls. * * @param callInfo The details of the relevant call. @@ -212,7 +214,7 @@ public abstract class CallService extends Service { * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. * After this is invoked, Telecomm does not expect any more updates about the call and will * actively ignore any such update. This is different from {@link #disconnect} where Telecomm - * expects confirmation via ICallServiceAdapter.markCallAsDisconnected. + * expects confirmation via CallServiceAdapter.markCallAsDisconnected. * * @param callId The identifier of the call to abort. */ @@ -222,7 +224,7 @@ public abstract class CallService extends Service { * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified * that this call service has a pending incoming call, see * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm - * additional information about the call through {@link ICallServiceAdapter#handleIncomingCall}. + * additional information about the call through {@link CallServiceAdapter#handleIncomingCall}. * Following that, the call service can update the call at will using the specified call ID. * * If a {@link Bundle} was passed (via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}) in diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java new file mode 100644 index 0000000000000..a391f34e79c34 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -0,0 +1,143 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.RemoteException; + +import com.android.internal.telecomm.ICallServiceAdapter; + +/** + * Provides methods for ICallService implementations to interact with the system phone app. + * TODO(santoscordon): Need final public-facing comments in this file. + */ +public final class CallServiceAdapter { + private final ICallServiceAdapter mAdapter; + + /** + * {@hide} + */ + public CallServiceAdapter(ICallServiceAdapter adapter) { + mAdapter = adapter; + } + + /** + * Receives confirmation of a call service's ability to place a call. This method is used in + * response to {@link CallService#isCompatibleWith}. + * + * @param callId The identifier of the call for which compatibility is being received. This ID + * should correspond to the ID given as part of the call information in + * {@link CallService#isCompatibleWith}. + * @param isCompatible True if the call service can place the call. + */ + public void setIsCompatibleWith(String callId, boolean isCompatible) { + try { + mAdapter.setIsCompatibleWith(callId, isCompatible); + } catch (RemoteException e) { + } + } + + /** + * Provides Telecomm with the details of an incoming call. An invocation of this method must + * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon + * the invocation of this method, Telecomm will bring up the incoming-call interface where the + * user can elect to answer or reject a call. + * + * @param callInfo The details of the relevant call. + */ + public void notifyIncomingCall(CallInfo callInfo) { + try { + mAdapter.notifyIncomingCall(callInfo); + } catch (RemoteException e) { + } + } + + /** + * Tells Telecomm that an attempt to place the specified outgoing call succeeded. + * TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is + * somehow no longer in the DIALING state. + * + * @param callId The ID of the outgoing call. + */ + public void handleSuccessfulOutgoingCall(String callId) { + try { + mAdapter.handleSuccessfulOutgoingCall(callId); + } catch (RemoteException e) { + } + } + + /** + * Tells Telecomm that an attempt to place the specified outgoing call failed. + * + * @param callId The ID of the outgoing call. + * @param errorMessage The error associated with the failed call attempt. + */ + public void handleFailedOutgoingCall(String callId, String errorMessage) { + try { + mAdapter.handleFailedOutgoingCall(callId, errorMessage); + } catch (RemoteException e) { + } + } + + /** + * Sets a call's state to active (e.g., an ongoing call where two parties can actively + * communicate). + * + * @param callId The unique ID of the call whose state is changing to active. + */ + public void setActive(String callId) { + try { + mAdapter.setActive(callId); + } catch (RemoteException e) { + } + } + + /** + * Sets a call's state to ringing (e.g., an inbound ringing call). + * + * @param callId The unique ID of the call whose state is changing to ringing. + */ + public void setRinging(String callId) { + try { + mAdapter.setRinging(callId); + } catch (RemoteException e) { + } + } + + /** + * Sets a call's state to dialing (e.g., dialing an outbound call). + * + * @param callId The unique ID of the call whose state is changing to dialing. + */ + public void setDialing(String callId) { + try { + mAdapter.setDialing(callId); + } catch (RemoteException e) { + } + } + + /** + * Sets a call's state to disconnected. + * + * @param callId The unique ID of the call whose state is changing to disconnected. + */ + public void setDisconnected(String callId) { + try { + mAdapter.setDisconnected(callId); + } catch (RemoteException e) { + } + } +} diff --git a/telecomm/java/android/telecomm/CallServiceLookupResponse.java b/telecomm/java/android/telecomm/CallServiceLookupResponse.java new file mode 100644 index 0000000000000..dd35a2439d8a4 --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceLookupResponse.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.RemoteException; + +import com.android.internal.telecomm.ICallServiceLookupResponse; + +import java.util.List; + +/** + * Used by {@link CallServiceProvider} to return a list of {@link CallServiceDescriptor}s. + */ +public final class CallServiceLookupResponse { + private final ICallServiceLookupResponse mResponse; + + /** + * {@hide} + */ + public CallServiceLookupResponse(ICallServiceLookupResponse response) { + mResponse = response; + } + + /** + * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used + * in the context of attempting to place a pending outgoing call. + * + * @param callServiceDescriptors The set of call-service descriptors from + * {@link CallServiceProvider}. + */ + public void setCallServiceDescriptors(List callServiceDescriptors) { + try { + mResponse.setCallServiceDescriptors(callServiceDescriptors); + } catch (RemoteException e) { + } + } +} diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 64294d8072ac9..5db7e2e2b5348 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -22,8 +22,8 @@ import android.os.Handler; import android.os.IBinder; import android.os.Message; -import android.telecomm.ICallServiceProvider; -import android.telecomm.ICallServiceLookupResponse; +import com.android.internal.telecomm.ICallServiceLookupResponse; +import com.android.internal.telecomm.ICallServiceProvider; /** * Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class @@ -45,9 +45,9 @@ public abstract class CallServiceProvider extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_LOOKUP_CALL_SERVICES: - lookupCallServices((ICallServiceLookupResponse) msg.obj); - break; - default: + CallServiceLookupResponse response = + new CallServiceLookupResponse((ICallServiceLookupResponse) msg.obj); + lookupCallServices(response); break; } } @@ -100,10 +100,10 @@ public abstract class CallServiceProvider extends Service { } /** - * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by * this provider. * * @param response The response object through which the list of call services is sent. */ - public abstract void lookupCallServices(ICallServiceLookupResponse response); + public abstract void lookupCallServices(CallServiceLookupResponse response); } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 6937bdfc081cc..44181d163692b 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -26,6 +26,9 @@ import android.os.RemoteException; import android.util.Log; import com.android.internal.os.SomeArgs; +import com.android.internal.telecomm.ICallServiceSelector; +import com.android.internal.telecomm.ICallServiceSelectionResponse; +import com.android.internal.telecomm.ICallSwitchabilityResponse; import java.util.List; @@ -108,7 +111,7 @@ public abstract class CallServiceSelector extends Service { } }; - /** Manages the binder calls so that the implementor does not need to deal it. */ + /** Manages the binder calls so that the implementor does not need to deal with it. */ private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub implements CallSwitchabilityResponse, CallServiceSelectionResponse { private ICallSwitchabilityResponse mSwitchabilityResponse; diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java new file mode 100644 index 0000000000000..c9bd8c2465bdb --- /dev/null +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.RemoteException; + +import com.android.internal.telecomm.IInCallAdapter; + +/** + * Receives commands from {@link InCallService} implementations which should be executed by + * Telecomm. When Telecomm binds to a {@link InCallService}, an instance of this class is given to + * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When + * the in-call service is notified of new calls ({@link InCallService#addCall}), it can use the + * given call IDs to execute commands such as {@link #answerCall} for incoming calls or + * {@link #disconnectCall} for active calls the user would like to end. Some commands are only + * appropriate for calls in certain states; please consult each method for such limitations. + * TODO(santoscordon): Needs more/better comments once the API is finalized. + * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. + */ +public final class InCallAdapter { + private final IInCallAdapter mAdapter; + + /** + * {@hide} + */ + public InCallAdapter(IInCallAdapter adapter) { + mAdapter = adapter; + } + + /** + * Instructs Telecomm to answer the specified call. + * + * @param callId The identifier of the call to answer. + */ + public void answerCall(String callId) { + try { + mAdapter.answerCall(callId); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecomm to reject the specified call. + * TODO(santoscordon): Add reject-with-text-message parameter when that feature + * is ported over. + * + * @param callId The identifier of the call to reject. + */ + public void rejectCall(String callId) { + try { + mAdapter.rejectCall(callId); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecomm to disconnect the specified call. + * + * @param callId The identifier of the call to disconnect. + */ + public void disconnectCall(String callId) { + try { + mAdapter.disconnectCall(callId); + } catch (RemoteException e) { + } + } +} diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java new file mode 100644 index 0000000000000..7819d44d47bb1 --- /dev/null +++ b/telecomm/java/android/telecomm/InCallService.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.app.Service; +import android.content.Intent; +import android.os.Handler; +import android.os.IBinder; +import android.os.Looper; +import android.os.Message; + +import com.android.internal.telecomm.IInCallAdapter; +import com.android.internal.telecomm.IInCallService; + +/** + * This service is implemented by any app that wishes to provide the user-interface for managing + * phone calls. Telecomm binds to this service while there exists a live (active or incoming) + * call, and uses it to notify the in-call app of any live and and recently disconnected calls. + * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better + * defined. + * TODO(santoscordon): What happens if two or more apps on a given device implement this interface? + */ +public abstract class InCallService extends Service { + private static final int MSG_SET_IN_CALL_ADAPTER = 1; + private static final int MSG_ADD_CALL = 2; + private static final int MSG_SET_ACTIVE = 3; + private static final int MSG_SET_DISCONNECTED = 4; + + /** Default Handler used to consolidate binder method calls onto a single thread. */ + private final Handler mHandler = new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message msg) { + switch (msg.what) { + case MSG_SET_IN_CALL_ADAPTER: + InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj); + setInCallAdapter(adapter); + break; + case MSG_ADD_CALL: + addCall((CallInfo) msg.obj); + break; + case MSG_SET_ACTIVE: + setActive((String) msg.obj); + break; + case MSG_SET_DISCONNECTED: + setDisconnected((String) msg.obj); + break; + default: + break; + } + } + }; + + /** Manages the binder calls so that the implementor does not need to deal with it. */ + private final class InCallServiceBinder extends IInCallService.Stub { + /** {@inheritDoc} */ + @Override + public void setInCallAdapter(IInCallAdapter inCallAdapter) { + mHandler.obtainMessage(MSG_SET_IN_CALL_ADAPTER, inCallAdapter).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void addCall(CallInfo callInfo) { + mHandler.obtainMessage(MSG_ADD_CALL, callInfo).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void setActive(String callId) { + mHandler.obtainMessage(MSG_SET_ACTIVE, callId).sendToTarget(); + } + + /** {@inheritDoc} */ + @Override + public void setDisconnected(String callId) { + mHandler.obtainMessage(MSG_SET_DISCONNECTED, callId).sendToTarget(); + } + } + + private final InCallServiceBinder mBinder; + + protected InCallService() { + mBinder = new InCallServiceBinder(); + } + + @Override + public final IBinder onBind(Intent intent) { + return mBinder; + } + + /** + * Provides the in-call app an adapter object through which to send call-commands such as + * answering and rejecting incoming calls, disconnecting active calls, and putting calls in + * special states (mute, hold, etc). + * + * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. + */ + protected abstract void setInCallAdapter(InCallAdapter inCallAdapter); + + /** + * Indicates to the in-call app that a new call has been created and an appropriate + * user-interface should be built and shown to notify the user. Information about the call + * including its current state is passed in through the callInfo object. + * + * @param callInfo Information about the new call. + */ + protected abstract void addCall(CallInfo callInfo); + + /** + * Indicates to the in-call app that a call has moved to the {@link CallState#ACTIVE} state. + * + * @param callId The identifier of the call that became active. + */ + protected abstract void setActive(String callId); + + /** + * Indicates to the in-call app that a call has been moved to the + * {@link CallState#DISCONNECTED} and the user should be notified. + * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both + * depending on what is ultimately needed to support all scenarios. + * + * @param callId The identifier of the call that was disconnected. + */ + protected abstract void setDisconnected(String callId); +} diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 564f0cb89372c..e6a086a556577 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -38,6 +38,21 @@ public final class TelecommConstants { */ public static final String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + /** + * The service action used to bind to {@link CallServiceProvider} implementations. + */ + public static final String ACTION_CALL_SERVICE_PROVIDER = CallServiceProvider.class.getName(); + + /** + * The service action used to bind to {@link CallService} implementations. + */ + public static final String ACTION_CALL_SERVICE = CallService.class.getName(); + + /** + * The service action used to bind to {@link CallServiceSelector} implementations. + */ + public static final String ACTION_CALL_SERVICE_SELECTOR = CallServiceSelector.class.getName(); + /** * Extra for {@link #ACTION_INCOMING_CALL} containing the {@link CallServiceDescriptor} that * describes the call service to use for the incoming call. diff --git a/telecomm/java/android/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/ICallService.aidl similarity index 98% rename from telecomm/java/android/telecomm/ICallService.aidl rename to telecomm/java/com/android/internal/telecomm/ICallService.aidl index 28f19ca805fae..1df3f80ab13ed 100644 --- a/telecomm/java/android/telecomm/ICallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallService.aidl @@ -14,11 +14,12 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.os.Bundle; import android.telecomm.CallInfo; -import android.telecomm.ICallServiceAdapter; + +import com.android.internal.telecomm.ICallServiceAdapter; /** * Service interface for services which would like to provide calls to be @@ -31,6 +32,7 @@ import android.telecomm.ICallServiceAdapter; * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. * * TODO(santoscordon): Need final public-facing comments in this file. + * {@hide} */ oneway interface ICallService { diff --git a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl similarity index 92% rename from telecomm/java/android/telecomm/ICallServiceAdapter.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index 2e03d391e7553..7920b64293f67 100644 --- a/telecomm/java/android/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -14,38 +14,37 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.telecomm.CallInfo; /** * Provides methods for ICallService implementations to interact with the system phone app. * TODO(santoscordon): Need final public-facing comments in this file. + * {@hide} */ oneway interface ICallServiceAdapter { /** * Receives confirmation of a call service's ability to place a call. This method is used in * response to {@link ICallService#isCompatibleWith}. - * TODO(santoscordon): rename to setIsCompatibleWith(). * * @param callId The identifier of the call for which compatibility is being received. This ID * should correspond to the ID given as part of the call information in * {@link ICallService#isCompatibleWith}. * @param isCompatible True if the call service can place the call. */ - void setCompatibleWith(String callId, boolean isCompatible); + void setIsCompatibleWith(String callId, boolean isCompatible); /** * Provides Telecomm with the details of an incoming call. An invocation of this method must * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon * the invocation of this method, Telecomm will bring up the incoming-call interface where the * user can elect to answer or reject a call. - * TODO(santoscordon): Consider renaming from handle* to notify*. * * @param callInfo The details of the relevant call. */ - void handleIncomingCall(in CallInfo callInfo); + void notifyIncomingCall(in CallInfo callInfo); /** * Tells Telecomm that an attempt to place the specified outgoing call succeeded. diff --git a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl similarity index 96% rename from telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl index 2f2725799bdb9..97fa834a106e6 100644 --- a/telecomm/java/android/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.os.IBinder; import android.telecomm.CallServiceDescriptor; @@ -22,6 +22,7 @@ import java.util.List; /** * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s. + * {@hide} */ oneway interface ICallServiceLookupResponse { /** diff --git a/telecomm/java/android/telecomm/ICallServiceProvider.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl similarity index 88% rename from telecomm/java/android/telecomm/ICallServiceProvider.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl index 8b0a736cfb446..39fedddbd60db 100644 --- a/telecomm/java/android/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl @@ -14,9 +14,11 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; -import android.telecomm.ICallServiceLookupResponse; +import android.telecomm.CallServiceDescriptor; + +import com.android.internal.telecomm.ICallServiceLookupResponse; /** * Interface for applications interested in providing call-service implementations. Only used in @@ -30,11 +32,12 @@ import android.telecomm.ICallServiceLookupResponse; * processed by the CallsManager and its helpers (potentially requesting input from the user) to * identify the best CallService. The user should obviously be notified upon zero candidates as * well as all (one or more) candidates failing to issue the call. + * {@hide} */ oneway interface ICallServiceProvider { /** - * Initiates the process to retrieve the list of {@link ICallService}s implemented by + * Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by * this provider. * TODO(santoscordon): Needs comments on how to populate the list within * ICallServiceLookupResponse and how to handle error conditions. diff --git a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl similarity index 96% rename from telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl index 51efb8e3af83f..8270aa5773ec0 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.os.IBinder; import android.telecomm.CallServiceDescriptor; @@ -23,6 +23,7 @@ import java.util.List; /** * Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService} * implementations with which to connect the corresponding outgoing call. + * {@hide} */ oneway interface ICallServiceSelectionResponse { /** diff --git a/telecomm/java/android/telecomm/ICallServiceSelector.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl similarity index 94% rename from telecomm/java/android/telecomm/ICallServiceSelector.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl index 8ca4c0cd4afcf..3b73d9b4ed29f 100644 --- a/telecomm/java/android/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl @@ -14,13 +14,14 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.telecomm.CallInfo; import android.telecomm.CallServiceDescriptor; -import android.telecomm.ICallService; -import android.telecomm.ICallServiceSelectionResponse; -import android.telecomm.ICallSwitchabilityResponse; + +import com.android.internal.telecomm.ICallService; +import com.android.internal.telecomm.ICallServiceSelectionResponse; +import com.android.internal.telecomm.ICallSwitchabilityResponse; import java.util.List; @@ -61,6 +62,7 @@ import java.util.List; * all supported (either for a given call or globally across a given selector) , isSwitchable * below can return false blindly to suppress all "select" calls beyond the initial one (that * is used to establish outgoing calls). + * {@hide} */ oneway interface ICallServiceSelector { diff --git a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl similarity index 96% rename from telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl rename to telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl index afb4122f40b71..9a7e9e588db64 100644 --- a/telecomm/java/android/telecomm/ICallSwitchabilityResponse.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl @@ -14,11 +14,12 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; /** * Used by {@link ICallServiceSelector}s to return whether or not the relevant * call is switchable. + * {@hide} */ oneway interface ICallSwitchabilityResponse { /** diff --git a/telecomm/java/android/telecomm/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl similarity index 97% rename from telecomm/java/android/telecomm/IInCallAdapter.aidl rename to telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl index 9fb7d4db91f10..d4e67fc1085f6 100644 --- a/telecomm/java/android/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl @@ -14,7 +14,7 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; /** * Receives commands from {@link IInCallService} implementations which should be executed by @@ -28,6 +28,7 @@ package android.telecomm; * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording * the javadoc to reference those states precisely. + * {@hide} */ oneway interface IInCallAdapter { /** diff --git a/telecomm/java/android/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl similarity index 85% rename from telecomm/java/android/telecomm/IInCallService.aidl rename to telecomm/java/com/android/internal/telecomm/IInCallService.aidl index bc3a6b6cf5aae..05b0d20834b35 100644 --- a/telecomm/java/android/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -14,10 +14,11 @@ * limitations under the License. */ -package android.telecomm; +package com.android.internal.telecomm; import android.telecomm.CallInfo; -import android.telecomm.IInCallAdapter; + +import com.android.internal.telecomm.IInCallAdapter; /** * This service is implemented by any app that wishes to provide the user-interface for managing @@ -25,7 +26,8 @@ import android.telecomm.IInCallAdapter; * call, and uses it to notify the in-call app of any live and and recently disconnected calls. * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better * defined. - * TODO(santoscordon): What happens if two or more apps on a given decide implement this interface? + * TODO(santoscordon): What happens if two or more apps on a given device implement this interface? + * {@hide} */ oneway interface IInCallService { @@ -48,17 +50,16 @@ oneway interface IInCallService { void addCall(in CallInfo callInfo); /** - * Indicates to the in-call app that a call has moved to the active state. - * TODO(santoscordon): link javadoc to "active" constant once CallState is defined. + * Indicates to the in-call app that a call has moved to the + * {@link android.telecomm.CallState#ACTIVE} state. * * @param callId The identifier of the call that became active. */ void setActive(String callId); /** - * Indicates to the in-call app that a call has been disconnected and the user should be - * notified. - * TODO(santoscordon): link javadoc to "disconnected" constant once CallState is defined. + * Indicates to the in-call app that a call has been moved to the + * {@link android.telecomm.CallState#DISCONNECTED} and the user should be notified. * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both * depending on what is ultimately needed to support all scenarios. * From d6c9a7f0cfb71b735f247cb1bfbafc07fa2da832 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 11 Mar 2014 20:44:22 -0700 Subject: [PATCH 077/102] Fix build break due to links to private APIs Change-Id: I22360bd93800e1d898becb9fee9312acf82b78c7 --- telecomm/java/android/telecomm/CallService.java | 4 ++-- telecomm/java/android/telecomm/CallServiceProvider.java | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 87a5372b64653..52b259904f76c 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -190,7 +190,7 @@ public abstract class CallService extends Service { /** * Determines if the CallService can place the specified call. Response is sent via - * {@link CallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be + * {@link CallServiceAdapter#setIsCompatibleWith}. When responding, the correct call ID must be * specified. Only used in the context of outgoing calls and call switching (handoff). * * @param callInfo The details of the relevant call. @@ -224,7 +224,7 @@ public abstract class CallService extends Service { * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified * that this call service has a pending incoming call, see * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm - * additional information about the call through {@link CallServiceAdapter#handleIncomingCall}. + * additional information about the call through {@link CallServiceAdapter#notifyIncomingCall}. * Following that, the call service can update the call at will using the specified call ID. * * If a {@link Bundle} was passed (via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}) in diff --git a/telecomm/java/android/telecomm/CallServiceProvider.java b/telecomm/java/android/telecomm/CallServiceProvider.java index 5db7e2e2b5348..c50334aeee512 100644 --- a/telecomm/java/android/telecomm/CallServiceProvider.java +++ b/telecomm/java/android/telecomm/CallServiceProvider.java @@ -26,11 +26,11 @@ import com.android.internal.telecomm.ICallServiceLookupResponse; import com.android.internal.telecomm.ICallServiceProvider; /** - * Base implementation of {@link ICallServiceProvider} which extends {@link Service}. This class + * Base implementation of a call service provider which extends {@link Service}. This class * should be extended by an app that wants to supply phone calls to be handled and managed by - * the device's in-call interface. All method-calls from the framework to - * {@link ICallServiceProvider} are passed through to the main thread for before executing the - * overriden methods of CallServiceProvider. + * the device's in-call interface. All method-calls from the framework to the call service provider + * are passed through to the main thread for before executing the overriden methods of + * CallServiceProvider. * * TODO(santoscordon): Improve paragraph above once the final design is in place. Needs more * about how this can be used. From f556086b5ba6d04034e4adfab2b47126e3d4cdee Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 12 Mar 2014 07:29:58 -0700 Subject: [PATCH 078/102] Fix the build (update API) There was a last-minute renaming of some constants and update-api was not re-run. Change-Id: I3278cc204ea9e03ab3d5400cd308abedbf3b6da8 --- api/current.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index 6fb67d253ae6d..34a7a776b5b78 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24487,10 +24487,10 @@ package android.telecomm { public final class TelecommConstants { ctor public TelecommConstants(); + field public static final java.lang.String ACTION_CALL_SERVICE; + field public static final java.lang.String ACTION_CALL_SERVICE_PROVIDER; + field public static final java.lang.String ACTION_CALL_SERVICE_SELECTOR; field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; - field public static final java.lang.String CALL_SERVICE_ACTION; - field public static final java.lang.String CALL_SERVICE_PROVIDER_ACTION; - field public static final java.lang.String CALL_SERVICE_SELECTOR_ACTION; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; } From 0ca17060a54e4a6fac91e74933c7ea34c22fb42d Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Wed, 12 Mar 2014 09:21:40 -0700 Subject: [PATCH 079/102] Fix the build (again) Need a make clean first to get rid of deleted classes. Change-Id: I92ae86d40a5e20296bbbf594850ea2d6a2dd3b3e --- api/current.txt | 119 ------------------------------------------------ 1 file changed, 119 deletions(-) diff --git a/api/current.txt b/api/current.txt index 34a7a776b5b78..e71c434c9a54a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24351,125 +24351,6 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState RINGING; } - public abstract interface ICallService implements android.os.IInterface { - method public abstract void abort(java.lang.String) throws android.os.RemoteException; - method public abstract void answer(java.lang.String) throws android.os.RemoteException; - method public abstract void call(android.telecomm.CallInfo) throws android.os.RemoteException; - method public abstract void disconnect(java.lang.String) throws android.os.RemoteException; - method public abstract void isCompatibleWith(android.telecomm.CallInfo) throws android.os.RemoteException; - method public abstract void reject(java.lang.String) throws android.os.RemoteException; - method public abstract void setCallServiceAdapter(android.telecomm.ICallServiceAdapter) throws android.os.RemoteException; - method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle) throws android.os.RemoteException; - } - - public static abstract class ICallService.Stub extends android.os.Binder implements android.telecomm.ICallService { - ctor public ICallService.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallService asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallServiceAdapter implements android.os.IInterface { - method public abstract void handleFailedOutgoingCall(java.lang.String, java.lang.String) throws android.os.RemoteException; - method public abstract void handleIncomingCall(android.telecomm.CallInfo) throws android.os.RemoteException; - method public abstract void handleSuccessfulOutgoingCall(java.lang.String) throws android.os.RemoteException; - method public abstract void setActive(java.lang.String) throws android.os.RemoteException; - method public abstract void setCompatibleWith(java.lang.String, boolean) throws android.os.RemoteException; - method public abstract void setDialing(java.lang.String) throws android.os.RemoteException; - method public abstract void setDisconnected(java.lang.String) throws android.os.RemoteException; - method public abstract void setRinging(java.lang.String) throws android.os.RemoteException; - } - - public static abstract class ICallServiceAdapter.Stub extends android.os.Binder implements android.telecomm.ICallServiceAdapter { - ctor public ICallServiceAdapter.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallServiceAdapter asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallServiceLookupResponse implements android.os.IInterface { - method public abstract void setCallServiceDescriptors(java.util.List) throws android.os.RemoteException; - } - - public static abstract class ICallServiceLookupResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceLookupResponse { - ctor public ICallServiceLookupResponse.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallServiceLookupResponse asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallServiceProvider implements android.os.IInterface { - method public abstract void lookupCallServices(android.telecomm.ICallServiceLookupResponse) throws android.os.RemoteException; - } - - public static abstract class ICallServiceProvider.Stub extends android.os.Binder implements android.telecomm.ICallServiceProvider { - ctor public ICallServiceProvider.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallServiceProvider asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallServiceSelectionResponse implements android.os.IInterface { - method public abstract void setSelectedCallServiceDescriptors(java.util.List) throws android.os.RemoteException; - } - - public static abstract class ICallServiceSelectionResponse.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelectionResponse { - ctor public ICallServiceSelectionResponse.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallServiceSelectionResponse asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallServiceSelector implements android.os.IInterface { - method public abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.ICallSwitchabilityResponse) throws android.os.RemoteException; - method public abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.ICallServiceSelectionResponse) throws android.os.RemoteException; - } - - public static abstract class ICallServiceSelector.Stub extends android.os.Binder implements android.telecomm.ICallServiceSelector { - ctor public ICallServiceSelector.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallServiceSelector asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface ICallSwitchabilityResponse implements android.os.IInterface { - method public abstract void setIsSwitchable(boolean) throws android.os.RemoteException; - } - - public static abstract class ICallSwitchabilityResponse.Stub extends android.os.Binder implements android.telecomm.ICallSwitchabilityResponse { - ctor public ICallSwitchabilityResponse.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.ICallSwitchabilityResponse asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface IInCallAdapter implements android.os.IInterface { - method public abstract void answerCall(java.lang.String) throws android.os.RemoteException; - method public abstract void disconnectCall(java.lang.String) throws android.os.RemoteException; - method public abstract void rejectCall(java.lang.String) throws android.os.RemoteException; - } - - public static abstract class IInCallAdapter.Stub extends android.os.Binder implements android.telecomm.IInCallAdapter { - ctor public IInCallAdapter.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.IInCallAdapter asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - - public abstract interface IInCallService implements android.os.IInterface { - method public abstract void addCall(android.telecomm.CallInfo) throws android.os.RemoteException; - method public abstract void setActive(java.lang.String) throws android.os.RemoteException; - method public abstract void setDisconnected(java.lang.String) throws android.os.RemoteException; - method public abstract void setInCallAdapter(android.telecomm.IInCallAdapter) throws android.os.RemoteException; - } - - public static abstract class IInCallService.Stub extends android.os.Binder implements android.telecomm.IInCallService { - ctor public IInCallService.Stub(); - method public android.os.IBinder asBinder(); - method public static android.telecomm.IInCallService asInterface(android.os.IBinder); - method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException; - } - public final class InCallAdapter { method public void answerCall(java.lang.String); method public void disconnectCall(java.lang.String); From 0436d89f2f3c0e977f4b2cfcef0a1bd10dcbcc82 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 13 Mar 2014 14:16:33 -0700 Subject: [PATCH 080/102] Fix SDK build due to missing import in TelecommConstants Change-Id: Ieffc1cbfa4edb913125a0c29284d98351b12f9f4 --- telecomm/java/android/telecomm/TelecommConstants.java | 1 + 1 file changed, 1 insertion(+) diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 6c7f7c0691eb7..a48063e73d3a2 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -17,6 +17,7 @@ package android.telecomm; import android.os.Bundle; +import android.telephony.TelephonyManager; /** * Defines constants for use with the Telecomm system. From 9a4bf4a52d9d76f118ad0a7ce53e6b2f4ed189cb Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Thu, 13 Mar 2014 21:55:27 -0700 Subject: [PATCH 081/102] Fix the SDK build Fix a bad {@link} tag which was breaking the SDK javadocs build. Change-Id: Ib44fc5c21738fa65ef3cec72f8c0e8e8f4b938c2 --- telecomm/java/android/telecomm/TelecommConstants.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index a48063e73d3a2..4269424f1f241 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -70,7 +70,7 @@ public final class TelecommConstants { "android.intent.extra.INCOMING_CALL_EXTRAS"; /** - * Optional extra for {@link TelephonyManager.ACTION_PHONE_STATE_CHANGED} containing the unique + * Optional extra for {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} containing the unique * ID of the call. */ public static final String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; From 37384dedab38239433a41641fe87fc3e51bb6976 Mon Sep 17 00:00:00 2001 From: Shishir Agrawal Date: Fri, 14 Mar 2014 09:32:22 -0700 Subject: [PATCH 082/102] Modify TelephonyManager to expose sendEnvelopeWithStatus instead of sendEnvelope. The RIL sendEnvelope command does not return the response from the SIM while the sendEnvelopeWithStatus does. Since the response is required for certain envelope commands, its better to expose sendEnvelopeWithStatus. Change-Id: I209bfc59e396bb6f91345d6f99c51cfa35f2d650 --- api/current.txt | 2 +- .../java/android/telephony/TelephonyManager.java | 11 ++++++----- .../com/android/internal/telephony/ITelephony.aidl | 9 +++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/api/current.txt b/api/current.txt index 333bb737da9be..ec25996997376 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24847,7 +24847,7 @@ package android.telephony { method public boolean isNetworkRoaming(); method public void listen(android.telephony.PhoneStateListener, int); method public void newIncomingThirdPartyCall(android.content.ComponentName, java.lang.String, java.lang.String); - method public java.lang.String sendEnvelope(java.lang.String); + method public java.lang.String sendEnvelopeWithStatus(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 diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index f621fa42c7f40..413f9e509dabf 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -1806,8 +1806,7 @@ public class TelephonyManager { } /** - * Send ENVELOPE to the SIM, after processing a proactive command sent by - * the SIM. + * Send ENVELOPE to the SIM and return the response. * *

Requires Permission: * {@link android.Manifest.permission#SIM_COMMUNICATION SIM_COMMUNICATION} @@ -1815,11 +1814,13 @@ public class TelephonyManager { * @param content String containing SAT/USAT response in hexadecimal * format starting with command tag. See TS 102 223 for * details. - * @return The APDU response from the ICC card. + * @return The APDU response from the ICC card, with the last 4 bytes + * being the status word. If the command fails, returns an empty + * string. */ - public String sendEnvelope(String content) { + public String sendEnvelopeWithStatus(String content) { try { - return getITelephony().sendEnvelope(content); + return getITelephony().sendEnvelopeWithStatus(content); } catch (RemoteException ex) { } catch (NullPointerException ex) { } diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl index 4c0f259be2049..e2abb9a2e18a3 100644 --- a/telephony/java/com/android/internal/telephony/ITelephony.aidl +++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl @@ -369,15 +369,16 @@ interface ITelephony { int p1, int p2, int p3, String data); /** - * Send ENVELOPE to the SIM, after processing a proactive command sent by - * the SIM. + * Send ENVELOPE to the SIM and returns the response. * * @param contents String containing SAT/USAT response in hexadecimal * format starting with command tag. See TS 102 223 for * details. - * @return The APDU response from the ICC card. + * @return The APDU response from the ICC card, with the last 4 bytes + * being the status word. If the command fails, returns an empty + * string. */ - String sendEnvelope(String content); + String sendEnvelopeWithStatus(String content); /** * Read one of the NV items defined in {@link RadioNVItems} / {@code ril_nv_items.h}. From 81ccaaa25cc90c576c7df7c2cccb8a232e8536a1 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 12 Mar 2014 18:33:19 -0700 Subject: [PATCH 083/102] Add hold support to frameworks/base/telecomm Bug: 13169202 Change-Id: Ib01990c1f8654f95a4cfcca4a91f0ab143722d8e --- api/current.txt | 7 ++++ .../java/android/telecomm/CallService.java | 34 ++++++++++++++++++- .../android/telecomm/CallServiceAdapter.java | 14 ++++++++ telecomm/java/android/telecomm/CallState.java | 8 +++++ .../java/android/telecomm/InCallAdapter.java | 24 +++++++++++++ .../java/android/telecomm/InCallService.java | 17 ++++++++++ .../internal/telecomm/ICallService.aidl | 18 +++++++++- .../telecomm/ICallServiceAdapter.aidl | 7 ++++ .../internal/telecomm/IInCallAdapter.aidl | 14 ++++++++ .../internal/telecomm/IInCallService.aidl | 8 +++++ 10 files changed, 149 insertions(+), 2 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8302aba0fa30c..cc4f2a0d5e818 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24455,11 +24455,13 @@ package android.telecomm { method public abstract void call(android.telecomm.CallInfo); method public abstract void disconnect(java.lang.String); method public final android.os.IBinder getBinder(); + method public abstract void hold(java.lang.String); method public abstract void isCompatibleWith(android.telecomm.CallInfo); method public final android.os.IBinder onBind(android.content.Intent); method public abstract void reject(java.lang.String); method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); + method public abstract void unhold(java.lang.String); } public final class CallServiceAdapter { @@ -24470,6 +24472,7 @@ package android.telecomm { method public void setDialing(java.lang.String); method public void setDisconnected(java.lang.String); method public void setIsCompatibleWith(java.lang.String, boolean); + method public void setOnHold(java.lang.String); method public void setRinging(java.lang.String); } @@ -24523,13 +24526,16 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState ACTIVE; enum_constant public static final android.telecomm.CallState DIALING; enum_constant public static final android.telecomm.CallState DISCONNECTED; + enum_constant public static final android.telecomm.CallState ON_HOLD; enum_constant public static final android.telecomm.CallState RINGING; } public final class InCallAdapter { method public void answerCall(java.lang.String); method public void disconnectCall(java.lang.String); + method public void holdCall(java.lang.String); method public void rejectCall(java.lang.String); + method public void unholdCall(java.lang.String); } public abstract class InCallService extends android.app.Service { @@ -24539,6 +24545,7 @@ package android.telecomm { method protected abstract void setActive(java.lang.String); method protected abstract void setDisconnected(java.lang.String); method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); + method protected abstract void setOnHold(java.lang.String); } public final class TelecommConstants { diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 52b259904f76c..395bcc1255465 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -86,6 +86,12 @@ public abstract class CallService extends Service { case MSG_DISCONNECT: disconnect((String) msg.obj); break; + case MSG_HOLD: + hold((String) msg.obj); + break; + case MSG_UNHOLD: + unhold((String) msg.obj); + break; default: break; } @@ -139,6 +145,16 @@ public abstract class CallService extends Service { public void disconnect(String callId) { mMessageHandler.obtainMessage(MSG_DISCONNECT, callId).sendToTarget(); } + + @Override + public void hold(String callId) { + mMessageHandler.obtainMessage(MSG_HOLD, callId).sendToTarget(); + } + + @Override + public void unhold(String callId) { + mMessageHandler.obtainMessage(MSG_UNHOLD, callId).sendToTarget(); + } } // Only used internally by this class. @@ -154,7 +170,9 @@ public abstract class CallService extends Service { MSG_SET_INCOMING_CALL_ID = 5, MSG_ANSWER = 6, MSG_REJECT = 7, - MSG_DISCONNECT = 8; + MSG_DISCONNECT = 8, + MSG_HOLD = 9, + MSG_UNHOLD = 10; /** * Message handler for consolidating binder callbacks onto a single thread. @@ -258,4 +276,18 @@ public abstract class CallService extends Service { * @param callId The ID of the call to disconnect. */ public abstract void disconnect(String callId); + + /** + * Puts the specified call on hold. + * + * @param callId The ID of the call to put on hold. + */ + public abstract void hold(String callId); + + /** + * Removes the specified call from hold. + * + * @param callId The ID of the call to unhold. + */ + public abstract void unhold(String callId); } diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java index a391f34e79c34..0527a6d777b61 100644 --- a/telecomm/java/android/telecomm/CallServiceAdapter.java +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -140,4 +140,18 @@ public final class CallServiceAdapter { } catch (RemoteException e) { } } + + /** + * Sets a call's state to be on hold. + * + * @param callId - The unique ID of the call whose state is changing to be on hold. + */ + public void setOnHold(String callId) { + try { + mAdapter.setOnHold(callId); + } catch (RemoteException e) { + } + } + + } diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index d699fbd23baab..3937b08844ce3 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -55,6 +55,14 @@ public enum CallState { */ ACTIVE, + /** + * Indicates that the call is currently on hold. In this state, the call is not terminated + * but no communication is allowed until the call is no longer on hold. The typical transition + * to this state is by the user putting an {@link #ACTIVE} call on hold by explicitly performing + * an action, such as clicking the hold button. + */ + ON_HOLD, + /** * Indicates that a call is currently disconnected. All states can transition to this state * by the call service giving notice that the connection has been severed. When the user diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java index c9bd8c2465bdb..6649ef71f8271 100644 --- a/telecomm/java/android/telecomm/InCallAdapter.java +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -78,4 +78,28 @@ public final class InCallAdapter { } catch (RemoteException e) { } } + + /** + * Instructs Telecomm to put the specified call on hold. + * + * @param callId The identifier of the call to put on hold. + */ + public void holdCall(String callId) { + try { + mAdapter.holdCall(callId); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecomm to release the specified call from hold. + * + * @param callId The identifier of the call to release from hold. + */ + public void unholdCall(String callId) { + try { + mAdapter.unholdCall(callId); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 7819d44d47bb1..cd6a882e252b1 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -39,6 +39,7 @@ public abstract class InCallService extends Service { private static final int MSG_ADD_CALL = 2; private static final int MSG_SET_ACTIVE = 3; private static final int MSG_SET_DISCONNECTED = 4; + private static final int MSG_SET_HOLD = 5; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -58,6 +59,8 @@ public abstract class InCallService extends Service { case MSG_SET_DISCONNECTED: setDisconnected((String) msg.obj); break; + case MSG_SET_HOLD: + setOnHold((String) msg.obj); default: break; } @@ -89,6 +92,12 @@ public abstract class InCallService extends Service { public void setDisconnected(String callId) { mHandler.obtainMessage(MSG_SET_DISCONNECTED, callId).sendToTarget(); } + + /** {@inheritDoc} */ + @Override + public void setOnHold(String callId) { + mHandler.obtainMessage(MSG_SET_HOLD, callId).sendToTarget(); + } } private final InCallServiceBinder mBinder; @@ -136,4 +145,12 @@ public abstract class InCallService extends Service { * @param callId The identifier of the call that was disconnected. */ protected abstract void setDisconnected(String callId); + + /** + * Indicates to the in-call app that a call has been moved to the + * {@link android.telecomm.CallState#ON_HOLD} state and the user should be notified. + * + * @param callId The identifier of the call that was put on hold. + */ + protected abstract void setOnHold(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/ICallService.aidl index 1df3f80ab13ed..d05a3e0926cad 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallService.aidl @@ -39,7 +39,7 @@ oneway interface ICallService { /** * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls * and communicate state changes of existing calls. This is the first method that is called - * after a the framework binds to the call service. + * after the framework binds to the call service. * * @param callServiceAdapter Interface to CallsManager for adding and updating calls. */ @@ -120,4 +120,20 @@ oneway interface ICallService { * @param callId The identifier of the call to disconnect. */ void disconnect(String callId); + + /** + * Puts the call identified by callId on hold. Telecomm invokes this method when a call should + * be placed on hold per user request or because a different call was made active. + * + * @param callId The identifier of the call to put on hold. + */ + void hold(String callId); + + /** + * Removes the call identified by callId from hold. Telecomm invokes this method when a call + * should be removed on hold per user request or because a different call was put on hold. + * + * @param callId The identifier of the call to remove from hold. + */ + void unhold(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index 7920b64293f67..e96defeef9462 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -91,4 +91,11 @@ oneway interface ICallServiceAdapter { * @param callId The unique ID of the call whose state is changing to disconnected. */ void setDisconnected(String callId); + + /** + * Sets a call's state to be on hold. + * + * @param callId The unique ID of the call whose state is changing to be on hold. + */ + void setOnHold(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl index d4e67fc1085f6..6ae055dd0f0df 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl @@ -53,4 +53,18 @@ oneway interface IInCallAdapter { * @param callId The identifier of the call to disconnect. */ void disconnectCall(String callId); + + /** + * Instructs Telecomm to put the specified call on hold. + * + * @param callId The identifier of the call to put on hold. + */ + void holdCall(String callId); + + /** + * Instructs Telecomm to release the specified call from hold. + * + * @param callId The identifier of the call to release from hold. + */ + void unholdCall(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index 05b0d20834b35..b3bd0a66b19b6 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -66,4 +66,12 @@ oneway interface IInCallService { * @param callId The identifier of the call that was disconnected. */ void setDisconnected(String callId); + + /** + * Indicates to the in-call app that a call has been moved to the + * {@link android.telecomm.CallState#HOLD} state and the user should be notified. + * + * @param callId The identifier of the call that was put on hold. + */ + void setOnHold(String callId); } From cadc1c144bd398b0ee32f63a1ffea69259b046dc Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Mon, 17 Mar 2014 18:34:10 -0700 Subject: [PATCH 084/102] frameworks/base: Use Uri for handle Change-Id: I7f3163da47159d68903ce45268429f5949203589 --- api/current.txt | 4 ++-- telecomm/java/android/telecomm/CallInfo.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8302aba0fa30c..2c75d81dbdff2 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24439,9 +24439,9 @@ package android.speech.tts { package android.telecomm { public final class CallInfo implements android.os.Parcelable { - ctor public CallInfo(java.lang.String, android.telecomm.CallState, java.lang.String); + ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri); method public int describeContents(); - method public java.lang.String getHandle(); + method public android.net.Uri getHandle(); method public java.lang.String getId(); method public android.telecomm.CallState getState(); method public void writeToParcel(android.os.Parcel, int); diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index b818e6dcf9f6d..b1413a6f0ae48 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -16,8 +16,10 @@ package android.telecomm; +import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; +import android.os.Parcelable; import java.util.Date; import java.util.UUID; @@ -43,7 +45,7 @@ public final class CallInfo implements Parcelable { * Endpoint to which the call is connected. * This could be the dialed value for outgoing calls or the caller id of incoming calls. */ - private final String mHandle; + private final Uri mHandle; // There are 4 timestamps that are important to a call: // 1) Created timestamp - The time at which the user explicitly chose to make the call. @@ -64,7 +66,7 @@ public final class CallInfo implements Parcelable { * @param state The state of the call. * @param handle The handle to the other party in this call. */ - public CallInfo(String id, CallState state, String handle) { + public CallInfo(String id, CallState state, Uri handle) { mId = id; mState = state; mHandle = handle; @@ -78,7 +80,7 @@ public final class CallInfo implements Parcelable { return mState; } - public String getHandle() { + public Uri getHandle() { return mHandle; } @@ -96,7 +98,7 @@ public final class CallInfo implements Parcelable { public CallInfo createFromParcel(Parcel source) { String id = source.readString(); CallState state = CallState.valueOf(source.readString()); - String handle = source.readString(); + Uri handle = Uri.CREATOR.createFromParcel(source); return new CallInfo(id, state, handle); } @@ -122,6 +124,6 @@ public final class CallInfo implements Parcelable { public void writeToParcel(Parcel destination, int flags) { destination.writeString(mId); destination.writeString(mState.name()); - destination.writeString(mHandle); + mHandle.writeToParcel(destination, 0); } } From 93fb1d00bc318079e58e53db39b4850adc31ffa1 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 19 Mar 2014 11:47:02 -0700 Subject: [PATCH 085/102] Add gateway support to frameworks/base/telecomm Add parcelable GatewayInfo class used to store gateway info in Call and CallInfo. Add gateway-related string constants to TelecommConstants Bug: 13477768 Change-Id: I35b2de2d66edeed6273f6cba5329ca0f26264db6 --- api/current.txt | 12 ++ telecomm/java/android/telecomm/CallInfo.java | 45 +++++++- .../java/android/telecomm/GatewayInfo.aidl | 19 ++++ .../java/android/telecomm/GatewayInfo.java | 106 ++++++++++++++++++ 4 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 telecomm/java/android/telecomm/GatewayInfo.aidl create mode 100644 telecomm/java/android/telecomm/GatewayInfo.java diff --git a/api/current.txt b/api/current.txt index 9209004f06122..d483cf5f459c2 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24531,8 +24531,10 @@ package android.telecomm { public final class CallInfo implements android.os.Parcelable { ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri); method public int describeContents(); + method public android.telecomm.GatewayInfo getGatewayInfo(); method public android.net.Uri getHandle(); method public java.lang.String getId(); + method public android.net.Uri getOriginalHandle(); method public android.telecomm.CallState getState(); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; @@ -24620,6 +24622,16 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState RINGING; } + public class GatewayInfo implements android.os.Parcelable { + method public int describeContents(); + method public android.net.Uri getGatewayHandle(); + method public java.lang.String getGatewayProviderPackageName(); + method public android.net.Uri getOriginalHandle(); + method public boolean isEmpty(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; + } + public final class InCallAdapter { method public void answerCall(java.lang.String); method public void disconnectCall(java.lang.String); diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index b1413a6f0ae48..bb08c2aac50cb 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -19,7 +19,6 @@ package android.telecomm; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; -import android.os.Parcelable; import java.util.Date; import java.util.UUID; @@ -47,6 +46,11 @@ public final class CallInfo implements Parcelable { */ private final Uri mHandle; + /** + * Gateway information for the call. + */ + private final GatewayInfo mGatewayInfo; + // There are 4 timestamps that are important to a call: // 1) Created timestamp - The time at which the user explicitly chose to make the call. // 2) Connected timestamp - The time at which a call service confirms that it has connected @@ -59,17 +63,25 @@ public final class CallInfo implements Parcelable { // other party. // 4) Disconnected timestamp - The time at which the call was disconnected. + public CallInfo(String id, CallState state, Uri handle) { + this(id, state, handle, null); + } + /** * Persists handle of the other party of this call. * * @param id The unique ID of the call. * @param state The state of the call. * @param handle The handle to the other party in this call. + * @param gatewayInfo Gateway information pertaining to this call. + * + * @hide */ - public CallInfo(String id, CallState state, Uri handle) { + public CallInfo(String id, CallState state, Uri handle, GatewayInfo gatewayInfo) { mId = id; mState = state; mHandle = handle; + mGatewayInfo = gatewayInfo; } public String getId() { @@ -84,6 +96,22 @@ public final class CallInfo implements Parcelable { return mHandle; } + /** + * @return The actual handle this call is associated with. This is used by call services to + * correctly indicate in their UI what handle the user is actually calling, and by other + * telecomm components that require the user-dialed handle to function. + */ + public Uri getOriginalHandle() { + if (mGatewayInfo != null) { + return mGatewayInfo.getOriginalHandle(); + } + return getHandle(); + } + + public GatewayInfo getGatewayInfo() { + return mGatewayInfo; + } + // // Parceling related code below here. // @@ -99,8 +127,13 @@ public final class CallInfo implements Parcelable { String id = source.readString(); CallState state = CallState.valueOf(source.readString()); Uri handle = Uri.CREATOR.createFromParcel(source); + boolean gatewayInfoPresent = source.readByte() != 0; + GatewayInfo gatewayInfo = null; + if (gatewayInfoPresent) { + gatewayInfo = GatewayInfo.CREATOR.createFromParcel(source); + } - return new CallInfo(id, state, handle); + return new CallInfo(id, state, handle, gatewayInfo); } @Override @@ -125,5 +158,11 @@ public final class CallInfo implements Parcelable { destination.writeString(mId); destination.writeString(mState.name()); mHandle.writeToParcel(destination, 0); + if (mGatewayInfo != null) { + destination.writeByte((byte) 1); + mGatewayInfo.writeToParcel(destination, 0); + } else { + destination.writeByte((byte) 0); + } } } diff --git a/telecomm/java/android/telecomm/GatewayInfo.aidl b/telecomm/java/android/telecomm/GatewayInfo.aidl new file mode 100644 index 0000000000000..d59e9b4376ec8 --- /dev/null +++ b/telecomm/java/android/telecomm/GatewayInfo.aidl @@ -0,0 +1,19 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +parcelable GatewayInfo; diff --git a/telecomm/java/android/telecomm/GatewayInfo.java b/telecomm/java/android/telecomm/GatewayInfo.java new file mode 100644 index 0000000000000..b95e6b68ad48b --- /dev/null +++ b/telecomm/java/android/telecomm/GatewayInfo.java @@ -0,0 +1,106 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.net.Uri; +import android.os.Parcel; +import android.os.Parcelable; +import android.text.TextUtils; + +/** + * When calls are made, they may contain gateway information for services which route phone calls + * through their own service/numbers. The data consists of a number to call and the package name of + * the service. This data is used in two ways: + *

    + *
  1. Call the appropriate routing number + *
  2. Display information about how the call is being routed to the user + *
+ */ +public class GatewayInfo implements Parcelable { + + private final String mGatewayProviderPackageName; + private final Uri mGatewayHandle; + private final Uri mOriginalHandle; + + /** @hide */ + public GatewayInfo(String packageName, Uri gatewayUri, Uri originalHandle) { + mGatewayProviderPackageName = packageName; + mGatewayHandle = gatewayUri; + mOriginalHandle = originalHandle; + } + + /** + * Package name of the gateway provider service. used to place the call with. + */ + public String getGatewayProviderPackageName() { + return mGatewayProviderPackageName; + } + + /** + * Gateway provider handle to use when actually placing the call. + */ + public Uri getGatewayHandle() { + return mGatewayHandle; + } + + /** + * The actual call handle that the user is trying to connect to via the gateway. + */ + public Uri getOriginalHandle() { + return mOriginalHandle; + } + + public boolean isEmpty() { + return TextUtils.isEmpty(mGatewayProviderPackageName) || mGatewayHandle == null; + } + + /** Implement the Parcelable interface */ + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator () { + + @Override + public GatewayInfo createFromParcel(Parcel source) { + String gatewayPackageName = source.readString(); + Uri gatewayUri = Uri.CREATOR.createFromParcel(source); + Uri originalHandle = Uri.CREATOR.createFromParcel(source); + return new GatewayInfo(gatewayPackageName, gatewayUri, originalHandle); + } + + @Override + public GatewayInfo[] newArray(int size) { + return new GatewayInfo[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * {@inheritDoc} + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(mGatewayProviderPackageName); + mGatewayHandle.writeToParcel(destination, 0); + mOriginalHandle.writeToParcel(destination, 0); + } +} From 4cff392a2b3702514e78c5419bf15de6e39c59af Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Wed, 19 Mar 2014 10:15:37 -0700 Subject: [PATCH 086/102] Add audio mode APIs Change-Id: Ia7e78b52b6b30f99a9ba066dae558a105dbebd96 --- api/current.txt | 19 +++ .../java/android/telecomm/CallAudioState.aidl | 19 +++ .../java/android/telecomm/CallAudioState.java | 160 ++++++++++++++++++ telecomm/java/android/telecomm/CallInfo.java | 1 - .../java/android/telecomm/CallService.java | 59 +++++-- .../java/android/telecomm/InCallAdapter.java | 24 +++ .../java/android/telecomm/InCallService.java | 17 ++ .../internal/telecomm/ICallService.aidl | 9 + .../internal/telecomm/IInCallAdapter.aidl | 16 ++ .../internal/telecomm/IInCallService.aidl | 8 + 10 files changed, 313 insertions(+), 19 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallAudioState.aidl create mode 100644 telecomm/java/android/telecomm/CallAudioState.java diff --git a/api/current.txt b/api/current.txt index a680a0340e06d..5365f6185706f 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24455,6 +24455,21 @@ package android.speech.tts { package android.telecomm { + public final class CallAudioState implements android.os.Parcelable { + method public int describeContents(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; + field public static int ROUTE_ALL; + field public static int ROUTE_BLUETOOTH; + field public static int ROUTE_EARPIECE; + field public static int ROUTE_SPEAKER; + field public static int ROUTE_WIRED_HEADSET; + field public static int ROUTE_WIRED_OR_EARPIECE; + field public final boolean isMuted; + field public final int route; + field public final int supportedRouteMask; + } + public final class CallInfo implements android.os.Parcelable { ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri); method public int describeContents(); @@ -24474,6 +24489,7 @@ package android.telecomm { method public final android.os.IBinder getBinder(); method public abstract void hold(java.lang.String); method public abstract void isCompatibleWith(android.telecomm.CallInfo); + method public abstract void onAudioStateChanged(java.lang.String, android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method public abstract void reject(java.lang.String); method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); @@ -24551,13 +24567,16 @@ package android.telecomm { method public void answerCall(java.lang.String); method public void disconnectCall(java.lang.String); method public void holdCall(java.lang.String); + method public void mute(boolean); method public void rejectCall(java.lang.String); + method public void setAudioRoute(int); method public void unholdCall(java.lang.String); } public abstract class InCallService extends android.app.Service { ctor protected InCallService(); method protected abstract void addCall(android.telecomm.CallInfo); + method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void setActive(java.lang.String); method protected abstract void setDisconnected(java.lang.String); diff --git a/telecomm/java/android/telecomm/CallAudioState.aidl b/telecomm/java/android/telecomm/CallAudioState.aidl new file mode 100644 index 0000000000000..ae645677e3eda --- /dev/null +++ b/telecomm/java/android/telecomm/CallAudioState.aidl @@ -0,0 +1,19 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +parcelable CallAudioState; diff --git a/telecomm/java/android/telecomm/CallAudioState.java b/telecomm/java/android/telecomm/CallAudioState.java new file mode 100644 index 0000000000000..d9a0090116d9a --- /dev/null +++ b/telecomm/java/android/telecomm/CallAudioState.java @@ -0,0 +1,160 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.Locale; + +/** + * Encapsulates all audio states during a call. + */ +public final class CallAudioState implements Parcelable { + /** Direct the audio stream through the device's earpiece. */ + public static int ROUTE_EARPIECE = 0x00000001; + + /** Direct the audio stream through Bluetooth. */ + public static int ROUTE_BLUETOOTH = 0x00000002; + + /** Direct the audio stream through a wired headset. */ + public static int ROUTE_WIRED_HEADSET = 0x00000004; + + /** Direct the audio stream through the device's spakerphone. */ + public static int ROUTE_SPEAKER = 0x00000008; + + /** + * Direct the audio stream through the device's earpiece or wired headset if one is + * connected. + */ + public static int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET; + + /** Bit mask of all possible audio routes. */ + public static int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET | + ROUTE_SPEAKER; + + /** True if the call is muted, false otherwise. */ + public final boolean isMuted; + + /** The route to use for the audio stream. */ + public final int route; + + /** Bit vector of all routes supported by this call. */ + public final int supportedRouteMask; + + /** @hide */ + public CallAudioState(boolean isMuted, int route, int supportedRouteMask) { + this.isMuted = isMuted; + this.route = route; + this.supportedRouteMask = supportedRouteMask; + } + + /** @hide */ + public CallAudioState(CallAudioState state) { + isMuted = state.isMuted; + route = state.route; + supportedRouteMask = state.supportedRouteMask; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof CallAudioState)) { + return false; + } + CallAudioState state = (CallAudioState) obj; + return isMuted == state.isMuted && route == state.route && + supportedRouteMask == state.supportedRouteMask; + } + + @Override + public String toString() { + return String.format(Locale.US, + "[CallAudioState isMuted: %b, route; %s, supportedRouteMask: %s]", + isMuted, audioRouteToString(route), audioRouteToString(supportedRouteMask)); + } + + /** @hide */ + public static String audioRouteToString(int route) { + if (route == 0 || (route & ~ROUTE_ALL) != 0x0) { + return "UNKNOWN"; + } + + StringBuffer buffer = new StringBuffer(); + if ((route & ROUTE_EARPIECE) == ROUTE_EARPIECE) { + listAppend(buffer, "EARPIECE"); + } + if ((route & ROUTE_BLUETOOTH) == ROUTE_BLUETOOTH) { + listAppend(buffer, "BLUETOOTH"); + } + if ((route & ROUTE_WIRED_HEADSET) == ROUTE_WIRED_HEADSET) { + listAppend(buffer, "WIRED_HEADSET"); + } + if ((route & ROUTE_SPEAKER) == ROUTE_SPEAKER) { + listAppend(buffer, "SPEAKER"); + } + + return buffer.toString(); + } + + private static void listAppend(StringBuffer buffer, String str) { + if (buffer.length() > 0) { + buffer.append(", "); + } + buffer.append(str); + } + + /** + * Responsible for creating CallAudioState objects for deserialized Parcels. + */ + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator () { + + @Override + public CallAudioState createFromParcel(Parcel source) { + boolean isMuted = source.readByte() == 0 ? false : true; + int route = source.readInt(); + int supportedRouteMask = source.readInt(); + return new CallAudioState(isMuted, route, supportedRouteMask); + } + + @Override + public CallAudioState[] newArray(int size) { + return new CallAudioState[size]; + } + }; + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + return 0; + } + + /** + * Writes CallAudioState object into a serializeable Parcel. + */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeByte((byte) (isMuted ? 1 : 0)); + destination.writeInt(route); + destination.writeInt(supportedRouteMask); + } +} diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index b1413a6f0ae48..718bc53e7f5b6 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -19,7 +19,6 @@ package android.telecomm; import android.net.Uri; import android.os.Parcel; import android.os.Parcelable; -import android.os.Parcelable; import java.util.Date; import java.util.UUID; diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 395bcc1255465..3b88be1eb5488 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -46,6 +46,18 @@ import com.android.internal.telecomm.ICallServiceAdapter; */ public abstract class CallService extends Service { + private static final int MSG_SET_CALL_SERVICE_ADAPTER = 1; + private static final int MSG_IS_COMPATIBLE_WITH = 2; + private static final int MSG_CALL = 3; + private static final int MSG_ABORT = 4; + private static final int MSG_SET_INCOMING_CALL_ID = 5; + private static final int MSG_ANSWER = 6; + private static final int MSG_REJECT = 7; + private static final int MSG_DISCONNECT = 8; + private static final int MSG_HOLD = 9; + private static final int MSG_UNHOLD = 10; + private static final int MSG_ON_AUDIO_STATE_CHANGED = 11; + /** * Default Handler used to consolidate binder method calls onto a single thread. */ @@ -67,7 +79,7 @@ public abstract class CallService extends Service { case MSG_ABORT: abort((String) msg.obj); break; - case MSG_SET_INCOMING_CALL_ID: + case MSG_SET_INCOMING_CALL_ID: { SomeArgs args = (SomeArgs) msg.obj; try { String callId = (String) args.arg1; @@ -77,6 +89,7 @@ public abstract class CallService extends Service { args.recycle(); } break; + } case MSG_ANSWER: answer((String) msg.obj); break; @@ -92,6 +105,17 @@ public abstract class CallService extends Service { case MSG_UNHOLD: unhold((String) msg.obj); break; + case MSG_ON_AUDIO_STATE_CHANGED: { + SomeArgs args = (SomeArgs) msg.obj; + try { + String callId = (String) args.arg1; + CallAudioState audioState = (CallAudioState) args.arg2; + onAudioStateChanged(callId, audioState); + } finally { + args.recycle(); + } + break; + } default: break; } @@ -155,24 +179,15 @@ public abstract class CallService extends Service { public void unhold(String callId) { mMessageHandler.obtainMessage(MSG_UNHOLD, callId).sendToTarget(); } - } - // Only used internally by this class. - // Binder method calls on this service can occur on multiple threads. These messages are used - // in conjunction with {@link #mMessageHandler} to ensure that all callbacks are handled on a - // single thread. Keeping it on a single thread allows CallService implementations to avoid - // needing multi-threaded code in their own callback routines. - private static final int - MSG_SET_CALL_SERVICE_ADAPTER = 1, - MSG_IS_COMPATIBLE_WITH = 2, - MSG_CALL = 3, - MSG_ABORT = 4, - MSG_SET_INCOMING_CALL_ID = 5, - MSG_ANSWER = 6, - MSG_REJECT = 7, - MSG_DISCONNECT = 8, - MSG_HOLD = 9, - MSG_UNHOLD = 10; + @Override + public void onAudioStateChanged(String callId, CallAudioState audioState) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = audioState; + mMessageHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, args).sendToTarget(); + } + } /** * Message handler for consolidating binder callbacks onto a single thread. @@ -290,4 +305,12 @@ public abstract class CallService extends Service { * @param callId The ID of the call to unhold. */ public abstract void unhold(String callId); + + /** + * Called when the audio state changes. + * + * @param activeCallId The identifier of the call that was active during the state change. + * @param audioState The new {@link CallAudioState}. + */ + public abstract void onAudioStateChanged(String activeCallId, CallAudioState audioState); } diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java index 6649ef71f8271..0a8571aa86508 100644 --- a/telecomm/java/android/telecomm/InCallAdapter.java +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -102,4 +102,28 @@ public final class InCallAdapter { } catch (RemoteException e) { } } + + /** + * Mute the microphone. + * + * @param shouldMute True if the microphone should be muted. + */ + public void mute(boolean shouldMute) { + try { + mAdapter.mute(shouldMute); + } catch (RemoteException e) { + } + } + + /** + * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}. + * + * @param route The audio route to use. + */ + public void setAudioRoute(int route) { + try { + mAdapter.setAudioRoute(route); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index cd6a882e252b1..ef15a61bd89c4 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -40,6 +40,7 @@ public abstract class InCallService extends Service { private static final int MSG_SET_ACTIVE = 3; private static final int MSG_SET_DISCONNECTED = 4; private static final int MSG_SET_HOLD = 5; + private static final int MSG_ON_AUDIO_STATE_CHANGED = 6; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -61,6 +62,9 @@ public abstract class InCallService extends Service { break; case MSG_SET_HOLD: setOnHold((String) msg.obj); + break; + case MSG_ON_AUDIO_STATE_CHANGED: + onAudioStateChanged((CallAudioState) msg.obj); default: break; } @@ -98,6 +102,12 @@ public abstract class InCallService extends Service { public void setOnHold(String callId) { mHandler.obtainMessage(MSG_SET_HOLD, callId).sendToTarget(); } + + /** {@inheritDoc} */ + @Override + public void onAudioStateChanged(CallAudioState audioState) { + mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget(); + } } private final InCallServiceBinder mBinder; @@ -153,4 +163,11 @@ public abstract class InCallService extends Service { * @param callId The identifier of the call that was put on hold. */ protected abstract void setOnHold(String callId); + + /** + * Called when the audio state changes. + * + * @param audioState The new {@link CallAudioState}. + */ + protected abstract void onAudioStateChanged(CallAudioState audioState); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/ICallService.aidl index d05a3e0926cad..3455efd2ce3b1 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallService.aidl @@ -17,6 +17,7 @@ package com.android.internal.telecomm; import android.os.Bundle; +import android.telecomm.CallAudioState; import android.telecomm.CallInfo; import com.android.internal.telecomm.ICallServiceAdapter; @@ -136,4 +137,12 @@ oneway interface ICallService { * @param callId The identifier of the call to remove from hold. */ void unhold(String callId); + + /** + * Called when the audio state changes. + * + * @param activeCallId The identifier of the call that was active during the state change. + * @param audioState The new {@link CallAudioState}. + */ + void onAudioStateChanged(String activeCallId, in CallAudioState audioState); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl index 6ae055dd0f0df..0fe3bfceea696 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl @@ -16,6 +16,8 @@ package com.android.internal.telecomm; +import android.telecomm.CallAudioState; + /** * Receives commands from {@link IInCallService} implementations which should be executed by * Telecomm. When Telecomm binds to a {@link IInCallService}, an instance of this class is given to @@ -67,4 +69,18 @@ oneway interface IInCallAdapter { * @param callId The identifier of the call to release from hold. */ void unholdCall(String callId); + + /** + * Mute the microphone. + * + * @param shouldMute True if the microphone should be muted. + */ + void mute(boolean shouldMute); + + /** + * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}. + * + * @param route The audio route to use. + */ + void setAudioRoute(int route); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index b3bd0a66b19b6..35498a340cd70 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -16,6 +16,7 @@ package com.android.internal.telecomm; +import android.telecomm.CallAudioState; import android.telecomm.CallInfo; import com.android.internal.telecomm.IInCallAdapter; @@ -74,4 +75,11 @@ oneway interface IInCallService { * @param callId The identifier of the call that was put on hold. */ void setOnHold(String callId); + + /** + * Called when the audio state changes. + * + * @param audioState The new {@link CallAudioState}. + */ + void onAudioStateChanged(in CallAudioState audioState); } From 1b469fecb03f28fd6379978802a14cab97a7549d Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 25 Mar 2014 21:12:23 -0700 Subject: [PATCH 087/102] Delete README file Documentation is out of date. Also, frameworks/base doesn't seem to have README files except for test directories. Change-Id: I408ede48d592e6f640a040c7be97d272a1c15bd5 --- telecomm/java/android/telecomm/README | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 telecomm/java/android/telecomm/README diff --git a/telecomm/java/android/telecomm/README b/telecomm/java/android/telecomm/README deleted file mode 100644 index defca73548654..0000000000000 --- a/telecomm/java/android/telecomm/README +++ /dev/null @@ -1,2 +0,0 @@ -Mostly AIDL files to interface between the rest of the system and code under -/packages/services/Telecomm/src/com/android/telecomm. \ No newline at end of file From 20e3f02c2de4efd4ccf56112b39b6056582f283a Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Thu, 27 Mar 2014 12:15:38 -0700 Subject: [PATCH 088/102] Add disconnect cause to setDisconnected. Change-Id: I4ba9b8f47a942b82b7a3d4bed43c0ca945957592 --- api/current.txt | 48 ++++++++++++++++++- .../android/telecomm/CallServiceAdapter.java | 7 ++- .../java/android/telecomm/InCallService.java | 12 ++--- .../telecomm/ICallServiceAdapter.aidl | 5 +- .../internal/telecomm/IInCallService.aidl | 6 +-- .../android/telephony/DisconnectCause.java | 5 +- 6 files changed, 65 insertions(+), 18 deletions(-) diff --git a/api/current.txt b/api/current.txt index 8d9ca890664c7..54dd135ce22bc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24868,7 +24868,7 @@ package android.telecomm { method public void notifyIncomingCall(android.telecomm.CallInfo); method public void setActive(java.lang.String); method public void setDialing(java.lang.String); - method public void setDisconnected(java.lang.String); + method public void setDisconnected(java.lang.String, int, java.lang.String); method public void setIsCompatibleWith(java.lang.String, boolean); method public void setOnHold(java.lang.String); method public void setRinging(java.lang.String); @@ -24954,7 +24954,7 @@ package android.telecomm { method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void setActive(java.lang.String); - method protected abstract void setDisconnected(java.lang.String); + method protected abstract void setDisconnected(java.lang.String, int); method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); method protected abstract void setOnHold(java.lang.String); } @@ -25120,6 +25120,50 @@ package android.telephony { field public static final android.os.Parcelable.Creator CREATOR; } + public class DisconnectCause { + method public static java.lang.String toString(int); + field public static final int BUSY = 4; // 0x4 + field public static final int CALL_BARRED = 20; // 0x14 + field public static final int CDMA_ACCESS_BLOCKED = 35; // 0x23 + field public static final int CDMA_ACCESS_FAILURE = 32; // 0x20 + field public static final int CDMA_DROP = 27; // 0x1b + field public static final int CDMA_INTERCEPT = 28; // 0x1c + field public static final int CDMA_LOCKED_UNTIL_POWER_CYCLE = 26; // 0x1a + field public static final int CDMA_NOT_EMERGENCY = 34; // 0x22 + field public static final int CDMA_PREEMPTED = 33; // 0x21 + field public static final int CDMA_REORDER = 29; // 0x1d + field public static final int CDMA_RETRY_ORDER = 31; // 0x1f + field public static final int CDMA_SO_REJECT = 30; // 0x1e + field public static final int CONGESTION = 5; // 0x5 + field public static final int CS_RESTRICTED = 22; // 0x16 + field public static final int CS_RESTRICTED_EMERGENCY = 24; // 0x18 + field public static final int CS_RESTRICTED_NORMAL = 23; // 0x17 + field public static final int ERROR_UNSPECIFIED = 36; // 0x24 + field public static final int FDN_BLOCKED = 21; // 0x15 + field public static final int ICC_ERROR = 19; // 0x13 + field public static final int INCOMING_MISSED = 1; // 0x1 + field public static final int INCOMING_REJECTED = 16; // 0x10 + field public static final int INVALID_CREDENTIALS = 10; // 0xa + field public static final int INVALID_NUMBER = 7; // 0x7 + field public static final int LIMIT_EXCEEDED = 15; // 0xf + field public static final int LOCAL = 3; // 0x3 + field public static final int LOST_SIGNAL = 14; // 0xe + field public static final int MAXIMUM_VALID_VALUE = 36; // 0x24 + field public static final int MINIMUM_VALID_VALUE = 0; // 0x0 + field public static final int MMI = 6; // 0x6 + field public static final int NORMAL = 2; // 0x2 + field public static final int NOT_DISCONNECTED = 0; // 0x0 + field public static final int NOT_VALID = -1; // 0xffffffff + field public static final int NUMBER_UNREACHABLE = 8; // 0x8 + field public static final int OUT_OF_NETWORK = 11; // 0xb + field public static final int OUT_OF_SERVICE = 18; // 0x12 + field public static final int POWER_OFF = 17; // 0x11 + field public static final int SERVER_ERROR = 12; // 0xc + field public static final int SERVER_UNREACHABLE = 9; // 0x9 + field public static final int TIMED_OUT = 13; // 0xd + field public static final int UNOBTAINABLE_NUMBER = 25; // 0x19 + } + public class NeighboringCellInfo implements android.os.Parcelable { ctor public deprecated NeighboringCellInfo(); ctor public deprecated NeighboringCellInfo(int, int); diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java index 0527a6d777b61..d5bb9893dbef8 100644 --- a/telecomm/java/android/telecomm/CallServiceAdapter.java +++ b/telecomm/java/android/telecomm/CallServiceAdapter.java @@ -133,10 +133,13 @@ public final class CallServiceAdapter { * Sets a call's state to disconnected. * * @param callId The unique ID of the call whose state is changing to disconnected. + * @param disconnectCause The reason for the disconnection, any of + * {@link android.telephony.DisconnectCause}. + * @param disconnectMessage Optional call-service-provided message about the disconnect. */ - public void setDisconnected(String callId) { + public void setDisconnected(String callId, int disconnectCause, String disconnectMessage) { try { - mAdapter.setDisconnected(callId); + mAdapter.setDisconnected(callId, disconnectCause, disconnectMessage); } catch (RemoteException e) { } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index ef15a61bd89c4..8f1add2b1e5a9 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -58,7 +58,7 @@ public abstract class InCallService extends Service { setActive((String) msg.obj); break; case MSG_SET_DISCONNECTED: - setDisconnected((String) msg.obj); + setDisconnected((String) msg.obj, msg.arg1); break; case MSG_SET_HOLD: setOnHold((String) msg.obj); @@ -93,8 +93,8 @@ public abstract class InCallService extends Service { /** {@inheritDoc} */ @Override - public void setDisconnected(String callId) { - mHandler.obtainMessage(MSG_SET_DISCONNECTED, callId).sendToTarget(); + public void setDisconnected(String callId, int disconnectCause) { + mHandler.obtainMessage(MSG_SET_DISCONNECTED, disconnectCause, 0, callId).sendToTarget(); } /** {@inheritDoc} */ @@ -149,12 +149,12 @@ public abstract class InCallService extends Service { /** * Indicates to the in-call app that a call has been moved to the * {@link CallState#DISCONNECTED} and the user should be notified. - * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both - * depending on what is ultimately needed to support all scenarios. * * @param callId The identifier of the call that was disconnected. + * @param disconnectCause The reason for the disconnection, any of + * {@link android.telephony.DisconnectCause}. */ - protected abstract void setDisconnected(String callId); + protected abstract void setDisconnected(String callId, int disconnectCause); /** * Indicates to the in-call app that a call has been moved to the diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index e96defeef9462..bbf4e8076186c 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -89,8 +89,11 @@ oneway interface ICallServiceAdapter { * Sets a call's state to disconnected. * * @param callId The unique ID of the call whose state is changing to disconnected. + * @param disconnectCause The reason for the disconnection, any of + * {@link android.telephony.DisconnectCause}. + * @param disconnectMessage The call-service-provided message about the disconnect cause. */ - void setDisconnected(String callId); + void setDisconnected(String callId, int disconnectCause, String disconnectMessage); /** * Sets a call's state to be on hold. diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index 35498a340cd70..4e902a26e073c 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -61,12 +61,12 @@ oneway interface IInCallService { /** * Indicates to the in-call app that a call has been moved to the * {@link android.telecomm.CallState#DISCONNECTED} and the user should be notified. - * TODO(santoscordon): Needs disconnect-cause either as a numberical constant, string or both - * depending on what is ultimately needed to support all scenarios. * * @param callId The identifier of the call that was disconnected. + * @param disconnectCause The reason for the disconnection, any of + * {@link android.telephony.DisconnectCause}. */ - void setDisconnected(String callId); + void setDisconnected(String callId, int disconnectCause); /** * Indicates to the in-call app that a call has been moved to the diff --git a/telephony/java/android/telephony/DisconnectCause.java b/telephony/java/android/telephony/DisconnectCause.java index 1c756585c9355..86813442e05e5 100644 --- a/telephony/java/android/telephony/DisconnectCause.java +++ b/telephony/java/android/telephony/DisconnectCause.java @@ -17,10 +17,7 @@ package android.telephony; /** - * Contains disconnect call causes generated by the - * framework and the RIL. - * - * @hide + * Contains disconnect call causes generated by the framework and the RIL. */ public class DisconnectCause { From 2f23664b4fb9527f3b4e12843926ffe2220ea559 Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Mon, 10 Mar 2014 15:33:45 -0700 Subject: [PATCH 089/102] DTMF dialing support in frameworks/base Change-Id: I86695161fab9c4fbd4a021ba69cc61ec5e585adc --- api/current.txt | 13 ++ .../java/android/telecomm/CallService.java | 37 ++++++ telecomm/java/android/telecomm/CallState.java | 16 +++ .../java/android/telecomm/InCallAdapter.java | 58 +++++++++ .../java/android/telecomm/InCallService.java | 111 +++++++++++++++++- .../android/telecomm/TelecommConstants.java | 12 ++ .../internal/telecomm/ICallService.aidl | 104 ++-------------- .../telecomm/ICallServiceAdapter.aidl | 66 +---------- .../internal/telecomm/IInCallAdapter.aidl | 58 ++------- .../internal/telecomm/IInCallService.aidl | 58 ++------- 10 files changed, 278 insertions(+), 255 deletions(-) diff --git a/api/current.txt b/api/current.txt index a48331d38879d..c90d2192dd0b1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24871,9 +24871,11 @@ package android.telecomm { method public abstract void isCompatibleWith(android.telecomm.CallInfo); method public abstract void onAudioStateChanged(java.lang.String, android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); + method public abstract void playDtmfTone(java.lang.String, char); method public abstract void reject(java.lang.String); method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); + method public abstract void stopDtmfTone(java.lang.String); method public abstract void unhold(java.lang.String); } @@ -24940,6 +24942,8 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState DIALING; enum_constant public static final android.telecomm.CallState DISCONNECTED; enum_constant public static final android.telecomm.CallState ON_HOLD; + enum_constant public static final android.telecomm.CallState POST_DIAL; + enum_constant public static final android.telecomm.CallState POST_DIAL_WAIT; enum_constant public static final android.telecomm.CallState RINGING; } @@ -24958,8 +24962,11 @@ package android.telecomm { method public void disconnectCall(java.lang.String); method public void holdCall(java.lang.String); method public void mute(boolean); + method public void playDtmfTone(java.lang.String, char); + method public void postDialContinue(java.lang.String); method public void rejectCall(java.lang.String); method public void setAudioRoute(int); + method public void stopDtmfTone(java.lang.String); method public void unholdCall(java.lang.String); } @@ -24969,9 +24976,13 @@ package android.telecomm { method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void setActive(java.lang.String); + method protected abstract void setDialing(java.lang.String); method protected abstract void setDisconnected(java.lang.String, int); method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); method protected abstract void setOnHold(java.lang.String); + method protected abstract void setPostDial(java.lang.String, java.lang.String); + method protected abstract void setPostDialWait(java.lang.String, java.lang.String); + method protected abstract void setRinging(java.lang.String); } public final class TelecommConstants { @@ -24980,6 +24991,8 @@ package android.telecomm { field public static final java.lang.String ACTION_CALL_SERVICE_PROVIDER; field public static final java.lang.String ACTION_CALL_SERVICE_SELECTOR; field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; + field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ',' + field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';' field public static final java.lang.String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 3b88be1eb5488..c34395be99069 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -57,6 +57,8 @@ public abstract class CallService extends Service { private static final int MSG_HOLD = 9; private static final int MSG_UNHOLD = 10; private static final int MSG_ON_AUDIO_STATE_CHANGED = 11; + private static final int MSG_PLAY_DTMF_TONE = 12; + private static final int MSG_STOP_DTMF_TONE = 13; /** * Default Handler used to consolidate binder method calls onto a single thread. @@ -116,6 +118,12 @@ public abstract class CallService extends Service { } break; } + case MSG_PLAY_DTMF_TONE: + playDtmfTone((String) msg.obj, (char) msg.arg1); + break; + case MSG_STOP_DTMF_TONE: + stopDtmfTone((String) msg.obj); + break; default: break; } @@ -180,6 +188,16 @@ public abstract class CallService extends Service { mMessageHandler.obtainMessage(MSG_UNHOLD, callId).sendToTarget(); } + @Override + public void playDtmfTone(String callId, char digit) { + mMessageHandler.obtainMessage(MSG_PLAY_DTMF_TONE, digit, 0, callId).sendToTarget(); + } + + @Override + public void stopDtmfTone(String callId) { + mMessageHandler.obtainMessage(MSG_STOP_DTMF_TONE, callId).sendToTarget(); + } + @Override public void onAudioStateChanged(String callId, CallAudioState audioState) { SomeArgs args = SomeArgs.obtain(); @@ -306,6 +324,25 @@ public abstract class CallService extends Service { */ public abstract void unhold(String callId); + /** + * Plays a dual-tone multi-frequency signaling (DTMF) tone in a call. + * + * @param callId The unique ID of the call in which the tone will be played. + * @param digit A character representing the DTMF digit for which to play the tone. This + * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. + */ + public abstract void playDtmfTone(String callId, char digit); + + /** + * Stops any dual-tone multi-frequency sinaling (DTMF) tone currently playing. + * + * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is + * currently playing, this method will do nothing. + * + * @param callId The unique ID of the call in which any currently playing tone will be stopped. + */ + public abstract void stopDtmfTone(String callId); + /** * Called when the audio state changes. * diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index 3937b08844ce3..fd611cc0cc9b4 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -48,6 +48,22 @@ public enum CallState { */ RINGING, + /** + * Indicates that the call is active but in a "post-dial" state where Telecomm is now sending + * some dual-tone multi-frequency signaling (DTMF) tones appended to the dialed number. Normal + * transitions are to {@link #POST_DIAL_WAIT} when the post-dial string requires user + * confirmation to proceed, {@link #ACTIVE} when the post-dial tones are completed, or + * {@link #DISCONNECTED}. + */ + POST_DIAL, + + /** + * Indicates that the call was in the {@link #POST_DIAL} state but is now waiting for user + * confirmation before the remaining digits can be sent. Normal transitions are to + * {@link #POST_DIAL} when the user asks Telecomm to proceed with the post-dial sequence. + */ + POST_DIAL_WAIT, + /** * Indicates that a call is currently connected to another party and a communication channel is * open between them. The normal transition to this state is by the user answering a diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java index 0a8571aa86508..4f32458b04edf 100644 --- a/telecomm/java/android/telecomm/InCallAdapter.java +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -126,4 +126,62 @@ public final class InCallAdapter { } catch (RemoteException e) { } } + + /** + * Instructs Telecomm to play a dual-tone multi-frequency signaling (DTMF) tone in a call. + * + * Any other currently playing DTMF tone in the specified call is immediately stopped. + * + * @param callId The unique ID of the call in which the tone will be played. + * @param digit A character representing the DTMF digit for which to play the tone. This + * value must be one of {@code '0'} through {@code '9'}, {@code '*'} or {@code '#'}. + */ + public void playDtmfTone(String callId, char digit) { + try { + mAdapter.playDtmfTone(callId, digit); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecomm to stop any dual-tone multi-frequency signaling (DTMF) tone currently + * playing. + * + * DTMF tones are played by calling {@link #playDtmfTone(String,char)}. If no DTMF tone is + * currently playing, this method will do nothing. + * + * @param callId The unique ID of the call in which any currently playing tone will be stopped. + */ + public void stopDtmfTone(String callId) { + try { + mAdapter.stopDtmfTone(callId); + } catch (RemoteException e) { + } + } + + /** + * Instructs Telecomm to continue playing a post-dial DTMF string. + * + * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, + * that are immediately sent as DTMF tones to the recipient as soon as the connection is made. + * While these tones are playing, Telecomm will notify the {@link InCallService} that the call + * is in the {@link InCallService#setPostDial(String)} state. + * + * If the DTMF string contains a {@link #DTMF_CHARACTER_PAUSE} symbol, Telecomm will temporarily + * pause playing the tones for a pre-defined period of time. + * + * If the DTMF string contains a {@link #DTMF_CHARACTER_WAIT} symbol, Telecomm will pause + * playing the tones and notify the {@link InCallService} that the call is in the + * {@link InCallService#setPostDialWait(String)} state. When the user decides to continue the + * postdial sequence, the {@link InCallService} should invoke the + * {@link #postDialContinue(String)} method. + * + * @param callId The unique ID of the call for which postdial string playing should continue. + */ + public void postDialContinue(String callId) { + try { + mAdapter.postDialContinue(callId); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 8f1add2b1e5a9..8131815d98c70 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -23,6 +23,7 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; +import com.android.internal.os.SomeArgs; import com.android.internal.telecomm.IInCallAdapter; import com.android.internal.telecomm.IInCallService; @@ -41,6 +42,10 @@ public abstract class InCallService extends Service { private static final int MSG_SET_DISCONNECTED = 4; private static final int MSG_SET_HOLD = 5; private static final int MSG_ON_AUDIO_STATE_CHANGED = 6; + private static final int MSG_SET_DIALING = 7; + private static final int MSG_SET_RINGING = 8; + private static final int MSG_SET_POST_DIAL = 9; + private static final int MSG_SET_POST_DIAL_WAIT = 10; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -57,6 +62,34 @@ public abstract class InCallService extends Service { case MSG_SET_ACTIVE: setActive((String) msg.obj); break; + case MSG_SET_DIALING: + setDialing((String) msg.obj); + break; + case MSG_SET_RINGING: + setRinging((String) msg.obj); + break; + case MSG_SET_POST_DIAL: { + SomeArgs args = (SomeArgs) msg.obj; + try { + String callId = (String) args.arg1; + String remaining = (String) args.arg2; + setPostDial(callId, remaining); + } finally { + args.recycle(); + } + break; + } + case MSG_SET_POST_DIAL_WAIT: { + SomeArgs args = (SomeArgs) msg.obj; + try { + String callId = (String) args.arg1; + String remaining = (String) args.arg2; + setPostDialWait(callId, remaining); + } finally { + args.recycle(); + } + break; + } case MSG_SET_DISCONNECTED: setDisconnected((String) msg.obj, msg.arg1); break; @@ -108,6 +141,32 @@ public abstract class InCallService extends Service { public void onAudioStateChanged(CallAudioState audioState) { mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget(); } + + @Override + public void setDialing(String callId) { + mHandler.obtainMessage(MSG_SET_DIALING, callId).sendToTarget(); + } + + @Override + public void setRinging(String callId) { + mHandler.obtainMessage(MSG_SET_RINGING, callId).sendToTarget(); + } + + @Override + public void setPostDial(String callId, String remaining) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = remaining; + mHandler.obtainMessage(MSG_SET_POST_DIAL, args).sendToTarget(); + } + + @Override + public void setPostDialWait(String callId, String remaining) { + SomeArgs args = SomeArgs.obtain(); + args.arg1 = callId; + args.arg2 = remaining; + mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget(); + } } private final InCallServiceBinder mBinder; @@ -140,12 +199,35 @@ public abstract class InCallService extends Service { protected abstract void addCall(CallInfo callInfo); /** - * Indicates to the in-call app that a call has moved to the {@link CallState#ACTIVE} state. + * Indicates to the in-call app that the specified call is currently connected to another party + * and a communication channel is open between them. Normal transitions are to + * {@link #setDisconnected(String)} when the call is complete. * - * @param callId The identifier of the call that became active. + * @param callId The identifier of the call changing state. */ protected abstract void setActive(String callId); + /** + * Indicates to the in-call app that the specified call is outgoing and in the dialing state. + * Normal transition are to {@link #setActive(String)} if the call was answered, + * {@link #setPostDial(String,String)} if the dialed number includes a post-dial DTMF string, or + * {@link #setDisconnected(String)} if the call was disconnected immediately. + * + * @param callId The identifier of the call changing state. + */ + protected abstract void setDialing(String callId); + + /** + * Indicates to the in-call app that the specified call is incoming and the user still has the + * option of answering, rejecting, or doing nothing with the call. This state is usually + * associated with some type of audible ringtone. Normal transitions are to + * {@link #setActive(String)} if the call is answered, or {@link #setDisconnected(String)} if + * the call is not answered or is otherwise disconnected for some reason. + * + * @param callId The identifier of the call changing state. + */ + protected abstract void setRinging(String callId); + /** * Indicates to the in-call app that a call has been moved to the * {@link CallState#DISCONNECTED} and the user should be notified. @@ -170,4 +252,29 @@ public abstract class InCallService extends Service { * @param audioState The new {@link CallAudioState}. */ protected abstract void onAudioStateChanged(CallAudioState audioState); + + /** + * Indicates to the in-call app that the specified call is active but in a "post-dial" state + * where Telecomm is now sending some dual-tone multi-frequency signaling (DTMF) tones appended + * to the dialed number. Normal transitions are to {@link #setPostDialWait(String,String)} when + * the post-dial string requires user confirmation to proceed, {@link #setActive(String)} when + * the post-dial tones are completed, or {@link #setDisconnected(String)} if the call is + * disconnected. + * + * @param callId The identifier of the call changing state. + * @param remaining The remaining postdial string to be dialed. + */ + protected abstract void setPostDial(String callId, String remaining); + + /** + * Indicates to the in-call app that the specified call was in the + * {@link #setPostDial(String,String)} state but is now waiting for user confirmation before the + * remaining digits can be sent. Normal transitions are to {@link #setPostDial(String,String)} + * when the user asks Telecomm to proceed with the post-dial sequence and the in-call app + * informs Telecomm of this by invoking {@link IInCallAdapter#postDialContinue(String)}. + * + * @param callId The identifier of the call changing state. + * @param remaining The remaining postdial string to be dialed. + */ + protected abstract void setPostDialWait(String callId, String remaining); } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index 4269424f1f241..c2cccf1250c15 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -74,4 +74,16 @@ public final class TelecommConstants { * ID of the call. */ public static final String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; + + /** + * The dual tone multi-frequency signaling character sent to indicate the dialing system should + * pause for a predefined period. + */ + public static final char DTMF_CHARACTER_PAUSE = ','; + + /** + * The dual-tone multi-frequency signaling character sent to indicate the dialing system should + * wait for user confirmation before proceeding. + */ + public static final char DTMF_CHARACTER_WAIT = ';'; } diff --git a/telecomm/java/com/android/internal/telecomm/ICallService.aidl b/telecomm/java/com/android/internal/telecomm/ICallService.aidl index 3455efd2ce3b1..cc0641ca8865d 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallService.aidl @@ -23,126 +23,36 @@ import android.telecomm.CallInfo; import com.android.internal.telecomm.ICallServiceAdapter; /** - * Service interface for services which would like to provide calls to be - * managed by the system in-call UI. + * Internal remote interface for call services. * - * This interface provides methods that the android framework can use to deliver commands - * for calls provided by this call service including making new calls and disconnecting - * existing ones. A binding to ICallService implementations exists for two conditions: - * 1) There exists one or more live calls for that call service, - * 2) Prior to an outbound call to test if this call service is compatible with the outgoing call. + * @see android.telecomm.CallService * - * TODO(santoscordon): Need final public-facing comments in this file. - * {@hide} + * @hide */ oneway interface ICallService { - - /** - * Sets an implementation of ICallServiceAdapter which the call service can use to add new calls - * and communicate state changes of existing calls. This is the first method that is called - * after the framework binds to the call service. - * - * @param callServiceAdapter Interface to CallsManager for adding and updating calls. - */ void setCallServiceAdapter(in ICallServiceAdapter callServiceAdapter); - /** - * Determines if the ICallService can place the specified call. Response is sent via - * {@link ICallServiceAdapter#setCompatibleWith}. When responding, the correct call ID must be - * specified. It is expected that the call service respond within 500 milliseconds. Any response - * that takes longer than 500 milliseconds will be treated as being incompatible. - * TODO(santoscordon): 500 ms was arbitrarily chosen and must be confirmed before this - * API is made public. Only used in the context of outgoing calls and call switching (handoff). - * - * @param callInfo The details of the relevant call. - */ void isCompatibleWith(in CallInfo callInfo); - /** - * Attempts to call the relevant party using the specified call's handle, be it a phone number, - * SIP address, or some other kind of user ID. Note that the set of handle types is - * dynamically extensible since call providers should be able to implement arbitrary - * handle-calling systems. See {@link #isCompatibleWith}. It is expected that the - * call service respond via {@link ICallServiceAdapter#handleSuccessfulOutgoingCall} if it can - * successfully make the call. Only used in the context of outgoing calls. - * TODO(santoscordon): Figure out how a call service can short-circuit a failure to the adapter. - * - * @param callInfo The details of the relevant call. - */ void call(in CallInfo callInfo); - /** - * Aborts the outgoing call attempt. Invoked in the unlikely event that Telecomm decides to - * abort an attempt to place a call. Only ever be invoked after {@link #call} invocations. - * After this is invoked, Telecomm does not expect any more updates about the call and will - * actively ignore any such update. This is different from {@link #disconnect} where Telecomm - * expects confirmation via ICallServiceAdapter.markCallAsDisconnected. - * - * @param callId The identifier of the call to abort. - */ void abort(String callId); - /** - * Receives a new call ID to use with an incoming call. Invoked by Telecomm after it is notified - * that this call service has a pending incoming call, see - * {@link TelecommConstants#ACTION_INCOMING_CALL}. The call service must first give Telecomm - * additional information of the call through {@link ICallServiceAdapter#handleIncomingCall}. - * Following that, the call service can update the call at will using the specified call ID. - * - * As part of the {@link TelecommConstants#ACTION_INCOMING_CALL} Intent, a Bundle of extra - * data could be sent via {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}, which is - * returned through this method. If no data was given, an empty Bundle will be returned. - * - * @param callId The ID of the call. - * @param extras The Bundle of extra information passed via - * {@link TelecommConstants#EXTRA_INCOMING_CALL_EXTRAS}. - */ void setIncomingCallId(String callId, in Bundle extras); - /** - * Answers a ringing call identified by callId. Telecomm invokes this method as a result of the - * user hitting the "answer" button in the incoming call screen. - * - * @param callId The ID of the call. - */ void answer(String callId); - /** - * Rejects a ringing call identified by callId. Telecomm invokes this method as a result of the - * user hitting the "reject" button in the incoming call screen. - * - * @param callId The ID of the call. - */ void reject(String callId); - /** - * Disconnects the call identified by callId. Used for outgoing and incoming calls. - * - * @param callId The identifier of the call to disconnect. - */ void disconnect(String callId); - /** - * Puts the call identified by callId on hold. Telecomm invokes this method when a call should - * be placed on hold per user request or because a different call was made active. - * - * @param callId The identifier of the call to put on hold. - */ void hold(String callId); - /** - * Removes the call identified by callId from hold. Telecomm invokes this method when a call - * should be removed on hold per user request or because a different call was put on hold. - * - * @param callId The identifier of the call to remove from hold. - */ void unhold(String callId); - /** - * Called when the audio state changes. - * - * @param activeCallId The identifier of the call that was active during the state change. - * @param audioState The new {@link CallAudioState}. - */ void onAudioStateChanged(String activeCallId, in CallAudioState audioState); + + void playDtmfTone(String callId, char digit); + + void stopDtmfTone(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl index bbf4e8076186c..dfdaa75a3686f 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl @@ -19,86 +19,28 @@ package com.android.internal.telecomm; import android.telecomm.CallInfo; /** - * Provides methods for ICallService implementations to interact with the system phone app. - * TODO(santoscordon): Need final public-facing comments in this file. + * Internal remote callback interface for call services. + * + * @see android.telecomm.CallServiceAdapter + * * {@hide} */ oneway interface ICallServiceAdapter { - - /** - * Receives confirmation of a call service's ability to place a call. This method is used in - * response to {@link ICallService#isCompatibleWith}. - * - * @param callId The identifier of the call for which compatibility is being received. This ID - * should correspond to the ID given as part of the call information in - * {@link ICallService#isCompatibleWith}. - * @param isCompatible True if the call service can place the call. - */ void setIsCompatibleWith(String callId, boolean isCompatible); - /** - * Provides Telecomm with the details of an incoming call. An invocation of this method must - * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon - * the invocation of this method, Telecomm will bring up the incoming-call interface where the - * user can elect to answer or reject a call. - * - * @param callInfo The details of the relevant call. - */ void notifyIncomingCall(in CallInfo callInfo); - /** - * Tells Telecomm that an attempt to place the specified outgoing call succeeded. - * TODO(santoscordon): Consider adding a CallState parameter in case this outgoing call is - * somehow no longer in the DIALING state. - * - * @param callId The ID of the outgoing call. - */ void handleSuccessfulOutgoingCall(String callId); - /** - * Tells Telecomm that an attempt to place the specified outgoing call failed. - * - * @param callId The ID of the outgoing call. - * @param errorMessage The error associated with the failed call attempt. - */ void handleFailedOutgoingCall(String callId, String errorMessage); - /** - * Sets a call's state to active (e.g., an ongoing call where two parties can actively - * communicate). - * - * @param callId The unique ID of the call whose state is changing to active. - */ void setActive(String callId); - /** - * Sets a call's state to ringing (e.g., an inbound ringing call). - * - * @param callId The unique ID of the call whose state is changing to ringing. - */ void setRinging(String callId); - /** - * Sets a call's state to dialing (e.g., dialing an outbound call). - * - * @param callId The unique ID of the call whose state is changing to dialing. - */ void setDialing(String callId); - /** - * Sets a call's state to disconnected. - * - * @param callId The unique ID of the call whose state is changing to disconnected. - * @param disconnectCause The reason for the disconnection, any of - * {@link android.telephony.DisconnectCause}. - * @param disconnectMessage The call-service-provided message about the disconnect cause. - */ void setDisconnected(String callId, int disconnectCause, String disconnectMessage); - /** - * Sets a call's state to be on hold. - * - * @param callId The unique ID of the call whose state is changing to be on hold. - */ void setOnHold(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl index 0fe3bfceea696..e0cdb83be4f6e 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl @@ -19,68 +19,30 @@ package com.android.internal.telecomm; import android.telecomm.CallAudioState; /** - * Receives commands from {@link IInCallService} implementations which should be executed by - * Telecomm. When Telecomm binds to a {@link IInCallService}, an instance of this class is given to - * the in-call service through which it can manipulate live (active, dialing, ringing) calls. When - * the in-call service is notified of new calls ({@link IInCallService#addCall}), it can use the - * given call IDs to execute commands such as {@link #answerCall} for incoming calls or - * {@link #disconnectCall} for active calls the user would like to end. Some commands are only - * appropriate for calls in certain states; please consult each method for such limitations. - * TODO(santoscordon): Needs more/better comments once the API is finalized. - * TODO(santoscordon): Specify the adapter will stop functioning when there are no more calls. - * TODO(santoscordon): Once we have proper "CallState" constant definitions, consider rewording - * the javadoc to reference those states precisely. + * Internal remote callback interface for in-call services. + * + * @see android.telecomm.InCallAdapter + * * {@hide} */ oneway interface IInCallAdapter { - /** - * Instructs Telecomm to answer the specified call. - * - * @param callId The identifier of the call to answer. - */ void answerCall(String callId); - /** - * Instructs Telecomm to reject the specified call. - * TODO(santoscordon): Add reject-with-text-message parameter when that feature - * is ported over. - * - * @param callId The identifier of the call to reject. - */ void rejectCall(String callId); - /** - * Instructs Telecomm to disconnect the specified call. - * - * @param callId The identifier of the call to disconnect. - */ void disconnectCall(String callId); - /** - * Instructs Telecomm to put the specified call on hold. - * - * @param callId The identifier of the call to put on hold. - */ void holdCall(String callId); - /** - * Instructs Telecomm to release the specified call from hold. - * - * @param callId The identifier of the call to release from hold. - */ void unholdCall(String callId); - /** - * Mute the microphone. - * - * @param shouldMute True if the microphone should be muted. - */ void mute(boolean shouldMute); - /** - * Sets the audio route (speaker, bluetooth, etc...). See {@link CallAudioState}. - * - * @param route The audio route to use. - */ void setAudioRoute(int route); + + void playDtmfTone(String callId, char digit); + + void stopDtmfTone(String callId); + + void postDialContinue(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index 4e902a26e073c..f5847df1d0eb0 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -22,64 +22,30 @@ import android.telecomm.CallInfo; import com.android.internal.telecomm.IInCallAdapter; /** - * This service is implemented by any app that wishes to provide the user-interface for managing - * phone calls. Telecomm binds to this service while there exists a live (active or incoming) - * call, and uses it to notify the in-call app of any live and and recently disconnected calls. - * TODO(santoscordon): Needs more/better description of lifecycle once the interface is better - * defined. - * TODO(santoscordon): What happens if two or more apps on a given device implement this interface? + * Internal remote interface for in-call services. + * + * @see android.telecomm.InCallService + * * {@hide} */ oneway interface IInCallService { - - /** - * Provides the in-call app an adapter object through which to send call-commands such as - * answering and rejecting incoming calls, disconnecting active calls, and putting calls in - * special states (mute, hold, etc). - * - * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. - */ void setInCallAdapter(in IInCallAdapter inCallAdapter); - /** - * Indicates to the in-call app that a new call has been created and an appropriate - * user-interface should be built and shown to notify the user. Information about the call - * including its current state is passed in through the callInfo object. - * - * @param callInfo Information about the new call. - */ void addCall(in CallInfo callInfo); - /** - * Indicates to the in-call app that a call has moved to the - * {@link android.telecomm.CallState#ACTIVE} state. - * - * @param callId The identifier of the call that became active. - */ void setActive(String callId); - /** - * Indicates to the in-call app that a call has been moved to the - * {@link android.telecomm.CallState#DISCONNECTED} and the user should be notified. - * - * @param callId The identifier of the call that was disconnected. - * @param disconnectCause The reason for the disconnection, any of - * {@link android.telephony.DisconnectCause}. - */ void setDisconnected(String callId, int disconnectCause); - /** - * Indicates to the in-call app that a call has been moved to the - * {@link android.telecomm.CallState#HOLD} state and the user should be notified. - * - * @param callId The identifier of the call that was put on hold. - */ + void setDialing(in String callId); + void setOnHold(String callId); - /** - * Called when the audio state changes. - * - * @param audioState The new {@link CallAudioState}. - */ void onAudioStateChanged(in CallAudioState audioState); + + void setRinging(String callId); + + void setPostDial(String callId, String remaining); + + void setPostDialWait(String callId, String remaining); } From 8acdbb8b11315f9b619d8831ef6113ea52ffbdbe Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Tue, 1 Apr 2014 13:50:07 -0700 Subject: [PATCH 090/102] Fix the build Fix some broken javadocs which are breaking the SDK build. Change-Id: I9b432ad1e871a82391c12ddbbd34cb64a556b2fe --- telecomm/java/android/telecomm/InCallAdapter.java | 14 +++++++------- telecomm/java/android/telecomm/InCallService.java | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java index 4f32458b04edf..2933f1780e8b4 100644 --- a/telecomm/java/android/telecomm/InCallAdapter.java +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -165,15 +165,15 @@ public final class InCallAdapter { * A post-dial DTMF string is a string of digits entered after a phone number, when dialed, * that are immediately sent as DTMF tones to the recipient as soon as the connection is made. * While these tones are playing, Telecomm will notify the {@link InCallService} that the call - * is in the {@link InCallService#setPostDial(String)} state. + * is in the {@link InCallService#setPostDial(String,String)} state. * - * If the DTMF string contains a {@link #DTMF_CHARACTER_PAUSE} symbol, Telecomm will temporarily - * pause playing the tones for a pre-defined period of time. + * If the DTMF string contains a {@link TelecommConstants#DTMF_CHARACTER_PAUSE} symbol, Telecomm + * will temporarily pause playing the tones for a pre-defined period of time. * - * If the DTMF string contains a {@link #DTMF_CHARACTER_WAIT} symbol, Telecomm will pause - * playing the tones and notify the {@link InCallService} that the call is in the - * {@link InCallService#setPostDialWait(String)} state. When the user decides to continue the - * postdial sequence, the {@link InCallService} should invoke the + * If the DTMF string contains a {@link TelecommConstants#DTMF_CHARACTER_WAIT} symbol, Telecomm + * will pause playing the tones and notify the {@link InCallService} that the call is in the + * {@link InCallService#setPostDialWait(String,String)} state. When the user decides to continue + * the postdial sequence, the {@link InCallService} should invoke the * {@link #postDialContinue(String)} method. * * @param callId The unique ID of the call for which postdial string playing should continue. diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 8131815d98c70..1d57ae96d2364 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -201,7 +201,7 @@ public abstract class InCallService extends Service { /** * Indicates to the in-call app that the specified call is currently connected to another party * and a communication channel is open between them. Normal transitions are to - * {@link #setDisconnected(String)} when the call is complete. + * {@link #setDisconnected(String,int)} when the call is complete. * * @param callId The identifier of the call changing state. */ @@ -211,7 +211,7 @@ public abstract class InCallService extends Service { * Indicates to the in-call app that the specified call is outgoing and in the dialing state. * Normal transition are to {@link #setActive(String)} if the call was answered, * {@link #setPostDial(String,String)} if the dialed number includes a post-dial DTMF string, or - * {@link #setDisconnected(String)} if the call was disconnected immediately. + * {@link #setDisconnected(String,int)} if the call was disconnected immediately. * * @param callId The identifier of the call changing state. */ @@ -221,8 +221,8 @@ public abstract class InCallService extends Service { * Indicates to the in-call app that the specified call is incoming and the user still has the * option of answering, rejecting, or doing nothing with the call. This state is usually * associated with some type of audible ringtone. Normal transitions are to - * {@link #setActive(String)} if the call is answered, or {@link #setDisconnected(String)} if - * the call is not answered or is otherwise disconnected for some reason. + * {@link #setActive(String)} if the call is answered, or {@link #setDisconnected(String,int)} + * if the call is not answered or is otherwise disconnected for some reason. * * @param callId The identifier of the call changing state. */ @@ -258,7 +258,7 @@ public abstract class InCallService extends Service { * where Telecomm is now sending some dual-tone multi-frequency signaling (DTMF) tones appended * to the dialed number. Normal transitions are to {@link #setPostDialWait(String,String)} when * the post-dial string requires user confirmation to proceed, {@link #setActive(String)} when - * the post-dial tones are completed, or {@link #setDisconnected(String)} if the call is + * the post-dial tones are completed, or {@link #setDisconnected(String,int)} if the call is * disconnected. * * @param callId The identifier of the call changing state. From fd2e620baf769564d9b2873103de7f60a39f95ea Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Tue, 1 Apr 2014 14:09:49 -0700 Subject: [PATCH 091/102] Fix the build, take #2 Missed one bad javadoc. Change-Id: Ic70abce0404e966bc9caeabfbd5fd40d170af4de --- telecomm/java/android/telecomm/InCallService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 1d57ae96d2364..3942d70b84233 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -271,7 +271,7 @@ public abstract class InCallService extends Service { * {@link #setPostDial(String,String)} state but is now waiting for user confirmation before the * remaining digits can be sent. Normal transitions are to {@link #setPostDial(String,String)} * when the user asks Telecomm to proceed with the post-dial sequence and the in-call app - * informs Telecomm of this by invoking {@link IInCallAdapter#postDialContinue(String)}. + * informs Telecomm of this by invoking {@link InCallAdapter#postDialContinue(String)}. * * @param callId The identifier of the call changing state. * @param remaining The remaining postdial string to be dialed. From f6e9b27f93ef2d0b806e8b24d3082234ae222d33 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 1 Apr 2014 14:23:09 -0700 Subject: [PATCH 092/102] Add CallCapabilities and CallNumberPresentation Bug: 13643568 Change-Id: I453a1b0db0edf31b26be64b4dcbabec58a4f96f5 --- api/current.txt | 23 +++++++++ .../android/telecomm/CallCapabilities.java | 50 +++++++++++++++++++ .../telecomm/CallNumberPresentation.java | 32 ++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 telecomm/java/android/telecomm/CallCapabilities.java create mode 100644 telecomm/java/android/telecomm/CallNumberPresentation.java diff --git a/api/current.txt b/api/current.txt index c90d2192dd0b1..e9bd376ba382a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24848,6 +24848,20 @@ package android.telecomm { field public final int supportedRouteMask; } + public class CallCapabilities { + ctor public CallCapabilities(); + field public static final int ADD_CALL = 16; // 0x10 + field public static final int ALL = 511; // 0x1ff + field public static final int CONNECTION_HANDOFF = 256; // 0x100 + field public static final int GENERIC_CONFERENCE = 128; // 0x80 + field public static final int HOLD = 1; // 0x1 + field public static final int MERGE_CALLS = 4; // 0x4 + field public static final int MUTE = 64; // 0x40 + field public static final int RESPOND_VIA_TEXT = 32; // 0x20 + field public static final int SUPPORT_HOLD = 2; // 0x2 + field public static final int SWAP_CALLS = 8; // 0x8 + } + public final class CallInfo implements android.os.Parcelable { ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri); method public int describeContents(); @@ -24860,6 +24874,15 @@ package android.telecomm { field public static final android.os.Parcelable.Creator CREATOR; } + public final class CallNumberPresentation extends java.lang.Enum { + method public static android.telecomm.CallNumberPresentation valueOf(java.lang.String); + method public static final android.telecomm.CallNumberPresentation[] values(); + enum_constant public static final android.telecomm.CallNumberPresentation ALLOWED; + enum_constant public static final android.telecomm.CallNumberPresentation PAYPHONE; + enum_constant public static final android.telecomm.CallNumberPresentation RESTRICTED; + enum_constant public static final android.telecomm.CallNumberPresentation UNKNOWN; + } + public abstract class CallService extends android.app.Service { ctor public CallService(); method public abstract void abort(java.lang.String); diff --git a/telecomm/java/android/telecomm/CallCapabilities.java b/telecomm/java/android/telecomm/CallCapabilities.java new file mode 100644 index 0000000000000..b2b33a34393fe --- /dev/null +++ b/telecomm/java/android/telecomm/CallCapabilities.java @@ -0,0 +1,50 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** Defines actions a call currently supports. */ +public class CallCapabilities { + /** Call can currently be put on hold or unheld. */ + public static final int HOLD = 0x00000001; + + /** Call supports the hold feature. */ + public static final int SUPPORT_HOLD = 0x00000002; + + /** Call can currently be merged. */ + public static final int MERGE_CALLS = 0x00000004; + + /* Call can currently be swapped with another call. */ + public static final int SWAP_CALLS = 0x00000008; + + /* Call currently supports adding another call to this one. */ + public static final int ADD_CALL = 0x00000010; + + /* Call supports responding via text option. */ + public static final int RESPOND_VIA_TEXT = 0x00000020; + + /* Call can be muted. */ + public static final int MUTE = 0x00000040; + + /* Call supports generic conference mode. */ + public static final int GENERIC_CONFERENCE = 0x00000080; + + /* Call currently supports switch between connections. */ + public static final int CONNECTION_HANDOFF = 0x00000100; + + public static final int ALL = HOLD | SUPPORT_HOLD | MERGE_CALLS | SWAP_CALLS | ADD_CALL + | RESPOND_VIA_TEXT | MUTE | GENERIC_CONFERENCE | CONNECTION_HANDOFF; +} diff --git a/telecomm/java/android/telecomm/CallNumberPresentation.java b/telecomm/java/android/telecomm/CallNumberPresentation.java new file mode 100644 index 0000000000000..6cd22f85d010b --- /dev/null +++ b/telecomm/java/android/telecomm/CallNumberPresentation.java @@ -0,0 +1,32 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +/** Defines how numbers are displayed in caller id. */ +public enum CallNumberPresentation { + /** Number is displayed normally. */ + ALLOWED, + + /** Number was blocked. */ + RESTRICTED, + + /** Presentation was not specified or is unknown. */ + UNKNOWN, + + /** Number should be displayed as a pay phone. */ + PAYPHONE +} From 8d20561554e159f31a30075c23cfeb6d477aa27e Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 1 Apr 2014 20:09:57 -0700 Subject: [PATCH 093/102] Add CallServiceSelectorAdapter Previously the selector would communicate with Telecomm using callbacks. For handoff, it's easier to communicate using an adapter. Bug: 13643568 Change-Id: Ida5859a3b5b15c9fa1c533f27a3e14fd0d7c36af --- Android.mk | 3 +- api/current.txt | 13 +- .../android/telecomm/CallServiceSelector.java | 157 ++++-------------- .../telecomm/CallServiceSelectorAdapter.java | 72 ++++++++ .../telecomm/ICallServiceLookupResponse.aidl | 14 +- .../telecomm/ICallServiceProvider.aidl | 24 +-- .../telecomm/ICallServiceSelector.aidl | 65 +------- ....aidl => ICallServiceSelectorAdapter.aidl} | 27 +-- .../telecomm/ICallSwitchabilityResponse.aidl | 36 ---- 9 files changed, 136 insertions(+), 275 deletions(-) create mode 100644 telecomm/java/android/telecomm/CallServiceSelectorAdapter.java rename telecomm/java/com/android/internal/telecomm/{ICallServiceSelectionResponse.aidl => ICallServiceSelectorAdapter.aidl} (58%) delete mode 100644 telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl diff --git a/Android.mk b/Android.mk index 798df3d93f77c..2bc026e1e198c 100644 --- a/Android.mk +++ b/Android.mk @@ -289,9 +289,8 @@ LOCAL_SRC_FILES += \ telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl \ telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl \ telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl \ - telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl \ telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl \ - telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl \ + telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \ telecomm/java/com/android/internal/telecomm/IInCallService.aidl \ telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \ diff --git a/api/current.txt b/api/current.txt index e9bd376ba382a..b56ca0bc7f4ce 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24945,17 +24945,14 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); - method protected abstract void isSwitchable(android.telecomm.CallInfo, android.telecomm.CallServiceSelector.CallSwitchabilityResponse); method public final android.os.IBinder onBind(android.content.Intent); - method protected abstract void select(android.telecomm.CallInfo, java.util.List, android.telecomm.CallServiceSelector.CallServiceSelectionResponse); + method protected abstract void select(android.telecomm.CallInfo, java.util.List); + method protected abstract void setCallServiceSelectorAdapter(android.telecomm.CallServiceSelectorAdapter); } - public static abstract interface CallServiceSelector.CallServiceSelectionResponse { - method public abstract void setSelectedCallServices(java.util.List); - } - - public static abstract interface CallServiceSelector.CallSwitchabilityResponse { - method public abstract void setSwitchable(boolean); + public final class CallServiceSelectorAdapter { + method public void setHandoffInfo(java.lang.String, android.net.Uri, android.os.Bundle); + method public void setSelectedCallServices(java.lang.String, java.util.List); } public final class CallState extends java.lang.Enum { diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 44181d163692b..8eec1427ac63d 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -23,145 +23,58 @@ import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.RemoteException; -import android.util.Log; import com.android.internal.os.SomeArgs; import com.android.internal.telecomm.ICallServiceSelector; -import com.android.internal.telecomm.ICallServiceSelectionResponse; -import com.android.internal.telecomm.ICallSwitchabilityResponse; +import com.android.internal.telecomm.ICallServiceSelectorAdapter; import java.util.List; /** * Allows for the organization of {@link CallService}s for outbound calls. Given a call and list of * {@link CallService} IDs, order the list in terms of priority and return it using - * {@link #select(CallInfo, List, CallServiceSelectionResponse)}.
- *
- * Also determine whether a call is switchable (can be moved between {@link CallService}s) or not - * using {@link #isSwitchable(CallInfo, CallSwitchabilityResponse)}. + * {@link #select(CallInfo, List)}. */ public abstract class CallServiceSelector extends Service { - private static final String TAG = CallServiceSelector.class.getSimpleName(); - - /** - * Used to tell {@link #mHandler} to move the call to - * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)} to the main - * thread. - */ - private static final int MSG_IS_SWITCHABLE = 1; - - /** - * Used to tell {@link #mHandler} to move the call to - * {@link #select(CallInfo, List, CallServiceSelectionResponse)} to the main thread. - */ - private static final int MSG_SELECT_CALL_SERVICES = 2; - - /** - * Listens for responses from the {@link CallServiceSelector} and passes them back through the - * Binder interface. This must be called from - * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}. - */ - public interface CallSwitchabilityResponse { - /** - * Mark a call as switchable (or not). This must be called by - * {@link CallServiceSelector#isSwitchable(CallInfo, CallSwitchabilityResponse)}. - * - * @param isSwitchable Whether the call was switchable or not. - */ - void setSwitchable(boolean isSwitchable); - } - - /** - * Listens for responses from the {@link CallServiceSelector} and passes them back through the - * Binder interface. This must be called from - * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}. - */ - public interface CallServiceSelectionResponse { - /** - * Sets the prioritized {@link CallServiceDescriptor}s for the given {@link CallInfo}. This - * must be called by - * {@link CallServiceSelector#select(CallInfo, List, CallServiceSelectionResponse)}. - * - * @param callServices The prioritized {@link CallServiceDescriptor}s. - */ - void setSelectedCallServices(List callServices); - } + private static final int MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER = 0; + private static final int MSG_SELECT = 1; /** Handler to move client-bound method calls to the main thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { - @SuppressWarnings("unchecked") @Override public void handleMessage(Message msg) { - final SomeArgs args = (SomeArgs) msg.obj; - try { - switch (msg.what) { - case MSG_IS_SWITCHABLE: - isSwitchable((CallInfo) args.arg1, (CallSwitchabilityResponse) args.arg2); - break; - case MSG_SELECT_CALL_SERVICES: - select((CallInfo) args.arg1, (List) args.arg2, - (CallServiceSelectionResponse) args.arg3); - break; - } - } finally { - if (args != null) { - args.recycle(); - } + switch (msg.what) { + case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER: + CallServiceSelectorAdapter adapter = new CallServiceSelectorAdapter( + (ICallServiceSelectorAdapter) msg.obj); + setCallServiceSelectorAdapter(adapter); + break; + case MSG_SELECT: + SomeArgs args = (SomeArgs) msg.obj; + try { + select((CallInfo) args.arg1, (List) args.arg2); + } finally { + args.recycle(); + } + break; } } }; /** Manages the binder calls so that the implementor does not need to deal with it. */ - private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub - implements CallSwitchabilityResponse, CallServiceSelectionResponse { - private ICallSwitchabilityResponse mSwitchabilityResponse; - private ICallServiceSelectionResponse mSelectionResponse; - + private final class CallServiceSelectorBinder extends ICallServiceSelector.Stub { @Override - public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response) - throws RemoteException { - mSwitchabilityResponse = response; - SomeArgs args = SomeArgs.obtain(); - args.arg1 = callInfo; - args.arg2 = this; - mHandler.obtainMessage(MSG_IS_SWITCHABLE, args).sendToTarget(); + public void setCallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) { + mHandler.obtainMessage(MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER, adapter) + .sendToTarget(); } @Override - public void select(CallInfo callInfo, List descriptors, - ICallServiceSelectionResponse response) throws RemoteException { - mSelectionResponse = response; + public void select(CallInfo callInfo, List descriptors) { SomeArgs args = SomeArgs.obtain(); args.arg1 = callInfo; args.arg2 = descriptors; - args.arg3 = this; - mHandler.obtainMessage(MSG_SELECT_CALL_SERVICES, args).sendToTarget(); - } - - @Override - public void setSwitchable(boolean isSwitchable) { - if (mSwitchabilityResponse != null) { - try { - mSwitchabilityResponse.setIsSwitchable(isSwitchable); - } catch (RemoteException e) { - Log.d(TAG, "Failed to set switchability", e); - } - } else { - Log.wtf(TAG, "Switchability response object not set"); - } - } - - @Override - public void setSelectedCallServices(List callServices) { - if (mSelectionResponse != null) { - try { - mSelectionResponse.setSelectedCallServiceDescriptors(callServices); - } catch (RemoteException e) { - Log.d(TAG, "Failed to set call services", e); - } - } else { - Log.wtf(TAG, "Selector response object not set"); - } + mHandler.obtainMessage(MSG_SELECT, args).sendToTarget(); } } @@ -177,31 +90,19 @@ public abstract class CallServiceSelector extends Service { } /** - * Determines whether the given call is switchable. That is, whether the call can be moved to - * another {@link CallService} seamlessly. Once this is determined, the result is passed to the - * given {@link CallSwitchabilityResponse} listener.
- *
- * This method is called on the main thread and is not safe to block. + * Sets an adapter that allows the selector to communicate with Telecomm. * - * @param callInfo The call being potentially switched between {@link CallService}s. - * @param response The {@link CallSwitchabilityResponse} listener to call back with the result. + * @param adapter Adapter object for communicating with Telecomm. */ - protected abstract void isSwitchable(CallInfo callInfo, CallSwitchabilityResponse response); + protected abstract void setCallServiceSelectorAdapter(CallServiceSelectorAdapter adapter); /** * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return - * them through the given {@link CallServiceSelectionResponse} listener.
- *
- * This method is called on the UI thread and is not safe to block. + * them through {@link CallServiceSelectorAdapter#select}. * * @param callInfo The call being placed using the {@link CallService}s. * @param descriptors The descriptors of the available {@link CallService}s with which to place * the call. - * @param response The {@link CallServiceSelectionResponse} listener to call back with the - * result. */ - protected abstract void select( - CallInfo callInfo, - List descriptors, - CallServiceSelectionResponse response); + protected abstract void select(CallInfo callInfo, List descriptors); } diff --git a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java new file mode 100644 index 0000000000000..8635f1aacd7df --- /dev/null +++ b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.net.Uri; +import android.os.Bundle; +import android.os.RemoteException; +import android.telecomm.CallServiceDescriptor; + +import com.android.internal.telecomm.ICallServiceSelectorAdapter; + +import java.util.List; + +/** + * Provides methods for ICallServiceSelector implementations to interact with Telecomm. + */ +public final class CallServiceSelectorAdapter { + private final ICallServiceSelectorAdapter mAdapter; + + /** + * {@hide} + */ + public CallServiceSelectorAdapter(ICallServiceSelectorAdapter adapter) { + mAdapter = adapter; + } + + /** + * Records the sorted set of call services that are preferred by the corresponding + * call-service selector. + * + * @param callId The ID of the call to complete. + * @param selectedCallServiceDescriptors The prioritized list of preferred call-service + * descriptors to use for completing the call. + */ + public void setSelectedCallServices( + String callId, + List selectedCallServiceDescriptors) { + try { + mAdapter.setSelectedCallServices(callId, selectedCallServiceDescriptors); + } catch (RemoteException e) { + } + } + + /** + * Associates handoff information with an ongoing call. Calls can switch from one call service + * to another. Setting handle to a non-null value marks the call as switchable. + * + * @param callId The ID of the call to set handoff information for. + * @param handle The handle used to place the call when switching. + * @param extras Optional extra that's attached to the call. + */ + public void setHandoffInfo(String callId, Uri handle, Bundle extras) { + try { + mAdapter.setHandoffInfo(callId, handle, extras); + } catch (RemoteException e) { + } + } +} diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl index 97fa834a106e6..10d73be7af05f 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceLookupResponse.aidl @@ -21,16 +21,12 @@ import android.telecomm.CallServiceDescriptor; import java.util.List; /** - * Used by {@link ICallServiceProvider} to return a list of {@link CallServiceDescriptor}s. - * {@hide} + * Internal remote interface for call service lookup response. + * + * @see android.telecomm.CallServiceLookupResponse + * + * @hide */ oneway interface ICallServiceLookupResponse { - /** - * Passes the sorted list of preferred {@link CallServiceDescriptor}s back to Telecomm. Used - * in the context of attempting to place a pending outgoing call. - * - * @param callServiceDescriptors The set of call-service descriptors from - * {@link ICallServiceProvider}. - */ void setCallServiceDescriptors(in List callServiceDescriptors); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl index 39fedddbd60db..96daeeda279e6 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceProvider.aidl @@ -21,28 +21,12 @@ import android.telecomm.CallServiceDescriptor; import com.android.internal.telecomm.ICallServiceLookupResponse; /** - * Interface for applications interested in providing call-service implementations. Only used in - * outgoing-call scenarios where the best-candidate service to issue the call over may need to be - * decided dynamically (unlike incoming call scenario where the call-service is known). + * Internal remote interface for call service providers. * - * Intended usage at time of writing is: Call intent received by the CallsManager, which in turn - * gathers and binds all ICallServiceProvider implementations (using the framework). Once bound, the - * CallsManager invokes the lookupCallServices API of each bound provider and waits until - * either all providers reply (asynchronously) or some timeout is met. The resulted list is then - * processed by the CallsManager and its helpers (potentially requesting input from the user) to - * identify the best CallService. The user should obviously be notified upon zero candidates as - * well as all (one or more) candidates failing to issue the call. - * {@hide} + * @see android.telecomm.CallServiceProvider + * + * @hide */ oneway interface ICallServiceProvider { - - /** - * Initiates the process to retrieve the list of {@link CallServiceDescriptor}s implemented by - * this provider. - * TODO(santoscordon): Needs comments on how to populate the list within - * ICallServiceLookupResponse and how to handle error conditions. - * - * @param response The response object through which the list of call services is sent. - */ void lookupCallServices(in ICallServiceLookupResponse response); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl index 3b73d9b4ed29f..0dd38558c6e82 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl @@ -20,72 +20,19 @@ import android.telecomm.CallInfo; import android.telecomm.CallServiceDescriptor; import com.android.internal.telecomm.ICallService; -import com.android.internal.telecomm.ICallServiceSelectionResponse; -import com.android.internal.telecomm.ICallSwitchabilityResponse; +import com.android.internal.telecomm.ICallServiceSelectorAdapter; import java.util.List; /** - * Interface for call-service selector implementations. + * Internal remote interface for call service selectors. * - * Call-service selectors are ultimately responsible for deciding which of the available call - * service implementations should be used to place an outgoing call, as well as which service - * to switch the call to upon system-provided opportunities to switch call services. + * @see android.telecomm.CallServiceSelector * - * Outgoing call scenario: - * - * Telecomm maintains a prioritized list of call-service selectors. Upon attempting to issue - * outgoing calls, the switchboard iterates through these (starting with the highest-priority - * selector). It then invokes the "select" API below passing -- among other parameters -- the - * list of available call services, excluding fully-utilized services that temporarily aren't - * capable of accommodating additional calls. Once invoked, selectors return a sorted subset - * from the specified list, containing the preferred services through which to place the call. - * Upon empty selection the switchboard continues to the next selector. Otherwise, upon non- - * empty selection, the returned call services are attempted in the specified order. The flow - * is concluded either when the call is placed by one of the specified services (e.g. ringing) - * or upon failure to connect by the time the set of selectors is exhausted. Failed calls are - * essentially abandoned by this flow and then picked up by the switchboard's monitor. - * - * Note that attempted-yet-failed call services within one outgoing-call cycle may be omitted - * from the set passed to the next selector. As for selector priority, at the time of writing - * this is intended to be a blend of built-in priorities (e.g. to handle emergency calls) and - * user-specified preferences (via settings, e.g. electing to use a particular selector prior - * to attempting the system-default call-service selector). - * - * Call-services switching scenario (applying to both incoming and outgoing calls): - * - * The switchboard may invoke any active selector (a selector associated with one or more on- - * going calls) up to once per ongoing call at its discretion (e.g. periodically), once again - * passing the available call services to the "select" API. As in the outgoing-call scenario - * above, returning the empty list means "pass" -- basically indicating that the current call - * service for this call need not be switched at this time. In cases where switching isn't at - * all supported (either for a given call or globally across a given selector) , isSwitchable - * below can return false blindly to suppress all "select" calls beyond the initial one (that - * is used to establish outgoing calls). - * {@hide} + * @hide */ oneway interface ICallServiceSelector { + void setCallServiceSelectorAdapter(in ICallServiceSelectorAdapter adapter); - /** - * Initiates the process to retrieve the sorted set of call services that are preferred by - * this call-service selector. - * - * @param callInfo The details of the relevant call. - * @param callServiceDescriptors The list of call-service descriptors to select from. - * @param response The response object through which the selected service IDs are passed back - * to Telecomm. - */ - void select( - in CallInfo callInfo, - in List callServiceDescriptors, - in ICallServiceSelectionResponse response); - - /** - * Determines if the specified ongoing call can/should be switched from the currently-used - * call service to another. - * - * @param callInfo The details of the relevant call. - * @param response The response object to be populated and returned to switchboard. - */ - void isSwitchable(in CallInfo callInfo, in ICallSwitchabilityResponse response); + void select(in CallInfo callInfo, in List callServiceDescriptors); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl similarity index 58% rename from telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl rename to telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl index 8270aa5773ec0..1b281b987e686 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectionResponse.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl @@ -16,23 +16,24 @@ package com.android.internal.telecomm; -import android.os.IBinder; +import android.net.Uri; +import android.os.Bundle; +import android.telecomm.CallInfo; import android.telecomm.CallServiceDescriptor; + import java.util.List; /** - * Used by {@link ICallServiceSelector} to return the preferred list of {@link ICallService} - * implementations with which to connect the corresponding outgoing call. - * {@hide} + * Internal remote interface for call service selector adapter. + * + * @see android.telecomm.CallServiceSelectorAdapter + * + * @hide */ -oneway interface ICallServiceSelectionResponse { - /** - * Records the sorted set of call services that are preferred by the corresponding - * call-service selector. - * - * @param selectedCallServiceDescriptors The prioritized list of preferred call-service - * descriptors to use for completing the call. - */ - void setSelectedCallServiceDescriptors( +oneway interface ICallServiceSelectorAdapter { + void setSelectedCallServices( + String callId, in List selectedCallServiceDescriptors); + + void setHandoffInfo(String callId, in Uri handle, in Bundle extras); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl b/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl deleted file mode 100644 index 9a7e9e588db64..0000000000000 --- a/telecomm/java/com/android/internal/telecomm/ICallSwitchabilityResponse.aidl +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.internal.telecomm; - -/** - * Used by {@link ICallServiceSelector}s to return whether or not the relevant - * call is switchable. - * {@hide} - */ -oneway interface ICallSwitchabilityResponse { - /** - * Records whether or not the corresponding call can potentially be switched to another - * call service. - * - * @param isSwitchable True if the associated call-service selector may be interested - * in switching call services. Setting isSwitchable to true should generally - * guarantee the "select" API of the associated selector to be invoked, hence - * allowing the selector to return either the empty list (meaning pass, don't - * switch) or the prioritized list of call-services to attempt switching to. - */ - void setIsSwitchable(boolean isSwitchable); -} From 8111bc57a1e55d2391598df64e505dd87ce23bff Mon Sep 17 00:00:00 2001 From: Ihab Awad Date: Wed, 2 Apr 2014 13:30:23 -0700 Subject: [PATCH 094/102] Fix build breakage due to Javadoc typo. Change-Id: Ib93191adc1b25afe673f3a1834eaa22f4c6bc9d5 --- telecomm/java/android/telecomm/CallServiceSelector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 8eec1427ac63d..73bcfcd179327 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -98,7 +98,8 @@ public abstract class CallServiceSelector extends Service { /** * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return - * them through {@link CallServiceSelectorAdapter#select}. + * them through + * {@link CallServiceSelectorAdapter#setSelectedCallServices(String,List)}. * * @param callInfo The call being placed using the {@link CallService}s. * @param descriptors The descriptors of the available {@link CallService}s with which to place From a3d3acae57b46ae498e55153860d63055b8169ba Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 1 Apr 2014 23:36:41 -0700 Subject: [PATCH 095/102] Add disconnect cause and message extras These extras will be sent out as a part of the ACTION_PHONE_STATE_CHANGED broadcast. Change-Id: I23fe43e7f3604471185ffb30be9ac553438b78f3 --- api/current.txt | 3 ++- .../java/android/telecomm/TelecommConstants.java | 14 +++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/api/current.txt b/api/current.txt index d3ae22df3f594..8d0686abb2c23 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25017,7 +25017,8 @@ package android.telecomm { field public static final java.lang.String ACTION_INCOMING_CALL = "android.intent.action.INCOMING_CALL"; field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ',' field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';' - field public static final java.lang.String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; + field public static final java.lang.String EXTRA_CALL_DISCONNECT_CAUSE = "android.telecomm.extra.CALL_DISCONNECT_CAUSE"; + field public static final java.lang.String EXTRA_CALL_DISCONNECT_MESSAGE = "android.telecomm.extra.CALL_DISCONNECT_MESSAGE"; field public static final java.lang.String EXTRA_CALL_SERVICE_DESCRIPTOR = "android.intent.extra.CALL_SERVICE_DESCRIPTOR"; field public static final java.lang.String EXTRA_INCOMING_CALL_EXTRAS = "android.intent.extra.INCOMING_CALL_EXTRAS"; } diff --git a/telecomm/java/android/telecomm/TelecommConstants.java b/telecomm/java/android/telecomm/TelecommConstants.java index c2cccf1250c15..8300c92f803ec 100644 --- a/telecomm/java/android/telecomm/TelecommConstants.java +++ b/telecomm/java/android/telecomm/TelecommConstants.java @@ -70,10 +70,18 @@ public final class TelecommConstants { "android.intent.extra.INCOMING_CALL_EXTRAS"; /** - * Optional extra for {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} containing the unique - * ID of the call. + * Optional extra for {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} containing the + * disconnect code. */ - public static final String EXTRA_CALL_ID = "android.telecomm.extra.CALL_ID"; + public static final String EXTRA_CALL_DISCONNECT_CAUSE = + "android.telecomm.extra.CALL_DISCONNECT_CAUSE"; + + /** + * Optional extra for {@link TelephonyManager#ACTION_PHONE_STATE_CHANGED} containing the + * disconnect message. + */ + public static final String EXTRA_CALL_DISCONNECT_MESSAGE = + "android.telecomm.extra.CALL_DISCONNECT_MESSAGE"; /** * The dual tone multi-frequency signaling character sent to indicate the dialing system should From b632e5b122d82333c390cc334ab17100bc2af7a2 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Thu, 3 Apr 2014 12:54:33 -0700 Subject: [PATCH 096/102] Handoff: Add APIs to allow handoff between call services This CL adds: - CallInfo.mExtra and CallInfo.mCurrentCallServiceDescriptor. These can be used by the selector to perform handoff. - InCallService.setHandoffEnabled to enform the in-call UI that handoff is allowed. - InCallAdapater.handoffCall to initiate handoff. Bug: 13643568 Change-Id: I94c28b10c0e0a253450f14d31ecdc416d5b44ca4 --- api/current.txt | 5 +++ telecomm/java/android/telecomm/CallInfo.java | 43 +++++++++++++++++-- .../android/telecomm/CallServiceSelector.java | 22 ++++++++++ .../java/android/telecomm/InCallAdapter.java | 12 ++++++ .../java/android/telecomm/InCallService.java | 19 ++++++++ .../telecomm/ICallServiceSelector.aidl | 4 ++ .../internal/telecomm/IInCallAdapter.aidl | 2 + .../internal/telecomm/IInCallService.aidl | 2 + 8 files changed, 106 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index 5da2dbee1bdc3..09073d3a297ca 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24874,6 +24874,8 @@ package android.telecomm { public final class CallInfo implements android.os.Parcelable { ctor public CallInfo(java.lang.String, android.telecomm.CallState, android.net.Uri); method public int describeContents(); + method public android.telecomm.CallServiceDescriptor getCurrentCallServiceDescriptor(); + method public android.os.Bundle getExtras(); method public android.telecomm.GatewayInfo getGatewayInfo(); method public android.net.Uri getHandle(); method public java.lang.String getId(); @@ -24954,6 +24956,7 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); + method protected final java.util.Collection getCalls(); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void select(android.telecomm.CallInfo, java.util.List); method protected abstract void setCallServiceSelectorAdapter(android.telecomm.CallServiceSelectorAdapter); @@ -24989,6 +24992,7 @@ package android.telecomm { public final class InCallAdapter { method public void answerCall(java.lang.String); method public void disconnectCall(java.lang.String); + method public void handoffCall(java.lang.String); method public void holdCall(java.lang.String); method public void mute(boolean); method public void playDtmfTone(java.lang.String, char); @@ -25007,6 +25011,7 @@ package android.telecomm { method protected abstract void setActive(java.lang.String); method protected abstract void setDialing(java.lang.String); method protected abstract void setDisconnected(java.lang.String, int); + method protected abstract void setHandoffEnabled(java.lang.String, boolean); method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); method protected abstract void setOnHold(java.lang.String); method protected abstract void setPostDial(java.lang.String, java.lang.String); diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index bb08c2aac50cb..b0a7a99b10491 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -17,6 +17,7 @@ package android.telecomm; import android.net.Uri; +import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; @@ -51,6 +52,15 @@ public final class CallInfo implements Parcelable { */ private final GatewayInfo mGatewayInfo; + /** + * Additional information that can be persisted. For example, extra handoff information can + * attached to a call using {@link CallServiceSelectorAdapter#setHandoffInfo(String,Uri,Bundle). + */ + private final Bundle mExtras; + + /** The descriptor for the call service currently routing this call. */ + private final CallServiceDescriptor mCurrentCallServiceDescriptor; + // There are 4 timestamps that are important to a call: // 1) Created timestamp - The time at which the user explicitly chose to make the call. // 2) Connected timestamp - The time at which a call service confirms that it has connected @@ -64,7 +74,7 @@ public final class CallInfo implements Parcelable { // 4) Disconnected timestamp - The time at which the call was disconnected. public CallInfo(String id, CallState state, Uri handle) { - this(id, state, handle, null); + this(id, state, handle, null, Bundle.EMPTY, null); } /** @@ -74,14 +84,25 @@ public final class CallInfo implements Parcelable { * @param state The state of the call. * @param handle The handle to the other party in this call. * @param gatewayInfo Gateway information pertaining to this call. + * @param extras Additional information that can be persisted. + * @param currentCallServiceDescriptor The descriptor for the call service currently routing + * this call. * * @hide */ - public CallInfo(String id, CallState state, Uri handle, GatewayInfo gatewayInfo) { + public CallInfo( + String id, + CallState state, + Uri handle, + GatewayInfo gatewayInfo, + Bundle extras, + CallServiceDescriptor currentCallServiceDescriptor) { mId = id; mState = state; mHandle = handle; mGatewayInfo = gatewayInfo; + mExtras = extras; + mCurrentCallServiceDescriptor = currentCallServiceDescriptor; } public String getId() { @@ -112,6 +133,14 @@ public final class CallInfo implements Parcelable { return mGatewayInfo; } + public Bundle getExtras() { + return mExtras; + } + + public CallServiceDescriptor getCurrentCallServiceDescriptor() { + return mCurrentCallServiceDescriptor; + } + // // Parceling related code below here. // @@ -127,13 +156,17 @@ public final class CallInfo implements Parcelable { String id = source.readString(); CallState state = CallState.valueOf(source.readString()); Uri handle = Uri.CREATOR.createFromParcel(source); + boolean gatewayInfoPresent = source.readByte() != 0; GatewayInfo gatewayInfo = null; if (gatewayInfoPresent) { gatewayInfo = GatewayInfo.CREATOR.createFromParcel(source); } - return new CallInfo(id, state, handle, gatewayInfo); + ClassLoader classLoader = CallInfo.class.getClassLoader(); + Bundle extras = source.readParcelable(classLoader); + CallServiceDescriptor descriptor = source.readParcelable(classLoader); + return new CallInfo(id, state, handle, gatewayInfo, extras, descriptor); } @Override @@ -158,11 +191,15 @@ public final class CallInfo implements Parcelable { destination.writeString(mId); destination.writeString(mState.name()); mHandle.writeToParcel(destination, 0); + if (mGatewayInfo != null) { destination.writeByte((byte) 1); mGatewayInfo.writeToParcel(destination, 0); } else { destination.writeByte((byte) 0); } + + destination.writeParcelable(mExtras, 0); + destination.writeParcelable(mCurrentCallServiceDescriptor, 0); } } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 73bcfcd179327..9e714b41785ce 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -28,6 +28,9 @@ import com.android.internal.os.SomeArgs; import com.android.internal.telecomm.ICallServiceSelector; import com.android.internal.telecomm.ICallServiceSelectorAdapter; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; import java.util.List; /** @@ -39,6 +42,8 @@ public abstract class CallServiceSelector extends Service { private static final int MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER = 0; private static final int MSG_SELECT = 1; + private final HashMap mCalls = new HashMap(); + /** Handler to move client-bound method calls to the main thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @Override @@ -76,6 +81,16 @@ public abstract class CallServiceSelector extends Service { args.arg2 = descriptors; mHandler.obtainMessage(MSG_SELECT, args).sendToTarget(); } + + @Override + public void onCallUpdated(CallInfo callInfo) { + mCalls.put(callInfo.getId(), callInfo); + } + + @Override + public void onCallRemoved(String callId) { + mCalls.remove(callId); + } } private final CallServiceSelectorBinder mBinder; @@ -89,6 +104,13 @@ public abstract class CallServiceSelector extends Service { return mBinder; } + /** + * Returns a list of all calls managed by this selector. + */ + protected final Collection getCalls() { + return Collections.unmodifiableCollection(mCalls.values()); + } + /** * Sets an adapter that allows the selector to communicate with Telecomm. * diff --git a/telecomm/java/android/telecomm/InCallAdapter.java b/telecomm/java/android/telecomm/InCallAdapter.java index 2933f1780e8b4..e41d3f638bce9 100644 --- a/telecomm/java/android/telecomm/InCallAdapter.java +++ b/telecomm/java/android/telecomm/InCallAdapter.java @@ -184,4 +184,16 @@ public final class InCallAdapter { } catch (RemoteException e) { } } + + /** + * Instructs Telecomm to handoff the call to another call service. + * + * @param callId The identifier of the call to handoff. + */ + public void handoffCall(String callId) { + try { + mAdapter.handoffCall(callId); + } catch (RemoteException e) { + } + } } diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 3942d70b84233..c70f56e949f1f 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -46,6 +46,7 @@ public abstract class InCallService extends Service { private static final int MSG_SET_RINGING = 8; private static final int MSG_SET_POST_DIAL = 9; private static final int MSG_SET_POST_DIAL_WAIT = 10; + private static final int MSG_SET_HANDOFF_ENABLED = 11; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -98,6 +99,10 @@ public abstract class InCallService extends Service { break; case MSG_ON_AUDIO_STATE_CHANGED: onAudioStateChanged((CallAudioState) msg.obj); + break; + case MSG_SET_HANDOFF_ENABLED: + setHandoffEnabled((String) msg.obj, msg.arg1 == 1 ? true : false); + break; default: break; } @@ -167,6 +172,12 @@ public abstract class InCallService extends Service { args.arg2 = remaining; mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget(); } + + @Override + public void setHandoffEnabled(String callId, boolean isHandoffEnabled) { + mHandler.obtainMessage(MSG_SET_HANDOFF_ENABLED, isHandoffEnabled ? 1 : 0, 0, + callId).sendToTarget(); + } } private final InCallServiceBinder mBinder; @@ -277,4 +288,12 @@ public abstract class InCallService extends Service { * @param remaining The remaining postdial string to be dialed. */ protected abstract void setPostDialWait(String callId, String remaining); + + /** + * Called when the call's handoff state has changed. + * + * @param callId The identifier of the call whose handoff state was changed. + * @param isHandoffEnabled True if handoff is enabled. + */ + protected abstract void setHandoffEnabled(String callId, boolean isHandoffEnabled); } diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl index 0dd38558c6e82..9597dc105e284 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelector.aidl @@ -35,4 +35,8 @@ oneway interface ICallServiceSelector { void setCallServiceSelectorAdapter(in ICallServiceSelectorAdapter adapter); void select(in CallInfo callInfo, in List callServiceDescriptors); + + void onCallUpdated(in CallInfo callInfo); + + void onCallRemoved(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl index e0cdb83be4f6e..512e8981b1d20 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl @@ -45,4 +45,6 @@ oneway interface IInCallAdapter { void stopDtmfTone(String callId); void postDialContinue(String callId); + + void handoffCall(String callId); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index f5847df1d0eb0..4187fa82b588a 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -48,4 +48,6 @@ oneway interface IInCallService { void setPostDial(String callId, String remaining); void setPostDialWait(String callId, String remaining); + + void setHandoffEnabled(String callId, boolean isHandoffEnabled); } From 924748fa3fc663c780c3fb21ec1332bd9757fcd2 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Thu, 3 Apr 2014 08:36:38 -0700 Subject: [PATCH 097/102] Add lifecycle methods to telecomm services Have the base classes track the adapters and provide an override-able hook (onAdapterAttached()) to notify when the adapter is set. Change-Id: I58ca5c6970328861327699ec497fa21288bce7df --- api/current.txt | 9 ++++--- .../java/android/telecomm/CallService.java | 23 +++++++++++++----- .../android/telecomm/CallServiceSelector.java | 22 +++++++++++++---- .../java/android/telecomm/InCallService.java | 24 +++++++++++++------ 4 files changed, 57 insertions(+), 21 deletions(-) diff --git a/api/current.txt b/api/current.txt index 09073d3a297ca..2c6047d74608c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24900,14 +24900,15 @@ package android.telecomm { method public abstract void answer(java.lang.String); method public abstract void call(android.telecomm.CallInfo); method public abstract void disconnect(java.lang.String); + method protected final android.telecomm.CallServiceAdapter getAdapter(); method public final android.os.IBinder getBinder(); method public abstract void hold(java.lang.String); method public abstract void isCompatibleWith(android.telecomm.CallInfo); + method protected void onAdapterAttached(android.telecomm.CallServiceAdapter); method public abstract void onAudioStateChanged(java.lang.String, android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method public abstract void playDtmfTone(java.lang.String, char); method public abstract void reject(java.lang.String); - method public abstract void setCallServiceAdapter(android.telecomm.CallServiceAdapter); method public abstract void setIncomingCallId(java.lang.String, android.os.Bundle); method public abstract void stopDtmfTone(java.lang.String); method public abstract void unhold(java.lang.String); @@ -24956,10 +24957,11 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); + method protected final android.telecomm.CallServiceSelectorAdapter getAdapter(); method protected final java.util.Collection getCalls(); + method protected void onAdapterAttached(android.telecomm.CallServiceSelectorAdapter); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void select(android.telecomm.CallInfo, java.util.List); - method protected abstract void setCallServiceSelectorAdapter(android.telecomm.CallServiceSelectorAdapter); } public final class CallServiceSelectorAdapter { @@ -25006,13 +25008,14 @@ package android.telecomm { public abstract class InCallService extends android.app.Service { ctor protected InCallService(); method protected abstract void addCall(android.telecomm.CallInfo); + method protected final android.telecomm.InCallAdapter getAdapter(); + method protected void onAdapterAttached(android.telecomm.InCallAdapter); method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); method protected abstract void setActive(java.lang.String); method protected abstract void setDialing(java.lang.String); method protected abstract void setDisconnected(java.lang.String, int); method protected abstract void setHandoffEnabled(java.lang.String, boolean); - method protected abstract void setInCallAdapter(android.telecomm.InCallAdapter); method protected abstract void setOnHold(java.lang.String); method protected abstract void setPostDial(java.lang.String, java.lang.String); method protected abstract void setPostDialWait(java.lang.String, java.lang.String); diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index c34395be99069..142c37e3afd01 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -70,7 +70,8 @@ public abstract class CallService extends Service { case MSG_SET_CALL_SERVICE_ADAPTER: CallServiceAdapter adapter = new CallServiceAdapter((ICallServiceAdapter) msg.obj); - setCallServiceAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_IS_COMPATIBLE_WITH: isCompatibleWith((CallInfo) msg.obj); @@ -218,6 +219,8 @@ public abstract class CallService extends Service { */ private final CallServiceBinder mBinder = new CallServiceBinder(); + private CallServiceAdapter mAdapter = null; + /** {@inheritDoc} */ @Override public final IBinder onBind(Intent intent) { @@ -232,12 +235,20 @@ public abstract class CallService extends Service { } /** - * Sets an implementation of CallServiceAdapter for adding new calls and communicating state - * changes of existing calls. - * - * @param callServiceAdapter Adapter object for communicating call to CallsManager + * @return The attached {@link CallServiceAdapter} if the service is bound, null otherwise. */ - public abstract void setCallServiceAdapter(CallServiceAdapter callServiceAdapter); + protected final CallServiceAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link CallService} has been attached to a + * {@link CallServiceAdapter}, indicating {@link #getAdapter()} is now safe to use. + * + * @param adapter The adapter now attached to this call service. + */ + protected void onAdapterAttached(CallServiceAdapter adapter) { + } /** * Determines if the CallService can place the specified call. Response is sent via diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 9e714b41785ce..a2ff617bb0fef 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -52,7 +52,8 @@ public abstract class CallServiceSelector extends Service { case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER: CallServiceSelectorAdapter adapter = new CallServiceSelectorAdapter( (ICallServiceSelectorAdapter) msg.obj); - setCallServiceSelectorAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_SELECT: SomeArgs args = (SomeArgs) msg.obj; @@ -95,6 +96,8 @@ public abstract class CallServiceSelector extends Service { private final CallServiceSelectorBinder mBinder; + private CallServiceSelectorAdapter mAdapter = null; + protected CallServiceSelector() { mBinder = new CallServiceSelectorBinder(); } @@ -112,11 +115,20 @@ public abstract class CallServiceSelector extends Service { } /** - * Sets an adapter that allows the selector to communicate with Telecomm. - * - * @param adapter Adapter object for communicating with Telecomm. + * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. */ - protected abstract void setCallServiceSelectorAdapter(CallServiceSelectorAdapter adapter); + protected final CallServiceSelectorAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link CallServiceSelector} has been attached + * to a {@link CallServiceSelectorAdapter}, indicating {@link #getAdapter()} is now safe to use. + * + * @param adapter The adapter now attached to this call service selector. + */ + protected void onAdapterAttached(CallServiceSelectorAdapter adapter) { + } /** * Given a list of {@link CallServiceDescriptor}s, order them into a prioritized list and return diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index c70f56e949f1f..14c6f2813ced8 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -55,7 +55,8 @@ public abstract class InCallService extends Service { switch (msg.what) { case MSG_SET_IN_CALL_ADAPTER: InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj); - setInCallAdapter(adapter); + mAdapter = adapter; + onAdapterAttached(adapter); break; case MSG_ADD_CALL: addCall((CallInfo) msg.obj); @@ -182,6 +183,8 @@ public abstract class InCallService extends Service { private final InCallServiceBinder mBinder; + private InCallAdapter mAdapter; + protected InCallService() { mBinder = new InCallServiceBinder(); } @@ -192,13 +195,20 @@ public abstract class InCallService extends Service { } /** - * Provides the in-call app an adapter object through which to send call-commands such as - * answering and rejecting incoming calls, disconnecting active calls, and putting calls in - * special states (mute, hold, etc). - * - * @param inCallAdapter Adapter through which an in-call app can send call-commands to Telecomm. + * @return The attached {@link CallServiceSelectorAdapter} if attached, or null otherwise. */ - protected abstract void setInCallAdapter(InCallAdapter inCallAdapter); + protected final InCallAdapter getAdapter() { + return mAdapter; + } + + /** + * Lifecycle callback which is called when this {@link InCallService} has been attached + * to a {@link InCallAdapter}, indicating {@link #getAdapter()} is now safe to use. + * + * @param adapter The adapter now attached to this in-call service. + */ + protected void onAdapterAttached(InCallAdapter adapter) { + } /** * Indicates to the in-call app that a new call has been created and an appropriate From 6043793d3e8455bc8867baed39353f0350daa63f Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Sat, 5 Apr 2014 16:44:55 -0700 Subject: [PATCH 098/102] Add InCallCall class to communicate with InCallService Change-Id: I3916e33e184f57bb6e58ed93a26b866d3ce0e7df --- api/current.txt | 24 ++- telecomm/java/android/telecomm/CallInfo.java | 23 +-- .../java/android/telecomm/CallService.java | 6 +- .../telecomm/CallServiceDescriptor.java | 15 ++ .../android/telecomm/CallServiceSelector.java | 5 +- .../java/android/telecomm/InCallCall.aidl | 19 +++ .../java/android/telecomm/InCallCall.java | 159 ++++++++++++++++++ .../java/android/telecomm/InCallService.java | 150 +++-------------- .../internal/telecomm/IInCallService.aidl | 18 +- 9 files changed, 245 insertions(+), 174 deletions(-) create mode 100644 telecomm/java/android/telecomm/InCallCall.aidl create mode 100644 telecomm/java/android/telecomm/InCallCall.java diff --git a/api/current.txt b/api/current.txt index a09db03e3602d..898eb86a9e446 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25011,21 +25011,31 @@ package android.telecomm { method public void unholdCall(java.lang.String); } + public final class InCallCall implements android.os.Parcelable { + method public int describeContents(); + method public int getCapabilities(); + method public long getConnectTimeMillis(); + method public android.telecomm.CallServiceDescriptor getCurrentCallServiceDescriptor(); + method public int getDisconnectCause(); + method public android.telecomm.GatewayInfo getGatewayInfo(); + method public android.net.Uri getHandle(); + method public android.telecomm.CallServiceDescriptor getHandoffCallServiceDescriptor(); + method public java.lang.String getId(); + method public android.telecomm.CallState getState(); + method public void writeToParcel(android.os.Parcel, int); + field public static final android.os.Parcelable.Creator CREATOR; + } + public abstract class InCallService extends android.app.Service { ctor protected InCallService(); - method protected abstract void addCall(android.telecomm.CallInfo); + method protected abstract void addCall(android.telecomm.InCallCall); method protected final android.telecomm.InCallAdapter getAdapter(); method protected void onAdapterAttached(android.telecomm.InCallAdapter); method protected abstract void onAudioStateChanged(android.telecomm.CallAudioState); method public final android.os.IBinder onBind(android.content.Intent); - method protected abstract void setActive(java.lang.String); - method protected abstract void setDialing(java.lang.String); - method protected abstract void setDisconnected(java.lang.String, int); - method protected abstract void setHandoffEnabled(java.lang.String, boolean); - method protected abstract void setOnHold(java.lang.String); method protected abstract void setPostDial(java.lang.String, java.lang.String); method protected abstract void setPostDialWait(java.lang.String, java.lang.String); - method protected abstract void setRinging(java.lang.String); + method protected abstract void updateCall(android.telecomm.InCallCall); } public final class TelecommConstants { diff --git a/telecomm/java/android/telecomm/CallInfo.java b/telecomm/java/android/telecomm/CallInfo.java index b0a7a99b10491..cb7f2dcd88638 100644 --- a/telecomm/java/android/telecomm/CallInfo.java +++ b/telecomm/java/android/telecomm/CallInfo.java @@ -22,7 +22,6 @@ import android.os.Parcel; import android.os.Parcelable; import java.util.Date; -import java.util.UUID; /** * A parcelable holder class of Call information data. This class is intended for transfering call @@ -32,7 +31,7 @@ import java.util.UUID; public final class CallInfo implements Parcelable { /** - * Unique identifier for the call as a UUID string. + * Unique identifier for the call. */ private final String mId; @@ -61,18 +60,6 @@ public final class CallInfo implements Parcelable { /** The descriptor for the call service currently routing this call. */ private final CallServiceDescriptor mCurrentCallServiceDescriptor; - // There are 4 timestamps that are important to a call: - // 1) Created timestamp - The time at which the user explicitly chose to make the call. - // 2) Connected timestamp - The time at which a call service confirms that it has connected - // this call. This happens through a method-call to either newOutgoingCall or newIncomingCall - // on CallServiceAdapter. Generally this should coincide roughly to the user physically - // hearing/seeing a ring. - // TODO(santoscordon): Consider renaming Call-active to better match the others. - // 3) Call-active timestamp - The time at which the call switches to the active state. This - // happens when the user answers an incoming call or an outgoing call was answered by the - // other party. - // 4) Disconnected timestamp - The time at which the call was disconnected. - public CallInfo(String id, CallState state, Uri handle) { this(id, state, handle, null, Bundle.EMPTY, null); } @@ -141,16 +128,10 @@ public final class CallInfo implements Parcelable { return mCurrentCallServiceDescriptor; } - // - // Parceling related code below here. - // - /** * Responsible for creating CallInfo objects for deserialized Parcels. */ - public static final Parcelable.Creator CREATOR = - new Parcelable.Creator () { - + public static final Parcelable.Creator CREATOR = new Parcelable.Creator () { @Override public CallInfo createFromParcel(Parcel source) { String id = source.readString(); diff --git a/telecomm/java/android/telecomm/CallService.java b/telecomm/java/android/telecomm/CallService.java index 142c37e3afd01..51f10c1028aea 100644 --- a/telecomm/java/android/telecomm/CallService.java +++ b/telecomm/java/android/telecomm/CallService.java @@ -68,10 +68,8 @@ public abstract class CallService extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_SET_CALL_SERVICE_ADAPTER: - CallServiceAdapter adapter = - new CallServiceAdapter((ICallServiceAdapter) msg.obj); - mAdapter = adapter; - onAdapterAttached(adapter); + mAdapter = new CallServiceAdapter((ICallServiceAdapter) msg.obj); + onAdapterAttached(mAdapter); break; case MSG_IS_COMPATIBLE_WITH: isCompatibleWith((CallInfo) msg.obj); diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java index 40f6ab9fce784..3bec2708fb966 100644 --- a/telecomm/java/android/telecomm/CallServiceDescriptor.java +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java @@ -108,6 +108,21 @@ public final class CallServiceDescriptor implements Parcelable { return mNetworkType; } + /** {@inheritDoc} */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof CallServiceDescriptor)) { + return false; + } + CallServiceDescriptor descriptor = (CallServiceDescriptor) obj; + return mCallServiceId.equals(descriptor.mCallServiceId) && + mComponentName.equals(descriptor.mComponentName) && + mNetworkType == descriptor.mNetworkType; + } + /** * @param context {@link Context} to use for the construction of the {@link Builder}. * @return A new {@link Builder} instance. diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index a2ff617bb0fef..8c9495ff136db 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -50,10 +50,9 @@ public abstract class CallServiceSelector extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_SET_CALL_SERVICE_SELECTOR_ADAPTER: - CallServiceSelectorAdapter adapter = new CallServiceSelectorAdapter( + mAdapter = new CallServiceSelectorAdapter( (ICallServiceSelectorAdapter) msg.obj); - mAdapter = adapter; - onAdapterAttached(adapter); + onAdapterAttached(mAdapter); break; case MSG_SELECT: SomeArgs args = (SomeArgs) msg.obj; diff --git a/telecomm/java/android/telecomm/InCallCall.aidl b/telecomm/java/android/telecomm/InCallCall.aidl new file mode 100644 index 0000000000000..be2cdf8b23d70 --- /dev/null +++ b/telecomm/java/android/telecomm/InCallCall.aidl @@ -0,0 +1,19 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +parcelable InCallCall; diff --git a/telecomm/java/android/telecomm/InCallCall.java b/telecomm/java/android/telecomm/InCallCall.java new file mode 100644 index 0000000000000..295df3c50661f --- /dev/null +++ b/telecomm/java/android/telecomm/InCallCall.java @@ -0,0 +1,159 @@ +/* + * Copyright 2014, The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.telecomm; + +import android.net.Uri; +import android.os.Bundle; +import android.os.Parcel; +import android.os.Parcelable; +import android.telephony.DisconnectCause; + +import java.util.Date; +import java.util.UUID; + +/** + * Information about a call that is used between InCallService and Telecomm. + */ +public final class InCallCall implements Parcelable { + private final String mId; + private final CallState mState; + private final int mDisconnectCause; + private final int mCapabilities; + private final long mConnectTimeMillis; + private final Uri mHandle; + private final GatewayInfo mGatewayInfo; + private final CallServiceDescriptor mCurrentCallServiceDescriptor; + private final CallServiceDescriptor mHandoffCallServiceDescriptor; + + /** @hide */ + public InCallCall( + String id, + CallState state, + int disconnectCause, + int capabilities, + long connectTimeMillis, + Uri handle, + GatewayInfo gatewayInfo, + CallServiceDescriptor descriptor, + CallServiceDescriptor handoffDescriptor) { + mId = id; + mState = state; + mDisconnectCause = disconnectCause; + mCapabilities = capabilities; + mConnectTimeMillis = connectTimeMillis; + mHandle = handle; + mGatewayInfo = gatewayInfo; + mCurrentCallServiceDescriptor = descriptor; + mHandoffCallServiceDescriptor = handoffDescriptor; + } + + /** The unique ID of the call. */ + public String getId() { + return mId; + } + + /** The current state of the call. */ + public CallState getState() { + return mState; + } + + /** + * Reason for disconnection, values are defined in {@link DisconnectCause}. Valid when call + * state is {@link CallState.DISCONNECTED}. + */ + public int getDisconnectCause() { + return mDisconnectCause; + } + + // Bit mask of actions a call supports, values are defined in {@link CallCapabilities}. + public int getCapabilities() { + return mCapabilities; + } + + /** The time that the call switched to the active state. */ + public long getConnectTimeMillis() { + return mConnectTimeMillis; + } + + /** The endpoint to which the call is connected. */ + public Uri getHandle() { + return mHandle; + } + + /** Gateway information for the call. */ + public GatewayInfo getGatewayInfo() { + return mGatewayInfo; + } + + /** The descriptor for the call service currently routing this call. */ + public CallServiceDescriptor getCurrentCallServiceDescriptor() { + return mCurrentCallServiceDescriptor; + } + + /** + * The descriptor for the call service that this call is being switched to, null if handoff is + * not in progress. + */ + public CallServiceDescriptor getHandoffCallServiceDescriptor() { + return mHandoffCallServiceDescriptor; + } + + /** Responsible for creating InCallCall objects for deserialized Parcels. */ + public static final Parcelable.Creator CREATOR = + new Parcelable.Creator () { + @Override + public InCallCall createFromParcel(Parcel source) { + String id = source.readString(); + CallState state = CallState.valueOf(source.readString()); + int disconnectCause = source.readInt(); + int capabilities = source.readInt(); + long connectTimeMillis = source.readLong(); + ClassLoader classLoader = InCallCall.class.getClassLoader(); + Uri handle = source.readParcelable(classLoader); + GatewayInfo gatewayInfo = source.readParcelable(classLoader); + CallServiceDescriptor descriptor = source.readParcelable(classLoader); + CallServiceDescriptor handoffDescriptor = source.readParcelable(classLoader); + return new InCallCall(id, state, disconnectCause, capabilities, connectTimeMillis, + handle, gatewayInfo, descriptor, handoffDescriptor); + } + + @Override + public InCallCall[] newArray(int size) { + return new InCallCall[size]; + } + }; + + /** {@inheritDoc} */ + @Override + public int describeContents() { + return 0; + } + + /** Writes InCallCall object into a Parcel. */ + @Override + public void writeToParcel(Parcel destination, int flags) { + destination.writeString(mId); + destination.writeString(mState.name()); + destination.writeInt(mDisconnectCause); + destination.writeInt(mCapabilities); + destination.writeLong(mConnectTimeMillis); + destination.writeParcelable(mHandle, 0); + destination.writeParcelable(mGatewayInfo, 0); + destination.writeParcelable(mCurrentCallServiceDescriptor, 0); + destination.writeParcelable(mHandoffCallServiceDescriptor, 0); + } +} diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 14c6f2813ced8..2e58a27b50a7d 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -38,15 +38,10 @@ import com.android.internal.telecomm.IInCallService; public abstract class InCallService extends Service { private static final int MSG_SET_IN_CALL_ADAPTER = 1; private static final int MSG_ADD_CALL = 2; - private static final int MSG_SET_ACTIVE = 3; - private static final int MSG_SET_DISCONNECTED = 4; - private static final int MSG_SET_HOLD = 5; + private static final int MSG_UPDATE_CALL = 3; + private static final int MSG_SET_POST_DIAL = 4; + private static final int MSG_SET_POST_DIAL_WAIT = 5; private static final int MSG_ON_AUDIO_STATE_CHANGED = 6; - private static final int MSG_SET_DIALING = 7; - private static final int MSG_SET_RINGING = 8; - private static final int MSG_SET_POST_DIAL = 9; - private static final int MSG_SET_POST_DIAL_WAIT = 10; - private static final int MSG_SET_HANDOFF_ENABLED = 11; /** Default Handler used to consolidate binder method calls onto a single thread. */ private final Handler mHandler = new Handler(Looper.getMainLooper()) { @@ -54,21 +49,14 @@ public abstract class InCallService extends Service { public void handleMessage(Message msg) { switch (msg.what) { case MSG_SET_IN_CALL_ADAPTER: - InCallAdapter adapter = new InCallAdapter((IInCallAdapter) msg.obj); - mAdapter = adapter; - onAdapterAttached(adapter); + mAdapter = new InCallAdapter((IInCallAdapter) msg.obj); + onAdapterAttached(mAdapter); break; case MSG_ADD_CALL: - addCall((CallInfo) msg.obj); + addCall((InCallCall) msg.obj); break; - case MSG_SET_ACTIVE: - setActive((String) msg.obj); - break; - case MSG_SET_DIALING: - setDialing((String) msg.obj); - break; - case MSG_SET_RINGING: - setRinging((String) msg.obj); + case MSG_UPDATE_CALL: + updateCall((InCallCall) msg.obj); break; case MSG_SET_POST_DIAL: { SomeArgs args = (SomeArgs) msg.obj; @@ -92,18 +80,9 @@ public abstract class InCallService extends Service { } break; } - case MSG_SET_DISCONNECTED: - setDisconnected((String) msg.obj, msg.arg1); - break; - case MSG_SET_HOLD: - setOnHold((String) msg.obj); - break; case MSG_ON_AUDIO_STATE_CHANGED: onAudioStateChanged((CallAudioState) msg.obj); break; - case MSG_SET_HANDOFF_ENABLED: - setHandoffEnabled((String) msg.obj, msg.arg1 == 1 ? true : false); - break; default: break; } @@ -120,42 +99,14 @@ public abstract class InCallService extends Service { /** {@inheritDoc} */ @Override - public void addCall(CallInfo callInfo) { - mHandler.obtainMessage(MSG_ADD_CALL, callInfo).sendToTarget(); + public void addCall(InCallCall call) { + mHandler.obtainMessage(MSG_ADD_CALL, call).sendToTarget(); } /** {@inheritDoc} */ @Override - public void setActive(String callId) { - mHandler.obtainMessage(MSG_SET_ACTIVE, callId).sendToTarget(); - } - - /** {@inheritDoc} */ - @Override - public void setDisconnected(String callId, int disconnectCause) { - mHandler.obtainMessage(MSG_SET_DISCONNECTED, disconnectCause, 0, callId).sendToTarget(); - } - - /** {@inheritDoc} */ - @Override - public void setOnHold(String callId) { - mHandler.obtainMessage(MSG_SET_HOLD, callId).sendToTarget(); - } - - /** {@inheritDoc} */ - @Override - public void onAudioStateChanged(CallAudioState audioState) { - mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget(); - } - - @Override - public void setDialing(String callId) { - mHandler.obtainMessage(MSG_SET_DIALING, callId).sendToTarget(); - } - - @Override - public void setRinging(String callId) { - mHandler.obtainMessage(MSG_SET_RINGING, callId).sendToTarget(); + public void updateCall(InCallCall call) { + mHandler.obtainMessage(MSG_UPDATE_CALL, call).sendToTarget(); } @Override @@ -174,10 +125,10 @@ public abstract class InCallService extends Service { mHandler.obtainMessage(MSG_SET_POST_DIAL_WAIT, args).sendToTarget(); } + /** {@inheritDoc} */ @Override - public void setHandoffEnabled(String callId, boolean isHandoffEnabled) { - mHandler.obtainMessage(MSG_SET_HANDOFF_ENABLED, isHandoffEnabled ? 1 : 0, 0, - callId).sendToTarget(); + public void onAudioStateChanged(CallAudioState audioState) { + mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget(); } } @@ -212,75 +163,25 @@ public abstract class InCallService extends Service { /** * Indicates to the in-call app that a new call has been created and an appropriate - * user-interface should be built and shown to notify the user. Information about the call - * including its current state is passed in through the callInfo object. + * user-interface should be built and shown to notify the user. * - * @param callInfo Information about the new call. + * @param call Information about the new call. */ - protected abstract void addCall(CallInfo callInfo); + protected abstract void addCall(InCallCall call); /** - * Indicates to the in-call app that the specified call is currently connected to another party - * and a communication channel is open between them. Normal transitions are to - * {@link #setDisconnected(String,int)} when the call is complete. + * Call when information about a call has changed. * - * @param callId The identifier of the call changing state. + * @param call Information about the new call. */ - protected abstract void setActive(String callId); - - /** - * Indicates to the in-call app that the specified call is outgoing and in the dialing state. - * Normal transition are to {@link #setActive(String)} if the call was answered, - * {@link #setPostDial(String,String)} if the dialed number includes a post-dial DTMF string, or - * {@link #setDisconnected(String,int)} if the call was disconnected immediately. - * - * @param callId The identifier of the call changing state. - */ - protected abstract void setDialing(String callId); - - /** - * Indicates to the in-call app that the specified call is incoming and the user still has the - * option of answering, rejecting, or doing nothing with the call. This state is usually - * associated with some type of audible ringtone. Normal transitions are to - * {@link #setActive(String)} if the call is answered, or {@link #setDisconnected(String,int)} - * if the call is not answered or is otherwise disconnected for some reason. - * - * @param callId The identifier of the call changing state. - */ - protected abstract void setRinging(String callId); - - /** - * Indicates to the in-call app that a call has been moved to the - * {@link CallState#DISCONNECTED} and the user should be notified. - * - * @param callId The identifier of the call that was disconnected. - * @param disconnectCause The reason for the disconnection, any of - * {@link android.telephony.DisconnectCause}. - */ - protected abstract void setDisconnected(String callId, int disconnectCause); - - /** - * Indicates to the in-call app that a call has been moved to the - * {@link android.telecomm.CallState#ON_HOLD} state and the user should be notified. - * - * @param callId The identifier of the call that was put on hold. - */ - protected abstract void setOnHold(String callId); - - /** - * Called when the audio state changes. - * - * @param audioState The new {@link CallAudioState}. - */ - protected abstract void onAudioStateChanged(CallAudioState audioState); + protected abstract void updateCall(InCallCall call); /** * Indicates to the in-call app that the specified call is active but in a "post-dial" state * where Telecomm is now sending some dual-tone multi-frequency signaling (DTMF) tones appended * to the dialed number. Normal transitions are to {@link #setPostDialWait(String,String)} when * the post-dial string requires user confirmation to proceed, {@link #setActive(String)} when - * the post-dial tones are completed, or {@link #setDisconnected(String,int)} if the call is - * disconnected. + * the post-dial tones are completed. * * @param callId The identifier of the call changing state. * @param remaining The remaining postdial string to be dialed. @@ -300,10 +201,9 @@ public abstract class InCallService extends Service { protected abstract void setPostDialWait(String callId, String remaining); /** - * Called when the call's handoff state has changed. + * Called when the audio state changes. * - * @param callId The identifier of the call whose handoff state was changed. - * @param isHandoffEnabled True if handoff is enabled. + * @param audioState The new {@link CallAudioState}. */ - protected abstract void setHandoffEnabled(String callId, boolean isHandoffEnabled); + protected abstract void onAudioStateChanged(CallAudioState audioState); } diff --git a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl index 4187fa82b588a..ccf7e3f6c387b 100644 --- a/telecomm/java/com/android/internal/telecomm/IInCallService.aidl +++ b/telecomm/java/com/android/internal/telecomm/IInCallService.aidl @@ -17,7 +17,7 @@ package com.android.internal.telecomm; import android.telecomm.CallAudioState; -import android.telecomm.CallInfo; +import android.telecomm.InCallCall; import com.android.internal.telecomm.IInCallAdapter; @@ -31,23 +31,13 @@ import com.android.internal.telecomm.IInCallAdapter; oneway interface IInCallService { void setInCallAdapter(in IInCallAdapter inCallAdapter); - void addCall(in CallInfo callInfo); + void addCall(in InCallCall call); - void setActive(String callId); - - void setDisconnected(String callId, int disconnectCause); - - void setDialing(in String callId); - - void setOnHold(String callId); - - void onAudioStateChanged(in CallAudioState audioState); - - void setRinging(String callId); + void updateCall(in InCallCall call); void setPostDial(String callId, String remaining); void setPostDialWait(String callId, String remaining); - void setHandoffEnabled(String callId, boolean isHandoffEnabled); + void onAudioStateChanged(in CallAudioState audioState); } From c1a48ef7c37751b28ff5af3ff8b12e7ddec7eadb Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 8 Apr 2014 14:32:20 -0700 Subject: [PATCH 099/102] Fix SDK build Change-Id: I325f5f5b3fae7c8a27640106e8f3298c4e18388d --- telecomm/java/android/telecomm/InCallCall.java | 2 +- telecomm/java/android/telecomm/InCallService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/telecomm/java/android/telecomm/InCallCall.java b/telecomm/java/android/telecomm/InCallCall.java index 295df3c50661f..c3b2ae7a20292 100644 --- a/telecomm/java/android/telecomm/InCallCall.java +++ b/telecomm/java/android/telecomm/InCallCall.java @@ -73,7 +73,7 @@ public final class InCallCall implements Parcelable { /** * Reason for disconnection, values are defined in {@link DisconnectCause}. Valid when call - * state is {@link CallState.DISCONNECTED}. + * state is {@link CallState#DISCONNECTED}. */ public int getDisconnectCause() { return mDisconnectCause; diff --git a/telecomm/java/android/telecomm/InCallService.java b/telecomm/java/android/telecomm/InCallService.java index 2e58a27b50a7d..63b2020c40d77 100644 --- a/telecomm/java/android/telecomm/InCallService.java +++ b/telecomm/java/android/telecomm/InCallService.java @@ -180,7 +180,7 @@ public abstract class InCallService extends Service { * Indicates to the in-call app that the specified call is active but in a "post-dial" state * where Telecomm is now sending some dual-tone multi-frequency signaling (DTMF) tones appended * to the dialed number. Normal transitions are to {@link #setPostDialWait(String,String)} when - * the post-dial string requires user confirmation to proceed, {@link #setActive(String)} when + * the post-dial string requires user confirmation to proceed, and {@link CallState#ACTIVE} when * the post-dial tones are completed. * * @param callId The identifier of the call changing state. From e9aa1aaa257c2c78b2cb310f8c1f86de82befb85 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Thu, 10 Apr 2014 09:21:03 -0700 Subject: [PATCH 100/102] Expose CallState.NEW Expose CallState.NEW so that we have a state before DIALING. Immediately transitioning calls to DIALING is wrong, because that shouldn't happen until the CallService is actually dialing. Bug: 13902624 Change-Id: Id5ee0d4d050deb2f3038f3de8fdd265caa75f7b2 --- api/current.txt | 1 + telecomm/java/android/telecomm/CallState.java | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/current.txt b/api/current.txt index c28a7b8a012ec..29fb090e3cf31 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25067,6 +25067,7 @@ package android.telecomm { enum_constant public static final android.telecomm.CallState ACTIVE; enum_constant public static final android.telecomm.CallState DIALING; enum_constant public static final android.telecomm.CallState DISCONNECTED; + enum_constant public static final android.telecomm.CallState NEW; enum_constant public static final android.telecomm.CallState ON_HOLD; enum_constant public static final android.telecomm.CallState POST_DIAL; enum_constant public static final android.telecomm.CallState POST_DIAL_WAIT; diff --git a/telecomm/java/android/telecomm/CallState.java b/telecomm/java/android/telecomm/CallState.java index fd611cc0cc9b4..152c2023e7fd0 100644 --- a/telecomm/java/android/telecomm/CallState.java +++ b/telecomm/java/android/telecomm/CallState.java @@ -26,9 +26,8 @@ public enum CallState { /** * Indicates that a call is new and not connected. This is used as the default state internally * within Telecomm and should not be used between Telecomm and call services. Call services are - * not expected to ever interact with NEW calls so we keep this value hidden as a Telecomm - * internal-only value. - * @hide + * not expected to ever interact with NEW calls, but {@link InCallService}s will see calls in + * this state. */ NEW, From 3c7fbb2214368689e8868ca1f37c3490429c4b05 Mon Sep 17 00:00:00 2001 From: Evan Charlton Date: Fri, 11 Apr 2014 15:55:43 -0700 Subject: [PATCH 101/102] Expose a method to cancel an outgoing call Expose a method which lets CallServiceSelectors abort an outgoing call. Bug: 13980764 Change-Id: Id0c608729cb5de3e2a37b2538f1f61ed94bcb31b --- api/current.txt | 2 ++ .../java/android/telecomm/CallServiceSelector.java | 10 ++++++++++ .../android/telecomm/CallServiceSelectorAdapter.java | 12 ++++++++++++ .../telecomm/ICallServiceSelectorAdapter.aidl | 2 ++ 4 files changed, 26 insertions(+) diff --git a/api/current.txt b/api/current.txt index 4763ca836416f..61c72270c8578 100644 --- a/api/current.txt +++ b/api/current.txt @@ -25086,6 +25086,7 @@ package android.telecomm { public abstract class CallServiceSelector extends android.app.Service { ctor protected CallServiceSelector(); + method protected final void cancelOutgoingCall(android.telecomm.CallInfo); method protected final android.telecomm.CallServiceSelectorAdapter getAdapter(); method protected final java.util.Collection getCalls(); method protected void onAdapterAttached(android.telecomm.CallServiceSelectorAdapter); @@ -25094,6 +25095,7 @@ package android.telecomm { } public final class CallServiceSelectorAdapter { + method public void cancelOutgoingCall(java.lang.String); method public void setHandoffInfo(java.lang.String, android.net.Uri, android.os.Bundle); method public void setSelectedCallServices(java.lang.String, java.util.List); } diff --git a/telecomm/java/android/telecomm/CallServiceSelector.java b/telecomm/java/android/telecomm/CallServiceSelector.java index 8c9495ff136db..c9c6ff6d1eaf4 100644 --- a/telecomm/java/android/telecomm/CallServiceSelector.java +++ b/telecomm/java/android/telecomm/CallServiceSelector.java @@ -120,6 +120,16 @@ public abstract class CallServiceSelector extends Service { return mAdapter; } + /** + * Cancel the outgoing call. Any subsequent calls to {@link #select(CallInfo, List)} will be + * ignored. + * + * @param callInfo The call to canceled. + */ + protected final void cancelOutgoingCall(CallInfo callInfo) { + getAdapter().cancelOutgoingCall(callInfo.getId()); + } + /** * Lifecycle callback which is called when this {@link CallServiceSelector} has been attached * to a {@link CallServiceSelectorAdapter}, indicating {@link #getAdapter()} is now safe to use. diff --git a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java index 8635f1aacd7df..4d2e8aa120549 100644 --- a/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java +++ b/telecomm/java/android/telecomm/CallServiceSelectorAdapter.java @@ -55,6 +55,18 @@ public final class CallServiceSelectorAdapter { } } + /** + * Cancels the specified outgoing call. + * + * @param callId The ID of the call to cancel. + */ + public void cancelOutgoingCall(String callId) { + try { + mAdapter.cancelOutgoingCall(callId); + } catch (RemoteException e) { + } + } + /** * Associates handoff information with an ongoing call. Calls can switch from one call service * to another. Setting handle to a non-null value marks the call as switchable. diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl index 1b281b987e686..ad71e3c550ba2 100644 --- a/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl +++ b/telecomm/java/com/android/internal/telecomm/ICallServiceSelectorAdapter.aidl @@ -35,5 +35,7 @@ oneway interface ICallServiceSelectorAdapter { String callId, in List selectedCallServiceDescriptors); + void cancelOutgoingCall(String callId); + void setHandoffInfo(String callId, in Uri handle, in Bundle extras); } From 5d9cb82b9b47dfd3d1911458c938cad61accdc75 Mon Sep 17 00:00:00 2001 From: Sailesh Nepal Date: Tue, 15 Apr 2014 11:19:19 -0700 Subject: [PATCH 102/102] Add toString to CallServiceDescriptor Change-Id: I847dbd8cf965516ad45f91d2db5df19469e2a2f8 --- telecomm/java/android/telecomm/CallServiceDescriptor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/telecomm/java/android/telecomm/CallServiceDescriptor.java b/telecomm/java/android/telecomm/CallServiceDescriptor.java index 3bec2708fb966..dec3791a4f909 100644 --- a/telecomm/java/android/telecomm/CallServiceDescriptor.java +++ b/telecomm/java/android/telecomm/CallServiceDescriptor.java @@ -22,6 +22,7 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; +import java.util.Locale; import java.util.UUID; /** @@ -123,6 +124,13 @@ public final class CallServiceDescriptor implements Parcelable { mNetworkType == descriptor.mNetworkType; } + @Override + public String toString() { + return String.format(Locale.US, "[%s, component: %s]", + CallServiceDescriptor.class.getSimpleName(), + mComponentName == null ? "null" : mComponentName.flattenToShortString()); + } + /** * @param context {@link Context} to use for the construction of the {@link Builder}. * @return A new {@link Builder} instance.