blob: 820551da274b3947b1286d57b1f646b94cc748da [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
Amit Mahajan1cfd4572015-07-09 11:12:19 -070019import android.Manifest;
Wink Savillea12a7b32012-09-20 10:09:45 -070020import android.app.ActivityManager;
Svet Ganov16a16892015-04-16 10:32:04 -070021import android.app.AppOpsManager;
Wink Savillea12a7b32012-09-20 10:09:45 -070022import android.content.BroadcastReceiver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.content.Context;
24import android.content.Intent;
Wink Savillea12a7b32012-09-20 10:09:45 -070025import android.content.IntentFilter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.content.pm.PackageManager;
Robert Greenwalt37e65eb2010-08-30 10:56:47 -070027import android.net.LinkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070028import android.net.NetworkCapabilities;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Binder;
30import android.os.Bundle;
Wink Savillea12a7b32012-09-20 10:09:45 -070031import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.os.IBinder;
Wink Savillea12a7b32012-09-20 10:09:45 -070033import android.os.Message;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.os.RemoteException;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070035import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.telephony.CellLocation;
Wink Savillef4cd25b2014-07-08 19:03:20 -070037import android.telephony.Rlog;
Wink Savillefb40dd42014-06-12 17:02:31 -070038import android.telephony.TelephonyManager;
39import android.telephony.SubscriptionManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080040import android.telephony.PhoneStateListener;
41import android.telephony.ServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -070042import android.telephony.SignalStrength;
John Wang963db55d2012-03-30 16:04:06 -070043import android.telephony.CellInfo;
Wink Savillefb40dd42014-06-12 17:02:31 -070044import android.telephony.VoLteServiceState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020045import android.telephony.DisconnectCause;
46import android.telephony.PreciseCallState;
47import android.telephony.PreciseDataConnectionState;
48import android.telephony.PreciseDisconnectCause;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049import android.text.TextUtils;
Wink Saville47d8d1b2014-07-10 13:01:52 -070050import android.text.format.Time;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051
52import java.util.ArrayList;
Wink Savilleb208a242012-07-25 14:08:09 -070053import java.util.List;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080054import java.io.FileDescriptor;
55import java.io.PrintWriter;
56
57import com.android.internal.app.IBatteryStats;
Wink Savilled09c4ca2014-11-22 10:08:16 -080058import com.android.internal.telephony.IOnSubscriptionsChangedListener;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059import com.android.internal.telephony.ITelephonyRegistry;
60import com.android.internal.telephony.IPhoneStateListener;
61import com.android.internal.telephony.DefaultPhoneNotifier;
Wink Savillea639b312012-07-10 12:37:54 -070062import com.android.internal.telephony.PhoneConstants;
Wink Savillec9330dd2011-01-12 13:37:38 -080063import com.android.internal.telephony.ServiceStateTracker;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080064import com.android.internal.telephony.TelephonyIntents;
65import com.android.server.am.BatteryStatsService;
66
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067/**
Wink Savillee9b06d72009-05-18 21:47:50 -070068 * Since phone process can be restarted, this class provides a centralized place
69 * that applications can register and be called back from.
Wink Savillee380b982014-07-26 18:24:22 -070070 *
71 * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026
72 * and 15973975 by saving the phoneId of the registrant and then using the
73 * phoneId when deciding to to make a callback. This is necessary because
74 * a subId changes from to a dummy value when a SIM is removed and thus won't
Wink Saville63f03dd2014-10-23 10:44:45 -070075 * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles
Wink Savillee380b982014-07-26 18:24:22 -070076 * the dummy value conversion we properly do the callbacks.
77 *
78 * Eventually we may want to remove the notion of dummy value but for now this
79 * looks like the best approach.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080080 */
81class TelephonyRegistry extends ITelephonyRegistry.Stub {
82 private static final String TAG = "TelephonyRegistry";
Wink Saville6d13bc82014-08-01 11:13:40 -070083 private static final boolean DBG = false; // STOPSHIP if true
Wink Savillefb40dd42014-06-12 17:02:31 -070084 private static final boolean DBG_LOC = false; // STOPSHIP if true
Wink Saville6d13bc82014-08-01 11:13:40 -070085 private static final boolean VDBG = false; // STOPSHIP if true
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080086
87 private static class Record {
Svet Ganov16a16892015-04-16 10:32:04 -070088 String callingPackage;
Wink Savillee9b06d72009-05-18 21:47:50 -070089
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080090 IBinder binder;
Wink Savillee9b06d72009-05-18 21:47:50 -070091
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092 IPhoneStateListener callback;
Wink Savilled09c4ca2014-11-22 10:08:16 -080093 IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback;
Wink Savillee9b06d72009-05-18 21:47:50 -070094
Fyodor Kupolov309b2f632015-06-03 16:29:01 -070095 int callerUserId;
Wink Savillea12a7b32012-09-20 10:09:45 -070096
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 int events;
Wink Savillea12a7b32012-09-20 10:09:45 -070098
Wink Savilled09c4ca2014-11-22 10:08:16 -080099 int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Wink Savillefb40dd42014-06-12 17:02:31 -0700100
Wink Savilled09c4ca2014-11-22 10:08:16 -0800101 int phoneId = SubscriptionManager.INVALID_PHONE_INDEX;
Wink Savillea374c3d2014-11-11 11:48:04 -0800102
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700103 boolean canReadPhoneState;
104
Wink Savillea374c3d2014-11-11 11:48:04 -0800105 boolean matchPhoneStateListenerEvent(int events) {
106 return (callback != null) && ((events & this.events) != 0);
107 }
108
Wink Savilled09c4ca2014-11-22 10:08:16 -0800109 boolean matchOnSubscriptionsChangedListener() {
110 return (onSubscriptionsChangedListenerCallback != null);
Wink Savillea374c3d2014-11-11 11:48:04 -0800111 }
Wink Savillee380b982014-07-26 18:24:22 -0700112
Wink Savillea12a7b32012-09-20 10:09:45 -0700113 @Override
114 public String toString() {
Svet Ganov16a16892015-04-16 10:32:04 -0700115 return "{callingPackage=" + callingPackage + " binder=" + binder
116 + " callback=" + callback
Wink Savilled09c4ca2014-11-22 10:08:16 -0800117 + " onSubscriptionsChangedListenererCallback="
118 + onSubscriptionsChangedListenerCallback
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700119 + " callerUserId=" + callerUserId + " subId=" + subId + " phoneId=" + phoneId
120 + " events=" + Integer.toHexString(events)
121 + " canReadPhoneState=" + canReadPhoneState + "}";
Wink Savillea12a7b32012-09-20 10:09:45 -0700122 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800123 }
124
125 private final Context mContext;
Wink Savillee9b06d72009-05-18 21:47:50 -0700126
Joe Onorato163d8d92010-10-21 13:21:20 -0400127 // access should be inside synchronized (mRecords) for these two fields
128 private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>();
129 private final ArrayList<Record> mRecords = new ArrayList<Record>();
Wink Savillee9b06d72009-05-18 21:47:50 -0700130
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800131 private final IBatteryStats mBatteryStats;
132
Svet Ganov16a16892015-04-16 10:32:04 -0700133 private final AppOpsManager mAppOps;
134
Wink Savilled09c4ca2014-11-22 10:08:16 -0800135 private boolean hasNotifySubscriptionInfoChangedOccurred = false;
136
Wink Savillefb40dd42014-06-12 17:02:31 -0700137 private int mNumPhones;
Wink Savillee9b06d72009-05-18 21:47:50 -0700138
Wink Savillefb40dd42014-06-12 17:02:31 -0700139 private int[] mCallState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700140
Wink Savillefb40dd42014-06-12 17:02:31 -0700141 private String[] mCallIncomingNumber;
Wink Savillee9b06d72009-05-18 21:47:50 -0700142
Wink Savillefb40dd42014-06-12 17:02:31 -0700143 private ServiceState[] mServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700144
Wink Savillefb40dd42014-06-12 17:02:31 -0700145 private SignalStrength[] mSignalStrength;
Wink Savillee9b06d72009-05-18 21:47:50 -0700146
Wink Savillefb40dd42014-06-12 17:02:31 -0700147 private boolean[] mMessageWaiting;
Wink Savillee9b06d72009-05-18 21:47:50 -0700148
Wink Savillefb40dd42014-06-12 17:02:31 -0700149 private boolean[] mCallForwarding;
Wink Savillee9b06d72009-05-18 21:47:50 -0700150
Wink Savillefb40dd42014-06-12 17:02:31 -0700151 private int[] mDataActivity;
Wink Savillee9b06d72009-05-18 21:47:50 -0700152
Wink Savillefb40dd42014-06-12 17:02:31 -0700153 private int[] mDataConnectionState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700154
Wink Savillefb40dd42014-06-12 17:02:31 -0700155 private boolean[] mDataConnectionPossible;
Wink Savillee9b06d72009-05-18 21:47:50 -0700156
Wink Savillefb40dd42014-06-12 17:02:31 -0700157 private String[] mDataConnectionReason;
158
159 private String[] mDataConnectionApn;
Wink Savillee9b06d72009-05-18 21:47:50 -0700160
Robert Greenwalt02648a42010-05-18 10:52:51 -0700161 private ArrayList<String> mConnectedApns;
Robert Greenwalt42acef32009-08-12 16:08:25 -0700162
Wink Savillefb40dd42014-06-12 17:02:31 -0700163 private LinkProperties[] mDataConnectionLinkProperties;
Wink Savillef61101f2010-09-16 16:36:42 -0700164
Wink Savillefb40dd42014-06-12 17:02:31 -0700165 private NetworkCapabilities[] mDataConnectionNetworkCapabilities;
Wink Savillee9b06d72009-05-18 21:47:50 -0700166
Wink Savillefb40dd42014-06-12 17:02:31 -0700167 private Bundle[] mCellLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800168
Wink Savillefb40dd42014-06-12 17:02:31 -0700169 private int[] mDataConnectionNetworkType;
Robert Greenwalt98e0b142009-10-08 21:15:52 -0700170
Wink Savillec9330dd2011-01-12 13:37:38 -0800171 private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
Wink Savillefd2d0132010-10-28 14:22:26 -0700172
Wink Savillefb40dd42014-06-12 17:02:31 -0700173 private ArrayList<List<CellInfo>> mCellInfo = null;
174
175 private VoLteServiceState mVoLteServiceState = new VoLteServiceState();
176
Wink Savilled09c4ca2014-11-22 10:08:16 -0800177 private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
xinhee9f16402014-09-25 16:39:28 -0700178
Wink Savilled09c4ca2014-11-22 10:08:16 -0800179 private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX;
xinhee9f16402014-09-25 16:39:28 -0700180
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200181 private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
182
183 private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
184
185 private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
186
187 private PreciseCallState mPreciseCallState = new PreciseCallState();
188
Andrew Flynn1f452642015-04-14 22:16:04 -0400189 private boolean mCarrierNetworkChangeState = false;
190
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200191 private PreciseDataConnectionState mPreciseDataConnectionState =
192 new PreciseDataConnectionState();
193
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700194 static final int ENFORCE_PHONE_STATE_PERMISSION_MASK =
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700195 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700196 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
197 PhoneStateListener.LISTEN_VOLTE_STATE;
198
199 static final int CHECK_PHONE_STATE_PERMISSION_MASK =
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700200 PhoneStateListener.LISTEN_CALL_STATE |
201 PhoneStateListener.LISTEN_DATA_ACTIVITY |
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700202 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE;
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700203
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200204 static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
205 PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
206 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
207
Wink Savillea12a7b32012-09-20 10:09:45 -0700208 private static final int MSG_USER_SWITCHED = 1;
Wink Savillefb40dd42014-06-12 17:02:31 -0700209 private static final int MSG_UPDATE_DEFAULT_SUB = 2;
Wink Savillea12a7b32012-09-20 10:09:45 -0700210
211 private final Handler mHandler = new Handler() {
212 @Override
213 public void handleMessage(Message msg) {
214 switch (msg.what) {
215 case MSG_USER_SWITCHED: {
Wink Savillee380b982014-07-26 18:24:22 -0700216 if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
Wink Savillefb40dd42014-06-12 17:02:31 -0700217 int numPhones = TelephonyManager.getDefault().getPhoneCount();
218 for (int sub = 0; sub < numPhones; sub++) {
Wink Savillebc027272014-09-08 14:50:58 -0700219 TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
Wink Savillee380b982014-07-26 18:24:22 -0700220 mCellLocation[sub]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700221 }
222 break;
223 }
xinhee9f16402014-09-25 16:39:28 -0700224 case MSG_UPDATE_DEFAULT_SUB: {
225 int newDefaultPhoneId = msg.arg1;
Wink Saville63f03dd2014-10-23 10:44:45 -0700226 int newDefaultSubId = (Integer)(msg.obj);
xinhee9f16402014-09-25 16:39:28 -0700227 if (VDBG) {
228 log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId
229 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
230 + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId);
231 }
232
233 //Due to possible risk condition,(notify call back using the new
234 //defaultSubId comes before new defaultSubId update) we need to recall all
235 //possible missed notify callback
236 synchronized (mRecords) {
Etan Cohena33cf072014-09-30 10:35:24 -0700237 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800238 if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
Etan Cohena33cf072014-09-30 10:35:24 -0700239 checkPossibleMissNotify(r, newDefaultPhoneId);
240 }
241 }
242 handleRemoveListLocked();
xinhee9f16402014-09-25 16:39:28 -0700243 }
244 mDefaultSubId = newDefaultSubId;
245 mDefaultPhoneId = newDefaultPhoneId;
Wink Savillea12a7b32012-09-20 10:09:45 -0700246 }
247 }
248 }
249 };
250
251 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
252 @Override
253 public void onReceive(Context context, Intent intent) {
254 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700255 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700256 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700257 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700258 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700259 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700260 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
Wink Saville63f03dd2014-10-23 10:44:45 -0700261 Integer newDefaultSubIdObj = new Integer(intent.getIntExtra(
Shishir Agrawal7ea3e8b2016-01-25 13:03:07 -0800262 PhoneConstants.SUBSCRIPTION_KEY,
263 SubscriptionManager.getDefaultSubscriptionId()));
xinhee9f16402014-09-25 16:39:28 -0700264 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
265 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700266 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700267 log("onReceive:current mDefaultSubId=" + mDefaultSubId
268 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
269 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700270 }
xinhee9f16402014-09-25 16:39:28 -0700271
Junda Liu985f52c2015-02-23 16:06:51 -0800272 if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId)
xinhee9f16402014-09-25 16:39:28 -0700273 || (newDefaultPhoneId != mDefaultPhoneId))) {
274 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
275 newDefaultPhoneId, 0, newDefaultSubIdObj));
276 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700277 }
278 }
279 };
280
Wink Savillee9b06d72009-05-18 21:47:50 -0700281 // we keep a copy of all of the state so we can send it out when folks
282 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800283 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700284 // In these calls we call with the lock held. This is safe becasuse remote
285 // calls go through a oneway interface and local calls going through a
286 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800287
288 TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700289 CellLocation location = CellLocation.getEmpty();
290
Wink Savillefb40dd42014-06-12 17:02:31 -0700291 mContext = context;
292 mBatteryStats = BatteryStatsService.getService();
293 mConnectedApns = new ArrayList<String>();
294
Wink Savillefb40dd42014-06-12 17:02:31 -0700295 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700296 if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700297 mNumPhones = numPhones;
298 mCallState = new int[numPhones];
299 mDataActivity = new int[numPhones];
300 mDataConnectionState = new int[numPhones];
301 mDataConnectionNetworkType = new int[numPhones];
302 mCallIncomingNumber = new String[numPhones];
303 mServiceState = new ServiceState[numPhones];
304 mSignalStrength = new SignalStrength[numPhones];
305 mMessageWaiting = new boolean[numPhones];
306 mDataConnectionPossible = new boolean[numPhones];
307 mDataConnectionReason = new String[numPhones];
308 mDataConnectionApn = new String[numPhones];
309 mCallForwarding = new boolean[numPhones];
310 mCellLocation = new Bundle[numPhones];
311 mDataConnectionLinkProperties = new LinkProperties[numPhones];
312 mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones];
313 mCellInfo = new ArrayList<List<CellInfo>>();
314 for (int i = 0; i < numPhones; i++) {
315 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
316 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
317 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
318 mCallIncomingNumber[i] = "";
319 mServiceState[i] = new ServiceState();
320 mSignalStrength[i] = new SignalStrength();
321 mMessageWaiting[i] = false;
322 mCallForwarding[i] = false;
323 mDataConnectionPossible[i] = false;
324 mDataConnectionReason[i] = "";
325 mDataConnectionApn[i] = "";
326 mCellLocation[i] = new Bundle();
327 mCellInfo.add(i, null);
328 }
329
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700330 // Note that location can be null for non-phone builds like
331 // like the generic one.
332 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700333 for (int i = 0; i < numPhones; i++) {
334 location.fillInNotifierBundle(mCellLocation[i]);
335 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700336 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700337 mConnectedApns = new ArrayList<String>();
Svet Ganov16a16892015-04-16 10:32:04 -0700338
339 mAppOps = mContext.getSystemService(AppOpsManager.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800340 }
341
Svetoslav Ganova0027152013-06-25 14:59:53 -0700342 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700343 // Watch for interesting updates
344 final IntentFilter filter = new IntentFilter();
345 filter.addAction(Intent.ACTION_USER_SWITCHED);
346 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700347 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700348 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700349 mContext.registerReceiver(mBroadcastReceiver, filter);
350 }
351
352 @Override
Svet Ganov16a16892015-04-16 10:32:04 -0700353 public void addOnSubscriptionsChangedListener(String callingPackage,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800354 IOnSubscriptionsChangedListener callback) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700355 int callerUserId = UserHandle.getCallingUserId();
Wink Savillea374c3d2014-11-11 11:48:04 -0800356 if (VDBG) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700357 log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
358 + " callerUserId=" + callerUserId + " callback=" + callback
Wink Savillea374c3d2014-11-11 11:48:04 -0800359 + " callback.asBinder=" + callback.asBinder());
360 }
361
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700362 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700363 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700364 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
365 "addOnSubscriptionsChangedListener");
Amit Mahajana9e72a72015-07-30 16:04:13 -0700366 // SKIP checking for run-time permission since caller or self has PRIVILEGED permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700367 } catch (SecurityException e) {
368 mContext.enforceCallingOrSelfPermission(
369 android.Manifest.permission.READ_PHONE_STATE,
370 "addOnSubscriptionsChangedListener");
Svet Ganov16a16892015-04-16 10:32:04 -0700371
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700372 if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
373 callingPackage) != AppOpsManager.MODE_ALLOWED) {
374 return;
375 }
Svet Ganov16a16892015-04-16 10:32:04 -0700376 }
377
Fyodor Kupolovac038a92015-06-09 13:14:54 -0700378 Record r;
Wink Savillea374c3d2014-11-11 11:48:04 -0800379
Wink Savilled09c4ca2014-11-22 10:08:16 -0800380 synchronized (mRecords) {
381 // register
382 find_and_add: {
383 IBinder b = callback.asBinder();
384 final int N = mRecords.size();
385 for (int i = 0; i < N; i++) {
386 r = mRecords.get(i);
387 if (b == r.binder) {
388 break find_and_add;
Wink Savillea374c3d2014-11-11 11:48:04 -0800389 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800390 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800391 r = new Record();
392 r.binder = b;
393 mRecords.add(r);
394 if (DBG) log("listen oscl: add new record");
Wink Savillea374c3d2014-11-11 11:48:04 -0800395 }
396
Wink Savilled09c4ca2014-11-22 10:08:16 -0800397 r.onSubscriptionsChangedListenerCallback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700398 r.callingPackage = callingPackage;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700399 r.callerUserId = callerUserId;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800400 r.events = 0;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700401 r.canReadPhoneState = true; // permission has been enforced above
Wink Savilled09c4ca2014-11-22 10:08:16 -0800402 if (DBG) {
403 log("listen oscl: Register r=" + r);
404 }
405 // Always notify when registration occurs if there has been a notification.
406 if (hasNotifySubscriptionInfoChangedOccurred) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800407 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800408 if (VDBG) log("listen oscl: send to r=" + r);
409 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
410 if (VDBG) log("listen oscl: sent to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800411 } catch (RemoteException e) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800412 if (VDBG) log("listen oscl: remote exception sending to r=" + r + " e=" + e);
Wink Savillea374c3d2014-11-11 11:48:04 -0800413 remove(r.binder);
414 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800415 } else {
416 log("listen oscl: hasNotifySubscriptionInfoChangedOccurred==false no callback");
Wink Savillea374c3d2014-11-11 11:48:04 -0800417 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800418 }
419 }
420
421 @Override
Wink Saville071743f2015-01-12 17:11:04 -0800422 public void removeOnSubscriptionsChangedListener(String pkgForDebug,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800423 IOnSubscriptionsChangedListener callback) {
424 if (DBG) log("listen oscl: Unregister");
Wink Savillea374c3d2014-11-11 11:48:04 -0800425 remove(callback.asBinder());
426 }
427
Wink Savillea374c3d2014-11-11 11:48:04 -0800428 @Override
429 public void notifySubscriptionInfoChanged() {
430 if (VDBG) log("notifySubscriptionInfoChanged:");
431 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800432 if (!hasNotifySubscriptionInfoChangedOccurred) {
433 log("notifySubscriptionInfoChanged: first invocation mRecords.size="
434 + mRecords.size());
435 }
436 hasNotifySubscriptionInfoChangedOccurred = true;
Wink Savillea374c3d2014-11-11 11:48:04 -0800437 mRemoveList.clear();
438 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800439 if (r.matchOnSubscriptionsChangedListener()) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800440 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800441 if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r);
442 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
443 if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800444 } catch (RemoteException ex) {
445 if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r);
446 mRemoveList.add(r.binder);
447 }
448 }
449 }
450 handleRemoveListLocked();
451 }
452 }
453
454 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800455 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
456 boolean notifyNow) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800457 listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback,
458 events, notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700459 }
460
461 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700462 public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700463 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700464 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700465 }
466
Svet Ganov16a16892015-04-16 10:32:04 -0700467 private void listen(String callingPackage, IPhoneStateListener callback, int events,
Wink Saville63f03dd2014-10-23 10:44:45 -0700468 boolean notifyNow, int subId) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700469 int callerUserId = UserHandle.getCallingUserId();
Wink Savillee380b982014-07-26 18:24:22 -0700470 if (VDBG) {
Svet Ganov16a16892015-04-16 10:32:04 -0700471 log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700472 + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
473 + UserHandle.myUserId() + " callerUserId=" + callerUserId);
Wink Savillea12a7b32012-09-20 10:09:45 -0700474 }
xinhe75c2c152014-10-16 11:49:45 -0700475
476 if (events != PhoneStateListener.LISTEN_NONE) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700477 /* Checks permission and throws Security exception */
478 checkListenerPermission(events);
Svet Ganov16a16892015-04-16 10:32:04 -0700479
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700480 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700481 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700482 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700483 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
Amit Mahajana9e72a72015-07-30 16:04:13 -0700484 // SKIP checking for run-time permission since caller or self has PRIVILEGED
485 // permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700486 } catch (SecurityException e) {
487 if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
488 callingPackage) != AppOpsManager.MODE_ALLOWED) {
489 return;
490 }
Svet Ganov16a16892015-04-16 10:32:04 -0700491 }
492 }
493
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800494 synchronized (mRecords) {
495 // register
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700496 Record r;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800497 find_and_add: {
498 IBinder b = callback.asBinder();
499 final int N = mRecords.size();
Wink Savillee9b06d72009-05-18 21:47:50 -0700500 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800501 r = mRecords.get(i);
502 if (b == r.binder) {
503 break find_and_add;
504 }
505 }
506 r = new Record();
507 r.binder = b;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800508 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700509 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510 }
xinhe43c50292014-09-18 17:56:48 -0700511
xinhe75c2c152014-10-16 11:49:45 -0700512 r.callback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700513 r.callingPackage = callingPackage;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700514 r.callerUserId = callerUserId;
515 boolean isPhoneStateEvent = (events & (CHECK_PHONE_STATE_PERMISSION_MASK
516 | ENFORCE_PHONE_STATE_PERMISSION_MASK)) != 0;
517 r.canReadPhoneState = isPhoneStateEvent && canReadPhoneState(callingPackage);
xinhe75c2c152014-10-16 11:49:45 -0700518 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
519 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
Wink Savillea54bf652014-12-11 13:37:50 -0800520 if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800521 r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
xinhe75c2c152014-10-16 11:49:45 -0700522 } else {//APP specify subID
523 r.subId = subId;
524 }
525 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
526
xinhe43c50292014-09-18 17:56:48 -0700527 int phoneId = r.phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800528 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700529 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700530 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700531 }
532 if (VDBG) toStringLogSSC("listen");
Wink Savillefb40dd42014-06-12 17:02:31 -0700533 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800534 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400535 try {
Wink Savillee380b982014-07-26 18:24:22 -0700536 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700537 r.callback.onServiceStateChanged(
538 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400539 } catch (RemoteException ex) {
540 remove(r.binder);
541 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 }
543 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
544 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700545 int gsmSignalStrength = mSignalStrength[phoneId]
546 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700547 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
548 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800549 } catch (RemoteException ex) {
550 remove(r.binder);
551 }
552 }
553 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
554 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700555 r.callback.onMessageWaitingIndicatorChanged(
556 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800557 } catch (RemoteException ex) {
558 remove(r.binder);
559 }
560 }
561 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
562 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700563 r.callback.onCallForwardingIndicatorChanged(
564 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 } catch (RemoteException ex) {
566 remove(r.binder);
567 }
568 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700569 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400570 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700571 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700572 + mCellLocation[phoneId]);
573 r.callback.onCellLocationChanged(
574 new Bundle(mCellLocation[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400575 } catch (RemoteException ex) {
576 remove(r.binder);
577 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800578 }
579 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
580 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700581 r.callback.onCallStateChanged(mCallState[phoneId],
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700582 getCallIncomingNumber(r, phoneId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800583 } catch (RemoteException ex) {
584 remove(r.binder);
585 }
586 }
587 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
588 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700589 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
590 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800591 } catch (RemoteException ex) {
592 remove(r.binder);
593 }
594 }
595 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
596 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700597 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800598 } catch (RemoteException ex) {
599 remove(r.binder);
600 }
601 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700602 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
603 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700604 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700605 } catch (RemoteException ex) {
606 remove(r.binder);
607 }
608 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700609 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
610 try {
611 r.callback.onOtaspChanged(mOtaspMode);
612 } catch (RemoteException ex) {
613 remove(r.binder);
614 }
615 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700616 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700617 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700618 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700619 + mCellInfo.get(phoneId));
620 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
John Wang963db55d2012-03-30 16:04:06 -0700621 } catch (RemoteException ex) {
622 remove(r.binder);
623 }
624 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200625 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
626 try {
627 r.callback.onPreciseCallStateChanged(mPreciseCallState);
628 } catch (RemoteException ex) {
629 remove(r.binder);
630 }
631 }
632 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
633 try {
634 r.callback.onPreciseDataConnectionStateChanged(
635 mPreciseDataConnectionState);
636 } catch (RemoteException ex) {
637 remove(r.binder);
638 }
639 }
Andrew Flynn1f452642015-04-14 22:16:04 -0400640 if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) {
641 try {
642 r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
643 } catch (RemoteException ex) {
644 remove(r.binder);
645 }
646 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800647 }
648 }
649 } else {
xinhe75c2c152014-10-16 11:49:45 -0700650 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800651 remove(callback.asBinder());
652 }
653 }
654
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700655 private boolean canReadPhoneState(String callingPackage) {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700656 if (mContext.checkCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700657 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) ==
658 PackageManager.PERMISSION_GRANTED) {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700659 // SKIP checking for run-time permission since caller or self has PRIVILEGED permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700660 return true;
661 }
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700662 boolean canReadPhoneState = mContext.checkCallingOrSelfPermission(
663 android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
664 if (canReadPhoneState &&
665 mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
666 callingPackage) != AppOpsManager.MODE_ALLOWED) {
667 return false;
668 }
669 return canReadPhoneState;
670 }
671
672 private String getCallIncomingNumber(Record record, int phoneId) {
673 // Hide the number if record's process has no READ_PHONE_STATE permission
674 return record.canReadPhoneState ? mCallIncomingNumber[phoneId] : "";
675 }
676
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800677 private void remove(IBinder binder) {
678 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700679 final int recordCount = mRecords.size();
680 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800681 if (mRecords.get(i).binder == binder) {
xinheac11ae92014-12-18 10:02:14 -0800682 if (DBG) {
683 Record r = mRecords.get(i);
Svet Ganov16a16892015-04-16 10:32:04 -0700684 log("remove: binder=" + binder + "r.callingPackage" + r.callingPackage
xinheac11ae92014-12-18 10:02:14 -0800685 + "r.callback" + r.callback);
686 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800687 mRecords.remove(i);
688 return;
689 }
690 }
691 }
692 }
693
694 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700695 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700696 return;
697 }
xinhe43c50292014-09-18 17:56:48 -0700698
699 if (VDBG) {
700 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
701 }
702
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800703 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700704 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800705 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800706 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800707 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700708 String incomingNumberOrEmpty = r.canReadPhoneState ? incomingNumber : "";
709 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800710 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400711 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 }
713 }
714 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400715 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800716 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800717 broadcastCallStateChanged(state, incomingNumber,
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -0700718 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800719 }
720
Wink Saville63f03dd2014-10-23 10:44:45 -0700721 public void notifyCallStateForSubscriber(int subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700722 if (!checkNotifyPermission("notifyCallState()")) {
723 return;
724 }
Wink Savillee380b982014-07-26 18:24:22 -0700725 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700726 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700727 + " state=" + state + " incomingNumber=" + incomingNumber);
728 }
729 synchronized (mRecords) {
730 int phoneId = SubscriptionManager.getPhoneId(subId);
731 if (validatePhoneId(phoneId)) {
732 mCallState[phoneId] = state;
733 mCallIncomingNumber[phoneId] = incomingNumber;
734 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800735 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
xinhe43c50292014-09-18 17:56:48 -0700736 (r.subId == subId) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800737 (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700738 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700739 String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId);
740 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
Wink Savillefb40dd42014-06-12 17:02:31 -0700741 } catch (RemoteException ex) {
742 mRemoveList.add(r.binder);
743 }
744 }
745 }
746 }
747 handleRemoveListLocked();
748 }
749 broadcastCallStateChanged(state, incomingNumber, subId);
750 }
751
Wink Saville63f03dd2014-10-23 10:44:45 -0700752 public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700753 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700754 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700755 }
xinhe43c50292014-09-18 17:56:48 -0700756
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800757 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700758 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700759 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700760 + " state=" + state);
761 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700762 if (validatePhoneId(phoneId)) {
763 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700764 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
765 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700766
Wink Savillefb40dd42014-06-12 17:02:31 -0700767 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700768 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700769 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700770 + " phoneId=" + phoneId + " state=" + state);
771 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800772 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) &&
xinhe8b79fb62014-11-05 14:55:03 -0800773 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700774 try {
Wink Savillee380b982014-07-26 18:24:22 -0700775 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700776 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700777 + " subId=" + subId + " phoneId=" + phoneId
778 + " state=" + state);
779 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700780 r.callback.onServiceStateChanged(new ServiceState(state));
781 } catch (RemoteException ex) {
782 mRemoveList.add(r.binder);
783 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400784 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800785 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700786 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700787 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800788 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400789 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700791 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800792 }
793
Wink Savillee9b06d72009-05-18 21:47:50 -0700794 public void notifySignalStrength(SignalStrength signalStrength) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800795 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
796 signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700797 }
798
Wink Saville63f03dd2014-10-23 10:44:45 -0700799 public void notifySignalStrengthForSubscriber(int subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700800 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700801 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700802 }
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000803 if (VDBG) {
804 log("notifySignalStrengthForSubscriber: subId=" + subId
805 + " signalStrength=" + signalStrength);
806 toStringLogSSC("notifySignalStrengthForSubscriber");
807 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800808 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700809 int phoneId = SubscriptionManager.getPhoneId(subId);
810 if (validatePhoneId(phoneId)) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000811 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700812 mSignalStrength[phoneId] = signalStrength;
813 for (Record r : mRecords) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000814 if (VDBG) {
815 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
816 + " phoneId=" + phoneId + " ss=" + signalStrength);
817 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800818 if (r.matchPhoneStateListenerEvent(
819 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) &&
xinhe8b79fb62014-11-05 14:55:03 -0800820 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700821 try {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000822 if (DBG) {
823 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
824 + " subId=" + subId + " phoneId=" + phoneId
825 + " ss=" + signalStrength);
826 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700827 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
828 } catch (RemoteException ex) {
829 mRemoveList.add(r.binder);
830 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400831 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800832 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) &&
xinhe8b79fb62014-11-05 14:55:03 -0800833 idMatch(r.subId, subId, phoneId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700834 try {
835 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700836 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000837 if (DBG) {
838 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
839 + " subId=" + subId + " phoneId=" + phoneId
840 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
841 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700842 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700843 } catch (RemoteException ex) {
844 mRemoveList.add(r.binder);
845 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800846 }
847 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700848 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700849 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800850 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400851 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800852 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700853 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 }
855
Andrew Flynn1f452642015-04-14 22:16:04 -0400856 @Override
857 public void notifyCarrierNetworkChange(boolean active) {
Andrew Flynnceaed682015-06-09 12:36:58 +0000858 enforceNotifyPermissionOrCarrierPrivilege("notifyCarrierNetworkChange()");
859
Andrew Flynn1f452642015-04-14 22:16:04 -0400860 if (VDBG) {
861 log("notifyCarrierNetworkChange: active=" + active);
862 }
863
864 synchronized (mRecords) {
865 mCarrierNetworkChangeState = active;
866 for (Record r : mRecords) {
867 if (r.matchPhoneStateListenerEvent(
868 PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE)) {
869 try {
870 r.callback.onCarrierNetworkChange(active);
871 } catch (RemoteException ex) {
872 mRemoveList.add(r.binder);
873 }
874 }
875 }
876 handleRemoveListLocked();
877 }
878 }
879
Wink Savilleb208a242012-07-25 14:08:09 -0700880 public void notifyCellInfo(List<CellInfo> cellInfo) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800881 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700882 }
883
Wink Saville63f03dd2014-10-23 10:44:45 -0700884 public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700885 if (!checkNotifyPermission("notifyCellInfo()")) {
886 return;
887 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700888 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700889 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700890 + " cellInfo=" + cellInfo);
891 }
John Wang963db55d2012-03-30 16:04:06 -0700892
893 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700894 int phoneId = SubscriptionManager.getPhoneId(subId);
895 if (validatePhoneId(phoneId)) {
896 mCellInfo.set(phoneId, cellInfo);
897 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700898 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhe8b79fb62014-11-05 14:55:03 -0800899 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700900 try {
901 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700902 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700903 }
904 r.callback.onCellInfoChanged(cellInfo);
905 } catch (RemoteException ex) {
906 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700907 }
John Wang963db55d2012-03-30 16:04:06 -0700908 }
909 }
910 }
911 handleRemoveListLocked();
912 }
913 }
914
xinhe43c50292014-09-18 17:56:48 -0700915 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700916 public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700917 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700918 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700919 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700920 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700921 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700922 + " mwi=" + mwi);
923 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800924 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700925 if (validatePhoneId(phoneId)) {
926 mMessageWaiting[phoneId] = mwi;
927 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800928 if (r.matchPhoneStateListenerEvent(
929 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800930 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700931 try {
932 r.callback.onMessageWaitingIndicatorChanged(mwi);
933 } catch (RemoteException ex) {
934 mRemoveList.add(r.binder);
935 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800936 }
937 }
938 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400939 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800940 }
941 }
942
943 public void notifyCallForwardingChanged(boolean cfi) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800944 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700945 }
946
Wink Saville63f03dd2014-10-23 10:44:45 -0700947 public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700948 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700949 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700950 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700951 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700952 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700953 + " cfi=" + cfi);
954 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800955 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700956 int phoneId = SubscriptionManager.getPhoneId(subId);
957 if (validatePhoneId(phoneId)) {
958 mCallForwarding[phoneId] = cfi;
959 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800960 if (r.matchPhoneStateListenerEvent(
961 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800962 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700963 try {
964 r.callback.onCallForwardingIndicatorChanged(cfi);
965 } catch (RemoteException ex) {
966 mRemoveList.add(r.binder);
967 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800968 }
969 }
970 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400971 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972 }
973 }
974
975 public void notifyDataActivity(int state) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800976 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -0700977 }
978
Wink Saville63f03dd2014-10-23 10:44:45 -0700979 public void notifyDataActivityForSubscriber(int subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700980 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700981 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700982 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800983 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700984 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -0800985 if (validatePhoneId(phoneId)) {
986 mDataActivity[phoneId] = state;
987 for (Record r : mRecords) {
988 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY)) {
989 try {
990 r.callback.onDataActivity(state);
991 } catch (RemoteException ex) {
992 mRemoveList.add(r.binder);
993 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800994 }
995 }
996 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400997 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800998 }
999 }
1000
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001001 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001002 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001003 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001004 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
xinhe43c50292014-09-18 17:56:48 -07001005 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001006 networkCapabilities, networkType, roaming);
1007 }
1008
Wink Saville63f03dd2014-10-23 10:44:45 -07001009 public void notifyDataConnectionForSubscriber(int subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -07001010 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
1011 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
1012 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001013 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001014 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001015 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001016 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001017 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001018 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
1019 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -07001020 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
xinheac11ae92014-12-18 10:02:14 -08001021 + " mRecords.size()=" + mRecords.size());
Wink Savillec9acde92011-09-21 11:05:43 -07001022 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001023 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001024 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001025 if (validatePhoneId(phoneId)) {
1026 boolean modified = false;
1027 if (state == TelephonyManager.DATA_CONNECTED) {
1028 if (!mConnectedApns.contains(apnType)) {
1029 mConnectedApns.add(apnType);
1030 if (mDataConnectionState[phoneId] != state) {
1031 mDataConnectionState[phoneId] = state;
1032 modified = true;
1033 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001034 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001035 } else {
1036 if (mConnectedApns.remove(apnType)) {
1037 if (mConnectedApns.isEmpty()) {
1038 mDataConnectionState[phoneId] = state;
1039 modified = true;
1040 } else {
1041 // leave mDataConnectionState as is and
1042 // send out the new status for the APN in question.
Wink Savillebaf21da2014-11-19 16:03:09 -08001043 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001044 }
1045 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001046 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
1047 mDataConnectionReason[phoneId] = reason;
1048 mDataConnectionLinkProperties[phoneId] = linkProperties;
1049 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
1050 if (mDataConnectionNetworkType[phoneId] != networkType) {
1051 mDataConnectionNetworkType[phoneId] = networkType;
1052 // need to tell registered listeners about the new network type
1053 modified = true;
1054 }
1055 if (modified) {
1056 if (DBG) {
1057 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
1058 + ", " + mDataConnectionNetworkType[phoneId] + ")");
1059 }
1060 for (Record r : mRecords) {
1061 if (r.matchPhoneStateListenerEvent(
1062 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) &&
1063 idMatch(r.subId, subId, phoneId)) {
1064 try {
1065 log("Notify data connection state changed on sub: " +
1066 subId);
1067 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1068 mDataConnectionNetworkType[phoneId]);
1069 } catch (RemoteException ex) {
1070 mRemoveList.add(r.binder);
1071 }
1072 }
1073 }
1074 handleRemoveListLocked();
1075 }
1076 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
1077 apnType, apn, reason, linkProperties, "");
1078 for (Record r : mRecords) {
1079 if (r.matchPhoneStateListenerEvent(
1080 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
1081 try {
1082 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1083 } catch (RemoteException ex) {
1084 mRemoveList.add(r.binder);
1085 }
Wink Saville2d1ee982014-11-20 20:29:51 +00001086 }
1087 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001088 }
1089 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001090 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001091 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -07001092 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001093 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
1094 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001095 }
1096
Robert Greenwalt02648a42010-05-18 10:52:51 -07001097 public void notifyDataConnectionFailed(String reason, String apnType) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001098 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
xinhe43c50292014-09-18 17:56:48 -07001099 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001100 }
1101
Wink Saville63f03dd2014-10-23 10:44:45 -07001102 public void notifyDataConnectionFailedForSubscriber(int subId,
Wink Savillefb40dd42014-06-12 17:02:31 -07001103 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001104 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001105 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001106 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001107 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001108 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001109 + " reason=" + reason + " apnType=" + apnType);
1110 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001111 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001112 mPreciseDataConnectionState = new PreciseDataConnectionState(
1113 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
1114 apnType, "", reason, null, "");
1115 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001116 if (r.matchPhoneStateListenerEvent(
1117 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001118 try {
1119 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1120 } catch (RemoteException ex) {
1121 mRemoveList.add(r.binder);
1122 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001123 }
1124 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001125 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001126 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001127 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001128 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1129 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001130 }
1131
1132 public void notifyCellLocation(Bundle cellLocation) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001133 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -07001134 }
1135
Wink Saville63f03dd2014-10-23 10:44:45 -07001136 public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) {
Wink Savillebc027272014-09-08 14:50:58 -07001137 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001138 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001139 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001140 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001141 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001142 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001143 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001144 + " cellLocation=" + cellLocation);
1145 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001146 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001147 int phoneId = SubscriptionManager.getPhoneId(subId);
1148 if (validatePhoneId(phoneId)) {
1149 mCellLocation[phoneId] = cellLocation;
1150 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001151 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhe8b79fb62014-11-05 14:55:03 -08001152 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001153 try {
1154 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001155 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -07001156 + " r=" + r);
1157 }
1158 r.callback.onCellLocationChanged(new Bundle(cellLocation));
1159 } catch (RemoteException ex) {
1160 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001161 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001162 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001163 }
1164 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001165 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -07001166 }
1167 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001168
Wink Savillefd2d0132010-10-28 14:22:26 -07001169 public void notifyOtaspChanged(int otaspMode) {
1170 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
1171 return;
1172 }
1173 synchronized (mRecords) {
1174 mOtaspMode = otaspMode;
1175 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001176 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) {
Wink Savillefd2d0132010-10-28 14:22:26 -07001177 try {
1178 r.callback.onOtaspChanged(otaspMode);
1179 } catch (RemoteException ex) {
1180 mRemoveList.add(r.binder);
1181 }
1182 }
1183 }
1184 handleRemoveListLocked();
1185 }
1186 }
1187
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001188 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1189 int backgroundCallState) {
1190 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1191 return;
1192 }
1193 synchronized (mRecords) {
1194 mRingingCallState = ringingCallState;
1195 mForegroundCallState = foregroundCallState;
1196 mBackgroundCallState = backgroundCallState;
1197 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1198 backgroundCallState,
1199 DisconnectCause.NOT_VALID,
1200 PreciseDisconnectCause.NOT_VALID);
1201 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001202 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001203 try {
1204 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1205 } catch (RemoteException ex) {
1206 mRemoveList.add(r.binder);
1207 }
1208 }
1209 }
1210 handleRemoveListLocked();
1211 }
1212 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1213 DisconnectCause.NOT_VALID,
1214 PreciseDisconnectCause.NOT_VALID);
1215 }
1216
1217 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1218 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1219 return;
1220 }
1221 synchronized (mRecords) {
1222 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1223 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1224 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001225 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001226 try {
1227 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1228 } catch (RemoteException ex) {
1229 mRemoveList.add(r.binder);
1230 }
1231 }
1232 }
1233 handleRemoveListLocked();
1234 }
1235 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1236 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1237 }
1238
1239 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1240 String apn, String failCause) {
1241 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1242 return;
1243 }
1244 synchronized (mRecords) {
1245 mPreciseDataConnectionState = new PreciseDataConnectionState(
1246 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1247 apnType, apn, reason, null, failCause);
1248 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001249 if (r.matchPhoneStateListenerEvent(
1250 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001251 try {
1252 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1253 } catch (RemoteException ex) {
1254 mRemoveList.add(r.binder);
1255 }
1256 }
1257 }
1258 handleRemoveListLocked();
1259 }
1260 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1261 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1262 }
1263
Wink Savillefb40dd42014-06-12 17:02:31 -07001264 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1265 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1266 return;
1267 }
1268 synchronized (mRecords) {
1269 mVoLteServiceState = lteState;
1270 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001271 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001272 try {
1273 r.callback.onVoLteServiceStateChanged(
1274 new VoLteServiceState(mVoLteServiceState));
1275 } catch (RemoteException ex) {
1276 mRemoveList.add(r.binder);
1277 }
1278 }
1279 }
1280 handleRemoveListLocked();
1281 }
1282 }
1283
Wink Saville63f03dd2014-10-23 10:44:45 -07001284 public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001285 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1286 return;
1287 }
1288
1289 synchronized (mRecords) {
1290 for (Record r : mRecords) {
1291 if (VDBG) {
1292 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1293 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001294 if ((r.matchPhoneStateListenerEvent(
1295 PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) &&
New Author Steven Liu485f2092014-09-11 10:18:45 -05001296 ((r.subId == subId) ||
Wink Savilled09c4ca2014-11-22 10:08:16 -08001297 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001298 try {
1299 r.callback.onOemHookRawEvent(rawData);
1300 } catch (RemoteException ex) {
1301 mRemoveList.add(r.binder);
1302 }
1303 }
1304 }
1305 handleRemoveListLocked();
1306 }
1307 }
1308
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001309 @Override
1310 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1311 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1312 != PackageManager.PERMISSION_GRANTED) {
1313 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001314 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001315 return;
1316 }
1317 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001318 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001319 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301320 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1321 pw.println(" Phone Id=" + i);
1322 pw.println(" mCallState=" + mCallState[i]);
1323 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1324 pw.println(" mServiceState=" + mServiceState[i]);
1325 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1326 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1327 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1328 pw.println(" mDataActivity=" + mDataActivity[i]);
1329 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1330 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1331 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1332 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1333 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1334 pw.println(" mDataConnectionNetworkCapabilities=" +
1335 mDataConnectionNetworkCapabilities[i]);
1336 pw.println(" mCellLocation=" + mCellLocation[i]);
1337 pw.println(" mCellInfo=" + mCellInfo.get(i));
1338 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001339 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001340 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001341 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001342 }
1343 }
1344 }
1345
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001346 //
1347 // the legacy intent broadcasting
1348 //
1349
Wink Saville63f03dd2014-10-23 10:44:45 -07001350 private void broadcastServiceStateChanged(ServiceState state, int subId) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001351 long ident = Binder.clearCallingIdentity();
1352 try {
1353 mBatteryStats.notePhoneState(state.getState());
1354 } catch (RemoteException re) {
1355 // Can't do much
1356 } finally {
1357 Binder.restoreCallingIdentity(ident);
1358 }
1359
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001360 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1361 Bundle data = new Bundle();
1362 state.fillInNotifierBundle(data);
1363 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001364 // Pass the subscription along with the intent.
1365 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001366 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001367 }
1368
Wink Saville63f03dd2014-10-23 10:44:45 -07001369 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001370 long ident = Binder.clearCallingIdentity();
1371 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001372 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001373 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001374 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001375 } finally {
1376 Binder.restoreCallingIdentity(ident);
1377 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001378
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001379 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001380 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001381 Bundle data = new Bundle();
1382 signalStrength.fillInNotifierBundle(data);
1383 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001384 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001385 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001386 }
1387
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001388 /**
1389 * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
1390 * a valid subId, in which case this function fires a subId-specific intent, or it
1391 * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
1392 * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
1393 */
Wink Saville63f03dd2014-10-23 10:44:45 -07001394 private void broadcastCallStateChanged(int state, String incomingNumber, int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001395 long ident = Binder.clearCallingIdentity();
1396 try {
1397 if (state == TelephonyManager.CALL_STATE_IDLE) {
1398 mBatteryStats.notePhoneOff();
1399 } else {
1400 mBatteryStats.notePhoneOn();
1401 }
1402 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001403 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001404 } finally {
1405 Binder.restoreCallingIdentity(ident);
1406 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001407
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001408 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001409 intent.putExtra(PhoneConstants.STATE_KEY,
1410 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001411 if (!TextUtils.isEmpty(incomingNumber)) {
1412 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1413 }
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001414
1415 // If a valid subId was specified, we should fire off a subId-specific state
1416 // change intent and include the subId.
1417 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
1418 intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
1419 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
1420 }
1421
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001422 // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
1423 // that have the runtime one
1424 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1425 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001426 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Svet Ganov16a16892015-04-16 10:32:04 -07001427 android.Manifest.permission.READ_PHONE_STATE,
1428 AppOpsManager.OP_READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001429 }
1430
Robert Greenwalt42acef32009-08-12 16:08:25 -07001431 private void broadcastDataConnectionStateChanged(int state,
1432 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001433 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Saville63f03dd2014-10-23 10:44:45 -07001434 NetworkCapabilities networkCapabilities, boolean roaming, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001435 // Note: not reporting to the battery stats service here, because the
1436 // status bar takes care of that after taking into account all of the
1437 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001438 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001439 intent.putExtra(PhoneConstants.STATE_KEY,
1440 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001441 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001442 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001443 }
1444 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001445 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001446 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001447 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001448 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001449 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001450 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001451 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001452 }
1453 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001454 if (networkCapabilities != null) {
1455 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001456 }
Wink Savillea639b312012-07-10 12:37:54 -07001457 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001458
Wink Savillea639b312012-07-10 12:37:54 -07001459 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1460 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001461 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001462 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001463 }
1464
Wink Savillefb40dd42014-06-12 17:02:31 -07001465 private void broadcastDataConnectionFailed(String reason, String apnType,
Wink Saville63f03dd2014-10-23 10:44:45 -07001466 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001467 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001468 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1469 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001470 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001471 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001472 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001473
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001474 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1475 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1476 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1477 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1478 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1479 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1480 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1481 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1482 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1483 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1484 }
1485
1486 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
Wink Savilled09c4ca2014-11-22 10:08:16 -08001487 String apnType, String apn, String reason, LinkProperties linkProperties,
1488 String failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001489 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1490 intent.putExtra(PhoneConstants.STATE_KEY, state);
1491 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1492 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1493 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1494 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001495 if (linkProperties != null) {
1496 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties);
1497 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001498 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1499
1500 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1501 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1502 }
1503
Andrew Flynnceaed682015-06-09 12:36:58 +00001504 private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
1505 if (checkNotifyPermission()) {
1506 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001507 }
1508
Andrew Flynnceaed682015-06-09 12:36:58 +00001509 enforceCarrierPrivilege();
Andrew Flynn1f452642015-04-14 22:16:04 -04001510 }
1511
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001512 private boolean checkNotifyPermission(String method) {
Andrew Flynn1f452642015-04-14 22:16:04 -04001513 if (checkNotifyPermission()) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001514 return true;
1515 }
1516 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001517 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001518 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001519 return false;
1520 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001521
Andrew Flynn1f452642015-04-14 22:16:04 -04001522 private boolean checkNotifyPermission() {
1523 return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1524 == PackageManager.PERMISSION_GRANTED;
1525 }
1526
Andrew Flynnceaed682015-06-09 12:36:58 +00001527 private void enforceCarrierPrivilege() {
Andrew Flynn1f452642015-04-14 22:16:04 -04001528 TelephonyManager tm = TelephonyManager.getDefault();
1529 String[] pkgs = mContext.getPackageManager().getPackagesForUid(Binder.getCallingUid());
1530 for (String pkg : pkgs) {
1531 if (tm.checkCarrierPrivilegesForPackage(pkg) ==
1532 TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
Andrew Flynnceaed682015-06-09 12:36:58 +00001533 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001534 }
1535 }
1536
Andrew Flynnceaed682015-06-09 12:36:58 +00001537 String msg = "Carrier Privilege Permission Denial: from pid=" + Binder.getCallingPid()
1538 + ", uid=" + Binder.getCallingUid();
1539 if (DBG) log(msg);
1540 throw new SecurityException(msg);
Andrew Flynn1f452642015-04-14 22:16:04 -04001541 }
1542
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001543 private void checkListenerPermission(int events) {
1544 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1545 mContext.enforceCallingOrSelfPermission(
1546 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1547
1548 }
1549
John Wang963db55d2012-03-30 16:04:06 -07001550 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1551 mContext.enforceCallingOrSelfPermission(
1552 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1553
1554 }
1555
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001556 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001557 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -07001558 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001559 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
Amit Mahajana9e72a72015-07-30 16:04:13 -07001560 // SKIP checking for run-time permission since caller or self has PRIVILEGED
1561 // permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001562 } catch (SecurityException e) {
1563 mContext.enforceCallingOrSelfPermission(
1564 android.Manifest.permission.READ_PHONE_STATE, null);
1565 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001566 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001567
1568 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1569 mContext.enforceCallingOrSelfPermission(
1570 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1571
1572 }
New Author Steven Liu485f2092014-09-11 10:18:45 -05001573
1574 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1575 mContext.enforceCallingOrSelfPermission(
1576 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1577 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001578 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001579
1580 private void handleRemoveListLocked() {
Wink Savillea374c3d2014-11-11 11:48:04 -08001581 int size = mRemoveList.size();
1582 if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size);
1583 if (size > 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -04001584 for (IBinder b: mRemoveList) {
1585 remove(b);
1586 }
1587 mRemoveList.clear();
1588 }
1589 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001590
1591 private boolean validateEventsAndUserLocked(Record r, int events) {
1592 int foregroundUser;
1593 long callingIdentity = Binder.clearCallingIdentity();
1594 boolean valid = false;
1595 try {
1596 foregroundUser = ActivityManager.getCurrentUser();
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001597 valid = r.callerUserId == foregroundUser && r.matchPhoneStateListenerEvent(events);
Wink Savillea12a7b32012-09-20 10:09:45 -07001598 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001599 log("validateEventsAndUserLocked: valid=" + valid
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001600 + " r.callerUserId=" + r.callerUserId + " foregroundUser=" + foregroundUser
Wink Savillea12a7b32012-09-20 10:09:45 -07001601 + " r.events=" + r.events + " events=" + events);
1602 }
1603 } finally {
1604 Binder.restoreCallingIdentity(callingIdentity);
1605 }
1606 return valid;
1607 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001608
1609 private boolean validatePhoneId(int phoneId) {
1610 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001611 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001612 return valid;
1613 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001614
1615 private static void log(String s) {
1616 Rlog.d(TAG, s);
1617 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001618
1619 private static class LogSSC {
1620 private Time mTime;
1621 private String mS;
Wink Saville63f03dd2014-10-23 10:44:45 -07001622 private int mSubId;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001623 private int mPhoneId;
1624 private ServiceState mState;
1625
Wink Saville63f03dd2014-10-23 10:44:45 -07001626 public void set(Time t, String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001627 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1628 }
1629
1630 @Override
1631 public String toString() {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001632 return mS + " Time " + mTime.toString() + " mSubId " + mSubId + " mPhoneId "
1633 + mPhoneId + " mState " + mState;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001634 }
1635 }
1636
1637 private LogSSC logSSC [] = new LogSSC[10];
1638 private int next = 0;
1639
Wink Saville63f03dd2014-10-23 10:44:45 -07001640 private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001641 if (logSSC == null || logSSC.length == 0) {
1642 return;
1643 }
1644 if (logSSC[next] == null) {
1645 logSSC[next] = new LogSSC();
1646 }
1647 Time t = new Time();
1648 t.setToNow();
1649 logSSC[next].set(t, s, subId, phoneId, state);
1650 if (++next >= logSSC.length) {
1651 next = 0;
1652 }
1653 }
1654
1655 private void toStringLogSSC(String prompt) {
1656 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1657 log(prompt + ": logSSC is empty");
1658 } else {
1659 // There is at least one element
1660 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1661 int i = next;
1662 if (logSSC[i] == null) {
1663 // logSSC is not full so back to the beginning
1664 i = 0;
1665 }
1666 do {
1667 log(logSSC[i].toString());
1668 if (++i >= logSSC.length) {
1669 i = 0;
1670 }
1671 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001672 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001673 }
1674 }
xinhee9f16402014-09-25 16:39:28 -07001675
xinhe8b79fb62014-11-05 14:55:03 -08001676 boolean idMatch(int rSubId, int subId, int phoneId) {
xinheac11ae92014-12-18 10:02:14 -08001677
1678 if(subId < 0) {
1679 // Invalid case, we need compare phoneId with default one.
1680 return (mDefaultPhoneId == phoneId);
1681 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001682 if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
xinhee9f16402014-09-25 16:39:28 -07001683 return (subId == mDefaultSubId);
1684 } else {
1685 return (rSubId == subId);
1686 }
1687 }
1688
1689 private void checkPossibleMissNotify(Record r, int phoneId) {
1690 int events = r.events;
1691
1692 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1693 try {
1694 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1695 mServiceState[phoneId]);
1696 r.callback.onServiceStateChanged(
1697 new ServiceState(mServiceState[phoneId]));
1698 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001699 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001700 }
1701 }
1702
1703 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1704 try {
1705 SignalStrength signalStrength = mSignalStrength[phoneId];
1706 if (DBG) {
1707 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1708 }
1709 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1710 } catch (RemoteException ex) {
1711 mRemoveList.add(r.binder);
1712 }
1713 }
1714
1715 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1716 try {
1717 int gsmSignalStrength = mSignalStrength[phoneId]
1718 .getGsmSignalStrength();
1719 if (DBG) {
1720 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1721 gsmSignalStrength);
1722 }
1723 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1724 : gsmSignalStrength));
1725 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001726 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001727 }
1728 }
1729
1730 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1731 try {
1732 if (DBG_LOC) {
1733 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1734 + mCellInfo.get(phoneId));
1735 }
1736 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1737 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001738 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001739 }
1740 }
1741
1742 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1743 try {
1744 if (VDBG) {
1745 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1746 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1747 }
1748 r.callback.onMessageWaitingIndicatorChanged(
1749 mMessageWaiting[phoneId]);
1750 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001751 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001752 }
1753 }
1754
1755 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1756 try {
1757 if (VDBG) {
1758 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1759 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1760 }
1761 r.callback.onCallForwardingIndicatorChanged(
1762 mCallForwarding[phoneId]);
1763 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001764 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001765 }
1766 }
1767
1768 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1769 try {
1770 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1771 + mCellLocation[phoneId]);
1772 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1773 } catch (RemoteException ex) {
1774 mRemoveList.add(r.binder);
1775 }
1776 }
1777
1778 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1779 try {
1780 if (DBG) {
1781 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1782 + "=" + mDataConnectionState[phoneId]
1783 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1784 + ")");
1785 }
1786 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1787 mDataConnectionNetworkType[phoneId]);
1788 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001789 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001790 }
1791 }
1792 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001793}