blob: e3e022829ad4cbf3332fdafb7f0ab25b872aeedb [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 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800349 if (events != 0) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700350 /* Checks permission and throws Security exception */
351 checkListenerPermission(events);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800352
353 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;
367 r.callback = callback;
368 r.pkgForDebug = pkgForDebug;
Wink Savillea12a7b32012-09-20 10:09:45 -0700369 r.callerUid = callerUid;
xinhe43c50292014-09-18 17:56:48 -0700370 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
371 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
372 if (!SubscriptionManager.isValidSubId(subId)) {
373 r.subId = SubscriptionManager.DEFAULT_SUB_ID;
374 } else {//APP specify subID
375 r.subId = subId;
Wink Savillefb40dd42014-06-12 17:02:31 -0700376 }
xinhe43c50292014-09-18 17:56:48 -0700377 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
378
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800379 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700380 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800381 }
xinhe43c50292014-09-18 17:56:48 -0700382
383 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) {
xinhe43c50292014-09-18 17:56:48 -0700386 log("listen: 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 {
506 remove(callback.asBinder());
507 }
508 }
509
510 private void remove(IBinder binder) {
511 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700512 final int recordCount = mRecords.size();
513 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800514 if (mRecords.get(i).binder == binder) {
515 mRecords.remove(i);
516 return;
517 }
518 }
519 }
520 }
521
522 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700523 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700524 return;
525 }
xinhe43c50292014-09-18 17:56:48 -0700526
527 if (VDBG) {
528 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
529 }
530
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800531 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700532 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700533 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700534 (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800535 try {
536 r.callback.onCallStateChanged(state, incomingNumber);
537 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400538 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800539 }
540 }
541 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400542 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 }
xinhe43c50292014-09-18 17:56:48 -0700544 broadcastCallStateChanged(state, incomingNumber, SubscriptionManager.DEFAULT_SUB_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800545 }
546
Wink Savillebc027272014-09-08 14:50:58 -0700547 public void notifyCallStateForSubscriber(long subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700548 if (!checkNotifyPermission("notifyCallState()")) {
549 return;
550 }
Wink Savillee380b982014-07-26 18:24:22 -0700551 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700552 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700553 + " state=" + state + " incomingNumber=" + incomingNumber);
554 }
555 synchronized (mRecords) {
556 int phoneId = SubscriptionManager.getPhoneId(subId);
557 if (validatePhoneId(phoneId)) {
558 mCallState[phoneId] = state;
559 mCallIncomingNumber[phoneId] = incomingNumber;
560 for (Record r : mRecords) {
561 if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) &&
xinhe43c50292014-09-18 17:56:48 -0700562 (r.subId == subId) &&
563 (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700564 try {
565 r.callback.onCallStateChanged(state, incomingNumber);
566 } catch (RemoteException ex) {
567 mRemoveList.add(r.binder);
568 }
569 }
570 }
571 }
572 handleRemoveListLocked();
573 }
574 broadcastCallStateChanged(state, incomingNumber, subId);
575 }
576
xinhe43c50292014-09-18 17:56:48 -0700577 public void notifyServiceStateForPhoneId(int phoneId, long subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700578 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700579 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700580 }
xinhe43c50292014-09-18 17:56:48 -0700581
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800582 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700583 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700584 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700585 + " state=" + state);
586 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700587 if (validatePhoneId(phoneId)) {
588 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700589 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
590 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700591
Wink Savillefb40dd42014-06-12 17:02:31 -0700592 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700593 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700594 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700595 + " phoneId=" + phoneId + " state=" + state);
596 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700597 if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700598 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700599 try {
Wink Savillee380b982014-07-26 18:24:22 -0700600 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700601 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700602 + " subId=" + subId + " phoneId=" + phoneId
603 + " state=" + state);
604 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700605 r.callback.onServiceStateChanged(new ServiceState(state));
606 } catch (RemoteException ex) {
607 mRemoveList.add(r.binder);
608 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400609 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800610 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700611 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700612 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800613 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400614 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800615 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700616 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800617 }
618
Wink Savillee9b06d72009-05-18 21:47:50 -0700619 public void notifySignalStrength(SignalStrength signalStrength) {
xinhe43c50292014-09-18 17:56:48 -0700620 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700621 }
622
Wink Savillebc027272014-09-08 14:50:58 -0700623 public void notifySignalStrengthForSubscriber(long subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700624 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700625 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700626 }
Wink Savillee380b982014-07-26 18:24:22 -0700627 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700628 log("notifySignalStrengthForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700629 + " signalStrength=" + signalStrength);
Wink Savillebc027272014-09-08 14:50:58 -0700630 toStringLogSSC("notifySignalStrengthForSubscriber");
Wink Savillefb40dd42014-06-12 17:02:31 -0700631 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800632 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700633 int phoneId = SubscriptionManager.getPhoneId(subId);
634 if (validatePhoneId(phoneId)) {
Wink Savillebc027272014-09-08 14:50:58 -0700635 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700636 mSignalStrength[phoneId] = signalStrength;
637 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700638 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700639 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700640 + " phoneId=" + phoneId + " ss=" + signalStrength);
641 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700642 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700643 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700644 try {
Wink Savillee380b982014-07-26 18:24:22 -0700645 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700646 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700647 + " subId=" + subId + " phoneId=" + phoneId
648 + " ss=" + signalStrength);
649 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700650 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
651 } catch (RemoteException ex) {
652 mRemoveList.add(r.binder);
653 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400654 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700655 if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700656 subIdMatch(r.subId, subId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700657 try {
658 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700659 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Wink Savillee380b982014-07-26 18:24:22 -0700660 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700661 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700662 + " subId=" + subId + " phoneId=" + phoneId
663 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
664 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700665 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700666 } catch (RemoteException ex) {
667 mRemoveList.add(r.binder);
668 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800669 }
670 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700671 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700672 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800673 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400674 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800675 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700676 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800677 }
678
Wink Savilleb208a242012-07-25 14:08:09 -0700679 public void notifyCellInfo(List<CellInfo> cellInfo) {
xinhe43c50292014-09-18 17:56:48 -0700680 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700681 }
682
Wink Savillebc027272014-09-08 14:50:58 -0700683 public void notifyCellInfoForSubscriber(long subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700684 if (!checkNotifyPermission("notifyCellInfo()")) {
685 return;
686 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700687 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700688 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700689 + " cellInfo=" + cellInfo);
690 }
John Wang963db55d2012-03-30 16:04:06 -0700691
692 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700693 int phoneId = SubscriptionManager.getPhoneId(subId);
694 if (validatePhoneId(phoneId)) {
695 mCellInfo.set(phoneId, cellInfo);
696 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700697 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhee9f16402014-09-25 16:39:28 -0700698 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700699 try {
700 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700701 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700702 }
703 r.callback.onCellInfoChanged(cellInfo);
704 } catch (RemoteException ex) {
705 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700706 }
John Wang963db55d2012-03-30 16:04:06 -0700707 }
708 }
709 }
710 handleRemoveListLocked();
711 }
712 }
713
Wink Saville070e0612014-04-15 22:04:10 -0700714 public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) {
715 if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) {
716 return;
717 }
718
719 synchronized (mRecords) {
720 mDcRtInfo = dcRtInfo;
721 for (Record r : mRecords) {
722 if (validateEventsAndUserLocked(r,
723 PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) {
724 try {
725 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700726 log("notifyDataConnectionRealTimeInfo: mDcRtInfo="
Wink Saville070e0612014-04-15 22:04:10 -0700727 + mDcRtInfo + " r=" + r);
728 }
729 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
730 } catch (RemoteException ex) {
731 mRemoveList.add(r.binder);
732 }
733 }
734 }
735 handleRemoveListLocked();
736 }
737 }
738
xinhe43c50292014-09-18 17:56:48 -0700739 @Override
740 public void notifyMessageWaitingChangedForPhoneId(int phoneId, long subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700741 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700742 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700743 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700744 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700745 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700746 + " mwi=" + mwi);
747 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800748 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700749 if (validatePhoneId(phoneId)) {
750 mMessageWaiting[phoneId] = mwi;
751 for (Record r : mRecords) {
752 if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700753 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700754 try {
755 r.callback.onMessageWaitingIndicatorChanged(mwi);
756 } catch (RemoteException ex) {
757 mRemoveList.add(r.binder);
758 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800759 }
760 }
761 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400762 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800763 }
764 }
765
766 public void notifyCallForwardingChanged(boolean cfi) {
xinhe43c50292014-09-18 17:56:48 -0700767 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700768 }
769
Wink Savillebc027272014-09-08 14:50:58 -0700770 public void notifyCallForwardingChangedForSubscriber(long subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700771 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700772 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700773 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700774 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700775 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700776 + " cfi=" + cfi);
777 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800778 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700779 int phoneId = SubscriptionManager.getPhoneId(subId);
780 if (validatePhoneId(phoneId)) {
781 mCallForwarding[phoneId] = cfi;
782 for (Record r : mRecords) {
783 if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700784 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700785 try {
786 r.callback.onCallForwardingIndicatorChanged(cfi);
787 } catch (RemoteException ex) {
788 mRemoveList.add(r.binder);
789 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800790 }
791 }
792 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400793 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800794 }
795 }
796
797 public void notifyDataActivity(int state) {
xinhe43c50292014-09-18 17:56:48 -0700798 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -0700799 }
800
Wink Savillebc027272014-09-08 14:50:58 -0700801 public void notifyDataActivityForSubscriber(long subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700802 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700803 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700804 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800805 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700806 int phoneId = SubscriptionManager.getPhoneId(subId);
807 mDataActivity[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700808 for (Record r : mRecords) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800809 if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
810 try {
811 r.callback.onDataActivity(state);
812 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400813 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800814 }
815 }
816 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400817 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800818 }
819 }
820
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700821 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -0700822 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -0700823 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
xinhe43c50292014-09-18 17:56:48 -0700824 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state,
825 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -0700826 networkCapabilities, networkType, roaming);
827 }
828
Wink Savillebc027272014-09-08 14:50:58 -0700829 public void notifyDataConnectionForSubscriber(long subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -0700830 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
831 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
832 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700833 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700834 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700835 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700836 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700837 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700838 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
839 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -0700840 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
841 + " mRecords.size()=" + mRecords.size() + " mRecords=" + mRecords);
Wink Savillec9acde92011-09-21 11:05:43 -0700842 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800843 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700844 int phoneId = SubscriptionManager.getPhoneId(subId);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700845 boolean modified = false;
846 if (state == TelephonyManager.DATA_CONNECTED) {
847 if (!mConnectedApns.contains(apnType)) {
848 mConnectedApns.add(apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700849 if (mDataConnectionState[phoneId] != state) {
850 mDataConnectionState[phoneId] = state;
Robert Greenwalt02648a42010-05-18 10:52:51 -0700851 modified = true;
852 }
853 }
854 } else {
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800855 if (mConnectedApns.remove(apnType)) {
856 if (mConnectedApns.isEmpty()) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700857 mDataConnectionState[phoneId] = state;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800858 modified = true;
859 } else {
860 // leave mDataConnectionState as is and
861 // send out the new status for the APN in question.
862 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700863 }
864 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700865 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
866 mDataConnectionReason[phoneId] = reason;
867 mDataConnectionLinkProperties[phoneId] = linkProperties;
868 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
869 if (mDataConnectionNetworkType[phoneId] != networkType) {
870 mDataConnectionNetworkType[phoneId] = networkType;
Robert Greenwalt8e7e0a92010-11-09 10:24:40 -0800871 // need to tell registered listeners about the new network type
Robert Greenwalt02648a42010-05-18 10:52:51 -0700872 modified = true;
873 }
874 if (modified) {
Wink Savillec9acde92011-09-21 11:05:43 -0700875 if (DBG) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700876 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
Wink Savillefb40dd42014-06-12 17:02:31 -0700877 + ", " + mDataConnectionNetworkType[phoneId] + ")");
Wink Savillec9acde92011-09-21 11:05:43 -0700878 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700879 for (Record r : mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700880 if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) &&
xinhee9f16402014-09-25 16:39:28 -0700881 subIdMatch(r.subId, subId)) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700882 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700883 log("Notify data connection state changed on sub: " +
Wink Savillefb40dd42014-06-12 17:02:31 -0700884 subId);
885 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
886 mDataConnectionNetworkType[phoneId]);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700887 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400888 mRemoveList.add(r.binder);
Robert Greenwalt02648a42010-05-18 10:52:51 -0700889 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800890 }
891 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400892 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800893 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200894 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
895 apnType, apn, reason, linkProperties, "");
896 for (Record r : mRecords) {
897 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
898 try {
899 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
900 } catch (RemoteException ex) {
901 mRemoveList.add(r.binder);
902 }
903 }
904 }
905 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800906 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700907 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -0700908 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200909 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
910 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800911 }
912
Robert Greenwalt02648a42010-05-18 10:52:51 -0700913 public void notifyDataConnectionFailed(String reason, String apnType) {
xinhe43c50292014-09-18 17:56:48 -0700914 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID,
915 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -0700916 }
917
Wink Savillebc027272014-09-08 14:50:58 -0700918 public void notifyDataConnectionFailedForSubscriber(long subId,
Wink Savillefb40dd42014-06-12 17:02:31 -0700919 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700920 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700921 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700922 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700923 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700924 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700925 + " reason=" + reason + " apnType=" + apnType);
926 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800927 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200928 mPreciseDataConnectionState = new PreciseDataConnectionState(
929 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
930 apnType, "", reason, null, "");
931 for (Record r : mRecords) {
932 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
933 try {
934 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
935 } catch (RemoteException ex) {
936 mRemoveList.add(r.binder);
937 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800938 }
939 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200940 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800941 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700942 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200943 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
944 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800945 }
946
947 public void notifyCellLocation(Bundle cellLocation) {
xinhe43c50292014-09-18 17:56:48 -0700948 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -0700949 }
950
Wink Savillebc027272014-09-08 14:50:58 -0700951 public void notifyCellLocationForSubscriber(long subId, Bundle cellLocation) {
952 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700953 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700954 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700955 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700956 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700957 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700958 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700959 + " cellLocation=" + cellLocation);
960 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800961 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700962 int phoneId = SubscriptionManager.getPhoneId(subId);
963 if (validatePhoneId(phoneId)) {
964 mCellLocation[phoneId] = cellLocation;
965 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700966 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhee9f16402014-09-25 16:39:28 -0700967 subIdMatch(r.subId, subId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700968 try {
969 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700970 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -0700971 + " r=" + r);
972 }
973 r.callback.onCellLocationChanged(new Bundle(cellLocation));
974 } catch (RemoteException ex) {
975 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700976 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400977 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800978 }
979 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400980 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -0700981 }
982 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800983
Wink Savillefd2d0132010-10-28 14:22:26 -0700984 public void notifyOtaspChanged(int otaspMode) {
985 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
986 return;
987 }
988 synchronized (mRecords) {
989 mOtaspMode = otaspMode;
990 for (Record r : mRecords) {
991 if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
992 try {
993 r.callback.onOtaspChanged(otaspMode);
994 } catch (RemoteException ex) {
995 mRemoveList.add(r.binder);
996 }
997 }
998 }
999 handleRemoveListLocked();
1000 }
1001 }
1002
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001003 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1004 int backgroundCallState) {
1005 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1006 return;
1007 }
1008 synchronized (mRecords) {
1009 mRingingCallState = ringingCallState;
1010 mForegroundCallState = foregroundCallState;
1011 mBackgroundCallState = backgroundCallState;
1012 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1013 backgroundCallState,
1014 DisconnectCause.NOT_VALID,
1015 PreciseDisconnectCause.NOT_VALID);
1016 for (Record r : mRecords) {
1017 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1018 try {
1019 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1020 } catch (RemoteException ex) {
1021 mRemoveList.add(r.binder);
1022 }
1023 }
1024 }
1025 handleRemoveListLocked();
1026 }
1027 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1028 DisconnectCause.NOT_VALID,
1029 PreciseDisconnectCause.NOT_VALID);
1030 }
1031
1032 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1033 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1034 return;
1035 }
1036 synchronized (mRecords) {
1037 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1038 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1039 for (Record r : mRecords) {
1040 if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
1041 try {
1042 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1043 } catch (RemoteException ex) {
1044 mRemoveList.add(r.binder);
1045 }
1046 }
1047 }
1048 handleRemoveListLocked();
1049 }
1050 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1051 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1052 }
1053
1054 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1055 String apn, String failCause) {
1056 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1057 return;
1058 }
1059 synchronized (mRecords) {
1060 mPreciseDataConnectionState = new PreciseDataConnectionState(
1061 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1062 apnType, apn, reason, null, failCause);
1063 for (Record r : mRecords) {
1064 if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
1065 try {
1066 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1067 } catch (RemoteException ex) {
1068 mRemoveList.add(r.binder);
1069 }
1070 }
1071 }
1072 handleRemoveListLocked();
1073 }
1074 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1075 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1076 }
1077
Wink Savillefb40dd42014-06-12 17:02:31 -07001078 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1079 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1080 return;
1081 }
1082 synchronized (mRecords) {
1083 mVoLteServiceState = lteState;
1084 for (Record r : mRecords) {
1085 if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) {
1086 try {
1087 r.callback.onVoLteServiceStateChanged(
1088 new VoLteServiceState(mVoLteServiceState));
1089 } catch (RemoteException ex) {
1090 mRemoveList.add(r.binder);
1091 }
1092 }
1093 }
1094 handleRemoveListLocked();
1095 }
1096 }
1097
New Author Steven Liu485f2092014-09-11 10:18:45 -05001098 public void notifyOemHookRawEventForSubscriber(long subId, byte[] rawData) {
1099 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1100 return;
1101 }
1102
1103 synchronized (mRecords) {
1104 for (Record r : mRecords) {
1105 if (VDBG) {
1106 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1107 }
1108 if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) &&
1109 ((r.subId == subId) ||
1110 (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) {
1111 try {
1112 r.callback.onOemHookRawEvent(rawData);
1113 } catch (RemoteException ex) {
1114 mRemoveList.add(r.binder);
1115 }
1116 }
1117 }
1118 handleRemoveListLocked();
1119 }
1120 }
1121
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001122 @Override
1123 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1124 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1125 != PackageManager.PERMISSION_GRANTED) {
1126 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001127 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001128 return;
1129 }
1130 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001131 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001132 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301133 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1134 pw.println(" Phone Id=" + i);
1135 pw.println(" mCallState=" + mCallState[i]);
1136 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1137 pw.println(" mServiceState=" + mServiceState[i]);
1138 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1139 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1140 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1141 pw.println(" mDataActivity=" + mDataActivity[i]);
1142 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1143 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1144 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1145 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1146 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1147 pw.println(" mDataConnectionNetworkCapabilities=" +
1148 mDataConnectionNetworkCapabilities[i]);
1149 pw.println(" mCellLocation=" + mCellLocation[i]);
1150 pw.println(" mCellInfo=" + mCellInfo.get(i));
1151 }
Wink Saville070e0612014-04-15 22:04:10 -07001152 pw.println(" mDcRtInfo=" + mDcRtInfo);
Wink Savillee9b06d72009-05-18 21:47:50 -07001153 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001154 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001155 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 }
1157 }
1158 }
1159
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 //
1161 // the legacy intent broadcasting
1162 //
1163
Wink Savillefb40dd42014-06-12 17:02:31 -07001164 private void broadcastServiceStateChanged(ServiceState state, long subId) {
1165 long ident = Binder.clearCallingIdentity();
1166 try {
1167 mBatteryStats.notePhoneState(state.getState());
1168 } catch (RemoteException re) {
1169 // Can't do much
1170 } finally {
1171 Binder.restoreCallingIdentity(ident);
1172 }
1173
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001174 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1175 Bundle data = new Bundle();
1176 state.fillInNotifierBundle(data);
1177 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001178 // Pass the subscription along with the intent.
1179 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001180 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001181 }
1182
Wink Savillefb40dd42014-06-12 17:02:31 -07001183 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001184 long ident = Binder.clearCallingIdentity();
1185 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001186 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001187 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001188 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001189 } finally {
1190 Binder.restoreCallingIdentity(ident);
1191 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001192
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001193 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001194 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001195 Bundle data = new Bundle();
1196 signalStrength.fillInNotifierBundle(data);
1197 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001198 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001199 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001200 }
1201
Wink Savillefb40dd42014-06-12 17:02:31 -07001202 private void broadcastCallStateChanged(int state, String incomingNumber, long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001203 long ident = Binder.clearCallingIdentity();
1204 try {
1205 if (state == TelephonyManager.CALL_STATE_IDLE) {
1206 mBatteryStats.notePhoneOff();
1207 } else {
1208 mBatteryStats.notePhoneOn();
1209 }
1210 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001211 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001212 } finally {
1213 Binder.restoreCallingIdentity(ident);
1214 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001215
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001216 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001217 intent.putExtra(PhoneConstants.STATE_KEY,
1218 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001219 if (!TextUtils.isEmpty(incomingNumber)) {
1220 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1221 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001222 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001223 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1224 android.Manifest.permission.READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001225 }
1226
Robert Greenwalt42acef32009-08-12 16:08:25 -07001227 private void broadcastDataConnectionStateChanged(int state,
1228 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001229 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001230 NetworkCapabilities networkCapabilities, boolean roaming, long subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001231 // Note: not reporting to the battery stats service here, because the
1232 // status bar takes care of that after taking into account all of the
1233 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001234 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001235 intent.putExtra(PhoneConstants.STATE_KEY,
1236 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001237 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001238 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001239 }
1240 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001241 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001242 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001243 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001244 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001245 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001246 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001247 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001248 }
1249 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001250 if (networkCapabilities != null) {
1251 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001252 }
Wink Savillea639b312012-07-10 12:37:54 -07001253 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001254
Wink Savillea639b312012-07-10 12:37:54 -07001255 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1256 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001257 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001258 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001259 }
1260
Wink Savillefb40dd42014-06-12 17:02:31 -07001261 private void broadcastDataConnectionFailed(String reason, String apnType,
1262 long subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001263 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001264 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1265 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001266 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001267 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001268 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001269
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001270 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1271 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1272 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1273 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1274 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1275 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1276 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1277 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1278 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1279 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1280 }
1281
1282 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
1283 String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) {
1284 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1285 intent.putExtra(PhoneConstants.STATE_KEY, state);
1286 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1287 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1288 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1289 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1290 if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
1291 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1292
1293 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1294 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1295 }
1296
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001297 private boolean checkNotifyPermission(String method) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001298 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1299 == PackageManager.PERMISSION_GRANTED) {
1300 return true;
1301 }
1302 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001303 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001304 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001305 return false;
1306 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001307
1308 private void checkListenerPermission(int events) {
1309 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1310 mContext.enforceCallingOrSelfPermission(
1311 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1312
1313 }
1314
John Wang963db55d2012-03-30 16:04:06 -07001315 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1316 mContext.enforceCallingOrSelfPermission(
1317 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1318
1319 }
1320
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001321 if ((events & PHONE_STATE_PERMISSION_MASK) != 0) {
1322 mContext.enforceCallingOrSelfPermission(
1323 android.Manifest.permission.READ_PHONE_STATE, null);
1324 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001325
1326 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1327 mContext.enforceCallingOrSelfPermission(
1328 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1329
1330 }
New Author Steven Liu485f2092014-09-11 10:18:45 -05001331
1332 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1333 mContext.enforceCallingOrSelfPermission(
1334 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1335 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001336 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001337
1338 private void handleRemoveListLocked() {
1339 if (mRemoveList.size() > 0) {
1340 for (IBinder b: mRemoveList) {
1341 remove(b);
1342 }
1343 mRemoveList.clear();
1344 }
1345 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001346
1347 private boolean validateEventsAndUserLocked(Record r, int events) {
1348 int foregroundUser;
1349 long callingIdentity = Binder.clearCallingIdentity();
1350 boolean valid = false;
1351 try {
1352 foregroundUser = ActivityManager.getCurrentUser();
1353 valid = r.callerUid == foregroundUser && (r.events & events) != 0;
1354 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001355 log("validateEventsAndUserLocked: valid=" + valid
Wink Savillea12a7b32012-09-20 10:09:45 -07001356 + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser
1357 + " r.events=" + r.events + " events=" + events);
1358 }
1359 } finally {
1360 Binder.restoreCallingIdentity(callingIdentity);
1361 }
1362 return valid;
1363 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001364
1365 private boolean validatePhoneId(int phoneId) {
1366 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001367 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001368 return valid;
1369 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001370
1371 private static void log(String s) {
1372 Rlog.d(TAG, s);
1373 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001374
1375 private static class LogSSC {
1376 private Time mTime;
1377 private String mS;
1378 private long mSubId;
1379 private int mPhoneId;
1380 private ServiceState mState;
1381
1382 public void set(Time t, String s, long subId, int phoneId, ServiceState state) {
1383 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1384 }
1385
1386 @Override
1387 public String toString() {
1388 return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState;
1389 }
1390 }
1391
1392 private LogSSC logSSC [] = new LogSSC[10];
1393 private int next = 0;
1394
1395 private void logServiceStateChanged(String s, long subId, int phoneId, ServiceState state) {
1396 if (logSSC == null || logSSC.length == 0) {
1397 return;
1398 }
1399 if (logSSC[next] == null) {
1400 logSSC[next] = new LogSSC();
1401 }
1402 Time t = new Time();
1403 t.setToNow();
1404 logSSC[next].set(t, s, subId, phoneId, state);
1405 if (++next >= logSSC.length) {
1406 next = 0;
1407 }
1408 }
1409
1410 private void toStringLogSSC(String prompt) {
1411 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1412 log(prompt + ": logSSC is empty");
1413 } else {
1414 // There is at least one element
1415 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1416 int i = next;
1417 if (logSSC[i] == null) {
1418 // logSSC is not full so back to the beginning
1419 i = 0;
1420 }
1421 do {
1422 log(logSSC[i].toString());
1423 if (++i >= logSSC.length) {
1424 i = 0;
1425 }
1426 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001427 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001428 }
1429 }
xinhee9f16402014-09-25 16:39:28 -07001430
1431 boolean subIdMatch(long rSubId, long subId) {
1432 if(rSubId == SubscriptionManager.DEFAULT_SUB_ID) {
1433 return (subId == mDefaultSubId);
1434 } else {
1435 return (rSubId == subId);
1436 }
1437 }
1438
1439 private void checkPossibleMissNotify(Record r, int phoneId) {
1440 int events = r.events;
1441
1442 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1443 try {
1444 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1445 mServiceState[phoneId]);
1446 r.callback.onServiceStateChanged(
1447 new ServiceState(mServiceState[phoneId]));
1448 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001449 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001450 }
1451 }
1452
1453 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1454 try {
1455 SignalStrength signalStrength = mSignalStrength[phoneId];
1456 if (DBG) {
1457 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1458 }
1459 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1460 } catch (RemoteException ex) {
1461 mRemoveList.add(r.binder);
1462 }
1463 }
1464
1465 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1466 try {
1467 int gsmSignalStrength = mSignalStrength[phoneId]
1468 .getGsmSignalStrength();
1469 if (DBG) {
1470 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1471 gsmSignalStrength);
1472 }
1473 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1474 : gsmSignalStrength));
1475 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001476 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001477 }
1478 }
1479
1480 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1481 try {
1482 if (DBG_LOC) {
1483 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1484 + mCellInfo.get(phoneId));
1485 }
1486 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1487 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001488 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001489 }
1490 }
1491
1492 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1493 try {
1494 if (VDBG) {
1495 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1496 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1497 }
1498 r.callback.onMessageWaitingIndicatorChanged(
1499 mMessageWaiting[phoneId]);
1500 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001501 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001502 }
1503 }
1504
1505 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1506 try {
1507 if (VDBG) {
1508 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1509 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1510 }
1511 r.callback.onCallForwardingIndicatorChanged(
1512 mCallForwarding[phoneId]);
1513 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001514 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001515 }
1516 }
1517
1518 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1519 try {
1520 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1521 + mCellLocation[phoneId]);
1522 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1523 } catch (RemoteException ex) {
1524 mRemoveList.add(r.binder);
1525 }
1526 }
1527
1528 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1529 try {
1530 if (DBG) {
1531 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1532 + "=" + mDataConnectionState[phoneId]
1533 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1534 + ")");
1535 }
1536 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1537 mDataConnectionNetworkType[phoneId]);
1538 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001539 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001540 }
1541 }
1542 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001543}