Loading Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -372,6 +372,7 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ telephony/java/com/android/internal/telephony/ISub.aidl \ telephony/java/com/android/internal/telephony/ISub.aidl \ telephony/java/com/android/internal/telephony/IMms.aidl \ telephony/java/com/android/internal/telephony/IMms.aidl \ Loading api/current.txt +15 −16 Original line number Original line Diff line number Diff line Loading @@ -28424,6 +28424,7 @@ package android.telephony { method public void downloadMultimediaMessage(android.content.Context, java.lang.String, android.net.Uri, android.os.Bundle, android.app.PendingIntent); method public void downloadMultimediaMessage(android.content.Context, java.lang.String, android.net.Uri, android.os.Bundle, android.app.PendingIntent); method public android.os.Bundle getCarrierConfigValues(); method public android.os.Bundle getCarrierConfigValues(); method public static android.telephony.SmsManager getDefault(); method public static android.telephony.SmsManager getDefault(); method public static int getDefaultSmsSubscriptionId(); method public static android.telephony.SmsManager getSmsManagerForSubscriber(int); method public static android.telephony.SmsManager getSmsManagerForSubscriber(int); method public int getSubId(); method public int getSubId(); method public void injectSmsPdu(byte[], java.lang.String, android.app.PendingIntent); method public void injectSmsPdu(byte[], java.lang.String, android.app.PendingIntent); Loading Loading @@ -28542,7 +28543,7 @@ package android.telephony { field public byte[] encodedScAddress; field public byte[] encodedScAddress; } } public class SubInfoRecord implements android.os.Parcelable { public class SubscriptionInfo implements android.os.Parcelable { method public android.graphics.Bitmap createIconBitmap(android.content.Context); method public android.graphics.Bitmap createIconBitmap(android.content.Context); method public int describeContents(); method public int describeContents(); method public int getDataRoaming(); method public int getDataRoaming(); Loading @@ -28556,25 +28557,23 @@ package android.telephony { method public int getSimSlotIndex(); method public int getSimSlotIndex(); method public int getSubscriptionId(); method public int getSubscriptionId(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.SubInfoRecord> CREATOR; field public static final android.os.Parcelable.Creator<android.telephony.SubscriptionInfo> CREATOR; } public class SubscriptionListener { ctor public SubscriptionListener(); ctor public SubscriptionListener(android.os.Looper); method public void onSubscriptionInfoChanged(); field public static final int LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED = 1; // 0x1 } } public class SubscriptionManager implements android.provider.BaseColumns { public class SubscriptionManager implements android.provider.BaseColumns { method public static java.util.List<android.telephony.SubInfoRecord> getActiveSubInfoList(); method public static java.util.List<android.telephony.SubscriptionInfo> getActiveSubscriptionInfoList(); method public static int getDefaultSmsSubId(); method public static android.telephony.SubscriptionInfo getSubscriptionInfoForSubscriber(int); method public static int getSlotId(int); method public static java.util.List<android.telephony.SubscriptionInfo> getSubscriptionInfoUsingSlotId(int); method public static android.telephony.SubInfoRecord getSubInfoForSubscriber(int); method public static void register(android.content.Context, android.telephony.SubscriptionListener, int); method public static java.util.List<android.telephony.SubInfoRecord> getSubInfoUsingSlotId(int); method public static void unregister(android.content.Context, android.telephony.SubscriptionListener); method public static boolean isValidSubId(int); field public static final int ASK_USER_SUB_ID = -1001; // 0xfffffc17 field public static final int DEFAULT_PHONE_ID = 2147483647; // 0x7fffffff field public static final int DEFAULT_SUB_ID = 2147483647; // 0x7fffffff field public static final int INVALID_PHONE_ID = -1000; // 0xfffffc18 field public static final int INVALID_SLOT_ID = -1000; // 0xfffffc18 field public static final int INVALID_SUB_ID = -1000; // 0xfffffc18 field public static final int INVALID_SUB_ID = -1000; // 0xfffffc18 field public static final java.lang.String MCC = "mcc"; field public static final java.lang.String MNC = "mnc"; field public static final int SIM_NOT_INSERTED = -1; // 0xffffffff } } public class TelephonyManager { public class TelephonyManager { services/core/java/com/android/server/TelephonyRegistry.java +143 −23 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.os.UserHandle; import android.telephony.CellLocation; import android.telephony.CellLocation; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.Rlog; import android.telephony.Rlog; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionListener; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; Loading @@ -56,6 +58,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.io.PrintWriter; import com.android.internal.app.IBatteryStats; import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.ISubscriptionListener; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.DefaultPhoneNotifier; import com.android.internal.telephony.DefaultPhoneNotifier; Loading Loading @@ -90,19 +93,30 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { IBinder binder; IBinder binder; IPhoneStateListener callback; IPhoneStateListener callback; ISubscriptionListener subscriptionListenerCallback; int callerUid; int callerUid; int events; int events; int subId; int subId = SubscriptionManager.INVALID_SUB_ID; int phoneId; int phoneId = SubscriptionManager.INVALID_PHONE_ID; boolean matchPhoneStateListenerEvent(int events) { return (callback != null) && ((events & this.events) != 0); } boolean matchSubscriptionListenerEvent(int events) { return (subscriptionListenerCallback != null) && ((events & this.events) != 0); } @Override @Override public String toString() { public String toString() { return "{pkgForDebug=" + pkgForDebug + " callerUid=" + callerUid + " subId=" + subId + return "{pkgForDebug=" + pkgForDebug + " binder=" + binder + " callback=" + callback " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}"; + " subscriptionListenererCallback=" + subscriptionListenerCallback + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}"; } } } } Loading Loading @@ -324,6 +338,101 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mContext.registerReceiver(mBroadcastReceiver, filter); mContext.registerReceiver(mBroadcastReceiver, filter); } } @Override public void registerSubscriptionListener(String pkgForDebug, ISubscriptionListener callback, int events) { int callerUid = UserHandle.getCallingUserId(); int myUid = UserHandle.myUserId(); if (VDBG) { log("listen sl: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) + " myUid=" + myUid + " callerUid=" + callerUid + " callback=" + callback + " callback.asBinder=" + callback.asBinder()); } if (events != 0) { /* Checks permission and throws Security exception */ checkSubscriptionListenerPermission(events); Record r = null; synchronized (mRecords) { // register find_and_add: { IBinder b = callback.asBinder(); final int N = mRecords.size(); for (int i = 0; i < N; i++) { r = mRecords.get(i); if (b == r.binder) { break find_and_add; } } r = new Record(); r.binder = b; mRecords.add(r); if (DBG) log("listen sl: add new record"); } r.subscriptionListenerCallback = callback; r.pkgForDebug = pkgForDebug; r.callerUid = callerUid; r.events = events; if (DBG) { log("listen sl: Register r=" + r); } } // Always notify when a listen is established. if (r.matchSubscriptionListenerEvent( SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED)) { try { if (VDBG) log("listen sl: send to r=" + r); r.subscriptionListenerCallback.onSubscriptionInfoChanged(); if (VDBG) log("listen sl: sent to r=" + r); } catch (RemoteException e) { if (VDBG) log("listen sl: remote exception sending to r=" + r + " e=" + e); remove(r.binder); } } } else { if (DBG) log("listen sl: Unregister as event is LISTEN_NONE"); unregisterSubscriptionListener(pkgForDebug, callback); } } @Override public void unregisterSubscriptionListener(String pkgForDebug, ISubscriptionListener callback) { if (DBG) log("listen sl: Unregister as event is LISTEN_NONE"); remove(callback.asBinder()); } private void checkSubscriptionListenerPermission(int events) { if ((events & SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED) != 0) { mContext.enforceCallingOrSelfPermission( SubscriptionListener.PERMISSION_LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED, null); } } @Override public void notifySubscriptionInfoChanged() { if (VDBG) log("notifySubscriptionInfoChanged:"); synchronized (mRecords) { mRemoveList.clear(); for (Record r : mRecords) { if (r.matchSubscriptionListenerEvent( SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED)) { try { if (VDBG) log("notifySubscriptionInfoChanged: send to r=" + r); r.subscriptionListenerCallback.onSubscriptionInfoChanged(); if (VDBG) log("notifySubscriptionInfoChanged: sent to r=" + r); } catch (RemoteException ex) { if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r); mRemoveList.add(r.binder); } } } handleRemoveListLocked(); } } @Override @Override public void listen(String pkgForDebug, IPhoneStateListener callback, int events, public void listen(String pkgForDebug, IPhoneStateListener callback, int events, boolean notifyNow) { boolean notifyNow) { Loading Loading @@ -513,6 +622,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { final int recordCount = mRecords.size(); final int recordCount = mRecords.size(); for (int i = 0; i < recordCount; i++) { for (int i = 0; i < recordCount; i++) { if (mRecords.get(i).binder == binder) { if (mRecords.get(i).binder == binder) { if (VDBG) log("remove: binder=" + binder); mRecords.remove(i); mRecords.remove(i); return; return; } } Loading @@ -531,7 +641,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) { (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) { try { try { r.callback.onCallStateChanged(state, incomingNumber); r.callback.onCallStateChanged(state, incomingNumber); Loading Loading @@ -559,7 +669,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mCallState[phoneId] = state; mCallState[phoneId] = state; mCallIncomingNumber[phoneId] = incomingNumber; mCallIncomingNumber[phoneId] = incomingNumber; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && (r.subId == subId) && (r.subId == subId) && (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) { (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) { try { try { Loading Loading @@ -595,7 +705,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state); + " phoneId=" + phoneId + " state=" + state); } } if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { if (DBG) { if (DBG) { Loading Loading @@ -640,7 +750,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " ss=" + signalStrength); + " phoneId=" + phoneId + " ss=" + signalStrength); } } if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { if (DBG) { if (DBG) { Loading @@ -653,7 +764,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mRemoveList.add(r.binder); mRemoveList.add(r.binder); } } } } if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) && idMatch(r.subId, subId, phoneId)){ idMatch(r.subId, subId, phoneId)){ try { try { int gsmSignalStrength = signalStrength.getGsmSignalStrength(); int gsmSignalStrength = signalStrength.getGsmSignalStrength(); Loading Loading @@ -750,7 +861,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { if (validatePhoneId(phoneId)) { mMessageWaiting[phoneId] = mwi; mMessageWaiting[phoneId] = mwi; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { r.callback.onMessageWaitingIndicatorChanged(mwi); r.callback.onMessageWaitingIndicatorChanged(mwi); Loading Loading @@ -781,7 +893,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { if (validatePhoneId(phoneId)) { mCallForwarding[phoneId] = cfi; mCallForwarding[phoneId] = cfi; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { r.callback.onCallForwardingIndicatorChanged(cfi); r.callback.onCallForwardingIndicatorChanged(cfi); Loading @@ -807,7 +920,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { int phoneId = SubscriptionManager.getPhoneId(subId); int phoneId = SubscriptionManager.getPhoneId(subId); mDataActivity[phoneId] = state; mDataActivity[phoneId] = state; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY)) { try { try { r.callback.onDataActivity(state); r.callback.onDataActivity(state); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -878,7 +991,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { + ", " + mDataConnectionNetworkType[phoneId] + ")"); + ", " + mDataConnectionNetworkType[phoneId] + ")"); } } for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { log("Notify data connection state changed on sub: " + log("Notify data connection state changed on sub: " + Loading @@ -895,7 +1009,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, apnType, apn, reason, linkProperties, ""); apnType, apn, reason, linkProperties, ""); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -930,7 +1045,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, ""); apnType, "", reason, null, ""); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -989,7 +1105,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { mOtaspMode = otaspMode; mOtaspMode = otaspMode; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) { try { try { r.callback.onOtaspChanged(otaspMode); r.callback.onOtaspChanged(otaspMode); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1015,7 +1131,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { DisconnectCause.NOT_VALID, DisconnectCause.NOT_VALID, PreciseDisconnectCause.NOT_VALID); PreciseDisconnectCause.NOT_VALID); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { try { try { r.callback.onPreciseCallStateChanged(mPreciseCallState); r.callback.onPreciseCallStateChanged(mPreciseCallState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1038,7 +1154,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, mBackgroundCallState, disconnectCause, preciseDisconnectCause); mBackgroundCallState, disconnectCause, preciseDisconnectCause); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { try { try { r.callback.onPreciseCallStateChanged(mPreciseCallState); r.callback.onPreciseCallStateChanged(mPreciseCallState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1062,7 +1178,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); apnType, apn, reason, null, failCause); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1083,7 +1200,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { mVoLteServiceState = lteState; mVoLteServiceState = lteState; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) { try { try { r.callback.onVoLteServiceStateChanged( r.callback.onVoLteServiceStateChanged( new VoLteServiceState(mVoLteServiceState)); new VoLteServiceState(mVoLteServiceState)); Loading @@ -1106,7 +1223,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (VDBG) { if (VDBG) { log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); } } if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) && if ((r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) && ((r.subId == subId) || ((r.subId == subId) || (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) { (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) { try { try { Loading Loading @@ -1337,7 +1455,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } private void handleRemoveListLocked() { private void handleRemoveListLocked() { if (mRemoveList.size() > 0) { int size = mRemoveList.size(); if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size); if (size > 0) { for (IBinder b: mRemoveList) { for (IBinder b: mRemoveList) { remove(b); remove(b); } } Loading @@ -1351,7 +1471,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { boolean valid = false; boolean valid = false; try { try { foregroundUser = ActivityManager.getCurrentUser(); foregroundUser = ActivityManager.getCurrentUser(); valid = r.callerUid == foregroundUser && (r.events & events) != 0; valid = r.callerUid == foregroundUser && r.matchPhoneStateListenerEvent(events); if (DBG | DBG_LOC) { if (DBG | DBG_LOC) { log("validateEventsAndUserLocked: valid=" + valid log("validateEventsAndUserLocked: valid=" + valid + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser Loading services/core/java/com/android/server/location/GpsLocationProvider.java +39 −20 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,9 @@ import android.provider.Settings; import android.provider.Telephony.Carriers; import android.provider.Telephony.Carriers; import android.provider.Telephony.Sms.Intents; import android.provider.Telephony.Sms.Intents; import android.telephony.SmsMessage; import android.telephony.SmsMessage; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.text.TextUtils; Loading @@ -88,6 +91,7 @@ import java.io.StringReader; import java.net.InetAddress; import java.net.InetAddress; import java.net.UnknownHostException; import java.net.UnknownHostException; import java.util.Date; import java.util.Date; import java.util.List; import java.util.Map.Entry; import java.util.Map.Entry; import java.util.Properties; import java.util.Properties; Loading Loading @@ -452,10 +456,21 @@ public class GpsLocationProvider implements LocationProviderInterface { || Intent.ACTION_SCREEN_OFF.equals(action) || Intent.ACTION_SCREEN_OFF.equals(action) || Intent.ACTION_SCREEN_ON.equals(action)) { || Intent.ACTION_SCREEN_ON.equals(action)) { updateLowPowerMode(); updateLowPowerMode(); } else if (action.equals(SIM_STATE_CHANGED) } else if (action.equals(SIM_STATE_CHANGED)) { || action.equals(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE) subscriptionOrSimChanged(context); || action.equals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED)) { } Log.d(TAG, "received SIM realted action: " + action); } }; private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() { @Override public void onSubscriptionInfoChanged() { subscriptionOrSimChanged(mContext); } }; private void subscriptionOrSimChanged(Context context) { Log.d(TAG, "received SIM realted action: "); TelephonyManager phone = (TelephonyManager) TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mContext.getSystemService(Context.TELEPHONY_SERVICE); String mccMnc = phone.getSimOperator(); String mccMnc = phone.getSimOperator(); Loading @@ -469,8 +484,6 @@ public class GpsLocationProvider implements LocationProviderInterface { Log.d(TAG, "SIM MCC/MNC is still not available"); Log.d(TAG, "SIM MCC/MNC is still not available"); } } } } } }; private void checkSmsSuplInit(Intent intent) { private void checkSmsSuplInit(Intent intent) { SmsMessage[] messages = Intents.getMessagesFromIntent(intent); SmsMessage[] messages = Intents.getMessagesFromIntent(intent); Loading Loading @@ -626,6 +639,16 @@ public class GpsLocationProvider implements LocationProviderInterface { mNetInitiatedListener, mNetInitiatedListener, mSuplEsEnabled); mSuplEsEnabled); // TODO: When this object "finishes" we should unregister by invoking // SubscriptionManager.unregister(mContext, mSubscriptionListener); // This is not strictly necessary because it will be unregistered if the // notification fails but it is good form. // Register for SubscriptionInfo list changes which is guaranteed // to invoke onSubscriptionInfoChanged the first time. SubscriptionManager.register(mContext, mSubscriptionListener, SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED); // construct handler, listen for events // construct handler, listen for events mHandler = new ProviderHandler(looper); mHandler = new ProviderHandler(looper); listenForBroadcasts(); listenForBroadcasts(); Loading Loading @@ -735,10 +758,6 @@ public class GpsLocationProvider implements LocationProviderInterface { intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(SIM_STATE_CHANGED); intentFilter.addAction(SIM_STATE_CHANGED); // TODO: remove the use TelephonyIntents. We are using it because SIM_STATE_CHANGED // is not reliable at the moment. intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE); intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED); mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler); mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler); } } Loading telephony/java/android/telephony/SubInfoRecord.aidl→telephony/java/android/telephony/SubscriptionInfo.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -16,4 +16,4 @@ package android.telephony; package android.telephony; parcelable SubInfoRecord; parcelable SubscriptionInfo; Loading
Android.mk +1 −0 Original line number Original line Diff line number Diff line Loading @@ -372,6 +372,7 @@ LOCAL_SRC_FILES += \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/ITelephony.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ISms.aidl \ telephony/java/com/android/internal/telephony/ISubscriptionListener.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ telephony/java/com/android/internal/telephony/IWapPushManager.aidl \ telephony/java/com/android/internal/telephony/ISub.aidl \ telephony/java/com/android/internal/telephony/ISub.aidl \ telephony/java/com/android/internal/telephony/IMms.aidl \ telephony/java/com/android/internal/telephony/IMms.aidl \ Loading
api/current.txt +15 −16 Original line number Original line Diff line number Diff line Loading @@ -28424,6 +28424,7 @@ package android.telephony { method public void downloadMultimediaMessage(android.content.Context, java.lang.String, android.net.Uri, android.os.Bundle, android.app.PendingIntent); method public void downloadMultimediaMessage(android.content.Context, java.lang.String, android.net.Uri, android.os.Bundle, android.app.PendingIntent); method public android.os.Bundle getCarrierConfigValues(); method public android.os.Bundle getCarrierConfigValues(); method public static android.telephony.SmsManager getDefault(); method public static android.telephony.SmsManager getDefault(); method public static int getDefaultSmsSubscriptionId(); method public static android.telephony.SmsManager getSmsManagerForSubscriber(int); method public static android.telephony.SmsManager getSmsManagerForSubscriber(int); method public int getSubId(); method public int getSubId(); method public void injectSmsPdu(byte[], java.lang.String, android.app.PendingIntent); method public void injectSmsPdu(byte[], java.lang.String, android.app.PendingIntent); Loading Loading @@ -28542,7 +28543,7 @@ package android.telephony { field public byte[] encodedScAddress; field public byte[] encodedScAddress; } } public class SubInfoRecord implements android.os.Parcelable { public class SubscriptionInfo implements android.os.Parcelable { method public android.graphics.Bitmap createIconBitmap(android.content.Context); method public android.graphics.Bitmap createIconBitmap(android.content.Context); method public int describeContents(); method public int describeContents(); method public int getDataRoaming(); method public int getDataRoaming(); Loading @@ -28556,25 +28557,23 @@ package android.telephony { method public int getSimSlotIndex(); method public int getSimSlotIndex(); method public int getSubscriptionId(); method public int getSubscriptionId(); method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator<android.telephony.SubInfoRecord> CREATOR; field public static final android.os.Parcelable.Creator<android.telephony.SubscriptionInfo> CREATOR; } public class SubscriptionListener { ctor public SubscriptionListener(); ctor public SubscriptionListener(android.os.Looper); method public void onSubscriptionInfoChanged(); field public static final int LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED = 1; // 0x1 } } public class SubscriptionManager implements android.provider.BaseColumns { public class SubscriptionManager implements android.provider.BaseColumns { method public static java.util.List<android.telephony.SubInfoRecord> getActiveSubInfoList(); method public static java.util.List<android.telephony.SubscriptionInfo> getActiveSubscriptionInfoList(); method public static int getDefaultSmsSubId(); method public static android.telephony.SubscriptionInfo getSubscriptionInfoForSubscriber(int); method public static int getSlotId(int); method public static java.util.List<android.telephony.SubscriptionInfo> getSubscriptionInfoUsingSlotId(int); method public static android.telephony.SubInfoRecord getSubInfoForSubscriber(int); method public static void register(android.content.Context, android.telephony.SubscriptionListener, int); method public static java.util.List<android.telephony.SubInfoRecord> getSubInfoUsingSlotId(int); method public static void unregister(android.content.Context, android.telephony.SubscriptionListener); method public static boolean isValidSubId(int); field public static final int ASK_USER_SUB_ID = -1001; // 0xfffffc17 field public static final int DEFAULT_PHONE_ID = 2147483647; // 0x7fffffff field public static final int DEFAULT_SUB_ID = 2147483647; // 0x7fffffff field public static final int INVALID_PHONE_ID = -1000; // 0xfffffc18 field public static final int INVALID_SLOT_ID = -1000; // 0xfffffc18 field public static final int INVALID_SUB_ID = -1000; // 0xfffffc18 field public static final int INVALID_SUB_ID = -1000; // 0xfffffc18 field public static final java.lang.String MCC = "mcc"; field public static final java.lang.String MNC = "mnc"; field public static final int SIM_NOT_INSERTED = -1; // 0xffffffff } } public class TelephonyManager { public class TelephonyManager {
services/core/java/com/android/server/TelephonyRegistry.java +143 −23 Original line number Original line Diff line number Diff line Loading @@ -34,6 +34,8 @@ import android.os.UserHandle; import android.telephony.CellLocation; import android.telephony.CellLocation; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.DataConnectionRealTimeInfo; import android.telephony.Rlog; import android.telephony.Rlog; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionListener; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager; import android.telephony.PhoneStateListener; import android.telephony.PhoneStateListener; Loading @@ -56,6 +58,7 @@ import java.io.FileDescriptor; import java.io.PrintWriter; import java.io.PrintWriter; import com.android.internal.app.IBatteryStats; import com.android.internal.app.IBatteryStats; import com.android.internal.telephony.ISubscriptionListener; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.ITelephonyRegistry; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.IPhoneStateListener; import com.android.internal.telephony.DefaultPhoneNotifier; import com.android.internal.telephony.DefaultPhoneNotifier; Loading Loading @@ -90,19 +93,30 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { IBinder binder; IBinder binder; IPhoneStateListener callback; IPhoneStateListener callback; ISubscriptionListener subscriptionListenerCallback; int callerUid; int callerUid; int events; int events; int subId; int subId = SubscriptionManager.INVALID_SUB_ID; int phoneId; int phoneId = SubscriptionManager.INVALID_PHONE_ID; boolean matchPhoneStateListenerEvent(int events) { return (callback != null) && ((events & this.events) != 0); } boolean matchSubscriptionListenerEvent(int events) { return (subscriptionListenerCallback != null) && ((events & this.events) != 0); } @Override @Override public String toString() { public String toString() { return "{pkgForDebug=" + pkgForDebug + " callerUid=" + callerUid + " subId=" + subId + return "{pkgForDebug=" + pkgForDebug + " binder=" + binder + " callback=" + callback " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}"; + " subscriptionListenererCallback=" + subscriptionListenerCallback + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}"; } } } } Loading Loading @@ -324,6 +338,101 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mContext.registerReceiver(mBroadcastReceiver, filter); mContext.registerReceiver(mBroadcastReceiver, filter); } } @Override public void registerSubscriptionListener(String pkgForDebug, ISubscriptionListener callback, int events) { int callerUid = UserHandle.getCallingUserId(); int myUid = UserHandle.myUserId(); if (VDBG) { log("listen sl: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) + " myUid=" + myUid + " callerUid=" + callerUid + " callback=" + callback + " callback.asBinder=" + callback.asBinder()); } if (events != 0) { /* Checks permission and throws Security exception */ checkSubscriptionListenerPermission(events); Record r = null; synchronized (mRecords) { // register find_and_add: { IBinder b = callback.asBinder(); final int N = mRecords.size(); for (int i = 0; i < N; i++) { r = mRecords.get(i); if (b == r.binder) { break find_and_add; } } r = new Record(); r.binder = b; mRecords.add(r); if (DBG) log("listen sl: add new record"); } r.subscriptionListenerCallback = callback; r.pkgForDebug = pkgForDebug; r.callerUid = callerUid; r.events = events; if (DBG) { log("listen sl: Register r=" + r); } } // Always notify when a listen is established. if (r.matchSubscriptionListenerEvent( SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED)) { try { if (VDBG) log("listen sl: send to r=" + r); r.subscriptionListenerCallback.onSubscriptionInfoChanged(); if (VDBG) log("listen sl: sent to r=" + r); } catch (RemoteException e) { if (VDBG) log("listen sl: remote exception sending to r=" + r + " e=" + e); remove(r.binder); } } } else { if (DBG) log("listen sl: Unregister as event is LISTEN_NONE"); unregisterSubscriptionListener(pkgForDebug, callback); } } @Override public void unregisterSubscriptionListener(String pkgForDebug, ISubscriptionListener callback) { if (DBG) log("listen sl: Unregister as event is LISTEN_NONE"); remove(callback.asBinder()); } private void checkSubscriptionListenerPermission(int events) { if ((events & SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED) != 0) { mContext.enforceCallingOrSelfPermission( SubscriptionListener.PERMISSION_LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED, null); } } @Override public void notifySubscriptionInfoChanged() { if (VDBG) log("notifySubscriptionInfoChanged:"); synchronized (mRecords) { mRemoveList.clear(); for (Record r : mRecords) { if (r.matchSubscriptionListenerEvent( SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED)) { try { if (VDBG) log("notifySubscriptionInfoChanged: send to r=" + r); r.subscriptionListenerCallback.onSubscriptionInfoChanged(); if (VDBG) log("notifySubscriptionInfoChanged: sent to r=" + r); } catch (RemoteException ex) { if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r); mRemoveList.add(r.binder); } } } handleRemoveListLocked(); } } @Override @Override public void listen(String pkgForDebug, IPhoneStateListener callback, int events, public void listen(String pkgForDebug, IPhoneStateListener callback, int events, boolean notifyNow) { boolean notifyNow) { Loading Loading @@ -513,6 +622,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { final int recordCount = mRecords.size(); final int recordCount = mRecords.size(); for (int i = 0; i < recordCount; i++) { for (int i = 0; i < recordCount; i++) { if (mRecords.get(i).binder == binder) { if (mRecords.get(i).binder == binder) { if (VDBG) log("remove: binder=" + binder); mRecords.remove(i); mRecords.remove(i); return; return; } } Loading @@ -531,7 +641,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) { (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) { try { try { r.callback.onCallStateChanged(state, incomingNumber); r.callback.onCallStateChanged(state, incomingNumber); Loading Loading @@ -559,7 +669,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mCallState[phoneId] = state; mCallState[phoneId] = state; mCallIncomingNumber[phoneId] = incomingNumber; mCallIncomingNumber[phoneId] = incomingNumber; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && (r.subId == subId) && (r.subId == subId) && (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) { (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) { try { try { Loading Loading @@ -595,7 +705,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " state=" + state); + " phoneId=" + phoneId + " state=" + state); } } if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { if (DBG) { if (DBG) { Loading Loading @@ -640,7 +750,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId + " phoneId=" + phoneId + " ss=" + signalStrength); + " phoneId=" + phoneId + " ss=" + signalStrength); } } if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { if (DBG) { if (DBG) { Loading @@ -653,7 +764,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mRemoveList.add(r.binder); mRemoveList.add(r.binder); } } } } if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) && if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) && idMatch(r.subId, subId, phoneId)){ idMatch(r.subId, subId, phoneId)){ try { try { int gsmSignalStrength = signalStrength.getGsmSignalStrength(); int gsmSignalStrength = signalStrength.getGsmSignalStrength(); Loading Loading @@ -750,7 +861,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { if (validatePhoneId(phoneId)) { mMessageWaiting[phoneId] = mwi; mMessageWaiting[phoneId] = mwi; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { r.callback.onMessageWaitingIndicatorChanged(mwi); r.callback.onMessageWaitingIndicatorChanged(mwi); Loading Loading @@ -781,7 +893,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (validatePhoneId(phoneId)) { if (validatePhoneId(phoneId)) { mCallForwarding[phoneId] = cfi; mCallForwarding[phoneId] = cfi; for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { r.callback.onCallForwardingIndicatorChanged(cfi); r.callback.onCallForwardingIndicatorChanged(cfi); Loading @@ -807,7 +920,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { int phoneId = SubscriptionManager.getPhoneId(subId); int phoneId = SubscriptionManager.getPhoneId(subId); mDataActivity[phoneId] = state; mDataActivity[phoneId] = state; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY)) { try { try { r.callback.onDataActivity(state); r.callback.onDataActivity(state); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -878,7 +991,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { + ", " + mDataConnectionNetworkType[phoneId] + ")"); + ", " + mDataConnectionNetworkType[phoneId] + ")"); } } for (Record r : mRecords) { for (Record r : mRecords) { if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) && if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) && idMatch(r.subId, subId, phoneId)) { idMatch(r.subId, subId, phoneId)) { try { try { log("Notify data connection state changed on sub: " + log("Notify data connection state changed on sub: " + Loading @@ -895,7 +1009,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, apnType, apn, reason, linkProperties, ""); apnType, apn, reason, linkProperties, ""); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -930,7 +1045,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, ""); apnType, "", reason, null, ""); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading Loading @@ -989,7 +1105,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { mOtaspMode = otaspMode; mOtaspMode = otaspMode; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) { try { try { r.callback.onOtaspChanged(otaspMode); r.callback.onOtaspChanged(otaspMode); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1015,7 +1131,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { DisconnectCause.NOT_VALID, DisconnectCause.NOT_VALID, PreciseDisconnectCause.NOT_VALID); PreciseDisconnectCause.NOT_VALID); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { try { try { r.callback.onPreciseCallStateChanged(mPreciseCallState); r.callback.onPreciseCallStateChanged(mPreciseCallState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1038,7 +1154,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, mBackgroundCallState, disconnectCause, preciseDisconnectCause); mBackgroundCallState, disconnectCause, preciseDisconnectCause); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { try { try { r.callback.onPreciseCallStateChanged(mPreciseCallState); r.callback.onPreciseCallStateChanged(mPreciseCallState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1062,7 +1178,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); apnType, apn, reason, null, failCause); for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { if (r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { try { try { r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); } catch (RemoteException ex) { } catch (RemoteException ex) { Loading @@ -1083,7 +1200,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { synchronized (mRecords) { synchronized (mRecords) { mVoLteServiceState = lteState; mVoLteServiceState = lteState; for (Record r : mRecords) { for (Record r : mRecords) { if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) { if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) { try { try { r.callback.onVoLteServiceStateChanged( r.callback.onVoLteServiceStateChanged( new VoLteServiceState(mVoLteServiceState)); new VoLteServiceState(mVoLteServiceState)); Loading @@ -1106,7 +1223,8 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { if (VDBG) { if (VDBG) { log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); } } if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) && if ((r.matchPhoneStateListenerEvent( PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) && ((r.subId == subId) || ((r.subId == subId) || (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) { (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) { try { try { Loading Loading @@ -1337,7 +1455,9 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { } } private void handleRemoveListLocked() { private void handleRemoveListLocked() { if (mRemoveList.size() > 0) { int size = mRemoveList.size(); if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size); if (size > 0) { for (IBinder b: mRemoveList) { for (IBinder b: mRemoveList) { remove(b); remove(b); } } Loading @@ -1351,7 +1471,7 @@ class TelephonyRegistry extends ITelephonyRegistry.Stub { boolean valid = false; boolean valid = false; try { try { foregroundUser = ActivityManager.getCurrentUser(); foregroundUser = ActivityManager.getCurrentUser(); valid = r.callerUid == foregroundUser && (r.events & events) != 0; valid = r.callerUid == foregroundUser && r.matchPhoneStateListenerEvent(events); if (DBG | DBG_LOC) { if (DBG | DBG_LOC) { log("validateEventsAndUserLocked: valid=" + valid log("validateEventsAndUserLocked: valid=" + valid + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser Loading
services/core/java/com/android/server/location/GpsLocationProvider.java +39 −20 Original line number Original line Diff line number Diff line Loading @@ -72,6 +72,9 @@ import android.provider.Settings; import android.provider.Telephony.Carriers; import android.provider.Telephony.Carriers; import android.provider.Telephony.Sms.Intents; import android.provider.Telephony.Sms.Intents; import android.telephony.SmsMessage; import android.telephony.SmsMessage; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionListener; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import android.telephony.gsm.GsmCellLocation; import android.telephony.gsm.GsmCellLocation; import android.text.TextUtils; import android.text.TextUtils; Loading @@ -88,6 +91,7 @@ import java.io.StringReader; import java.net.InetAddress; import java.net.InetAddress; import java.net.UnknownHostException; import java.net.UnknownHostException; import java.util.Date; import java.util.Date; import java.util.List; import java.util.Map.Entry; import java.util.Map.Entry; import java.util.Properties; import java.util.Properties; Loading Loading @@ -452,10 +456,21 @@ public class GpsLocationProvider implements LocationProviderInterface { || Intent.ACTION_SCREEN_OFF.equals(action) || Intent.ACTION_SCREEN_OFF.equals(action) || Intent.ACTION_SCREEN_ON.equals(action)) { || Intent.ACTION_SCREEN_ON.equals(action)) { updateLowPowerMode(); updateLowPowerMode(); } else if (action.equals(SIM_STATE_CHANGED) } else if (action.equals(SIM_STATE_CHANGED)) { || action.equals(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE) subscriptionOrSimChanged(context); || action.equals(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED)) { } Log.d(TAG, "received SIM realted action: " + action); } }; private final SubscriptionListener mSubscriptionListener = new SubscriptionListener() { @Override public void onSubscriptionInfoChanged() { subscriptionOrSimChanged(mContext); } }; private void subscriptionOrSimChanged(Context context) { Log.d(TAG, "received SIM realted action: "); TelephonyManager phone = (TelephonyManager) TelephonyManager phone = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mContext.getSystemService(Context.TELEPHONY_SERVICE); String mccMnc = phone.getSimOperator(); String mccMnc = phone.getSimOperator(); Loading @@ -469,8 +484,6 @@ public class GpsLocationProvider implements LocationProviderInterface { Log.d(TAG, "SIM MCC/MNC is still not available"); Log.d(TAG, "SIM MCC/MNC is still not available"); } } } } } }; private void checkSmsSuplInit(Intent intent) { private void checkSmsSuplInit(Intent intent) { SmsMessage[] messages = Intents.getMessagesFromIntent(intent); SmsMessage[] messages = Intents.getMessagesFromIntent(intent); Loading Loading @@ -626,6 +639,16 @@ public class GpsLocationProvider implements LocationProviderInterface { mNetInitiatedListener, mNetInitiatedListener, mSuplEsEnabled); mSuplEsEnabled); // TODO: When this object "finishes" we should unregister by invoking // SubscriptionManager.unregister(mContext, mSubscriptionListener); // This is not strictly necessary because it will be unregistered if the // notification fails but it is good form. // Register for SubscriptionInfo list changes which is guaranteed // to invoke onSubscriptionInfoChanged the first time. SubscriptionManager.register(mContext, mSubscriptionListener, SubscriptionListener.LISTEN_SUBSCRIPTION_INFO_LIST_CHANGED); // construct handler, listen for events // construct handler, listen for events mHandler = new ProviderHandler(looper); mHandler = new ProviderHandler(looper); listenForBroadcasts(); listenForBroadcasts(); Loading Loading @@ -735,10 +758,6 @@ public class GpsLocationProvider implements LocationProviderInterface { intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_OFF); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(Intent.ACTION_SCREEN_ON); intentFilter.addAction(SIM_STATE_CHANGED); intentFilter.addAction(SIM_STATE_CHANGED); // TODO: remove the use TelephonyIntents. We are using it because SIM_STATE_CHANGED // is not reliable at the moment. intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_CONTENT_CHANGE); intentFilter.addAction(TelephonyIntents.ACTION_SUBINFO_RECORD_UPDATED); mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler); mContext.registerReceiver(mBroadcastReceiver, intentFilter, null, mHandler); } } Loading
telephony/java/android/telephony/SubInfoRecord.aidl→telephony/java/android/telephony/SubscriptionInfo.aidl +1 −1 Original line number Original line Diff line number Diff line Loading @@ -16,4 +16,4 @@ package android.telephony; package android.telephony; parcelable SubInfoRecord; parcelable SubscriptionInfo;