blob: 7b58608ff1631b083d55585b4ea5c9b42971c4fa [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) {
Etan Cohena33cf072014-09-30 10:35:24 -0700215 for (Record r : mRecords) {
216 if(r.subId == SubscriptionManager.DEFAULT_SUB_ID) {
217 checkPossibleMissNotify(r, newDefaultPhoneId);
218 }
219 }
220 handleRemoveListLocked();
xinhee9f16402014-09-25 16:39:28 -0700221 }
222 mDefaultSubId = newDefaultSubId;
223 mDefaultPhoneId = newDefaultPhoneId;
Wink Savillea12a7b32012-09-20 10:09:45 -0700224 }
225 }
226 }
227 };
228
229 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
230 @Override
231 public void onReceive(Context context, Intent intent) {
232 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700233 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700234 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700235 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700236 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700237 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700238 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
xinhee9f16402014-09-25 16:39:28 -0700239 Long newDefaultSubIdObj = new Long(intent.getLongExtra(
240 PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSubId()));
241 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
242 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700243 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700244 log("onReceive:current mDefaultSubId=" + mDefaultSubId
245 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
246 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700247 }
xinhee9f16402014-09-25 16:39:28 -0700248
249 if(validatePhoneId(newDefaultPhoneId) && (newDefaultSubIdObj.equals(mDefaultSubId)
250 || (newDefaultPhoneId != mDefaultPhoneId))) {
251 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
252 newDefaultPhoneId, 0, newDefaultSubIdObj));
253 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700254 }
255 }
256 };
257
Wink Savillee9b06d72009-05-18 21:47:50 -0700258 // we keep a copy of all of the state so we can send it out when folks
259 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800260 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700261 // In these calls we call with the lock held. This is safe becasuse remote
262 // calls go through a oneway interface and local calls going through a
263 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800264
265 TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700266 CellLocation location = CellLocation.getEmpty();
267
Wink Savillefb40dd42014-06-12 17:02:31 -0700268 mContext = context;
269 mBatteryStats = BatteryStatsService.getService();
270 mConnectedApns = new ArrayList<String>();
271
Wink Savillefb40dd42014-06-12 17:02:31 -0700272 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700273 if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700274 mNumPhones = numPhones;
275 mCallState = new int[numPhones];
276 mDataActivity = new int[numPhones];
277 mDataConnectionState = new int[numPhones];
278 mDataConnectionNetworkType = new int[numPhones];
279 mCallIncomingNumber = new String[numPhones];
280 mServiceState = new ServiceState[numPhones];
281 mSignalStrength = new SignalStrength[numPhones];
282 mMessageWaiting = new boolean[numPhones];
283 mDataConnectionPossible = new boolean[numPhones];
284 mDataConnectionReason = new String[numPhones];
285 mDataConnectionApn = new String[numPhones];
286 mCallForwarding = new boolean[numPhones];
287 mCellLocation = new Bundle[numPhones];
288 mDataConnectionLinkProperties = new LinkProperties[numPhones];
289 mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones];
290 mCellInfo = new ArrayList<List<CellInfo>>();
291 for (int i = 0; i < numPhones; i++) {
292 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
293 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
294 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
295 mCallIncomingNumber[i] = "";
296 mServiceState[i] = new ServiceState();
297 mSignalStrength[i] = new SignalStrength();
298 mMessageWaiting[i] = false;
299 mCallForwarding[i] = false;
300 mDataConnectionPossible[i] = false;
301 mDataConnectionReason[i] = "";
302 mDataConnectionApn[i] = "";
303 mCellLocation[i] = new Bundle();
304 mCellInfo.add(i, null);
305 }
306
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700307 // Note that location can be null for non-phone builds like
308 // like the generic one.
309 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700310 for (int i = 0; i < numPhones; i++) {
311 location.fillInNotifierBundle(mCellLocation[i]);
312 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700313 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700314 mConnectedApns = new ArrayList<String>();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800315 }
316
Svetoslav Ganova0027152013-06-25 14:59:53 -0700317 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700318 // Watch for interesting updates
319 final IntentFilter filter = new IntentFilter();
320 filter.addAction(Intent.ACTION_USER_SWITCHED);
321 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700322 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700323 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700324 mContext.registerReceiver(mBroadcastReceiver, filter);
325 }
326
327 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800328 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
329 boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700330 listenForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, pkgForDebug, callback, events,
331 notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700332 }
333
334 @Override
Wink Savillebc027272014-09-08 14:50:58 -0700335 public void listenForSubscriber(long subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700336 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700337 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700338 }
339
340 private void listen(String pkgForDebug, IPhoneStateListener callback, int events,
xinhe43c50292014-09-18 17:56:48 -0700341 boolean notifyNow, long subId) {
Wink Savillea12a7b32012-09-20 10:09:45 -0700342 int callerUid = UserHandle.getCallingUserId();
343 int myUid = UserHandle.myUserId();
Wink Savillee380b982014-07-26 18:24:22 -0700344 if (VDBG) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700345 log("listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events)
xinhe43c50292014-09-18 17:56:48 -0700346 + " notifyNow=" + notifyNow + " subId=" + subId + " myUid=" + myUid
Wink Savillea12a7b32012-09-20 10:09:45 -0700347 + " callerUid=" + callerUid);
348 }
xinhe75c2c152014-10-16 11:49:45 -0700349
350 if (events != PhoneStateListener.LISTEN_NONE) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700351 /* Checks permission and throws Security exception */
352 checkListenerPermission(events);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800353 synchronized (mRecords) {
354 // register
355 Record r = null;
356 find_and_add: {
357 IBinder b = callback.asBinder();
358 final int N = mRecords.size();
Wink Savillee9b06d72009-05-18 21:47:50 -0700359 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800360 r = mRecords.get(i);
361 if (b == r.binder) {
362 break find_and_add;
363 }
364 }
365 r = new Record();
366 r.binder = b;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800367 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700368 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800369 }
xinhe43c50292014-09-18 17:56:48 -0700370
xinhe75c2c152014-10-16 11:49:45 -0700371 r.callback = callback;
372 r.pkgForDebug = pkgForDebug;
373 r.callerUid = callerUid;
374 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
375 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
376 if (!SubscriptionManager.isValidSubId(subId)) {
377 r.subId = SubscriptionManager.DEFAULT_SUB_ID;
378 } else {//APP specify subID
379 r.subId = subId;
380 }
381 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
382
xinhe43c50292014-09-18 17:56:48 -0700383 int phoneId = r.phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800384 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700385 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700386 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700387 }
388 if (VDBG) toStringLogSSC("listen");
Wink Savillefb40dd42014-06-12 17:02:31 -0700389 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800390 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400391 try {
Wink Savillee380b982014-07-26 18:24:22 -0700392 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700393 r.callback.onServiceStateChanged(
394 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400395 } catch (RemoteException ex) {
396 remove(r.binder);
397 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800398 }
399 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
400 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700401 int gsmSignalStrength = mSignalStrength[phoneId]
402 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700403 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
404 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800405 } catch (RemoteException ex) {
406 remove(r.binder);
407 }
408 }
409 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
410 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700411 r.callback.onMessageWaitingIndicatorChanged(
412 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800413 } catch (RemoteException ex) {
414 remove(r.binder);
415 }
416 }
417 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
418 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700419 r.callback.onCallForwardingIndicatorChanged(
420 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800421 } catch (RemoteException ex) {
422 remove(r.binder);
423 }
424 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700425 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400426 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700427 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700428 + mCellLocation[phoneId]);
429 r.callback.onCellLocationChanged(
430 new Bundle(mCellLocation[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400431 } catch (RemoteException ex) {
432 remove(r.binder);
433 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800434 }
435 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
436 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700437 r.callback.onCallStateChanged(mCallState[phoneId],
438 mCallIncomingNumber[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800439 } catch (RemoteException ex) {
440 remove(r.binder);
441 }
442 }
443 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
444 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700445 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
446 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800447 } catch (RemoteException ex) {
448 remove(r.binder);
449 }
450 }
451 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
452 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700453 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800454 } catch (RemoteException ex) {
455 remove(r.binder);
456 }
457 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700458 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
459 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700460 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700461 } catch (RemoteException ex) {
462 remove(r.binder);
463 }
464 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700465 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
466 try {
467 r.callback.onOtaspChanged(mOtaspMode);
468 } catch (RemoteException ex) {
469 remove(r.binder);
470 }
471 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700472 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700473 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700474 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700475 + mCellInfo.get(phoneId));
476 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
John Wang963db55d2012-03-30 16:04:06 -0700477 } catch (RemoteException ex) {
478 remove(r.binder);
479 }
480 }
Wink Saville070e0612014-04-15 22:04:10 -0700481 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) {
482 try {
483 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
484 } catch (RemoteException ex) {
485 remove(r.binder);
486 }
487 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200488 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
489 try {
490 r.callback.onPreciseCallStateChanged(mPreciseCallState);
491 } catch (RemoteException ex) {
492 remove(r.binder);
493 }
494 }
495 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
496 try {
497 r.callback.onPreciseDataConnectionStateChanged(
498 mPreciseDataConnectionState);
499 } catch (RemoteException ex) {
500 remove(r.binder);
501 }
502 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 }
504 }
505 } else {
xinhe75c2c152014-10-16 11:49:45 -0700506 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800507 remove(callback.asBinder());
508 }
509 }
510
511 private void remove(IBinder binder) {
512 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700513 final int recordCount = mRecords.size();
514 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800515 if (mRecords.get(i).binder == binder) {
516 mRecords.remove(i);
517 return;
518 }
519 }
520 }
521 }
522
523 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700524 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700525 return;
526 }
xinhe43c50292014-09-18 17:56:48 -0700527
528 if (VDBG) {
529 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
530 }
531
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800532 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700533 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700534 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700535 (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800536 try {
537 r.callback.onCallStateChanged(state, incomingNumber);
538 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400539 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800540 }
541 }
542 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400543 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 }
xinhe43c50292014-09-18 17:56:48 -0700545 broadcastCallStateChanged(state, incomingNumber, SubscriptionManager.DEFAULT_SUB_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800546 }
547
Wink Savillebc027272014-09-08 14:50:58 -0700548 public void notifyCallStateForSubscriber(long subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700549 if (!checkNotifyPermission("notifyCallState()")) {
550 return;
551 }
Wink Savillee380b982014-07-26 18:24:22 -0700552 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700553 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700554 + " state=" + state + " incomingNumber=" + incomingNumber);
555 }
556 synchronized (mRecords) {
557 int phoneId = SubscriptionManager.getPhoneId(subId);
558 if (validatePhoneId(phoneId)) {
559 mCallState[phoneId] = state;
560 mCallIncomingNumber[phoneId] = incomingNumber;
561 for (Record r : mRecords) {
562 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700563 (r.subId == subId) &&
564 (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700565 try {
566 r.callback.onCallStateChanged(state, incomingNumber);
567 } catch (RemoteException ex) {
568 mRemoveList.add(r.binder);
569 }
570 }
571 }
572 }
573 handleRemoveListLocked();
574 }
575 broadcastCallStateChanged(state, incomingNumber, subId);
576 }
577
xinhe43c50292014-09-18 17:56:48 -0700578 public void notifyServiceStateForPhoneId(int phoneId, long subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700579 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700580 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700581 }
xinhe43c50292014-09-18 17:56:48 -0700582
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800583 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700584 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700585 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700586 + " state=" + state);
587 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700588 if (validatePhoneId(phoneId)) {
589 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700590 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
591 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700592
Wink Savillefb40dd42014-06-12 17:02:31 -0700593 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700594 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700595 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700596 + " phoneId=" + phoneId + " state=" + state);
597 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700598 if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700599 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700600 try {
Wink Savillee380b982014-07-26 18:24:22 -0700601 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700602 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700603 + " subId=" + subId + " phoneId=" + phoneId
604 + " state=" + state);
605 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700606 r.callback.onServiceStateChanged(new ServiceState(state));
607 } catch (RemoteException ex) {
608 mRemoveList.add(r.binder);
609 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400610 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800611 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700612 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700613 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400615 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800616 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700617 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800618 }
619
Wink Savillee9b06d72009-05-18 21:47:50 -0700620 public void notifySignalStrength(SignalStrength signalStrength) {
xinhe43c50292014-09-18 17:56:48 -0700621 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700622 }
623
Wink Savillebc027272014-09-08 14:50:58 -0700624 public void notifySignalStrengthForSubscriber(long subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700625 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700626 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700627 }
Wink Savillee380b982014-07-26 18:24:22 -0700628 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700629 log("notifySignalStrengthForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700630 + " signalStrength=" + signalStrength);
Wink Savillebc027272014-09-08 14:50:58 -0700631 toStringLogSSC("notifySignalStrengthForSubscriber");
Wink Savillefb40dd42014-06-12 17:02:31 -0700632 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800633 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700634 int phoneId = SubscriptionManager.getPhoneId(subId);
635 if (validatePhoneId(phoneId)) {
Wink Savillebc027272014-09-08 14:50:58 -0700636 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700637 mSignalStrength[phoneId] = signalStrength;
638 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700639 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700640 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700641 + " phoneId=" + phoneId + " ss=" + signalStrength);
642 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700643 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700644 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700645 try {
Wink Savillee380b982014-07-26 18:24:22 -0700646 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700647 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700648 + " subId=" + subId + " phoneId=" + phoneId
649 + " ss=" + signalStrength);
650 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700651 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
652 } catch (RemoteException ex) {
653 mRemoveList.add(r.binder);
654 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400655 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700656 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700657 subIdMatch(r.subId, subId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700658 try {
659 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700660 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Wink Savillee380b982014-07-26 18:24:22 -0700661 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700662 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700663 + " subId=" + subId + " phoneId=" + phoneId
664 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
665 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700666 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700667 } catch (RemoteException ex) {
668 mRemoveList.add(r.binder);
669 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 }
671 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700672 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700673 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800674 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400675 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800676 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700677 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800678 }
679
Wink Savilleb208a242012-07-25 14:08:09 -0700680 public void notifyCellInfo(List<CellInfo> cellInfo) {
xinhe43c50292014-09-18 17:56:48 -0700681 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700682 }
683
Wink Savillebc027272014-09-08 14:50:58 -0700684 public void notifyCellInfoForSubscriber(long subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700685 if (!checkNotifyPermission("notifyCellInfo()")) {
686 return;
687 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700688 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700689 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700690 + " cellInfo=" + cellInfo);
691 }
John Wang963db55d2012-03-30 16:04:06 -0700692
693 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700694 int phoneId = SubscriptionManager.getPhoneId(subId);
695 if (validatePhoneId(phoneId)) {
696 mCellInfo.set(phoneId, cellInfo);
697 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700698 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhee9f16402014-09-25 16:39:28 -0700699 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700700 try {
701 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700702 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700703 }
704 r.callback.onCellInfoChanged(cellInfo);
705 } catch (RemoteException ex) {
706 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700707 }
John Wang963db55d2012-03-30 16:04:06 -0700708 }
709 }
710 }
711 handleRemoveListLocked();
712 }
713 }
714
Wink Saville070e0612014-04-15 22:04:10 -0700715 public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) {
716 if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) {
717 return;
718 }
719
720 synchronized (mRecords) {
721 mDcRtInfo = dcRtInfo;
722 for (Record r : mRecords) {
723 if (validateEventsAndUserLocked(r,
724 PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) {
725 try {
726 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700727 log("notifyDataConnectionRealTimeInfo: mDcRtInfo="
Wink Saville070e0612014-04-15 22:04:10 -0700728 + mDcRtInfo + " r=" + r);
729 }
730 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
731 } catch (RemoteException ex) {
732 mRemoveList.add(r.binder);
733 }
734 }
735 }
736 handleRemoveListLocked();
737 }
738 }
739
xinhe43c50292014-09-18 17:56:48 -0700740 @Override
741 public void notifyMessageWaitingChangedForPhoneId(int phoneId, long subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700742 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700743 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700744 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700745 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700746 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700747 + " mwi=" + mwi);
748 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800749 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700750 if (validatePhoneId(phoneId)) {
751 mMessageWaiting[phoneId] = mwi;
752 for (Record r : mRecords) {
753 if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700754 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700755 try {
756 r.callback.onMessageWaitingIndicatorChanged(mwi);
757 } catch (RemoteException ex) {
758 mRemoveList.add(r.binder);
759 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800760 }
761 }
762 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400763 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800764 }
765 }
766
767 public void notifyCallForwardingChanged(boolean cfi) {
xinhe43c50292014-09-18 17:56:48 -0700768 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700769 }
770
Wink Savillebc027272014-09-08 14:50:58 -0700771 public void notifyCallForwardingChangedForSubscriber(long subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700772 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700773 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700774 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700775 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700776 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700777 + " cfi=" + cfi);
778 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800779 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700780 int phoneId = SubscriptionManager.getPhoneId(subId);
781 if (validatePhoneId(phoneId)) {
782 mCallForwarding[phoneId] = cfi;
783 for (Record r : mRecords) {
784 if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700785 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700786 try {
787 r.callback.onCallForwardingIndicatorChanged(cfi);
788 } catch (RemoteException ex) {
789 mRemoveList.add(r.binder);
790 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800791 }
792 }
793 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400794 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800795 }
796 }
797
798 public void notifyDataActivity(int state) {
xinhe43c50292014-09-18 17:56:48 -0700799 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -0700800 }
801
Wink Savillebc027272014-09-08 14:50:58 -0700802 public void notifyDataActivityForSubscriber(long subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700803 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700804 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700805 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800806 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700807 int phoneId = SubscriptionManager.getPhoneId(subId);
808 mDataActivity[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700809 for (Record r : mRecords) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800810 if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
811 try {
812 r.callback.onDataActivity(state);
813 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400814 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800815 }
816 }
817 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400818 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800819 }
820 }
821
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700822 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -0700823 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -0700824 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
xinhe43c50292014-09-18 17:56:48 -0700825 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state,
826 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -0700827 networkCapabilities, networkType, roaming);
828 }
829
Wink Savillebc027272014-09-08 14:50:58 -0700830 public void notifyDataConnectionForSubscriber(long subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -0700831 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
832 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
833 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700834 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700835 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700836 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700837 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700838 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700839 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
840 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -0700841 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
842 + " mRecords.size()=" + mRecords.size() + " mRecords=" + mRecords);
Wink Savillec9acde92011-09-21 11:05:43 -0700843 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800844 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700845 int phoneId = SubscriptionManager.getPhoneId(subId);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700846 boolean modified = false;
847 if (state == TelephonyManager.DATA_CONNECTED) {
848 if (!mConnectedApns.contains(apnType)) {
849 mConnectedApns.add(apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700850 if (mDataConnectionState[phoneId] != state) {
851 mDataConnectionState[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700852 modified = true;
853 }
854 }
855 } else {
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800856 if (mConnectedApns.remove(apnType)) {
857 if (mConnectedApns.isEmpty()) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700858 mDataConnectionState[phoneId] = state;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800859 modified = true;
860 } else {
861 // leave mDataConnectionState as is and
862 // send out the new status for the APN in question.
863 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700864 }
865 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700866 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
867 mDataConnectionReason[phoneId] = reason;
868 mDataConnectionLinkProperties[phoneId] = linkProperties;
869 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
870 if (mDataConnectionNetworkType[phoneId] != networkType) {
871 mDataConnectionNetworkType[phoneId] = networkType;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800872 // need to tell registered listeners about the new network type
Robert Greenwalt02648a42010-05-18 10:52:51 -0700873 modified = true;
874 }
875 if (modified) {
Wink Savillec9acde92011-09-21 11:05:43 -0700876 if (DBG) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700877 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
Wink Savillefb40dd42014-06-12 17:02:31 -0700878 + ", " + mDataConnectionNetworkType[phoneId] + ")");
Wink Savillec9acde92011-09-21 11:05:43 -0700879 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700880 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700881 if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700882 subIdMatch(r.subId, subId)) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700883 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700884 log("Notify data connection state changed on sub: " +
Wink Savillefb40dd42014-06-12 17:02:31 -0700885 subId);
886 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
887 mDataConnectionNetworkType[phoneId]);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700888 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400889 mRemoveList.add(r.binder);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700890 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800891 }
892 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400893 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800894 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200895 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
896 apnType, apn, reason, linkProperties, "");
897 for (Record r : mRecords) {
898 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
899 try {
900 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
901 } catch (RemoteException ex) {
902 mRemoveList.add(r.binder);
903 }
904 }
905 }
906 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800907 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700908 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -0700909 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200910 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
911 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800912 }
913
Robert Greenwalt02648a42010-05-18 10:52:51 -0700914 public void notifyDataConnectionFailed(String reason, String apnType) {
xinhe43c50292014-09-18 17:56:48 -0700915 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID,
916 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700917 }
918
Wink Savillebc027272014-09-08 14:50:58 -0700919 public void notifyDataConnectionFailedForSubscriber(long subId,
Wink Savillefb40dd42014-06-12 17:02:31 -0700920 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700921 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700922 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700923 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700924 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700925 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700926 + " reason=" + reason + " apnType=" + apnType);
927 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800928 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200929 mPreciseDataConnectionState = new PreciseDataConnectionState(
930 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
931 apnType, "", reason, null, "");
932 for (Record r : mRecords) {
933 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
934 try {
935 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
936 } catch (RemoteException ex) {
937 mRemoveList.add(r.binder);
938 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800939 }
940 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200941 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800942 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700943 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200944 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
945 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800946 }
947
948 public void notifyCellLocation(Bundle cellLocation) {
xinhe43c50292014-09-18 17:56:48 -0700949 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -0700950 }
951
Wink Savillebc027272014-09-08 14:50:58 -0700952 public void notifyCellLocationForSubscriber(long subId, Bundle cellLocation) {
953 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700954 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700955 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700956 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700957 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700958 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700959 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700960 + " cellLocation=" + cellLocation);
961 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800962 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700963 int phoneId = SubscriptionManager.getPhoneId(subId);
964 if (validatePhoneId(phoneId)) {
965 mCellLocation[phoneId] = cellLocation;
966 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700967 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhee9f16402014-09-25 16:39:28 -0700968 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700969 try {
970 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700971 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -0700972 + " r=" + r);
973 }
974 r.callback.onCellLocationChanged(new Bundle(cellLocation));
975 } catch (RemoteException ex) {
976 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700977 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400978 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 }
980 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400981 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -0700982 }
983 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800984
Wink Savillefd2d0132010-10-28 14:22:26 -0700985 public void notifyOtaspChanged(int otaspMode) {
986 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
987 return;
988 }
989 synchronized (mRecords) {
990 mOtaspMode = otaspMode;
991 for (Record r : mRecords) {
992 if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
993 try {
994 r.callback.onOtaspChanged(otaspMode);
995 } catch (RemoteException ex) {
996 mRemoveList.add(r.binder);
997 }
998 }
999 }
1000 handleRemoveListLocked();
1001 }
1002 }
1003
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001004 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1005 int backgroundCallState) {
1006 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1007 return;
1008 }
1009 synchronized (mRecords) {
1010 mRingingCallState = ringingCallState;
1011 mForegroundCallState = foregroundCallState;
1012 mBackgroundCallState = backgroundCallState;
1013 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1014 backgroundCallState,
1015 DisconnectCause.NOT_VALID,
1016 PreciseDisconnectCause.NOT_VALID);
1017 for (Record r : mRecords) {
1018 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1019 try {
1020 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1021 } catch (RemoteException ex) {
1022 mRemoveList.add(r.binder);
1023 }
1024 }
1025 }
1026 handleRemoveListLocked();
1027 }
1028 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1029 DisconnectCause.NOT_VALID,
1030 PreciseDisconnectCause.NOT_VALID);
1031 }
1032
1033 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1034 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1035 return;
1036 }
1037 synchronized (mRecords) {
1038 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1039 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1040 for (Record r : mRecords) {
1041 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1042 try {
1043 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1044 } catch (RemoteException ex) {
1045 mRemoveList.add(r.binder);
1046 }
1047 }
1048 }
1049 handleRemoveListLocked();
1050 }
1051 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1052 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1053 }
1054
1055 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1056 String apn, String failCause) {
1057 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1058 return;
1059 }
1060 synchronized (mRecords) {
1061 mPreciseDataConnectionState = new PreciseDataConnectionState(
1062 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1063 apnType, apn, reason, null, failCause);
1064 for (Record r : mRecords) {
1065 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
1066 try {
1067 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1068 } catch (RemoteException ex) {
1069 mRemoveList.add(r.binder);
1070 }
1071 }
1072 }
1073 handleRemoveListLocked();
1074 }
1075 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1076 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1077 }
1078
Wink Savillefb40dd42014-06-12 17:02:31 -07001079 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1080 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1081 return;
1082 }
1083 synchronized (mRecords) {
1084 mVoLteServiceState = lteState;
1085 for (Record r : mRecords) {
1086 if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) {
1087 try {
1088 r.callback.onVoLteServiceStateChanged(
1089 new VoLteServiceState(mVoLteServiceState));
1090 } catch (RemoteException ex) {
1091 mRemoveList.add(r.binder);
1092 }
1093 }
1094 }
1095 handleRemoveListLocked();
1096 }
1097 }
1098
New Author Steven Liu485f2092014-09-11 10:18:45 -05001099 public void notifyOemHookRawEventForSubscriber(long subId, byte[] rawData) {
1100 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1101 return;
1102 }
1103
1104 synchronized (mRecords) {
1105 for (Record r : mRecords) {
1106 if (VDBG) {
1107 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1108 }
1109 if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) &&
1110 ((r.subId == subId) ||
1111 (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) {
1112 try {
1113 r.callback.onOemHookRawEvent(rawData);
1114 } catch (RemoteException ex) {
1115 mRemoveList.add(r.binder);
1116 }
1117 }
1118 }
1119 handleRemoveListLocked();
1120 }
1121 }
1122
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001123 @Override
1124 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1125 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1126 != PackageManager.PERMISSION_GRANTED) {
1127 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001128 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001129 return;
1130 }
1131 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001132 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001133 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301134 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1135 pw.println(" Phone Id=" + i);
1136 pw.println(" mCallState=" + mCallState[i]);
1137 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1138 pw.println(" mServiceState=" + mServiceState[i]);
1139 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1140 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1141 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1142 pw.println(" mDataActivity=" + mDataActivity[i]);
1143 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1144 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1145 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1146 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1147 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1148 pw.println(" mDataConnectionNetworkCapabilities=" +
1149 mDataConnectionNetworkCapabilities[i]);
1150 pw.println(" mCellLocation=" + mCellLocation[i]);
1151 pw.println(" mCellInfo=" + mCellInfo.get(i));
1152 }
Wink Saville070e0612014-04-15 22:04:10 -07001153 pw.println(" mDcRtInfo=" + mDcRtInfo);
Wink Savillee9b06d72009-05-18 21:47:50 -07001154 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001155 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001156 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001157 }
1158 }
1159 }
1160
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001161 //
1162 // the legacy intent broadcasting
1163 //
1164
Wink Savillefb40dd42014-06-12 17:02:31 -07001165 private void broadcastServiceStateChanged(ServiceState state, long subId) {
1166 long ident = Binder.clearCallingIdentity();
1167 try {
1168 mBatteryStats.notePhoneState(state.getState());
1169 } catch (RemoteException re) {
1170 // Can't do much
1171 } finally {
1172 Binder.restoreCallingIdentity(ident);
1173 }
1174
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001175 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1176 Bundle data = new Bundle();
1177 state.fillInNotifierBundle(data);
1178 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001179 // Pass the subscription along with the intent.
1180 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001181 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001182 }
1183
Wink Savillefb40dd42014-06-12 17:02:31 -07001184 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001185 long ident = Binder.clearCallingIdentity();
1186 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001187 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001188 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001189 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001190 } finally {
1191 Binder.restoreCallingIdentity(ident);
1192 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001193
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001194 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001195 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001196 Bundle data = new Bundle();
1197 signalStrength.fillInNotifierBundle(data);
1198 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001199 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001200 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001201 }
1202
Wink Savillefb40dd42014-06-12 17:02:31 -07001203 private void broadcastCallStateChanged(int state, String incomingNumber, long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001204 long ident = Binder.clearCallingIdentity();
1205 try {
1206 if (state == TelephonyManager.CALL_STATE_IDLE) {
1207 mBatteryStats.notePhoneOff();
1208 } else {
1209 mBatteryStats.notePhoneOn();
1210 }
1211 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001212 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001213 } finally {
1214 Binder.restoreCallingIdentity(ident);
1215 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001216
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001217 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001218 intent.putExtra(PhoneConstants.STATE_KEY,
1219 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001220 if (!TextUtils.isEmpty(incomingNumber)) {
1221 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1222 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001223 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001224 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1225 android.Manifest.permission.READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001226 }
1227
Robert Greenwalt42acef32009-08-12 16:08:25 -07001228 private void broadcastDataConnectionStateChanged(int state,
1229 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001230 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001231 NetworkCapabilities networkCapabilities, boolean roaming, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001232 // Note: not reporting to the battery stats service here, because the
1233 // status bar takes care of that after taking into account all of the
1234 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001235 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001236 intent.putExtra(PhoneConstants.STATE_KEY,
1237 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001238 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001239 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001240 }
1241 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001242 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001243 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001244 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001245 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001246 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001247 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001248 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001249 }
1250 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001251 if (networkCapabilities != null) {
1252 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001253 }
Wink Savillea639b312012-07-10 12:37:54 -07001254 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001255
Wink Savillea639b312012-07-10 12:37:54 -07001256 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1257 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001258 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001259 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001260 }
1261
Wink Savillefb40dd42014-06-12 17:02:31 -07001262 private void broadcastDataConnectionFailed(String reason, String apnType,
1263 long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001264 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001265 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1266 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001267 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001268 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001269 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001270
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001271 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1272 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1273 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1274 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1275 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1276 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1277 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1278 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1279 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1280 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1281 }
1282
1283 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
1284 String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) {
1285 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1286 intent.putExtra(PhoneConstants.STATE_KEY, state);
1287 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1288 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1289 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1290 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1291 if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
1292 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1293
1294 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1295 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1296 }
1297
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001298 private boolean checkNotifyPermission(String method) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001299 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1300 == PackageManager.PERMISSION_GRANTED) {
1301 return true;
1302 }
1303 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001304 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001305 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001306 return false;
1307 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001308
1309 private void checkListenerPermission(int events) {
1310 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1311 mContext.enforceCallingOrSelfPermission(
1312 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1313
1314 }
1315
John Wang963db55d2012-03-30 16:04:06 -07001316 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1317 mContext.enforceCallingOrSelfPermission(
1318 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1319
1320 }
1321
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001322 if ((events & PHONE_STATE_PERMISSION_MASK) != 0) {
1323 mContext.enforceCallingOrSelfPermission(
1324 android.Manifest.permission.READ_PHONE_STATE, null);
1325 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001326
1327 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1328 mContext.enforceCallingOrSelfPermission(
1329 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1330
1331 }
New Author Steven Liu485f2092014-09-11 10:18:45 -05001332
1333 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1334 mContext.enforceCallingOrSelfPermission(
1335 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1336 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001337 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001338
1339 private void handleRemoveListLocked() {
1340 if (mRemoveList.size() > 0) {
1341 for (IBinder b: mRemoveList) {
1342 remove(b);
1343 }
1344 mRemoveList.clear();
1345 }
1346 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001347
1348 private boolean validateEventsAndUserLocked(Record r, int events) {
1349 int foregroundUser;
1350 long callingIdentity = Binder.clearCallingIdentity();
1351 boolean valid = false;
1352 try {
1353 foregroundUser = ActivityManager.getCurrentUser();
1354 valid = r.callerUid == foregroundUser && (r.events & events) != 0;
1355 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001356 log("validateEventsAndUserLocked: valid=" + valid
Wink Savillea12a7b32012-09-20 10:09:45 -07001357 + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser
1358 + " r.events=" + r.events + " events=" + events);
1359 }
1360 } finally {
1361 Binder.restoreCallingIdentity(callingIdentity);
1362 }
1363 return valid;
1364 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001365
1366 private boolean validatePhoneId(int phoneId) {
1367 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001368 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001369 return valid;
1370 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001371
1372 private static void log(String s) {
1373 Rlog.d(TAG, s);
1374 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001375
1376 private static class LogSSC {
1377 private Time mTime;
1378 private String mS;
1379 private long mSubId;
1380 private int mPhoneId;
1381 private ServiceState mState;
1382
1383 public void set(Time t, String s, long subId, int phoneId, ServiceState state) {
1384 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1385 }
1386
1387 @Override
1388 public String toString() {
1389 return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState;
1390 }
1391 }
1392
1393 private LogSSC logSSC [] = new LogSSC[10];
1394 private int next = 0;
1395
1396 private void logServiceStateChanged(String s, long subId, int phoneId, ServiceState state) {
1397 if (logSSC == null || logSSC.length == 0) {
1398 return;
1399 }
1400 if (logSSC[next] == null) {
1401 logSSC[next] = new LogSSC();
1402 }
1403 Time t = new Time();
1404 t.setToNow();
1405 logSSC[next].set(t, s, subId, phoneId, state);
1406 if (++next >= logSSC.length) {
1407 next = 0;
1408 }
1409 }
1410
1411 private void toStringLogSSC(String prompt) {
1412 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1413 log(prompt + ": logSSC is empty");
1414 } else {
1415 // There is at least one element
1416 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1417 int i = next;
1418 if (logSSC[i] == null) {
1419 // logSSC is not full so back to the beginning
1420 i = 0;
1421 }
1422 do {
1423 log(logSSC[i].toString());
1424 if (++i >= logSSC.length) {
1425 i = 0;
1426 }
1427 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001428 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001429 }
1430 }
xinhee9f16402014-09-25 16:39:28 -07001431
1432 boolean subIdMatch(long rSubId, long subId) {
1433 if(rSubId == SubscriptionManager.DEFAULT_SUB_ID) {
1434 return (subId == mDefaultSubId);
1435 } else {
1436 return (rSubId == subId);
1437 }
1438 }
1439
1440 private void checkPossibleMissNotify(Record r, int phoneId) {
1441 int events = r.events;
1442
1443 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1444 try {
1445 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1446 mServiceState[phoneId]);
1447 r.callback.onServiceStateChanged(
1448 new ServiceState(mServiceState[phoneId]));
1449 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001450 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001451 }
1452 }
1453
1454 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1455 try {
1456 SignalStrength signalStrength = mSignalStrength[phoneId];
1457 if (DBG) {
1458 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1459 }
1460 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1461 } catch (RemoteException ex) {
1462 mRemoveList.add(r.binder);
1463 }
1464 }
1465
1466 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1467 try {
1468 int gsmSignalStrength = mSignalStrength[phoneId]
1469 .getGsmSignalStrength();
1470 if (DBG) {
1471 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1472 gsmSignalStrength);
1473 }
1474 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1475 : gsmSignalStrength));
1476 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001477 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001478 }
1479 }
1480
1481 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1482 try {
1483 if (DBG_LOC) {
1484 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1485 + mCellInfo.get(phoneId));
1486 }
1487 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1488 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001489 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001490 }
1491 }
1492
1493 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1494 try {
1495 if (VDBG) {
1496 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1497 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1498 }
1499 r.callback.onMessageWaitingIndicatorChanged(
1500 mMessageWaiting[phoneId]);
1501 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001502 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001503 }
1504 }
1505
1506 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1507 try {
1508 if (VDBG) {
1509 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1510 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1511 }
1512 r.callback.onCallForwardingIndicatorChanged(
1513 mCallForwarding[phoneId]);
1514 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001515 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001516 }
1517 }
1518
1519 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1520 try {
1521 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1522 + mCellLocation[phoneId]);
1523 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1524 } catch (RemoteException ex) {
1525 mRemoveList.add(r.binder);
1526 }
1527 }
1528
1529 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1530 try {
1531 if (DBG) {
1532 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1533 + "=" + mDataConnectionState[phoneId]
1534 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1535 + ")");
1536 }
1537 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1538 mDataConnectionNetworkType[phoneId]);
1539 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001540 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001541 }
1542 }
1543 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001544}