blob: b46b6149ab538f1cc09a4ba4d02c0c3ccb152c8c [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
Wink Savillea12a7b32012-09-20 10:09:45 -070019import android.app.ActivityManager;
20import android.content.BroadcastReceiver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.content.Context;
22import android.content.Intent;
Wink Savillea12a7b32012-09-20 10:09:45 -070023import android.content.IntentFilter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024import android.content.pm.PackageManager;
Robert Greenwalt37e65eb2010-08-30 10:56:47 -070025import android.net.LinkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070026import android.net.NetworkCapabilities;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.os.Binder;
28import android.os.Bundle;
Wink Savillea12a7b32012-09-20 10:09:45 -070029import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.IBinder;
Wink Savillea12a7b32012-09-20 10:09:45 -070031import android.os.Message;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.os.RemoteException;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070033import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.telephony.CellLocation;
Wink Saville070e0612014-04-15 22:04:10 -070035import android.telephony.DataConnectionRealTimeInfo;
Wink Savillef4cd25b2014-07-08 19:03:20 -070036import android.telephony.Rlog;
Wink Savillefb40dd42014-06-12 17:02:31 -070037import android.telephony.TelephonyManager;
38import android.telephony.SubscriptionManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039import android.telephony.PhoneStateListener;
40import android.telephony.ServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -070041import android.telephony.SignalStrength;
John Wang963db55d2012-03-30 16:04:06 -070042import android.telephony.CellInfo;
Wink Savillefb40dd42014-06-12 17:02:31 -070043import android.telephony.VoLteServiceState;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080044import android.telephony.TelephonyManager;
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 Saville47d8d1b2014-07-10 13:01:52 -070053import java.util.Calendar;
Wink Savilleb208a242012-07-25 14:08:09 -070054import java.util.List;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055import java.io.FileDescriptor;
56import java.io.PrintWriter;
57
58import com.android.internal.app.IBatteryStats;
59import 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
75 * compare properly. Because SubscriptionManager.getPhoneId(long subId) handles
76 * 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 {
88 String pkgForDebug;
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 Savillee9b06d72009-05-18 21:47:50 -070093
Wink Savillea12a7b32012-09-20 10:09:45 -070094 int callerUid;
95
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 int events;
Wink Savillea12a7b32012-09-20 10:09:45 -070097
Wink Savillefb40dd42014-06-12 17:02:31 -070098 long subId;
99
Wink Savillee380b982014-07-26 18:24:22 -0700100 int phoneId;
101
Wink Savillea12a7b32012-09-20 10:09:45 -0700102 @Override
103 public String toString() {
Wink Savilleeeacf932014-06-18 01:07:10 -0700104 return "{pkgForDebug=" + pkgForDebug + " callerUid=" + callerUid + " subId=" + subId +
Wink Savillee380b982014-07-26 18:24:22 -0700105 " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}";
Wink Savillea12a7b32012-09-20 10:09:45 -0700106 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800107 }
108
109 private final Context mContext;
Wink Savillee9b06d72009-05-18 21:47:50 -0700110
Joe Onorato163d8d92010-10-21 13:21:20 -0400111 // access should be inside synchronized (mRecords) for these two fields
112 private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>();
113 private final ArrayList<Record> mRecords = new ArrayList<Record>();
Wink Savillee9b06d72009-05-18 21:47:50 -0700114
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800115 private final IBatteryStats mBatteryStats;
116
Wink Savillefb40dd42014-06-12 17:02:31 -0700117 private int mNumPhones;
Wink Savillee9b06d72009-05-18 21:47:50 -0700118
Wink Savillefb40dd42014-06-12 17:02:31 -0700119 private int[] mCallState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700120
Wink Savillefb40dd42014-06-12 17:02:31 -0700121 private String[] mCallIncomingNumber;
Wink Savillee9b06d72009-05-18 21:47:50 -0700122
Wink Savillefb40dd42014-06-12 17:02:31 -0700123 private ServiceState[] mServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700124
Wink Savillefb40dd42014-06-12 17:02:31 -0700125 private SignalStrength[] mSignalStrength;
Wink Savillee9b06d72009-05-18 21:47:50 -0700126
Wink Savillefb40dd42014-06-12 17:02:31 -0700127 private boolean[] mMessageWaiting;
Wink Savillee9b06d72009-05-18 21:47:50 -0700128
Wink Savillefb40dd42014-06-12 17:02:31 -0700129 private boolean[] mCallForwarding;
Wink Savillee9b06d72009-05-18 21:47:50 -0700130
Wink Savillefb40dd42014-06-12 17:02:31 -0700131 private int[] mDataActivity;
Wink Savillee9b06d72009-05-18 21:47:50 -0700132
Wink Savillefb40dd42014-06-12 17:02:31 -0700133 private int[] mDataConnectionState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700134
Wink Savillefb40dd42014-06-12 17:02:31 -0700135 private boolean[] mDataConnectionPossible;
Wink Savillee9b06d72009-05-18 21:47:50 -0700136
Wink Savillefb40dd42014-06-12 17:02:31 -0700137 private String[] mDataConnectionReason;
138
139 private String[] mDataConnectionApn;
Wink Savillee9b06d72009-05-18 21:47:50 -0700140
Robert Greenwalt02648a42010-05-18 10:52:51 -0700141 private ArrayList<String> mConnectedApns;
Robert Greenwalt42acef32009-08-12 16:08:25 -0700142
Wink Savillefb40dd42014-06-12 17:02:31 -0700143 private LinkProperties[] mDataConnectionLinkProperties;
Wink Savillef61101f2010-09-16 16:36:42 -0700144
Wink Savillefb40dd42014-06-12 17:02:31 -0700145 private NetworkCapabilities[] mDataConnectionNetworkCapabilities;
Wink Savillee9b06d72009-05-18 21:47:50 -0700146
Wink Savillefb40dd42014-06-12 17:02:31 -0700147 private Bundle[] mCellLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800148
Wink Savillefb40dd42014-06-12 17:02:31 -0700149 private int[] mDataConnectionNetworkType;
Robert Greenwalt98e0b142009-10-08 21:15:52 -0700150
Wink Savillec9330dd2011-01-12 13:37:38 -0800151 private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
Wink Savillefd2d0132010-10-28 14:22:26 -0700152
Wink Savillefb40dd42014-06-12 17:02:31 -0700153 private ArrayList<List<CellInfo>> mCellInfo = null;
154
155 private VoLteServiceState mVoLteServiceState = new VoLteServiceState();
156
xinhee9f16402014-09-25 16:39:28 -0700157 private long mDefaultSubId = SubscriptionManager.INVALID_SUB_ID;
158
159 private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_ID;
160
Wink Saville070e0612014-04-15 22:04:10 -0700161 private DataConnectionRealTimeInfo mDcRtInfo = new DataConnectionRealTimeInfo();
162
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200163 private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
164
165 private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
166
167 private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
168
169 private PreciseCallState mPreciseCallState = new PreciseCallState();
170
171 private PreciseDataConnectionState mPreciseDataConnectionState =
172 new PreciseDataConnectionState();
173
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700174 static final int PHONE_STATE_PERMISSION_MASK =
175 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
176 PhoneStateListener.LISTEN_CALL_STATE |
177 PhoneStateListener.LISTEN_DATA_ACTIVITY |
178 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE |
Wink Savillefb40dd42014-06-12 17:02:31 -0700179 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
180 PhoneStateListener.LISTEN_VOLTE_STATE;;
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700181
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200182 static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
183 PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
184 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
185
Wink Savillea12a7b32012-09-20 10:09:45 -0700186 private static final int MSG_USER_SWITCHED = 1;
Wink Savillefb40dd42014-06-12 17:02:31 -0700187 private static final int MSG_UPDATE_DEFAULT_SUB = 2;
Wink Savillea12a7b32012-09-20 10:09:45 -0700188
189 private final Handler mHandler = new Handler() {
190 @Override
191 public void handleMessage(Message msg) {
192 switch (msg.what) {
193 case MSG_USER_SWITCHED: {
Wink Savillee380b982014-07-26 18:24:22 -0700194 if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
Wink Savillefb40dd42014-06-12 17:02:31 -0700195 int numPhones = TelephonyManager.getDefault().getPhoneCount();
196 for (int sub = 0; sub < numPhones; sub++) {
Wink Savillebc027272014-09-08 14:50:58 -0700197 TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
Wink Savillee380b982014-07-26 18:24:22 -0700198 mCellLocation[sub]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700199 }
200 break;
201 }
xinhee9f16402014-09-25 16:39:28 -0700202 case MSG_UPDATE_DEFAULT_SUB: {
203 int newDefaultPhoneId = msg.arg1;
204 long newDefaultSubId = (Long)(msg.obj);
205 if (VDBG) {
206 log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId
207 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
208 + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId);
209 }
210
211 //Due to possible risk condition,(notify call back using the new
212 //defaultSubId comes before new defaultSubId update) we need to recall all
213 //possible missed notify callback
214 synchronized (mRecords) {
215 for (Record r : mRecords) {
216 if(r.subId == SubscriptionManager.DEFAULT_SUB_ID) {
217 checkPossibleMissNotify(r, newDefaultPhoneId);
218 }
219 }
220 }
221 mDefaultSubId = newDefaultSubId;
222 mDefaultPhoneId = newDefaultPhoneId;
Wink Savillea12a7b32012-09-20 10:09:45 -0700223 }
224 }
225 }
226 };
227
228 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
229 @Override
230 public void onReceive(Context context, Intent intent) {
231 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700232 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700233 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700234 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700235 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700236 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700237 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
xinhee9f16402014-09-25 16:39:28 -0700238 Long newDefaultSubIdObj = new Long(intent.getLongExtra(
239 PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSubId()));
240 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
241 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700242 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700243 log("onReceive:current mDefaultSubId=" + mDefaultSubId
244 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
245 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700246 }
xinhee9f16402014-09-25 16:39:28 -0700247
248 if(validatePhoneId(newDefaultPhoneId) && (newDefaultSubIdObj.equals(mDefaultSubId)
249 || (newDefaultPhoneId != mDefaultPhoneId))) {
250 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
251 newDefaultPhoneId, 0, newDefaultSubIdObj));
252 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700253 }
254 }
255 };
256
Wink Savillee9b06d72009-05-18 21:47:50 -0700257 // we keep a copy of all of the state so we can send it out when folks
258 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800259 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700260 // In these calls we call with the lock held. This is safe becasuse remote
261 // calls go through a oneway interface and local calls going through a
262 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800263
264 TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700265 CellLocation location = CellLocation.getEmpty();
266
Wink Savillefb40dd42014-06-12 17:02:31 -0700267 mContext = context;
268 mBatteryStats = BatteryStatsService.getService();
269 mConnectedApns = new ArrayList<String>();
270
Wink Savillefb40dd42014-06-12 17:02:31 -0700271 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700272 if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700273 mNumPhones = numPhones;
274 mCallState = new int[numPhones];
275 mDataActivity = new int[numPhones];
276 mDataConnectionState = new int[numPhones];
277 mDataConnectionNetworkType = new int[numPhones];
278 mCallIncomingNumber = new String[numPhones];
279 mServiceState = new ServiceState[numPhones];
280 mSignalStrength = new SignalStrength[numPhones];
281 mMessageWaiting = new boolean[numPhones];
282 mDataConnectionPossible = new boolean[numPhones];
283 mDataConnectionReason = new String[numPhones];
284 mDataConnectionApn = new String[numPhones];
285 mCallForwarding = new boolean[numPhones];
286 mCellLocation = new Bundle[numPhones];
287 mDataConnectionLinkProperties = new LinkProperties[numPhones];
288 mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones];
289 mCellInfo = new ArrayList<List<CellInfo>>();
290 for (int i = 0; i < numPhones; i++) {
291 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
292 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
293 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
294 mCallIncomingNumber[i] = "";
295 mServiceState[i] = new ServiceState();
296 mSignalStrength[i] = new SignalStrength();
297 mMessageWaiting[i] = false;
298 mCallForwarding[i] = false;
299 mDataConnectionPossible[i] = false;
300 mDataConnectionReason[i] = "";
301 mDataConnectionApn[i] = "";
302 mCellLocation[i] = new Bundle();
303 mCellInfo.add(i, null);
304 }
305
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700306 // Note that location can be null for non-phone builds like
307 // like the generic one.
308 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700309 for (int i = 0; i < numPhones; i++) {
310 location.fillInNotifierBundle(mCellLocation[i]);
311 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700312 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700313 mConnectedApns = new ArrayList<String>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800314 }
315
Svetoslav Ganova0027152013-06-25 14:59:53 -0700316 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700317 // Watch for interesting updates
318 final IntentFilter filter = new IntentFilter();
319 filter.addAction(Intent.ACTION_USER_SWITCHED);
320 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700321 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700322 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700323 mContext.registerReceiver(mBroadcastReceiver, filter);
324 }
325
326 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800327 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
328 boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700329 listenForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, pkgForDebug, callback, events,
330 notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700331 }
332
333 @Override
Wink Savillebc027272014-09-08 14:50:58 -0700334 public void listenForSubscriber(long subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700335 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700336 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700337 }
338
339 private void listen(String pkgForDebug, IPhoneStateListener callback, int events,
xinhe43c50292014-09-18 17:56:48 -0700340 boolean notifyNow, long subId) {
Wink Savillea12a7b32012-09-20 10:09:45 -0700341 int callerUid = UserHandle.getCallingUserId();
342 int myUid = UserHandle.myUserId();
Wink Savillee380b982014-07-26 18:24:22 -0700343 if (VDBG) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700344 log("listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events)
xinhe43c50292014-09-18 17:56:48 -0700345 + " notifyNow=" + notifyNow + " subId=" + subId + " myUid=" + myUid
Wink Savillea12a7b32012-09-20 10:09:45 -0700346 + " callerUid=" + callerUid);
347 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800348 if (events != 0) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700349 /* Checks permission and throws Security exception */
350 checkListenerPermission(events);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800351
352 synchronized (mRecords) {
353 // register
354 Record r = null;
355 find_and_add: {
356 IBinder b = callback.asBinder();
357 final int N = mRecords.size();
Wink Savillee9b06d72009-05-18 21:47:50 -0700358 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800359 r = mRecords.get(i);
360 if (b == r.binder) {
361 break find_and_add;
362 }
363 }
364 r = new Record();
365 r.binder = b;
366 r.callback = callback;
367 r.pkgForDebug = pkgForDebug;
Wink Savillea12a7b32012-09-20 10:09:45 -0700368 r.callerUid = callerUid;
xinhe43c50292014-09-18 17:56:48 -0700369 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
370 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
371 if (!SubscriptionManager.isValidSubId(subId)) {
372 r.subId = SubscriptionManager.DEFAULT_SUB_ID;
373 } else {//APP specify subID
374 r.subId = subId;
Wink Savillefb40dd42014-06-12 17:02:31 -0700375 }
xinhe43c50292014-09-18 17:56:48 -0700376 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
377
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800378 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700379 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800380 }
xinhe43c50292014-09-18 17:56:48 -0700381
382 int phoneId = r.phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800383 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700384 if (DBG) {
xinhe43c50292014-09-18 17:56:48 -0700385 log("listen: r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700386 }
387 if (VDBG) toStringLogSSC("listen");
Wink Savillefb40dd42014-06-12 17:02:31 -0700388 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800389 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400390 try {
Wink Savillee380b982014-07-26 18:24:22 -0700391 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700392 r.callback.onServiceStateChanged(
393 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400394 } catch (RemoteException ex) {
395 remove(r.binder);
396 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 }
398 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
399 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700400 int gsmSignalStrength = mSignalStrength[phoneId]
401 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700402 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
403 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800404 } catch (RemoteException ex) {
405 remove(r.binder);
406 }
407 }
408 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
409 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700410 r.callback.onMessageWaitingIndicatorChanged(
411 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800412 } catch (RemoteException ex) {
413 remove(r.binder);
414 }
415 }
416 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
417 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700418 r.callback.onCallForwardingIndicatorChanged(
419 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800420 } catch (RemoteException ex) {
421 remove(r.binder);
422 }
423 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700424 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400425 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700426 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700427 + mCellLocation[phoneId]);
428 r.callback.onCellLocationChanged(
429 new Bundle(mCellLocation[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400430 } catch (RemoteException ex) {
431 remove(r.binder);
432 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800433 }
434 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
435 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700436 r.callback.onCallStateChanged(mCallState[phoneId],
437 mCallIncomingNumber[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800438 } catch (RemoteException ex) {
439 remove(r.binder);
440 }
441 }
442 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
443 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700444 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
445 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 } catch (RemoteException ex) {
447 remove(r.binder);
448 }
449 }
450 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
451 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700452 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800453 } catch (RemoteException ex) {
454 remove(r.binder);
455 }
456 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700457 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
458 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700459 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700460 } catch (RemoteException ex) {
461 remove(r.binder);
462 }
463 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700464 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
465 try {
466 r.callback.onOtaspChanged(mOtaspMode);
467 } catch (RemoteException ex) {
468 remove(r.binder);
469 }
470 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700471 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700472 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700473 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700474 + mCellInfo.get(phoneId));
475 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
John Wang963db55d2012-03-30 16:04:06 -0700476 } catch (RemoteException ex) {
477 remove(r.binder);
478 }
479 }
Wink Saville070e0612014-04-15 22:04:10 -0700480 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) {
481 try {
482 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
483 } catch (RemoteException ex) {
484 remove(r.binder);
485 }
486 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200487 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
488 try {
489 r.callback.onPreciseCallStateChanged(mPreciseCallState);
490 } catch (RemoteException ex) {
491 remove(r.binder);
492 }
493 }
494 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
495 try {
496 r.callback.onPreciseDataConnectionStateChanged(
497 mPreciseDataConnectionState);
498 } catch (RemoteException ex) {
499 remove(r.binder);
500 }
501 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 }
503 }
504 } else {
505 remove(callback.asBinder());
506 }
507 }
508
509 private void remove(IBinder binder) {
510 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700511 final int recordCount = mRecords.size();
512 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800513 if (mRecords.get(i).binder == binder) {
514 mRecords.remove(i);
515 return;
516 }
517 }
518 }
519 }
520
521 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700522 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700523 return;
524 }
xinhe43c50292014-09-18 17:56:48 -0700525
526 if (VDBG) {
527 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
528 }
529
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700531 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700532 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700533 (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800534 try {
535 r.callback.onCallStateChanged(state, incomingNumber);
536 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400537 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800538 }
539 }
540 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400541 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800542 }
xinhe43c50292014-09-18 17:56:48 -0700543 broadcastCallStateChanged(state, incomingNumber, SubscriptionManager.DEFAULT_SUB_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 }
545
Wink Savillebc027272014-09-08 14:50:58 -0700546 public void notifyCallStateForSubscriber(long subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700547 if (!checkNotifyPermission("notifyCallState()")) {
548 return;
549 }
Wink Savillee380b982014-07-26 18:24:22 -0700550 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700551 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700552 + " state=" + state + " incomingNumber=" + incomingNumber);
553 }
554 synchronized (mRecords) {
555 int phoneId = SubscriptionManager.getPhoneId(subId);
556 if (validatePhoneId(phoneId)) {
557 mCallState[phoneId] = state;
558 mCallIncomingNumber[phoneId] = incomingNumber;
559 for (Record r : mRecords) {
560 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700561 (r.subId == subId) &&
562 (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700563 try {
564 r.callback.onCallStateChanged(state, incomingNumber);
565 } catch (RemoteException ex) {
566 mRemoveList.add(r.binder);
567 }
568 }
569 }
570 }
571 handleRemoveListLocked();
572 }
573 broadcastCallStateChanged(state, incomingNumber, subId);
574 }
575
xinhe43c50292014-09-18 17:56:48 -0700576 public void notifyServiceStateForPhoneId(int phoneId, long subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700577 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700578 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700579 }
xinhe43c50292014-09-18 17:56:48 -0700580
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800581 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700582 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700583 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700584 + " state=" + state);
585 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700586 if (validatePhoneId(phoneId)) {
587 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700588 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
589 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700590
Wink Savillefb40dd42014-06-12 17:02:31 -0700591 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700592 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700593 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700594 + " phoneId=" + phoneId + " state=" + state);
595 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700596 if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700597 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700598 try {
Wink Savillee380b982014-07-26 18:24:22 -0700599 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700600 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700601 + " subId=" + subId + " phoneId=" + phoneId
602 + " state=" + state);
603 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700604 r.callback.onServiceStateChanged(new ServiceState(state));
605 } catch (RemoteException ex) {
606 mRemoveList.add(r.binder);
607 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400608 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800609 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700610 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700611 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800612 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400613 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700615 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 }
617
Wink Savillee9b06d72009-05-18 21:47:50 -0700618 public void notifySignalStrength(SignalStrength signalStrength) {
xinhe43c50292014-09-18 17:56:48 -0700619 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700620 }
621
Wink Savillebc027272014-09-08 14:50:58 -0700622 public void notifySignalStrengthForSubscriber(long subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700623 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700624 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700625 }
Wink Savillee380b982014-07-26 18:24:22 -0700626 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700627 log("notifySignalStrengthForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700628 + " signalStrength=" + signalStrength);
Wink Savillebc027272014-09-08 14:50:58 -0700629 toStringLogSSC("notifySignalStrengthForSubscriber");
Wink Savillefb40dd42014-06-12 17:02:31 -0700630 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800631 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700632 int phoneId = SubscriptionManager.getPhoneId(subId);
633 if (validatePhoneId(phoneId)) {
Wink Savillebc027272014-09-08 14:50:58 -0700634 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700635 mSignalStrength[phoneId] = signalStrength;
636 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700637 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700638 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700639 + " phoneId=" + phoneId + " ss=" + signalStrength);
640 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700641 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700642 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700643 try {
Wink Savillee380b982014-07-26 18:24:22 -0700644 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700645 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700646 + " subId=" + subId + " phoneId=" + phoneId
647 + " ss=" + signalStrength);
648 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700649 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
650 } catch (RemoteException ex) {
651 mRemoveList.add(r.binder);
652 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400653 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700654 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700655 subIdMatch(r.subId, subId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700656 try {
657 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700658 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Wink Savillee380b982014-07-26 18:24:22 -0700659 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700660 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700661 + " subId=" + subId + " phoneId=" + phoneId
662 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
663 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700664 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700665 } catch (RemoteException ex) {
666 mRemoveList.add(r.binder);
667 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800668 }
669 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700670 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700671 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800672 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400673 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800674 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700675 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800676 }
677
Wink Savilleb208a242012-07-25 14:08:09 -0700678 public void notifyCellInfo(List<CellInfo> cellInfo) {
xinhe43c50292014-09-18 17:56:48 -0700679 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700680 }
681
Wink Savillebc027272014-09-08 14:50:58 -0700682 public void notifyCellInfoForSubscriber(long subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700683 if (!checkNotifyPermission("notifyCellInfo()")) {
684 return;
685 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700686 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700687 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700688 + " cellInfo=" + cellInfo);
689 }
John Wang963db55d2012-03-30 16:04:06 -0700690
691 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700692 int phoneId = SubscriptionManager.getPhoneId(subId);
693 if (validatePhoneId(phoneId)) {
694 mCellInfo.set(phoneId, cellInfo);
695 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700696 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhee9f16402014-09-25 16:39:28 -0700697 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700698 try {
699 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700700 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700701 }
702 r.callback.onCellInfoChanged(cellInfo);
703 } catch (RemoteException ex) {
704 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700705 }
John Wang963db55d2012-03-30 16:04:06 -0700706 }
707 }
708 }
709 handleRemoveListLocked();
710 }
711 }
712
Wink Saville070e0612014-04-15 22:04:10 -0700713 public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) {
714 if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) {
715 return;
716 }
717
718 synchronized (mRecords) {
719 mDcRtInfo = dcRtInfo;
720 for (Record r : mRecords) {
721 if (validateEventsAndUserLocked(r,
722 PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) {
723 try {
724 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700725 log("notifyDataConnectionRealTimeInfo: mDcRtInfo="
Wink Saville070e0612014-04-15 22:04:10 -0700726 + mDcRtInfo + " r=" + r);
727 }
728 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
729 } catch (RemoteException ex) {
730 mRemoveList.add(r.binder);
731 }
732 }
733 }
734 handleRemoveListLocked();
735 }
736 }
737
xinhe43c50292014-09-18 17:56:48 -0700738 @Override
739 public void notifyMessageWaitingChangedForPhoneId(int phoneId, long subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700740 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700741 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700742 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700743 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700744 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700745 + " mwi=" + mwi);
746 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800747 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700748 if (validatePhoneId(phoneId)) {
749 mMessageWaiting[phoneId] = mwi;
750 for (Record r : mRecords) {
751 if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700752 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700753 try {
754 r.callback.onMessageWaitingIndicatorChanged(mwi);
755 } catch (RemoteException ex) {
756 mRemoveList.add(r.binder);
757 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800758 }
759 }
760 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400761 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800762 }
763 }
764
765 public void notifyCallForwardingChanged(boolean cfi) {
xinhe43c50292014-09-18 17:56:48 -0700766 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700767 }
768
Wink Savillebc027272014-09-08 14:50:58 -0700769 public void notifyCallForwardingChangedForSubscriber(long subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700770 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700771 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700772 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700773 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700774 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700775 + " cfi=" + cfi);
776 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800777 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700778 int phoneId = SubscriptionManager.getPhoneId(subId);
779 if (validatePhoneId(phoneId)) {
780 mCallForwarding[phoneId] = cfi;
781 for (Record r : mRecords) {
782 if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700783 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700784 try {
785 r.callback.onCallForwardingIndicatorChanged(cfi);
786 } catch (RemoteException ex) {
787 mRemoveList.add(r.binder);
788 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800789 }
790 }
791 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400792 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800793 }
794 }
795
796 public void notifyDataActivity(int state) {
xinhe43c50292014-09-18 17:56:48 -0700797 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -0700798 }
799
Wink Savillebc027272014-09-08 14:50:58 -0700800 public void notifyDataActivityForSubscriber(long subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700801 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700802 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700803 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800804 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700805 int phoneId = SubscriptionManager.getPhoneId(subId);
806 mDataActivity[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700807 for (Record r : mRecords) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800808 if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
809 try {
810 r.callback.onDataActivity(state);
811 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400812 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800813 }
814 }
815 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400816 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800817 }
818 }
819
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700820 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -0700821 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -0700822 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
xinhe43c50292014-09-18 17:56:48 -0700823 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state,
824 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -0700825 networkCapabilities, networkType, roaming);
826 }
827
Wink Savillebc027272014-09-08 14:50:58 -0700828 public void notifyDataConnectionForSubscriber(long subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -0700829 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
830 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
831 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700832 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700833 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700834 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700835 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700836 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700837 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
838 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -0700839 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
840 + " mRecords.size()=" + mRecords.size() + " mRecords=" + mRecords);
Wink Savillec9acde92011-09-21 11:05:43 -0700841 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800842 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700843 int phoneId = SubscriptionManager.getPhoneId(subId);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700844 boolean modified = false;
845 if (state == TelephonyManager.DATA_CONNECTED) {
846 if (!mConnectedApns.contains(apnType)) {
847 mConnectedApns.add(apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700848 if (mDataConnectionState[phoneId] != state) {
849 mDataConnectionState[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700850 modified = true;
851 }
852 }
853 } else {
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800854 if (mConnectedApns.remove(apnType)) {
855 if (mConnectedApns.isEmpty()) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700856 mDataConnectionState[phoneId] = state;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800857 modified = true;
858 } else {
859 // leave mDataConnectionState as is and
860 // send out the new status for the APN in question.
861 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700862 }
863 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700864 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
865 mDataConnectionReason[phoneId] = reason;
866 mDataConnectionLinkProperties[phoneId] = linkProperties;
867 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
868 if (mDataConnectionNetworkType[phoneId] != networkType) {
869 mDataConnectionNetworkType[phoneId] = networkType;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800870 // need to tell registered listeners about the new network type
Robert Greenwalt02648a42010-05-18 10:52:51 -0700871 modified = true;
872 }
873 if (modified) {
Wink Savillec9acde92011-09-21 11:05:43 -0700874 if (DBG) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700875 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
Wink Savillefb40dd42014-06-12 17:02:31 -0700876 + ", " + mDataConnectionNetworkType[phoneId] + ")");
Wink Savillec9acde92011-09-21 11:05:43 -0700877 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700878 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700879 if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700880 subIdMatch(r.subId, subId)) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700881 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700882 log("Notify data connection state changed on sub: " +
Wink Savillefb40dd42014-06-12 17:02:31 -0700883 subId);
884 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
885 mDataConnectionNetworkType[phoneId]);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700886 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400887 mRemoveList.add(r.binder);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700888 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800889 }
890 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400891 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200893 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
894 apnType, apn, reason, linkProperties, "");
895 for (Record r : mRecords) {
896 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
897 try {
898 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
899 } catch (RemoteException ex) {
900 mRemoveList.add(r.binder);
901 }
902 }
903 }
904 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800905 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700906 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -0700907 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200908 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
909 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 }
911
Robert Greenwalt02648a42010-05-18 10:52:51 -0700912 public void notifyDataConnectionFailed(String reason, String apnType) {
xinhe43c50292014-09-18 17:56:48 -0700913 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID,
914 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700915 }
916
Wink Savillebc027272014-09-08 14:50:58 -0700917 public void notifyDataConnectionFailedForSubscriber(long subId,
Wink Savillefb40dd42014-06-12 17:02:31 -0700918 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700919 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700920 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700921 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700922 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700923 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700924 + " reason=" + reason + " apnType=" + apnType);
925 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800926 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200927 mPreciseDataConnectionState = new PreciseDataConnectionState(
928 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
929 apnType, "", reason, null, "");
930 for (Record r : mRecords) {
931 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
932 try {
933 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
934 } catch (RemoteException ex) {
935 mRemoveList.add(r.binder);
936 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800937 }
938 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200939 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800940 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700941 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200942 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
943 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800944 }
945
946 public void notifyCellLocation(Bundle cellLocation) {
xinhe43c50292014-09-18 17:56:48 -0700947 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -0700948 }
949
Wink Savillebc027272014-09-08 14:50:58 -0700950 public void notifyCellLocationForSubscriber(long subId, Bundle cellLocation) {
951 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700952 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700953 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700954 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700955 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700956 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700957 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700958 + " cellLocation=" + cellLocation);
959 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800960 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700961 int phoneId = SubscriptionManager.getPhoneId(subId);
962 if (validatePhoneId(phoneId)) {
963 mCellLocation[phoneId] = cellLocation;
964 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700965 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhee9f16402014-09-25 16:39:28 -0700966 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700967 try {
968 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700969 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -0700970 + " r=" + r);
971 }
972 r.callback.onCellLocationChanged(new Bundle(cellLocation));
973 } catch (RemoteException ex) {
974 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700975 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400976 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800977 }
978 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400979 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -0700980 }
981 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800982
Wink Savillefd2d0132010-10-28 14:22:26 -0700983 public void notifyOtaspChanged(int otaspMode) {
984 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
985 return;
986 }
987 synchronized (mRecords) {
988 mOtaspMode = otaspMode;
989 for (Record r : mRecords) {
990 if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
991 try {
992 r.callback.onOtaspChanged(otaspMode);
993 } catch (RemoteException ex) {
994 mRemoveList.add(r.binder);
995 }
996 }
997 }
998 handleRemoveListLocked();
999 }
1000 }
1001
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001002 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1003 int backgroundCallState) {
1004 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1005 return;
1006 }
1007 synchronized (mRecords) {
1008 mRingingCallState = ringingCallState;
1009 mForegroundCallState = foregroundCallState;
1010 mBackgroundCallState = backgroundCallState;
1011 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1012 backgroundCallState,
1013 DisconnectCause.NOT_VALID,
1014 PreciseDisconnectCause.NOT_VALID);
1015 for (Record r : mRecords) {
1016 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1017 try {
1018 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1019 } catch (RemoteException ex) {
1020 mRemoveList.add(r.binder);
1021 }
1022 }
1023 }
1024 handleRemoveListLocked();
1025 }
1026 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1027 DisconnectCause.NOT_VALID,
1028 PreciseDisconnectCause.NOT_VALID);
1029 }
1030
1031 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1032 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1033 return;
1034 }
1035 synchronized (mRecords) {
1036 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1037 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1038 for (Record r : mRecords) {
1039 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1040 try {
1041 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1042 } catch (RemoteException ex) {
1043 mRemoveList.add(r.binder);
1044 }
1045 }
1046 }
1047 handleRemoveListLocked();
1048 }
1049 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1050 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1051 }
1052
1053 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1054 String apn, String failCause) {
1055 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1056 return;
1057 }
1058 synchronized (mRecords) {
1059 mPreciseDataConnectionState = new PreciseDataConnectionState(
1060 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1061 apnType, apn, reason, null, failCause);
1062 for (Record r : mRecords) {
1063 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
1064 try {
1065 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1066 } catch (RemoteException ex) {
1067 mRemoveList.add(r.binder);
1068 }
1069 }
1070 }
1071 handleRemoveListLocked();
1072 }
1073 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1074 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1075 }
1076
Wink Savillefb40dd42014-06-12 17:02:31 -07001077 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1078 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1079 return;
1080 }
1081 synchronized (mRecords) {
1082 mVoLteServiceState = lteState;
1083 for (Record r : mRecords) {
1084 if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) {
1085 try {
1086 r.callback.onVoLteServiceStateChanged(
1087 new VoLteServiceState(mVoLteServiceState));
1088 } catch (RemoteException ex) {
1089 mRemoveList.add(r.binder);
1090 }
1091 }
1092 }
1093 handleRemoveListLocked();
1094 }
1095 }
1096
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001097 @Override
1098 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1099 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1100 != PackageManager.PERMISSION_GRANTED) {
1101 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001102 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001103 return;
1104 }
1105 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001106 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001107 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301108 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1109 pw.println(" Phone Id=" + i);
1110 pw.println(" mCallState=" + mCallState[i]);
1111 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1112 pw.println(" mServiceState=" + mServiceState[i]);
1113 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1114 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1115 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1116 pw.println(" mDataActivity=" + mDataActivity[i]);
1117 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1118 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1119 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1120 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1121 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1122 pw.println(" mDataConnectionNetworkCapabilities=" +
1123 mDataConnectionNetworkCapabilities[i]);
1124 pw.println(" mCellLocation=" + mCellLocation[i]);
1125 pw.println(" mCellInfo=" + mCellInfo.get(i));
1126 }
Wink Saville070e0612014-04-15 22:04:10 -07001127 pw.println(" mDcRtInfo=" + mDcRtInfo);
Wink Savillee9b06d72009-05-18 21:47:50 -07001128 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001129 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001130 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001131 }
1132 }
1133 }
1134
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001135 //
1136 // the legacy intent broadcasting
1137 //
1138
Wink Savillefb40dd42014-06-12 17:02:31 -07001139 private void broadcastServiceStateChanged(ServiceState state, long subId) {
1140 long ident = Binder.clearCallingIdentity();
1141 try {
1142 mBatteryStats.notePhoneState(state.getState());
1143 } catch (RemoteException re) {
1144 // Can't do much
1145 } finally {
1146 Binder.restoreCallingIdentity(ident);
1147 }
1148
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001149 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1150 Bundle data = new Bundle();
1151 state.fillInNotifierBundle(data);
1152 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001153 // Pass the subscription along with the intent.
1154 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001155 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 }
1157
Wink Savillefb40dd42014-06-12 17:02:31 -07001158 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001159 long ident = Binder.clearCallingIdentity();
1160 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001161 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001162 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001163 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001164 } finally {
1165 Binder.restoreCallingIdentity(ident);
1166 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001167
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001168 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001169 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001170 Bundle data = new Bundle();
1171 signalStrength.fillInNotifierBundle(data);
1172 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001173 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001174 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001175 }
1176
Wink Savillefb40dd42014-06-12 17:02:31 -07001177 private void broadcastCallStateChanged(int state, String incomingNumber, long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001178 long ident = Binder.clearCallingIdentity();
1179 try {
1180 if (state == TelephonyManager.CALL_STATE_IDLE) {
1181 mBatteryStats.notePhoneOff();
1182 } else {
1183 mBatteryStats.notePhoneOn();
1184 }
1185 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001186 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001187 } finally {
1188 Binder.restoreCallingIdentity(ident);
1189 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001190
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001191 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001192 intent.putExtra(PhoneConstants.STATE_KEY,
1193 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001194 if (!TextUtils.isEmpty(incomingNumber)) {
1195 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1196 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001197 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001198 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1199 android.Manifest.permission.READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001200 }
1201
Robert Greenwalt42acef32009-08-12 16:08:25 -07001202 private void broadcastDataConnectionStateChanged(int state,
1203 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001204 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001205 NetworkCapabilities networkCapabilities, boolean roaming, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001206 // Note: not reporting to the battery stats service here, because the
1207 // status bar takes care of that after taking into account all of the
1208 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001209 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001210 intent.putExtra(PhoneConstants.STATE_KEY,
1211 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001213 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001214 }
1215 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001216 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001218 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001219 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001220 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001221 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001222 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001223 }
1224 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001225 if (networkCapabilities != null) {
1226 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001227 }
Wink Savillea639b312012-07-10 12:37:54 -07001228 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001229
Wink Savillea639b312012-07-10 12:37:54 -07001230 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1231 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001232 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001233 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001234 }
1235
Wink Savillefb40dd42014-06-12 17:02:31 -07001236 private void broadcastDataConnectionFailed(String reason, String apnType,
1237 long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001238 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001239 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1240 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001241 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001242 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001243 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001244
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001245 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1246 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1247 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1248 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1249 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1250 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1251 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1252 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1253 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1254 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1255 }
1256
1257 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
1258 String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) {
1259 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1260 intent.putExtra(PhoneConstants.STATE_KEY, state);
1261 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1262 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1263 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1264 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1265 if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
1266 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1267
1268 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1269 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1270 }
1271
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001272 private boolean checkNotifyPermission(String method) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001273 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1274 == PackageManager.PERMISSION_GRANTED) {
1275 return true;
1276 }
1277 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001278 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001279 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001280 return false;
1281 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001282
1283 private void checkListenerPermission(int events) {
1284 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1285 mContext.enforceCallingOrSelfPermission(
1286 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1287
1288 }
1289
John Wang963db55d2012-03-30 16:04:06 -07001290 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1291 mContext.enforceCallingOrSelfPermission(
1292 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1293
1294 }
1295
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001296 if ((events & PHONE_STATE_PERMISSION_MASK) != 0) {
1297 mContext.enforceCallingOrSelfPermission(
1298 android.Manifest.permission.READ_PHONE_STATE, null);
1299 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001300
1301 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1302 mContext.enforceCallingOrSelfPermission(
1303 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1304
1305 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001306 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001307
1308 private void handleRemoveListLocked() {
1309 if (mRemoveList.size() > 0) {
1310 for (IBinder b: mRemoveList) {
1311 remove(b);
1312 }
1313 mRemoveList.clear();
1314 }
1315 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001316
1317 private boolean validateEventsAndUserLocked(Record r, int events) {
1318 int foregroundUser;
1319 long callingIdentity = Binder.clearCallingIdentity();
1320 boolean valid = false;
1321 try {
1322 foregroundUser = ActivityManager.getCurrentUser();
1323 valid = r.callerUid == foregroundUser && (r.events & events) != 0;
1324 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001325 log("validateEventsAndUserLocked: valid=" + valid
Wink Savillea12a7b32012-09-20 10:09:45 -07001326 + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser
1327 + " r.events=" + r.events + " events=" + events);
1328 }
1329 } finally {
1330 Binder.restoreCallingIdentity(callingIdentity);
1331 }
1332 return valid;
1333 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001334
1335 private boolean validatePhoneId(int phoneId) {
1336 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001337 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001338 return valid;
1339 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001340
1341 private static void log(String s) {
1342 Rlog.d(TAG, s);
1343 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001344
1345 private static class LogSSC {
1346 private Time mTime;
1347 private String mS;
1348 private long mSubId;
1349 private int mPhoneId;
1350 private ServiceState mState;
1351
1352 public void set(Time t, String s, long subId, int phoneId, ServiceState state) {
1353 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1354 }
1355
1356 @Override
1357 public String toString() {
1358 return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState;
1359 }
1360 }
1361
1362 private LogSSC logSSC [] = new LogSSC[10];
1363 private int next = 0;
1364
1365 private void logServiceStateChanged(String s, long subId, int phoneId, ServiceState state) {
1366 if (logSSC == null || logSSC.length == 0) {
1367 return;
1368 }
1369 if (logSSC[next] == null) {
1370 logSSC[next] = new LogSSC();
1371 }
1372 Time t = new Time();
1373 t.setToNow();
1374 logSSC[next].set(t, s, subId, phoneId, state);
1375 if (++next >= logSSC.length) {
1376 next = 0;
1377 }
1378 }
1379
1380 private void toStringLogSSC(String prompt) {
1381 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1382 log(prompt + ": logSSC is empty");
1383 } else {
1384 // There is at least one element
1385 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1386 int i = next;
1387 if (logSSC[i] == null) {
1388 // logSSC is not full so back to the beginning
1389 i = 0;
1390 }
1391 do {
1392 log(logSSC[i].toString());
1393 if (++i >= logSSC.length) {
1394 i = 0;
1395 }
1396 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001397 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001398 }
1399 }
xinhee9f16402014-09-25 16:39:28 -07001400
1401 boolean subIdMatch(long rSubId, long subId) {
1402 if(rSubId == SubscriptionManager.DEFAULT_SUB_ID) {
1403 return (subId == mDefaultSubId);
1404 } else {
1405 return (rSubId == subId);
1406 }
1407 }
1408
1409 private void checkPossibleMissNotify(Record r, int phoneId) {
1410 int events = r.events;
1411
1412 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1413 try {
1414 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1415 mServiceState[phoneId]);
1416 r.callback.onServiceStateChanged(
1417 new ServiceState(mServiceState[phoneId]));
1418 } catch (RemoteException ex) {
1419 remove(r.binder);
1420 }
1421 }
1422
1423 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1424 try {
1425 SignalStrength signalStrength = mSignalStrength[phoneId];
1426 if (DBG) {
1427 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1428 }
1429 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1430 } catch (RemoteException ex) {
1431 mRemoveList.add(r.binder);
1432 }
1433 }
1434
1435 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1436 try {
1437 int gsmSignalStrength = mSignalStrength[phoneId]
1438 .getGsmSignalStrength();
1439 if (DBG) {
1440 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1441 gsmSignalStrength);
1442 }
1443 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1444 : gsmSignalStrength));
1445 } catch (RemoteException ex) {
1446 remove(r.binder);
1447 }
1448 }
1449
1450 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1451 try {
1452 if (DBG_LOC) {
1453 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1454 + mCellInfo.get(phoneId));
1455 }
1456 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1457 } catch (RemoteException ex) {
1458 remove(r.binder);
1459 }
1460 }
1461
1462 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1463 try {
1464 if (VDBG) {
1465 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1466 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1467 }
1468 r.callback.onMessageWaitingIndicatorChanged(
1469 mMessageWaiting[phoneId]);
1470 } catch (RemoteException ex) {
1471 remove(r.binder);
1472 }
1473 }
1474
1475 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1476 try {
1477 if (VDBG) {
1478 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1479 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1480 }
1481 r.callback.onCallForwardingIndicatorChanged(
1482 mCallForwarding[phoneId]);
1483 } catch (RemoteException ex) {
1484 remove(r.binder);
1485 }
1486 }
1487
1488 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1489 try {
1490 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1491 + mCellLocation[phoneId]);
1492 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1493 } catch (RemoteException ex) {
1494 mRemoveList.add(r.binder);
1495 }
1496 }
1497
1498 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1499 try {
1500 if (DBG) {
1501 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1502 + "=" + mDataConnectionState[phoneId]
1503 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1504 + ")");
1505 }
1506 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1507 mDataConnectionNetworkType[phoneId]);
1508 } catch (RemoteException ex) {
1509 remove(r.binder);
1510 }
1511 }
1512 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001513}