summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/TelephonyRegistry.java
diff options
context:
space:
mode:
authorWink Saville <wink@google.com>2014-02-13 08:44:55 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-13 08:44:55 +0000
commit27bf55c8159e7f883ddc839453d5a12374ddc50a (patch)
treeeb49c7485ec2acd9a6d054821ec6de732218d715 /services/core/java/com/android/server/TelephonyRegistry.java
parent321cd18ab21966383d75ba1e9c09b0adf932383b (diff)
parent16c0b295ef069e128a4e01fd2f72da06784950a1 (diff)
downloadframeworks_base-27bf55c8159e7f883ddc839453d5a12374ddc50a.zip
frameworks_base-27bf55c8159e7f883ddc839453d5a12374ddc50a.tar.gz
frameworks_base-27bf55c8159e7f883ddc839453d5a12374ddc50a.tar.bz2
am 16c0b295: am bba3a694: Merge "Telephony API extension v2"
* commit '16c0b295ef069e128a4e01fd2f72da06784950a1': Telephony API extension v2
Diffstat (limited to 'services/core/java/com/android/server/TelephonyRegistry.java')
-rw-r--r--services/core/java/com/android/server/TelephonyRegistry.java179
1 files changed, 169 insertions, 10 deletions
diff --git a/services/core/java/com/android/server/TelephonyRegistry.java b/services/core/java/com/android/server/TelephonyRegistry.java
index 699d79e..77f5182 100644
--- a/services/core/java/com/android/server/TelephonyRegistry.java
+++ b/services/core/java/com/android/server/TelephonyRegistry.java
@@ -37,6 +37,10 @@ import android.telephony.ServiceState;
import android.telephony.SignalStrength;
import android.telephony.CellInfo;
import android.telephony.TelephonyManager;
+import android.telephony.DisconnectCause;
+import android.telephony.PreciseCallState;
+import android.telephony.PreciseDataConnectionState;
+import android.telephony.PreciseDisconnectCause;
import android.text.TextUtils;
import android.util.Slog;
@@ -125,6 +129,17 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
private List<CellInfo> mCellInfo = null;
+ private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
+
+ private PreciseCallState mPreciseCallState = new PreciseCallState();
+
+ private PreciseDataConnectionState mPreciseDataConnectionState =
+ new PreciseDataConnectionState();
+
static final int PHONE_STATE_PERMISSION_MASK =
PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
PhoneStateListener.LISTEN_CALL_STATE |
@@ -132,6 +147,10 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR;
+ static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
+ PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
+ PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
+
private static final int MSG_USER_SWITCHED = 1;
private final Handler mHandler = new Handler() {
@@ -305,6 +324,21 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
remove(r.binder);
}
}
+ if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
+ if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(
+ mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ remove(r.binder);
+ }
+ }
}
}
} else {
@@ -533,30 +567,47 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
handleRemoveListLocked();
}
+ mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
+ apnType, apn, reason, linkProperties, "");
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
}
broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
apnType, linkProperties, linkCapabilities, roaming);
+ broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
+ linkProperties, "");
}
public void notifyDataConnectionFailed(String reason, String apnType) {
if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
return;
}
- /*
- * This is commented out because there is no onDataConnectionFailed callback
- * in PhoneStateListener. There should be.
synchronized (mRecords) {
- mDataConnectionFailedReason = reason;
- final int N = mRecords.size();
- for (int i=N-1; i>=0; i--) {
- Record r = mRecords.get(i);
- if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_FAILED) != 0) {
- // XXX
+ mPreciseDataConnectionState = new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ apnType, "", reason, null, "");
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
}
}
+ handleRemoveListLocked();
}
- */
broadcastDataConnectionFailed(reason, apnType);
+ broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
}
public void notifyCellLocation(Bundle cellLocation) {
@@ -602,6 +653,81 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
+ public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
+ int backgroundCallState) {
+ if (!checkNotifyPermission("notifyPreciseCallState()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mRingingCallState = ringingCallState;
+ mForegroundCallState = foregroundCallState;
+ mBackgroundCallState = backgroundCallState;
+ mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
+ backgroundCallState,
+ DisconnectCause.NOT_VALID,
+ PreciseDisconnectCause.NOT_VALID);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
+ DisconnectCause.NOT_VALID,
+ PreciseDisconnectCause.NOT_VALID);
+ }
+
+ public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
+ if (!checkNotifyPermission("notifyDisconnectCause()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
+ mBackgroundCallState, disconnectCause, preciseDisconnectCause);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
+ try {
+ r.callback.onPreciseCallStateChanged(mPreciseCallState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
+ mBackgroundCallState, disconnectCause, preciseDisconnectCause);
+ }
+
+ public void notifyPreciseDataConnectionFailed(String reason, String apnType,
+ String apn, String failCause) {
+ if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
+ return;
+ }
+ synchronized (mRecords) {
+ mPreciseDataConnectionState = new PreciseDataConnectionState(
+ TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
+ apnType, apn, reason, null, failCause);
+ for (Record r : mRecords) {
+ if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
+ try {
+ r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
+ } catch (RemoteException ex) {
+ mRemoveList.add(r.binder);
+ }
+ }
+ }
+ handleRemoveListLocked();
+ }
+ broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
+ TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
+ }
+
@Override
public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
@@ -738,6 +864,33 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
}
+ private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
+ int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
+ Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
+ intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
+ intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
+ intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
+ intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
+ intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE);
+ }
+
+ private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
+ String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) {
+ Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
+ intent.putExtra(PhoneConstants.STATE_KEY, state);
+ intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
+ if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
+ if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
+ if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
+ if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
+ if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
+
+ mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE);
+ }
+
private boolean checkNotifyPermission(String method) {
if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
== PackageManager.PERMISSION_GRANTED) {
@@ -766,6 +919,12 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.READ_PHONE_STATE, null);
}
+
+ if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
+
+ }
}
private void handleRemoveListLocked() {