blob: 19a4851525a659fe766e813878b696f6366bbdb3 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
Amit Mahajan1cfd4572015-07-09 11:12:19 -070019import android.Manifest;
Wink Savillea12a7b32012-09-20 10:09:45 -070020import android.app.ActivityManager;
Svet Ganov16a16892015-04-16 10:32:04 -070021import android.app.AppOpsManager;
Wink Savillea12a7b32012-09-20 10:09:45 -070022import android.content.BroadcastReceiver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023import android.content.Context;
24import android.content.Intent;
Wink Savillea12a7b32012-09-20 10:09:45 -070025import android.content.IntentFilter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026import android.content.pm.PackageManager;
Robert Greenwalt37e65eb2010-08-30 10:56:47 -070027import android.net.LinkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070028import android.net.NetworkCapabilities;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029import android.os.Binder;
30import android.os.Bundle;
Wink Savillea12a7b32012-09-20 10:09:45 -070031import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.os.IBinder;
Wink Savillea12a7b32012-09-20 10:09:45 -070033import android.os.Message;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.os.RemoteException;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070035import android.os.UserHandle;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036import android.telephony.CellLocation;
Wink Saville070e0612014-04-15 22:04:10 -070037import android.telephony.DataConnectionRealTimeInfo;
Wink Savillef4cd25b2014-07-08 19:03:20 -070038import android.telephony.Rlog;
Wink Savillefb40dd42014-06-12 17:02:31 -070039import android.telephony.TelephonyManager;
40import android.telephony.SubscriptionManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041import android.telephony.PhoneStateListener;
42import android.telephony.ServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -070043import android.telephony.SignalStrength;
John Wang963db55d2012-03-30 16:04:06 -070044import android.telephony.CellInfo;
Wink Savillefb40dd42014-06-12 17:02:31 -070045import android.telephony.VoLteServiceState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020046import android.telephony.DisconnectCause;
47import android.telephony.PreciseCallState;
48import android.telephony.PreciseDataConnectionState;
49import android.telephony.PreciseDisconnectCause;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050import android.text.TextUtils;
Wink Saville47d8d1b2014-07-10 13:01:52 -070051import android.text.format.Time;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080052
53import java.util.ArrayList;
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;
Wink Savilled09c4ca2014-11-22 10:08:16 -080059import com.android.internal.telephony.IOnSubscriptionsChangedListener;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080060import com.android.internal.telephony.ITelephonyRegistry;
61import com.android.internal.telephony.IPhoneStateListener;
62import com.android.internal.telephony.DefaultPhoneNotifier;
Wink Savillea639b312012-07-10 12:37:54 -070063import com.android.internal.telephony.PhoneConstants;
Wink Savillec9330dd2011-01-12 13:37:38 -080064import com.android.internal.telephony.ServiceStateTracker;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065import com.android.internal.telephony.TelephonyIntents;
66import com.android.server.am.BatteryStatsService;
67
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068/**
Wink Savillee9b06d72009-05-18 21:47:50 -070069 * Since phone process can be restarted, this class provides a centralized place
70 * that applications can register and be called back from.
Wink Savillee380b982014-07-26 18:24:22 -070071 *
72 * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026
73 * and 15973975 by saving the phoneId of the registrant and then using the
74 * phoneId when deciding to to make a callback. This is necessary because
75 * a subId changes from to a dummy value when a SIM is removed and thus won't
Wink Saville63f03dd2014-10-23 10:44:45 -070076 * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles
Wink Savillee380b982014-07-26 18:24:22 -070077 * the dummy value conversion we properly do the callbacks.
78 *
79 * Eventually we may want to remove the notion of dummy value but for now this
80 * looks like the best approach.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080081 */
82class TelephonyRegistry extends ITelephonyRegistry.Stub {
83 private static final String TAG = "TelephonyRegistry";
Wink Saville6d13bc82014-08-01 11:13:40 -070084 private static final boolean DBG = false; // STOPSHIP if true
Wink Savillefb40dd42014-06-12 17:02:31 -070085 private static final boolean DBG_LOC = false; // STOPSHIP if true
Wink Saville6d13bc82014-08-01 11:13:40 -070086 private static final boolean VDBG = false; // STOPSHIP if true
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080087
88 private static class Record {
Svet Ganov16a16892015-04-16 10:32:04 -070089 String callingPackage;
Wink Savillee9b06d72009-05-18 21:47:50 -070090
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091 IBinder binder;
Wink Savillee9b06d72009-05-18 21:47:50 -070092
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080093 IPhoneStateListener callback;
Wink Savilled09c4ca2014-11-22 10:08:16 -080094 IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback;
Wink Savillee9b06d72009-05-18 21:47:50 -070095
Fyodor Kupolov309b2f632015-06-03 16:29:01 -070096 int callerUserId;
Wink Savillea12a7b32012-09-20 10:09:45 -070097
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 int events;
Wink Savillea12a7b32012-09-20 10:09:45 -070099
Wink Savilled09c4ca2014-11-22 10:08:16 -0800100 int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Wink Savillefb40dd42014-06-12 17:02:31 -0700101
Wink Savilled09c4ca2014-11-22 10:08:16 -0800102 int phoneId = SubscriptionManager.INVALID_PHONE_INDEX;
Wink Savillea374c3d2014-11-11 11:48:04 -0800103
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700104 boolean canReadPhoneState;
105
Wink Savillea374c3d2014-11-11 11:48:04 -0800106 boolean matchPhoneStateListenerEvent(int events) {
107 return (callback != null) && ((events & this.events) != 0);
108 }
109
Wink Savilled09c4ca2014-11-22 10:08:16 -0800110 boolean matchOnSubscriptionsChangedListener() {
111 return (onSubscriptionsChangedListenerCallback != null);
Wink Savillea374c3d2014-11-11 11:48:04 -0800112 }
Wink Savillee380b982014-07-26 18:24:22 -0700113
Wink Savillea12a7b32012-09-20 10:09:45 -0700114 @Override
115 public String toString() {
Svet Ganov16a16892015-04-16 10:32:04 -0700116 return "{callingPackage=" + callingPackage + " binder=" + binder
117 + " callback=" + callback
Wink Savilled09c4ca2014-11-22 10:08:16 -0800118 + " onSubscriptionsChangedListenererCallback="
119 + onSubscriptionsChangedListenerCallback
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700120 + " callerUserId=" + callerUserId + " subId=" + subId + " phoneId=" + phoneId
121 + " events=" + Integer.toHexString(events)
122 + " canReadPhoneState=" + canReadPhoneState + "}";
Wink Savillea12a7b32012-09-20 10:09:45 -0700123 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800124 }
125
126 private final Context mContext;
Wink Savillee9b06d72009-05-18 21:47:50 -0700127
Joe Onorato163d8d92010-10-21 13:21:20 -0400128 // access should be inside synchronized (mRecords) for these two fields
129 private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>();
130 private final ArrayList<Record> mRecords = new ArrayList<Record>();
Wink Savillee9b06d72009-05-18 21:47:50 -0700131
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800132 private final IBatteryStats mBatteryStats;
133
Svet Ganov16a16892015-04-16 10:32:04 -0700134 private final AppOpsManager mAppOps;
135
Wink Savilled09c4ca2014-11-22 10:08:16 -0800136 private boolean hasNotifySubscriptionInfoChangedOccurred = false;
137
Wink Savillefb40dd42014-06-12 17:02:31 -0700138 private int mNumPhones;
Wink Savillee9b06d72009-05-18 21:47:50 -0700139
Wink Savillefb40dd42014-06-12 17:02:31 -0700140 private int[] mCallState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700141
Wink Savillefb40dd42014-06-12 17:02:31 -0700142 private String[] mCallIncomingNumber;
Wink Savillee9b06d72009-05-18 21:47:50 -0700143
Wink Savillefb40dd42014-06-12 17:02:31 -0700144 private ServiceState[] mServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700145
Wink Savillefb40dd42014-06-12 17:02:31 -0700146 private SignalStrength[] mSignalStrength;
Wink Savillee9b06d72009-05-18 21:47:50 -0700147
Wink Savillefb40dd42014-06-12 17:02:31 -0700148 private boolean[] mMessageWaiting;
Wink Savillee9b06d72009-05-18 21:47:50 -0700149
Wink Savillefb40dd42014-06-12 17:02:31 -0700150 private boolean[] mCallForwarding;
Wink Savillee9b06d72009-05-18 21:47:50 -0700151
Wink Savillefb40dd42014-06-12 17:02:31 -0700152 private int[] mDataActivity;
Wink Savillee9b06d72009-05-18 21:47:50 -0700153
Wink Savillefb40dd42014-06-12 17:02:31 -0700154 private int[] mDataConnectionState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700155
Wink Savillefb40dd42014-06-12 17:02:31 -0700156 private boolean[] mDataConnectionPossible;
Wink Savillee9b06d72009-05-18 21:47:50 -0700157
Wink Savillefb40dd42014-06-12 17:02:31 -0700158 private String[] mDataConnectionReason;
159
160 private String[] mDataConnectionApn;
Wink Savillee9b06d72009-05-18 21:47:50 -0700161
Robert Greenwalt02648a42010-05-18 10:52:51 -0700162 private ArrayList<String> mConnectedApns;
Robert Greenwalt42acef32009-08-12 16:08:25 -0700163
Wink Savillefb40dd42014-06-12 17:02:31 -0700164 private LinkProperties[] mDataConnectionLinkProperties;
Wink Savillef61101f2010-09-16 16:36:42 -0700165
Wink Savillefb40dd42014-06-12 17:02:31 -0700166 private NetworkCapabilities[] mDataConnectionNetworkCapabilities;
Wink Savillee9b06d72009-05-18 21:47:50 -0700167
Wink Savillefb40dd42014-06-12 17:02:31 -0700168 private Bundle[] mCellLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800169
Wink Savillefb40dd42014-06-12 17:02:31 -0700170 private int[] mDataConnectionNetworkType;
Robert Greenwalt98e0b142009-10-08 21:15:52 -0700171
Wink Savillec9330dd2011-01-12 13:37:38 -0800172 private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN;
Wink Savillefd2d0132010-10-28 14:22:26 -0700173
Wink Savillefb40dd42014-06-12 17:02:31 -0700174 private ArrayList<List<CellInfo>> mCellInfo = null;
175
176 private VoLteServiceState mVoLteServiceState = new VoLteServiceState();
177
Wink Savilled09c4ca2014-11-22 10:08:16 -0800178 private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
xinhee9f16402014-09-25 16:39:28 -0700179
Wink Savilled09c4ca2014-11-22 10:08:16 -0800180 private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX;
xinhee9f16402014-09-25 16:39:28 -0700181
Wink Saville070e0612014-04-15 22:04:10 -0700182 private DataConnectionRealTimeInfo mDcRtInfo = new DataConnectionRealTimeInfo();
183
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200184 private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
185
186 private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
187
188 private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
189
190 private PreciseCallState mPreciseCallState = new PreciseCallState();
191
Andrew Flynn1f452642015-04-14 22:16:04 -0400192 private boolean mCarrierNetworkChangeState = false;
193
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200194 private PreciseDataConnectionState mPreciseDataConnectionState =
195 new PreciseDataConnectionState();
196
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700197 static final int ENFORCE_PHONE_STATE_PERMISSION_MASK =
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700198 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700199 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
200 PhoneStateListener.LISTEN_VOLTE_STATE;
201
202 static final int CHECK_PHONE_STATE_PERMISSION_MASK =
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700203 PhoneStateListener.LISTEN_CALL_STATE |
204 PhoneStateListener.LISTEN_DATA_ACTIVITY |
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700205 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE;
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700206
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200207 static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
208 PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
209 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
210
Wink Savillea12a7b32012-09-20 10:09:45 -0700211 private static final int MSG_USER_SWITCHED = 1;
Wink Savillefb40dd42014-06-12 17:02:31 -0700212 private static final int MSG_UPDATE_DEFAULT_SUB = 2;
Wink Savillea12a7b32012-09-20 10:09:45 -0700213
214 private final Handler mHandler = new Handler() {
215 @Override
216 public void handleMessage(Message msg) {
217 switch (msg.what) {
218 case MSG_USER_SWITCHED: {
Wink Savillee380b982014-07-26 18:24:22 -0700219 if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
Wink Savillefb40dd42014-06-12 17:02:31 -0700220 int numPhones = TelephonyManager.getDefault().getPhoneCount();
221 for (int sub = 0; sub < numPhones; sub++) {
Wink Savillebc027272014-09-08 14:50:58 -0700222 TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
Wink Savillee380b982014-07-26 18:24:22 -0700223 mCellLocation[sub]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700224 }
225 break;
226 }
xinhee9f16402014-09-25 16:39:28 -0700227 case MSG_UPDATE_DEFAULT_SUB: {
228 int newDefaultPhoneId = msg.arg1;
Wink Saville63f03dd2014-10-23 10:44:45 -0700229 int newDefaultSubId = (Integer)(msg.obj);
xinhee9f16402014-09-25 16:39:28 -0700230 if (VDBG) {
231 log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId
232 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
233 + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId);
234 }
235
236 //Due to possible risk condition,(notify call back using the new
237 //defaultSubId comes before new defaultSubId update) we need to recall all
238 //possible missed notify callback
239 synchronized (mRecords) {
Etan Cohena33cf072014-09-30 10:35:24 -0700240 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800241 if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
Etan Cohena33cf072014-09-30 10:35:24 -0700242 checkPossibleMissNotify(r, newDefaultPhoneId);
243 }
244 }
245 handleRemoveListLocked();
xinhee9f16402014-09-25 16:39:28 -0700246 }
247 mDefaultSubId = newDefaultSubId;
248 mDefaultPhoneId = newDefaultPhoneId;
Wink Savillea12a7b32012-09-20 10:09:45 -0700249 }
250 }
251 }
252 };
253
254 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
255 @Override
256 public void onReceive(Context context, Intent intent) {
257 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700258 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700259 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700260 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700261 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700262 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700263 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
Wink Saville63f03dd2014-10-23 10:44:45 -0700264 Integer newDefaultSubIdObj = new Integer(intent.getIntExtra(
xinhee9f16402014-09-25 16:39:28 -0700265 PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSubId()));
266 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
267 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700268 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700269 log("onReceive:current mDefaultSubId=" + mDefaultSubId
270 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
271 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700272 }
xinhee9f16402014-09-25 16:39:28 -0700273
Junda Liu985f52c2015-02-23 16:06:51 -0800274 if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId)
xinhee9f16402014-09-25 16:39:28 -0700275 || (newDefaultPhoneId != mDefaultPhoneId))) {
276 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
277 newDefaultPhoneId, 0, newDefaultSubIdObj));
278 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700279 }
280 }
281 };
282
Wink Savillee9b06d72009-05-18 21:47:50 -0700283 // we keep a copy of all of the state so we can send it out when folks
284 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800285 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700286 // In these calls we call with the lock held. This is safe becasuse remote
287 // calls go through a oneway interface and local calls going through a
288 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800289
290 TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700291 CellLocation location = CellLocation.getEmpty();
292
Wink Savillefb40dd42014-06-12 17:02:31 -0700293 mContext = context;
294 mBatteryStats = BatteryStatsService.getService();
295 mConnectedApns = new ArrayList<String>();
296
Wink Savillefb40dd42014-06-12 17:02:31 -0700297 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700298 if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700299 mNumPhones = numPhones;
300 mCallState = new int[numPhones];
301 mDataActivity = new int[numPhones];
302 mDataConnectionState = new int[numPhones];
303 mDataConnectionNetworkType = new int[numPhones];
304 mCallIncomingNumber = new String[numPhones];
305 mServiceState = new ServiceState[numPhones];
306 mSignalStrength = new SignalStrength[numPhones];
307 mMessageWaiting = new boolean[numPhones];
308 mDataConnectionPossible = new boolean[numPhones];
309 mDataConnectionReason = new String[numPhones];
310 mDataConnectionApn = new String[numPhones];
311 mCallForwarding = new boolean[numPhones];
312 mCellLocation = new Bundle[numPhones];
313 mDataConnectionLinkProperties = new LinkProperties[numPhones];
314 mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones];
315 mCellInfo = new ArrayList<List<CellInfo>>();
316 for (int i = 0; i < numPhones; i++) {
317 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
318 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
319 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
320 mCallIncomingNumber[i] = "";
321 mServiceState[i] = new ServiceState();
322 mSignalStrength[i] = new SignalStrength();
323 mMessageWaiting[i] = false;
324 mCallForwarding[i] = false;
325 mDataConnectionPossible[i] = false;
326 mDataConnectionReason[i] = "";
327 mDataConnectionApn[i] = "";
328 mCellLocation[i] = new Bundle();
329 mCellInfo.add(i, null);
330 }
331
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700332 // Note that location can be null for non-phone builds like
333 // like the generic one.
334 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700335 for (int i = 0; i < numPhones; i++) {
336 location.fillInNotifierBundle(mCellLocation[i]);
337 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700338 }
Robert Greenwalt02648a42010-05-18 10:52:51 -0700339 mConnectedApns = new ArrayList<String>();
Svet Ganov16a16892015-04-16 10:32:04 -0700340
341 mAppOps = mContext.getSystemService(AppOpsManager.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342 }
343
Svetoslav Ganova0027152013-06-25 14:59:53 -0700344 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700345 // Watch for interesting updates
346 final IntentFilter filter = new IntentFilter();
347 filter.addAction(Intent.ACTION_USER_SWITCHED);
348 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700349 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700350 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700351 mContext.registerReceiver(mBroadcastReceiver, filter);
352 }
353
354 @Override
Svet Ganov16a16892015-04-16 10:32:04 -0700355 public void addOnSubscriptionsChangedListener(String callingPackage,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800356 IOnSubscriptionsChangedListener callback) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700357 int callerUserId = UserHandle.getCallingUserId();
Wink Savillea374c3d2014-11-11 11:48:04 -0800358 if (VDBG) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700359 log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
360 + " callerUserId=" + callerUserId + " callback=" + callback
Wink Savillea374c3d2014-11-11 11:48:04 -0800361 + " callback.asBinder=" + callback.asBinder());
362 }
363
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700364 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700365 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700366 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
367 "addOnSubscriptionsChangedListener");
Amit Mahajana9e72a72015-07-30 16:04:13 -0700368 // SKIP checking for run-time permission since caller or self has PRIVILEGED permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700369 } catch (SecurityException e) {
370 mContext.enforceCallingOrSelfPermission(
371 android.Manifest.permission.READ_PHONE_STATE,
372 "addOnSubscriptionsChangedListener");
Svet Ganov16a16892015-04-16 10:32:04 -0700373
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700374 if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
375 callingPackage) != AppOpsManager.MODE_ALLOWED) {
376 return;
377 }
Svet Ganov16a16892015-04-16 10:32:04 -0700378 }
379
Fyodor Kupolovac038a92015-06-09 13:14:54 -0700380 Record r;
Wink Savillea374c3d2014-11-11 11:48:04 -0800381
Wink Savilled09c4ca2014-11-22 10:08:16 -0800382 synchronized (mRecords) {
383 // register
384 find_and_add: {
385 IBinder b = callback.asBinder();
386 final int N = mRecords.size();
387 for (int i = 0; i < N; i++) {
388 r = mRecords.get(i);
389 if (b == r.binder) {
390 break find_and_add;
Wink Savillea374c3d2014-11-11 11:48:04 -0800391 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800392 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800393 r = new Record();
394 r.binder = b;
395 mRecords.add(r);
396 if (DBG) log("listen oscl: add new record");
Wink Savillea374c3d2014-11-11 11:48:04 -0800397 }
398
Wink Savilled09c4ca2014-11-22 10:08:16 -0800399 r.onSubscriptionsChangedListenerCallback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700400 r.callingPackage = callingPackage;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700401 r.callerUserId = callerUserId;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800402 r.events = 0;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700403 r.canReadPhoneState = true; // permission has been enforced above
Wink Savilled09c4ca2014-11-22 10:08:16 -0800404 if (DBG) {
405 log("listen oscl: Register r=" + r);
406 }
407 // Always notify when registration occurs if there has been a notification.
408 if (hasNotifySubscriptionInfoChangedOccurred) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800409 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800410 if (VDBG) log("listen oscl: send to r=" + r);
411 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
412 if (VDBG) log("listen oscl: sent to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800413 } catch (RemoteException e) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800414 if (VDBG) log("listen oscl: remote exception sending to r=" + r + " e=" + e);
Wink Savillea374c3d2014-11-11 11:48:04 -0800415 remove(r.binder);
416 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800417 } else {
418 log("listen oscl: hasNotifySubscriptionInfoChangedOccurred==false no callback");
Wink Savillea374c3d2014-11-11 11:48:04 -0800419 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800420 }
421 }
422
423 @Override
Wink Saville071743f2015-01-12 17:11:04 -0800424 public void removeOnSubscriptionsChangedListener(String pkgForDebug,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800425 IOnSubscriptionsChangedListener callback) {
426 if (DBG) log("listen oscl: Unregister");
Wink Savillea374c3d2014-11-11 11:48:04 -0800427 remove(callback.asBinder());
428 }
429
Wink Savillea374c3d2014-11-11 11:48:04 -0800430 @Override
431 public void notifySubscriptionInfoChanged() {
432 if (VDBG) log("notifySubscriptionInfoChanged:");
433 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800434 if (!hasNotifySubscriptionInfoChangedOccurred) {
435 log("notifySubscriptionInfoChanged: first invocation mRecords.size="
436 + mRecords.size());
437 }
438 hasNotifySubscriptionInfoChangedOccurred = true;
Wink Savillea374c3d2014-11-11 11:48:04 -0800439 mRemoveList.clear();
440 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800441 if (r.matchOnSubscriptionsChangedListener()) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800442 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800443 if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r);
444 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
445 if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800446 } catch (RemoteException ex) {
447 if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r);
448 mRemoveList.add(r.binder);
449 }
450 }
451 }
452 handleRemoveListLocked();
453 }
454 }
455
456 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800457 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
458 boolean notifyNow) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800459 listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback,
460 events, notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700461 }
462
463 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700464 public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700465 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700466 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700467 }
468
Svet Ganov16a16892015-04-16 10:32:04 -0700469 private void listen(String callingPackage, IPhoneStateListener callback, int events,
Wink Saville63f03dd2014-10-23 10:44:45 -0700470 boolean notifyNow, int subId) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700471 int callerUserId = UserHandle.getCallingUserId();
Wink Savillee380b982014-07-26 18:24:22 -0700472 if (VDBG) {
Svet Ganov16a16892015-04-16 10:32:04 -0700473 log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700474 + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
475 + UserHandle.myUserId() + " callerUserId=" + callerUserId);
Wink Savillea12a7b32012-09-20 10:09:45 -0700476 }
xinhe75c2c152014-10-16 11:49:45 -0700477
478 if (events != PhoneStateListener.LISTEN_NONE) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700479 /* Checks permission and throws Security exception */
480 checkListenerPermission(events);
Svet Ganov16a16892015-04-16 10:32:04 -0700481
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700482 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700483 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700484 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700485 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
Amit Mahajana9e72a72015-07-30 16:04:13 -0700486 // SKIP checking for run-time permission since caller or self has PRIVILEGED
487 // permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700488 } catch (SecurityException e) {
489 if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
490 callingPackage) != AppOpsManager.MODE_ALLOWED) {
491 return;
492 }
Svet Ganov16a16892015-04-16 10:32:04 -0700493 }
494 }
495
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800496 synchronized (mRecords) {
497 // register
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700498 Record r;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800499 find_and_add: {
500 IBinder b = callback.asBinder();
501 final int N = mRecords.size();
Wink Savillee9b06d72009-05-18 21:47:50 -0700502 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800503 r = mRecords.get(i);
504 if (b == r.binder) {
505 break find_and_add;
506 }
507 }
508 r = new Record();
509 r.binder = b;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800510 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700511 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800512 }
xinhe43c50292014-09-18 17:56:48 -0700513
xinhe75c2c152014-10-16 11:49:45 -0700514 r.callback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700515 r.callingPackage = callingPackage;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700516 r.callerUserId = callerUserId;
517 boolean isPhoneStateEvent = (events & (CHECK_PHONE_STATE_PERMISSION_MASK
518 | ENFORCE_PHONE_STATE_PERMISSION_MASK)) != 0;
519 r.canReadPhoneState = isPhoneStateEvent && canReadPhoneState(callingPackage);
xinhe75c2c152014-10-16 11:49:45 -0700520 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
521 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
Wink Savillea54bf652014-12-11 13:37:50 -0800522 if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800523 r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
xinhe75c2c152014-10-16 11:49:45 -0700524 } else {//APP specify subID
525 r.subId = subId;
526 }
527 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
528
xinhe43c50292014-09-18 17:56:48 -0700529 int phoneId = r.phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800530 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700531 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700532 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700533 }
534 if (VDBG) toStringLogSSC("listen");
Wink Savillefb40dd42014-06-12 17:02:31 -0700535 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800536 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400537 try {
Wink Savillee380b982014-07-26 18:24:22 -0700538 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700539 r.callback.onServiceStateChanged(
540 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400541 } catch (RemoteException ex) {
542 remove(r.binder);
543 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800544 }
545 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
546 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700547 int gsmSignalStrength = mSignalStrength[phoneId]
548 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700549 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
550 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800551 } catch (RemoteException ex) {
552 remove(r.binder);
553 }
554 }
555 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
556 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700557 r.callback.onMessageWaitingIndicatorChanged(
558 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800559 } catch (RemoteException ex) {
560 remove(r.binder);
561 }
562 }
563 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
564 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700565 r.callback.onCallForwardingIndicatorChanged(
566 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800567 } catch (RemoteException ex) {
568 remove(r.binder);
569 }
570 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700571 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400572 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700573 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700574 + mCellLocation[phoneId]);
575 r.callback.onCellLocationChanged(
576 new Bundle(mCellLocation[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400577 } catch (RemoteException ex) {
578 remove(r.binder);
579 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800580 }
581 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
582 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700583 r.callback.onCallStateChanged(mCallState[phoneId],
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700584 getCallIncomingNumber(r, phoneId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800585 } catch (RemoteException ex) {
586 remove(r.binder);
587 }
588 }
589 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
590 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700591 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
592 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800593 } catch (RemoteException ex) {
594 remove(r.binder);
595 }
596 }
597 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
598 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700599 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800600 } catch (RemoteException ex) {
601 remove(r.binder);
602 }
603 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700604 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
605 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700606 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700607 } catch (RemoteException ex) {
608 remove(r.binder);
609 }
610 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700611 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
612 try {
613 r.callback.onOtaspChanged(mOtaspMode);
614 } catch (RemoteException ex) {
615 remove(r.binder);
616 }
617 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700618 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700619 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700620 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700621 + mCellInfo.get(phoneId));
622 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
John Wang963db55d2012-03-30 16:04:06 -0700623 } catch (RemoteException ex) {
624 remove(r.binder);
625 }
626 }
Wink Saville070e0612014-04-15 22:04:10 -0700627 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) {
628 try {
629 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
630 } catch (RemoteException ex) {
631 remove(r.binder);
632 }
633 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200634 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
635 try {
636 r.callback.onPreciseCallStateChanged(mPreciseCallState);
637 } catch (RemoteException ex) {
638 remove(r.binder);
639 }
640 }
641 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
642 try {
643 r.callback.onPreciseDataConnectionStateChanged(
644 mPreciseDataConnectionState);
645 } catch (RemoteException ex) {
646 remove(r.binder);
647 }
648 }
Andrew Flynn1f452642015-04-14 22:16:04 -0400649 if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) {
650 try {
651 r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
652 } catch (RemoteException ex) {
653 remove(r.binder);
654 }
655 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800656 }
657 }
658 } else {
xinhe75c2c152014-10-16 11:49:45 -0700659 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800660 remove(callback.asBinder());
661 }
662 }
663
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700664 private boolean canReadPhoneState(String callingPackage) {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700665 if (mContext.checkCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700666 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) ==
667 PackageManager.PERMISSION_GRANTED) {
Amit Mahajana9e72a72015-07-30 16:04:13 -0700668 // SKIP checking for run-time permission since caller or self has PRIVILEGED permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700669 return true;
670 }
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700671 boolean canReadPhoneState = mContext.checkCallingOrSelfPermission(
672 android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
673 if (canReadPhoneState &&
674 mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
675 callingPackage) != AppOpsManager.MODE_ALLOWED) {
676 return false;
677 }
678 return canReadPhoneState;
679 }
680
681 private String getCallIncomingNumber(Record record, int phoneId) {
682 // Hide the number if record's process has no READ_PHONE_STATE permission
683 return record.canReadPhoneState ? mCallIncomingNumber[phoneId] : "";
684 }
685
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800686 private void remove(IBinder binder) {
687 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700688 final int recordCount = mRecords.size();
689 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800690 if (mRecords.get(i).binder == binder) {
xinheac11ae92014-12-18 10:02:14 -0800691 if (DBG) {
692 Record r = mRecords.get(i);
Svet Ganov16a16892015-04-16 10:32:04 -0700693 log("remove: binder=" + binder + "r.callingPackage" + r.callingPackage
xinheac11ae92014-12-18 10:02:14 -0800694 + "r.callback" + r.callback);
695 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800696 mRecords.remove(i);
697 return;
698 }
699 }
700 }
701 }
702
703 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700704 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700705 return;
706 }
xinhe43c50292014-09-18 17:56:48 -0700707
708 if (VDBG) {
709 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
710 }
711
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800712 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700713 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800714 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800715 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800716 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700717 String incomingNumberOrEmpty = r.canReadPhoneState ? incomingNumber : "";
718 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800719 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400720 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800721 }
722 }
723 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400724 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800725 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800726 broadcastCallStateChanged(state, incomingNumber,
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -0700727 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800728 }
729
Wink Saville63f03dd2014-10-23 10:44:45 -0700730 public void notifyCallStateForSubscriber(int subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700731 if (!checkNotifyPermission("notifyCallState()")) {
732 return;
733 }
Wink Savillee380b982014-07-26 18:24:22 -0700734 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700735 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700736 + " state=" + state + " incomingNumber=" + incomingNumber);
737 }
738 synchronized (mRecords) {
739 int phoneId = SubscriptionManager.getPhoneId(subId);
740 if (validatePhoneId(phoneId)) {
741 mCallState[phoneId] = state;
742 mCallIncomingNumber[phoneId] = incomingNumber;
743 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800744 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
xinhe43c50292014-09-18 17:56:48 -0700745 (r.subId == subId) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800746 (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700747 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700748 String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId);
749 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
Wink Savillefb40dd42014-06-12 17:02:31 -0700750 } catch (RemoteException ex) {
751 mRemoveList.add(r.binder);
752 }
753 }
754 }
755 }
756 handleRemoveListLocked();
757 }
758 broadcastCallStateChanged(state, incomingNumber, subId);
759 }
760
Wink Saville63f03dd2014-10-23 10:44:45 -0700761 public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700762 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700763 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700764 }
xinhe43c50292014-09-18 17:56:48 -0700765
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800766 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700767 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700768 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700769 + " state=" + state);
770 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700771 if (validatePhoneId(phoneId)) {
772 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700773 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
774 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700775
Wink Savillefb40dd42014-06-12 17:02:31 -0700776 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700777 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700778 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700779 + " phoneId=" + phoneId + " state=" + state);
780 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800781 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) &&
xinhe8b79fb62014-11-05 14:55:03 -0800782 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700783 try {
Wink Savillee380b982014-07-26 18:24:22 -0700784 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700785 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700786 + " subId=" + subId + " phoneId=" + phoneId
787 + " state=" + state);
788 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700789 r.callback.onServiceStateChanged(new ServiceState(state));
790 } catch (RemoteException ex) {
791 mRemoveList.add(r.binder);
792 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400793 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800794 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700795 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700796 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800797 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400798 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800799 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700800 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800801 }
802
Wink Savillee9b06d72009-05-18 21:47:50 -0700803 public void notifySignalStrength(SignalStrength signalStrength) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800804 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
805 signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700806 }
807
Wink Saville63f03dd2014-10-23 10:44:45 -0700808 public void notifySignalStrengthForSubscriber(int subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700809 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700810 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700811 }
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000812 if (VDBG) {
813 log("notifySignalStrengthForSubscriber: subId=" + subId
814 + " signalStrength=" + signalStrength);
815 toStringLogSSC("notifySignalStrengthForSubscriber");
816 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800817 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700818 int phoneId = SubscriptionManager.getPhoneId(subId);
819 if (validatePhoneId(phoneId)) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000820 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700821 mSignalStrength[phoneId] = signalStrength;
822 for (Record r : mRecords) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000823 if (VDBG) {
824 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
825 + " phoneId=" + phoneId + " ss=" + signalStrength);
826 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800827 if (r.matchPhoneStateListenerEvent(
828 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) &&
xinhe8b79fb62014-11-05 14:55:03 -0800829 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700830 try {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000831 if (DBG) {
832 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
833 + " subId=" + subId + " phoneId=" + phoneId
834 + " ss=" + signalStrength);
835 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700836 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
837 } catch (RemoteException ex) {
838 mRemoveList.add(r.binder);
839 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400840 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800841 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) &&
xinhe8b79fb62014-11-05 14:55:03 -0800842 idMatch(r.subId, subId, phoneId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700843 try {
844 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700845 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000846 if (DBG) {
847 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
848 + " subId=" + subId + " phoneId=" + phoneId
849 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
850 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700851 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700852 } catch (RemoteException ex) {
853 mRemoveList.add(r.binder);
854 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800855 }
856 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700857 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700858 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800859 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400860 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800861 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700862 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800863 }
864
Andrew Flynn1f452642015-04-14 22:16:04 -0400865 @Override
866 public void notifyCarrierNetworkChange(boolean active) {
Andrew Flynnceaed682015-06-09 12:36:58 +0000867 enforceNotifyPermissionOrCarrierPrivilege("notifyCarrierNetworkChange()");
868
Andrew Flynn1f452642015-04-14 22:16:04 -0400869 if (VDBG) {
870 log("notifyCarrierNetworkChange: active=" + active);
871 }
872
873 synchronized (mRecords) {
874 mCarrierNetworkChangeState = active;
875 for (Record r : mRecords) {
876 if (r.matchPhoneStateListenerEvent(
877 PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE)) {
878 try {
879 r.callback.onCarrierNetworkChange(active);
880 } catch (RemoteException ex) {
881 mRemoveList.add(r.binder);
882 }
883 }
884 }
885 handleRemoveListLocked();
886 }
887 }
888
Wink Savilleb208a242012-07-25 14:08:09 -0700889 public void notifyCellInfo(List<CellInfo> cellInfo) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800890 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700891 }
892
Wink Saville63f03dd2014-10-23 10:44:45 -0700893 public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700894 if (!checkNotifyPermission("notifyCellInfo()")) {
895 return;
896 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700897 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700898 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700899 + " cellInfo=" + cellInfo);
900 }
John Wang963db55d2012-03-30 16:04:06 -0700901
902 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700903 int phoneId = SubscriptionManager.getPhoneId(subId);
904 if (validatePhoneId(phoneId)) {
905 mCellInfo.set(phoneId, cellInfo);
906 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700907 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhe8b79fb62014-11-05 14:55:03 -0800908 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700909 try {
910 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700911 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700912 }
913 r.callback.onCellInfoChanged(cellInfo);
914 } catch (RemoteException ex) {
915 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700916 }
John Wang963db55d2012-03-30 16:04:06 -0700917 }
918 }
919 }
920 handleRemoveListLocked();
921 }
922 }
923
Wink Saville070e0612014-04-15 22:04:10 -0700924 public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) {
925 if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) {
926 return;
927 }
928
929 synchronized (mRecords) {
930 mDcRtInfo = dcRtInfo;
931 for (Record r : mRecords) {
932 if (validateEventsAndUserLocked(r,
933 PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) {
934 try {
935 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700936 log("notifyDataConnectionRealTimeInfo: mDcRtInfo="
Wink Saville070e0612014-04-15 22:04:10 -0700937 + mDcRtInfo + " r=" + r);
938 }
939 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
940 } catch (RemoteException ex) {
941 mRemoveList.add(r.binder);
942 }
943 }
944 }
945 handleRemoveListLocked();
946 }
947 }
948
xinhe43c50292014-09-18 17:56:48 -0700949 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700950 public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700951 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700952 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700953 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700954 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700955 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700956 + " mwi=" + mwi);
957 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800958 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700959 if (validatePhoneId(phoneId)) {
960 mMessageWaiting[phoneId] = mwi;
961 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800962 if (r.matchPhoneStateListenerEvent(
963 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800964 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700965 try {
966 r.callback.onMessageWaitingIndicatorChanged(mwi);
967 } catch (RemoteException ex) {
968 mRemoveList.add(r.binder);
969 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800970 }
971 }
972 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400973 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800974 }
975 }
976
977 public void notifyCallForwardingChanged(boolean cfi) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800978 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700979 }
980
Wink Saville63f03dd2014-10-23 10:44:45 -0700981 public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700982 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700983 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700984 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700985 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700986 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700987 + " cfi=" + cfi);
988 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800989 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700990 int phoneId = SubscriptionManager.getPhoneId(subId);
991 if (validatePhoneId(phoneId)) {
992 mCallForwarding[phoneId] = cfi;
993 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800994 if (r.matchPhoneStateListenerEvent(
995 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800996 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700997 try {
998 r.callback.onCallForwardingIndicatorChanged(cfi);
999 } catch (RemoteException ex) {
1000 mRemoveList.add(r.binder);
1001 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001002 }
1003 }
1004 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001005 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001006 }
1007 }
1008
1009 public void notifyDataActivity(int state) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001010 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -07001011 }
1012
Wink Saville63f03dd2014-10-23 10:44:45 -07001013 public void notifyDataActivityForSubscriber(int subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001014 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001015 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001016 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001017 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001018 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001019 if (validatePhoneId(phoneId)) {
1020 mDataActivity[phoneId] = state;
1021 for (Record r : mRecords) {
1022 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY)) {
1023 try {
1024 r.callback.onDataActivity(state);
1025 } catch (RemoteException ex) {
1026 mRemoveList.add(r.binder);
1027 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001028 }
1029 }
1030 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001031 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001032 }
1033 }
1034
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001035 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001036 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001037 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001038 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
xinhe43c50292014-09-18 17:56:48 -07001039 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001040 networkCapabilities, networkType, roaming);
1041 }
1042
Wink Saville63f03dd2014-10-23 10:44:45 -07001043 public void notifyDataConnectionForSubscriber(int subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -07001044 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
1045 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
1046 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001047 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001048 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001049 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001050 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001051 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001052 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
1053 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -07001054 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
xinheac11ae92014-12-18 10:02:14 -08001055 + " mRecords.size()=" + mRecords.size());
Wink Savillec9acde92011-09-21 11:05:43 -07001056 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001057 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001058 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001059 if (validatePhoneId(phoneId)) {
1060 boolean modified = false;
1061 if (state == TelephonyManager.DATA_CONNECTED) {
1062 if (!mConnectedApns.contains(apnType)) {
1063 mConnectedApns.add(apnType);
1064 if (mDataConnectionState[phoneId] != state) {
1065 mDataConnectionState[phoneId] = state;
1066 modified = true;
1067 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001068 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001069 } else {
1070 if (mConnectedApns.remove(apnType)) {
1071 if (mConnectedApns.isEmpty()) {
1072 mDataConnectionState[phoneId] = state;
1073 modified = true;
1074 } else {
1075 // leave mDataConnectionState as is and
1076 // send out the new status for the APN in question.
Wink Savillebaf21da2014-11-19 16:03:09 -08001077 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001078 }
1079 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001080 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
1081 mDataConnectionReason[phoneId] = reason;
1082 mDataConnectionLinkProperties[phoneId] = linkProperties;
1083 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
1084 if (mDataConnectionNetworkType[phoneId] != networkType) {
1085 mDataConnectionNetworkType[phoneId] = networkType;
1086 // need to tell registered listeners about the new network type
1087 modified = true;
1088 }
1089 if (modified) {
1090 if (DBG) {
1091 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
1092 + ", " + mDataConnectionNetworkType[phoneId] + ")");
1093 }
1094 for (Record r : mRecords) {
1095 if (r.matchPhoneStateListenerEvent(
1096 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) &&
1097 idMatch(r.subId, subId, phoneId)) {
1098 try {
1099 log("Notify data connection state changed on sub: " +
1100 subId);
1101 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1102 mDataConnectionNetworkType[phoneId]);
1103 } catch (RemoteException ex) {
1104 mRemoveList.add(r.binder);
1105 }
1106 }
1107 }
1108 handleRemoveListLocked();
1109 }
1110 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
1111 apnType, apn, reason, linkProperties, "");
1112 for (Record r : mRecords) {
1113 if (r.matchPhoneStateListenerEvent(
1114 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
1115 try {
1116 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1117 } catch (RemoteException ex) {
1118 mRemoveList.add(r.binder);
1119 }
Wink Saville2d1ee982014-11-20 20:29:51 +00001120 }
1121 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001122 }
1123 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001124 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001125 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -07001126 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001127 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
1128 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001129 }
1130
Robert Greenwalt02648a42010-05-18 10:52:51 -07001131 public void notifyDataConnectionFailed(String reason, String apnType) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001132 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
xinhe43c50292014-09-18 17:56:48 -07001133 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001134 }
1135
Wink Saville63f03dd2014-10-23 10:44:45 -07001136 public void notifyDataConnectionFailedForSubscriber(int subId,
Wink Savillefb40dd42014-06-12 17:02:31 -07001137 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001138 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001139 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001140 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001141 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001142 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001143 + " reason=" + reason + " apnType=" + apnType);
1144 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001145 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001146 mPreciseDataConnectionState = new PreciseDataConnectionState(
1147 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
1148 apnType, "", reason, null, "");
1149 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001150 if (r.matchPhoneStateListenerEvent(
1151 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001152 try {
1153 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1154 } catch (RemoteException ex) {
1155 mRemoveList.add(r.binder);
1156 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001157 }
1158 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001159 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001160 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001161 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001162 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1163 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001164 }
1165
1166 public void notifyCellLocation(Bundle cellLocation) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001167 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -07001168 }
1169
Wink Saville63f03dd2014-10-23 10:44:45 -07001170 public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) {
Wink Savillebc027272014-09-08 14:50:58 -07001171 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001172 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001173 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001174 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001175 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001176 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001177 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001178 + " cellLocation=" + cellLocation);
1179 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001180 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001181 int phoneId = SubscriptionManager.getPhoneId(subId);
1182 if (validatePhoneId(phoneId)) {
1183 mCellLocation[phoneId] = cellLocation;
1184 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001185 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhe8b79fb62014-11-05 14:55:03 -08001186 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001187 try {
1188 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001189 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -07001190 + " r=" + r);
1191 }
1192 r.callback.onCellLocationChanged(new Bundle(cellLocation));
1193 } catch (RemoteException ex) {
1194 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001195 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001196 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001197 }
1198 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001199 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -07001200 }
1201 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001202
Wink Savillefd2d0132010-10-28 14:22:26 -07001203 public void notifyOtaspChanged(int otaspMode) {
1204 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
1205 return;
1206 }
1207 synchronized (mRecords) {
1208 mOtaspMode = otaspMode;
1209 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001210 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) {
Wink Savillefd2d0132010-10-28 14:22:26 -07001211 try {
1212 r.callback.onOtaspChanged(otaspMode);
1213 } catch (RemoteException ex) {
1214 mRemoveList.add(r.binder);
1215 }
1216 }
1217 }
1218 handleRemoveListLocked();
1219 }
1220 }
1221
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001222 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1223 int backgroundCallState) {
1224 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1225 return;
1226 }
1227 synchronized (mRecords) {
1228 mRingingCallState = ringingCallState;
1229 mForegroundCallState = foregroundCallState;
1230 mBackgroundCallState = backgroundCallState;
1231 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1232 backgroundCallState,
1233 DisconnectCause.NOT_VALID,
1234 PreciseDisconnectCause.NOT_VALID);
1235 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001236 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001237 try {
1238 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1239 } catch (RemoteException ex) {
1240 mRemoveList.add(r.binder);
1241 }
1242 }
1243 }
1244 handleRemoveListLocked();
1245 }
1246 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1247 DisconnectCause.NOT_VALID,
1248 PreciseDisconnectCause.NOT_VALID);
1249 }
1250
1251 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1252 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1253 return;
1254 }
1255 synchronized (mRecords) {
1256 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1257 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1258 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001259 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001260 try {
1261 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1262 } catch (RemoteException ex) {
1263 mRemoveList.add(r.binder);
1264 }
1265 }
1266 }
1267 handleRemoveListLocked();
1268 }
1269 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1270 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1271 }
1272
1273 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1274 String apn, String failCause) {
1275 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1276 return;
1277 }
1278 synchronized (mRecords) {
1279 mPreciseDataConnectionState = new PreciseDataConnectionState(
1280 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1281 apnType, apn, reason, null, failCause);
1282 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001283 if (r.matchPhoneStateListenerEvent(
1284 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001285 try {
1286 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1287 } catch (RemoteException ex) {
1288 mRemoveList.add(r.binder);
1289 }
1290 }
1291 }
1292 handleRemoveListLocked();
1293 }
1294 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1295 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1296 }
1297
Wink Savillefb40dd42014-06-12 17:02:31 -07001298 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1299 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1300 return;
1301 }
1302 synchronized (mRecords) {
1303 mVoLteServiceState = lteState;
1304 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001305 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001306 try {
1307 r.callback.onVoLteServiceStateChanged(
1308 new VoLteServiceState(mVoLteServiceState));
1309 } catch (RemoteException ex) {
1310 mRemoveList.add(r.binder);
1311 }
1312 }
1313 }
1314 handleRemoveListLocked();
1315 }
1316 }
1317
Wink Saville63f03dd2014-10-23 10:44:45 -07001318 public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001319 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1320 return;
1321 }
1322
1323 synchronized (mRecords) {
1324 for (Record r : mRecords) {
1325 if (VDBG) {
1326 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1327 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001328 if ((r.matchPhoneStateListenerEvent(
1329 PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) &&
New Author Steven Liu485f2092014-09-11 10:18:45 -05001330 ((r.subId == subId) ||
Wink Savilled09c4ca2014-11-22 10:08:16 -08001331 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001332 try {
1333 r.callback.onOemHookRawEvent(rawData);
1334 } catch (RemoteException ex) {
1335 mRemoveList.add(r.binder);
1336 }
1337 }
1338 }
1339 handleRemoveListLocked();
1340 }
1341 }
1342
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001343 @Override
1344 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1345 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1346 != PackageManager.PERMISSION_GRANTED) {
1347 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001348 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001349 return;
1350 }
1351 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001352 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001353 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301354 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1355 pw.println(" Phone Id=" + i);
1356 pw.println(" mCallState=" + mCallState[i]);
1357 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1358 pw.println(" mServiceState=" + mServiceState[i]);
1359 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1360 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1361 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1362 pw.println(" mDataActivity=" + mDataActivity[i]);
1363 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1364 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1365 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1366 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1367 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1368 pw.println(" mDataConnectionNetworkCapabilities=" +
1369 mDataConnectionNetworkCapabilities[i]);
1370 pw.println(" mCellLocation=" + mCellLocation[i]);
1371 pw.println(" mCellInfo=" + mCellInfo.get(i));
1372 }
Wink Saville070e0612014-04-15 22:04:10 -07001373 pw.println(" mDcRtInfo=" + mDcRtInfo);
Wink Savillee9b06d72009-05-18 21:47:50 -07001374 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001375 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001376 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001377 }
1378 }
1379 }
1380
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001381 //
1382 // the legacy intent broadcasting
1383 //
1384
Wink Saville63f03dd2014-10-23 10:44:45 -07001385 private void broadcastServiceStateChanged(ServiceState state, int subId) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001386 long ident = Binder.clearCallingIdentity();
1387 try {
1388 mBatteryStats.notePhoneState(state.getState());
1389 } catch (RemoteException re) {
1390 // Can't do much
1391 } finally {
1392 Binder.restoreCallingIdentity(ident);
1393 }
1394
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001395 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1396 Bundle data = new Bundle();
1397 state.fillInNotifierBundle(data);
1398 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001399 // Pass the subscription along with the intent.
1400 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001401 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001402 }
1403
Wink Saville63f03dd2014-10-23 10:44:45 -07001404 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001405 long ident = Binder.clearCallingIdentity();
1406 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001407 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001408 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001409 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001410 } finally {
1411 Binder.restoreCallingIdentity(ident);
1412 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001413
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001414 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001415 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001416 Bundle data = new Bundle();
1417 signalStrength.fillInNotifierBundle(data);
1418 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001419 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001420 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001421 }
1422
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001423 /**
1424 * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
1425 * a valid subId, in which case this function fires a subId-specific intent, or it
1426 * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
1427 * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
1428 */
Wink Saville63f03dd2014-10-23 10:44:45 -07001429 private void broadcastCallStateChanged(int state, String incomingNumber, int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001430 long ident = Binder.clearCallingIdentity();
1431 try {
1432 if (state == TelephonyManager.CALL_STATE_IDLE) {
1433 mBatteryStats.notePhoneOff();
1434 } else {
1435 mBatteryStats.notePhoneOn();
1436 }
1437 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001438 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001439 } finally {
1440 Binder.restoreCallingIdentity(ident);
1441 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001442
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001443 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001444 intent.putExtra(PhoneConstants.STATE_KEY,
1445 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001446 if (!TextUtils.isEmpty(incomingNumber)) {
1447 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1448 }
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001449
1450 // If a valid subId was specified, we should fire off a subId-specific state
1451 // change intent and include the subId.
1452 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
1453 intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
1454 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
1455 }
1456
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001457 // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
1458 // that have the runtime one
1459 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1460 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001461 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Svet Ganov16a16892015-04-16 10:32:04 -07001462 android.Manifest.permission.READ_PHONE_STATE,
1463 AppOpsManager.OP_READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001464 }
1465
Robert Greenwalt42acef32009-08-12 16:08:25 -07001466 private void broadcastDataConnectionStateChanged(int state,
1467 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001468 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Saville63f03dd2014-10-23 10:44:45 -07001469 NetworkCapabilities networkCapabilities, boolean roaming, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001470 // Note: not reporting to the battery stats service here, because the
1471 // status bar takes care of that after taking into account all of the
1472 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001473 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001474 intent.putExtra(PhoneConstants.STATE_KEY,
1475 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001476 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001477 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001478 }
1479 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001480 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001481 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001482 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001483 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001484 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001485 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001486 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001487 }
1488 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001489 if (networkCapabilities != null) {
1490 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001491 }
Wink Savillea639b312012-07-10 12:37:54 -07001492 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001493
Wink Savillea639b312012-07-10 12:37:54 -07001494 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1495 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001496 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001497 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001498 }
1499
Wink Savillefb40dd42014-06-12 17:02:31 -07001500 private void broadcastDataConnectionFailed(String reason, String apnType,
Wink Saville63f03dd2014-10-23 10:44:45 -07001501 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001502 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001503 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1504 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001505 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001506 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001507 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001508
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001509 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1510 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1511 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1512 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1513 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1514 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1515 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1516 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1517 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1518 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1519 }
1520
1521 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
Wink Savilled09c4ca2014-11-22 10:08:16 -08001522 String apnType, String apn, String reason, LinkProperties linkProperties,
1523 String failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001524 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1525 intent.putExtra(PhoneConstants.STATE_KEY, state);
1526 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1527 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1528 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1529 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001530 if (linkProperties != null) {
1531 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties);
1532 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001533 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1534
1535 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1536 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1537 }
1538
Andrew Flynnceaed682015-06-09 12:36:58 +00001539 private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
1540 if (checkNotifyPermission()) {
1541 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001542 }
1543
Andrew Flynnceaed682015-06-09 12:36:58 +00001544 enforceCarrierPrivilege();
Andrew Flynn1f452642015-04-14 22:16:04 -04001545 }
1546
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001547 private boolean checkNotifyPermission(String method) {
Andrew Flynn1f452642015-04-14 22:16:04 -04001548 if (checkNotifyPermission()) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001549 return true;
1550 }
1551 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001552 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001553 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001554 return false;
1555 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001556
Andrew Flynn1f452642015-04-14 22:16:04 -04001557 private boolean checkNotifyPermission() {
1558 return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1559 == PackageManager.PERMISSION_GRANTED;
1560 }
1561
Andrew Flynnceaed682015-06-09 12:36:58 +00001562 private void enforceCarrierPrivilege() {
Andrew Flynn1f452642015-04-14 22:16:04 -04001563 TelephonyManager tm = TelephonyManager.getDefault();
1564 String[] pkgs = mContext.getPackageManager().getPackagesForUid(Binder.getCallingUid());
1565 for (String pkg : pkgs) {
1566 if (tm.checkCarrierPrivilegesForPackage(pkg) ==
1567 TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
Andrew Flynnceaed682015-06-09 12:36:58 +00001568 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001569 }
1570 }
1571
Andrew Flynnceaed682015-06-09 12:36:58 +00001572 String msg = "Carrier Privilege Permission Denial: from pid=" + Binder.getCallingPid()
1573 + ", uid=" + Binder.getCallingUid();
1574 if (DBG) log(msg);
1575 throw new SecurityException(msg);
Andrew Flynn1f452642015-04-14 22:16:04 -04001576 }
1577
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001578 private void checkListenerPermission(int events) {
1579 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1580 mContext.enforceCallingOrSelfPermission(
1581 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1582
1583 }
1584
John Wang963db55d2012-03-30 16:04:06 -07001585 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1586 mContext.enforceCallingOrSelfPermission(
1587 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1588
1589 }
1590
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001591 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001592 try {
Amit Mahajana9e72a72015-07-30 16:04:13 -07001593 mContext.enforceCallingOrSelfPermission(
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001594 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
Amit Mahajana9e72a72015-07-30 16:04:13 -07001595 // SKIP checking for run-time permission since caller or self has PRIVILEGED
1596 // permission
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001597 } catch (SecurityException e) {
1598 mContext.enforceCallingOrSelfPermission(
1599 android.Manifest.permission.READ_PHONE_STATE, null);
1600 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001601 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001602
1603 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1604 mContext.enforceCallingOrSelfPermission(
1605 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1606
1607 }
New Author Steven Liu485f2092014-09-11 10:18:45 -05001608
1609 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1610 mContext.enforceCallingOrSelfPermission(
1611 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1612 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001613 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001614
1615 private void handleRemoveListLocked() {
Wink Savillea374c3d2014-11-11 11:48:04 -08001616 int size = mRemoveList.size();
1617 if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size);
1618 if (size > 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -04001619 for (IBinder b: mRemoveList) {
1620 remove(b);
1621 }
1622 mRemoveList.clear();
1623 }
1624 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001625
1626 private boolean validateEventsAndUserLocked(Record r, int events) {
1627 int foregroundUser;
1628 long callingIdentity = Binder.clearCallingIdentity();
1629 boolean valid = false;
1630 try {
1631 foregroundUser = ActivityManager.getCurrentUser();
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001632 valid = r.callerUserId == foregroundUser && r.matchPhoneStateListenerEvent(events);
Wink Savillea12a7b32012-09-20 10:09:45 -07001633 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001634 log("validateEventsAndUserLocked: valid=" + valid
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001635 + " r.callerUserId=" + r.callerUserId + " foregroundUser=" + foregroundUser
Wink Savillea12a7b32012-09-20 10:09:45 -07001636 + " r.events=" + r.events + " events=" + events);
1637 }
1638 } finally {
1639 Binder.restoreCallingIdentity(callingIdentity);
1640 }
1641 return valid;
1642 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001643
1644 private boolean validatePhoneId(int phoneId) {
1645 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001646 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001647 return valid;
1648 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001649
1650 private static void log(String s) {
1651 Rlog.d(TAG, s);
1652 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001653
1654 private static class LogSSC {
1655 private Time mTime;
1656 private String mS;
Wink Saville63f03dd2014-10-23 10:44:45 -07001657 private int mSubId;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001658 private int mPhoneId;
1659 private ServiceState mState;
1660
Wink Saville63f03dd2014-10-23 10:44:45 -07001661 public void set(Time t, String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001662 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1663 }
1664
1665 @Override
1666 public String toString() {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001667 return mS + " Time " + mTime.toString() + " mSubId " + mSubId + " mPhoneId "
1668 + mPhoneId + " mState " + mState;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001669 }
1670 }
1671
1672 private LogSSC logSSC [] = new LogSSC[10];
1673 private int next = 0;
1674
Wink Saville63f03dd2014-10-23 10:44:45 -07001675 private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001676 if (logSSC == null || logSSC.length == 0) {
1677 return;
1678 }
1679 if (logSSC[next] == null) {
1680 logSSC[next] = new LogSSC();
1681 }
1682 Time t = new Time();
1683 t.setToNow();
1684 logSSC[next].set(t, s, subId, phoneId, state);
1685 if (++next >= logSSC.length) {
1686 next = 0;
1687 }
1688 }
1689
1690 private void toStringLogSSC(String prompt) {
1691 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1692 log(prompt + ": logSSC is empty");
1693 } else {
1694 // There is at least one element
1695 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1696 int i = next;
1697 if (logSSC[i] == null) {
1698 // logSSC is not full so back to the beginning
1699 i = 0;
1700 }
1701 do {
1702 log(logSSC[i].toString());
1703 if (++i >= logSSC.length) {
1704 i = 0;
1705 }
1706 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001707 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001708 }
1709 }
xinhee9f16402014-09-25 16:39:28 -07001710
xinhe8b79fb62014-11-05 14:55:03 -08001711 boolean idMatch(int rSubId, int subId, int phoneId) {
xinheac11ae92014-12-18 10:02:14 -08001712
1713 if(subId < 0) {
1714 // Invalid case, we need compare phoneId with default one.
1715 return (mDefaultPhoneId == phoneId);
1716 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001717 if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
xinhee9f16402014-09-25 16:39:28 -07001718 return (subId == mDefaultSubId);
1719 } else {
1720 return (rSubId == subId);
1721 }
1722 }
1723
1724 private void checkPossibleMissNotify(Record r, int phoneId) {
1725 int events = r.events;
1726
1727 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1728 try {
1729 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1730 mServiceState[phoneId]);
1731 r.callback.onServiceStateChanged(
1732 new ServiceState(mServiceState[phoneId]));
1733 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001734 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001735 }
1736 }
1737
1738 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1739 try {
1740 SignalStrength signalStrength = mSignalStrength[phoneId];
1741 if (DBG) {
1742 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1743 }
1744 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1745 } catch (RemoteException ex) {
1746 mRemoveList.add(r.binder);
1747 }
1748 }
1749
1750 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1751 try {
1752 int gsmSignalStrength = mSignalStrength[phoneId]
1753 .getGsmSignalStrength();
1754 if (DBG) {
1755 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1756 gsmSignalStrength);
1757 }
1758 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1759 : gsmSignalStrength));
1760 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001761 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001762 }
1763 }
1764
1765 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1766 try {
1767 if (DBG_LOC) {
1768 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1769 + mCellInfo.get(phoneId));
1770 }
1771 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1772 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001773 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001774 }
1775 }
1776
1777 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1778 try {
1779 if (VDBG) {
1780 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1781 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1782 }
1783 r.callback.onMessageWaitingIndicatorChanged(
1784 mMessageWaiting[phoneId]);
1785 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001786 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001787 }
1788 }
1789
1790 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1791 try {
1792 if (VDBG) {
1793 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1794 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1795 }
1796 r.callback.onCallForwardingIndicatorChanged(
1797 mCallForwarding[phoneId]);
1798 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001799 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001800 }
1801 }
1802
1803 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1804 try {
1805 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1806 + mCellLocation[phoneId]);
1807 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1808 } catch (RemoteException ex) {
1809 mRemoveList.add(r.binder);
1810 }
1811 }
1812
1813 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1814 try {
1815 if (DBG) {
1816 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1817 + "=" + mDataConnectionState[phoneId]
1818 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1819 + ")");
1820 }
1821 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1822 mDataConnectionNetworkType[phoneId]);
1823 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001824 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001825 }
1826 }
1827 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001828}