summaryrefslogtreecommitdiffstats
path: root/telephony
diff options
context:
space:
mode:
authorSailesh Nepal <sail@google.com>2014-03-25 13:02:59 -0700
committerSailesh Nepal <sail@google.com>2014-03-25 13:02:59 -0700
commit00ffde305da868401b78f92c3ad33fef0221bf7c (patch)
tree455f8032ecb0dddd303edf9c51380e7a7a47a38e /telephony
parentfa1ce103c65c9f4eba708f1555a59959a4581e4e (diff)
parent2d72d000939acc10ba0f5000689ad86483b7c19e (diff)
downloadframeworks_base-00ffde305da868401b78f92c3ad33fef0221bf7c.zip
frameworks_base-00ffde305da868401b78f92c3ad33fef0221bf7c.tar.gz
frameworks_base-00ffde305da868401b78f92c3ad33fef0221bf7c.tar.bz2
resolved conflicts for merge of 2d72d000 to master-nova
Change-Id: Icfb617ffab2da2f8805e4628e75e006c620b479d
Diffstat (limited to 'telephony')
-rw-r--r--telephony/java/android/telephony/CallStateListener.java36
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java506
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephony.aidl51
-rw-r--r--telephony/java/com/android/internal/telephony/ITelephonyListener.aidl38
4 files changed, 629 insertions, 2 deletions
diff --git a/telephony/java/android/telephony/CallStateListener.java b/telephony/java/android/telephony/CallStateListener.java
new file mode 100644
index 0000000..e2ffbfa
--- /dev/null
+++ b/telephony/java/android/telephony/CallStateListener.java
@@ -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.telephony;
+
+import android.annotation.PrivateApi;
+
+/** @hide */
+@PrivateApi
+public interface CallStateListener {
+ /**
+ * Notify of a new or updated call.
+ * Any time the state of a call is updated, it will alert any listeners. This includes changes
+ * of state such as when a call is put on hold or conferenced.
+ *
+ * @param callId a unique ideCntifier for a given call that can be used to track state changes
+ * @param state the new state of the call.
+ * {@see com.android.services.telephony.common.Call$State}
+ * @param number the phone number of the call. For some states, this may be blank. However, it
+ * will be populated for any initial state.
+ */
+ public void onCallStateChanged(int callId, int state, String number);
+}
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 413f9e50..48e4b2e 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -21,12 +21,16 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.content.ComponentName;
import android.content.Context;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
+import android.util.Log;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ITelephony;
+import com.android.internal.telephony.ITelephonyListener;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
@@ -34,6 +38,7 @@ import com.android.internal.telephony.TelephonyProperties;
import java.io.FileInputStream;
import java.io.IOException;
+import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -97,6 +102,38 @@ public class TelephonyManager {
}
private static TelephonyManager sInstance = new TelephonyManager();
+ private HashMap<CallStateListener, Listener> mListeners
+ = new HashMap<CallStateListener, Listener>();
+
+ private static class Listener extends ITelephonyListener.Stub {
+ final CallStateListener mListener;
+ private static final int WHAT = 1;
+
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(Message msg) {
+ mListener.onCallStateChanged(msg.arg1, msg.arg2, (String) msg.obj);
+ }
+ };
+
+ Listener(CallStateListener listener) {
+ mListener = listener;
+ }
+
+ @Override
+ public void onUpdate(final int callId, final int state, final String number) {
+ if (mHandler != null) {
+ mHandler.sendMessage(mHandler.obtainMessage(WHAT, callId, state, number));
+ }
+ }
+
+ void clearQueue() {
+ mHandler.removeMessages(WHAT);
+
+ // Don't accept more incoming binder calls either.
+ mHandler = null;
+ }
+ }
/** @hide
/* @deprecated - use getSystemService as described above */
@@ -1969,4 +2006,473 @@ public class TelephonyManager {
}
return false;
}
+
+ /**
+ * Expose the rest of ITelephony to @PrivateApi
+ */
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void dial(String number) {
+ try {
+ getITelephony().dial(number);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#dial");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void call(String callingPackage, String number) {
+ try {
+ getITelephony().call(callingPackage, number);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#call");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean showCallScreen() {
+ try {
+ return getITelephony().showCallScreen();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#showCallScreen");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean showCallScreenWithDialpad(boolean showDialpad) {
+ try {
+ return getITelephony().showCallScreenWithDialpad(showDialpad);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#showCallScreenWithDialpad");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean endCall() {
+ try {
+ return getITelephony().endCall();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#endCall");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void answerRingingCall() {
+ try {
+ getITelephony().answerRingingCall();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#answerRingingCall");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void toggleHold() {
+ try {
+ getITelephony().toggleHold();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#toggleHold");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void merge() {
+ try {
+ getITelephony().merge();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#merge");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void swap() {
+ try {
+ getITelephony().swap();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#swap");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void mute(boolean mute) {
+ try {
+ getITelephony().mute(mute);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#mute");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void silenceRinger() {
+ try {
+ getITelephony().silenceRinger();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#silenceRinger");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isOffhook() {
+ try {
+ return getITelephony().isOffhook();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isOffhook");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isRinging() {
+ try {
+ return getITelephony().isRinging();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isRinging");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isIdle() {
+ try {
+ return getITelephony().isIdle();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isIdle");
+ }
+ return true;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isRadioOn() {
+ try {
+ return getITelephony().isRadioOn();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isRadioOn");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isSimPinEnabled() {
+ try {
+ return getITelephony().isSimPinEnabled();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isSimPinEnabled");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void cancelMissedCallsNotification() {
+ try {
+ getITelephony().cancelMissedCallsNotification();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#cancelMissedCallsNotification");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean supplyPin(String pin) {
+ try {
+ return getITelephony().supplyPin(pin);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#supplyPin");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean supplyPuk(String puk, String pin) {
+ try {
+ return getITelephony().supplyPuk(puk, pin);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#supplyPuk");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public int[] supplyPinReportResult(String pin) {
+ try {
+ return getITelephony().supplyPinReportResult(pin);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#supplyPinReportResult");
+ }
+ return new int[0];
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public int[] supplyPukReportResult(String puk, String pin) {
+ try {
+ return getITelephony().supplyPukReportResult(puk, pin);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#]");
+ }
+ return new int[0];
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean handlePinMmi(String dialString) {
+ try {
+ return getITelephony().handlePinMmi(dialString);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#handlePinMmi");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void toggleRadioOnOff() {
+ try {
+ getITelephony().toggleRadioOnOff();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#toggleRadioOnOff");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean setRadio(boolean turnOn) {
+ try {
+ return getITelephony().setRadio(turnOn);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#setRadio");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean setRadioPower(boolean turnOn) {
+ try {
+ return getITelephony().setRadioPower(turnOn);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#setRadioPower");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void updateServiceLocation() {
+ try {
+ getITelephony().updateServiceLocation();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#updateServiceLocation");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public int enableApnType(String type) {
+ try {
+ return getITelephony().enableApnType(type);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#enableApnType");
+ }
+ return PhoneConstants.APN_REQUEST_FAILED;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public int disableApnType(String type) {
+ try {
+ return getITelephony().disableApnType(type);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#disableApnType");
+ }
+ return PhoneConstants.APN_REQUEST_FAILED;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean enableDataConnectivity() {
+ try {
+ return getITelephony().enableDataConnectivity();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#enableDataConnectivity");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean disableDataConnectivity() {
+ try {
+ return getITelephony().disableDataConnectivity();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#disableDataConnectivity");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean isDataConnectivityPossible() {
+ try {
+ return getITelephony().isDataConnectivityPossible();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#isDataConnectivityPossible");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public boolean needsOtaServiceProvisioning() {
+ try {
+ return getITelephony().needsOtaServiceProvisioning();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#needsOtaServiceProvisioning");
+ }
+ return false;
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void playDtmfTone(char digit, boolean timedShortCode) {
+ try {
+ getITelephony().playDtmfTone(digit, timedShortCode);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#playDtmfTone");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void stopDtmfTone() {
+ try {
+ getITelephony().stopDtmfTone();
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#stopDtmfTone");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void addCallStateListener(CallStateListener listener) {
+ try {
+ if (listener == null) {
+ throw new RuntimeException("Listener can't be null");
+ }
+ if (!mListeners.containsKey(listener)) {
+ final Listener l = new Listener(listener);
+ mListeners.put(listener, l);
+ getITelephony().addListener(l);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#addListener");
+ }
+ }
+
+ /**
+ * @hide
+ * @PrivateApi
+ */
+ public void removeCallStateListener(CallStateListener listener) {
+ try {
+ final Listener l = mListeners.remove(listener);
+ if (l != null) {
+ // Make sure that no callbacks that are already in flight come.
+ l.clearQueue();
+ getITelephony().removeListener(l);
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "Error calling ITelephony#removeListener");
+ }
+ }
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephony.aidl b/telephony/java/com/android/internal/telephony/ITelephony.aidl
index e2abb9a..ab2a9b8 100644
--- a/telephony/java/com/android/internal/telephony/ITelephony.aidl
+++ b/telephony/java/com/android/internal/telephony/ITelephony.aidl
@@ -16,10 +16,14 @@
package com.android.internal.telephony;
-import android.os.Bundle;
import android.content.ComponentName;
-import android.telephony.NeighboringCellInfo;
+import android.os.Bundle;
import android.telephony.CellInfo;
+import android.telephony.NeighboringCellInfo;
+
+import com.android.internal.telephony.ITelephonyListener;
+
+import java.util.List;
import java.util.List;
@@ -459,4 +463,47 @@ interface ITelephony {
* @return true on success; false on any failure.
*/
boolean setPreferredNetworkType(int networkType);
+
+ /**
+ * Put a call on hold.
+ */
+ void toggleHold();
+
+ /**
+ * Merge foreground and background calls.
+ */
+ void merge();
+
+ /**
+ * Swap foreground and background calls.
+ */
+ void swap();
+
+ /**
+ * Mute the phone.
+ */
+ void mute(boolean mute);
+
+ /**
+ * Start playing DTMF tone for the specified digit.
+ *
+ * @param digit the digit that corresponds with the desired tone.
+ * @param timedShortcode whether the specified digit should be played as a timed short code.
+ */
+ void playDtmfTone(char digit, boolean timedShortCode);
+
+ /**
+ * Stop playing DTMF tones.
+ */
+ void stopDtmfTone();
+
+ /**
+ * Register a callback.
+ */
+ void addListener(ITelephonyListener listener);
+
+ /**
+ * Unregister a callback.
+ */
+ void removeListener(ITelephonyListener listener);
}
diff --git a/telephony/java/com/android/internal/telephony/ITelephonyListener.aidl b/telephony/java/com/android/internal/telephony/ITelephonyListener.aidl
new file mode 100644
index 0000000..8f5441c
--- /dev/null
+++ b/telephony/java/com/android/internal/telephony/ITelephonyListener.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 com.android.internal.telephony;
+
+/**
+ * Interface used to register a listener that gets more detailed call state information than
+ * {@link android.telephony.PhoneStateListener}
+ *
+ * {@hide}
+ */
+oneway interface ITelephonyListener {
+ /**
+ * Notify of a new or updated call.
+ * Any time the state of a call is updated, it will alert any listeners. This includes changes
+ * of state such as when a call is put on hold or conferenced.
+ *
+ * @param callId a unique identifier for a given call that can be used to track state changes
+ * @param state the new state of the call.
+ * {@see com.android.services.telephony.common.Call$State}
+ * @param number the phone number of the call. For some states, this may be blank. However, it
+ * will be populated for any initial state.
+ */
+ void onUpdate(int callId, int state, String number);
+}