blob: a06bb3069d640aca3691ac8ac24afaa51acbc7b0 [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 {
365 mContext.enforceCallingPermission(
366 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE,
367 "addOnSubscriptionsChangedListener");
368 // SKIP checking for run-time permission since obtained PRIVILEGED
369 } 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 {
484 mContext.enforceCallingPermission(
485 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
486 // SKIP checking for run-time permission since obtained PRIVILEGED
487 } catch (SecurityException e) {
488 if (mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
489 callingPackage) != AppOpsManager.MODE_ALLOWED) {
490 return;
491 }
Svet Ganov16a16892015-04-16 10:32:04 -0700492 }
493 }
494
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800495 synchronized (mRecords) {
496 // register
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700497 Record r;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800498 find_and_add: {
499 IBinder b = callback.asBinder();
500 final int N = mRecords.size();
Wink Savillee9b06d72009-05-18 21:47:50 -0700501 for (int i = 0; i < N; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800502 r = mRecords.get(i);
503 if (b == r.binder) {
504 break find_and_add;
505 }
506 }
507 r = new Record();
508 r.binder = b;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800509 mRecords.add(r);
Wink Savillee380b982014-07-26 18:24:22 -0700510 if (DBG) log("listen: add new record");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800511 }
xinhe43c50292014-09-18 17:56:48 -0700512
xinhe75c2c152014-10-16 11:49:45 -0700513 r.callback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700514 r.callingPackage = callingPackage;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700515 r.callerUserId = callerUserId;
516 boolean isPhoneStateEvent = (events & (CHECK_PHONE_STATE_PERMISSION_MASK
517 | ENFORCE_PHONE_STATE_PERMISSION_MASK)) != 0;
518 r.canReadPhoneState = isPhoneStateEvent && canReadPhoneState(callingPackage);
xinhe75c2c152014-10-16 11:49:45 -0700519 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
520 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
Wink Savillea54bf652014-12-11 13:37:50 -0800521 if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800522 r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
xinhe75c2c152014-10-16 11:49:45 -0700523 } else {//APP specify subID
524 r.subId = subId;
525 }
526 r.phoneId = SubscriptionManager.getPhoneId(r.subId);
527
xinhe43c50292014-09-18 17:56:48 -0700528 int phoneId = r.phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800529 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700530 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700531 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700532 }
533 if (VDBG) toStringLogSSC("listen");
Wink Savillefb40dd42014-06-12 17:02:31 -0700534 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800535 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400536 try {
Wink Savillee380b982014-07-26 18:24:22 -0700537 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700538 r.callback.onServiceStateChanged(
539 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400540 } catch (RemoteException ex) {
541 remove(r.binder);
542 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800543 }
544 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
545 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700546 int gsmSignalStrength = mSignalStrength[phoneId]
547 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700548 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
549 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800550 } catch (RemoteException ex) {
551 remove(r.binder);
552 }
553 }
554 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
555 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700556 r.callback.onMessageWaitingIndicatorChanged(
557 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800558 } catch (RemoteException ex) {
559 remove(r.binder);
560 }
561 }
562 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
563 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700564 r.callback.onCallForwardingIndicatorChanged(
565 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800566 } catch (RemoteException ex) {
567 remove(r.binder);
568 }
569 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700570 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400571 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700572 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700573 + mCellLocation[phoneId]);
574 r.callback.onCellLocationChanged(
575 new Bundle(mCellLocation[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400576 } catch (RemoteException ex) {
577 remove(r.binder);
578 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800579 }
580 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
581 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700582 r.callback.onCallStateChanged(mCallState[phoneId],
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700583 getCallIncomingNumber(r, phoneId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800584 } catch (RemoteException ex) {
585 remove(r.binder);
586 }
587 }
588 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
589 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700590 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
591 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 } catch (RemoteException ex) {
593 remove(r.binder);
594 }
595 }
596 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
597 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700598 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 } catch (RemoteException ex) {
600 remove(r.binder);
601 }
602 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700603 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
604 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700605 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700606 } catch (RemoteException ex) {
607 remove(r.binder);
608 }
609 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700610 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
611 try {
612 r.callback.onOtaspChanged(mOtaspMode);
613 } catch (RemoteException ex) {
614 remove(r.binder);
615 }
616 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700617 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700618 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700619 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700620 + mCellInfo.get(phoneId));
621 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
John Wang963db55d2012-03-30 16:04:06 -0700622 } catch (RemoteException ex) {
623 remove(r.binder);
624 }
625 }
Wink Saville070e0612014-04-15 22:04:10 -0700626 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) {
627 try {
628 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
629 } catch (RemoteException ex) {
630 remove(r.binder);
631 }
632 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200633 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
634 try {
635 r.callback.onPreciseCallStateChanged(mPreciseCallState);
636 } catch (RemoteException ex) {
637 remove(r.binder);
638 }
639 }
640 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
641 try {
642 r.callback.onPreciseDataConnectionStateChanged(
643 mPreciseDataConnectionState);
644 } catch (RemoteException ex) {
645 remove(r.binder);
646 }
647 }
Andrew Flynn1f452642015-04-14 22:16:04 -0400648 if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) {
649 try {
650 r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
651 } catch (RemoteException ex) {
652 remove(r.binder);
653 }
654 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800655 }
656 }
657 } else {
xinhe75c2c152014-10-16 11:49:45 -0700658 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800659 remove(callback.asBinder());
660 }
661 }
662
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700663 private boolean canReadPhoneState(String callingPackage) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -0700664 if (mContext.checkCallingPermission(
665 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) ==
666 PackageManager.PERMISSION_GRANTED) {
667 // SKIP checking for run-time permission since obtained PRIVILEGED
668 return true;
669 }
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700670 boolean canReadPhoneState = mContext.checkCallingOrSelfPermission(
671 android.Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
672 if (canReadPhoneState &&
673 mAppOps.noteOp(AppOpsManager.OP_READ_PHONE_STATE, Binder.getCallingUid(),
674 callingPackage) != AppOpsManager.MODE_ALLOWED) {
675 return false;
676 }
677 return canReadPhoneState;
678 }
679
680 private String getCallIncomingNumber(Record record, int phoneId) {
681 // Hide the number if record's process has no READ_PHONE_STATE permission
682 return record.canReadPhoneState ? mCallIncomingNumber[phoneId] : "";
683 }
684
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685 private void remove(IBinder binder) {
686 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700687 final int recordCount = mRecords.size();
688 for (int i = 0; i < recordCount; i++) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800689 if (mRecords.get(i).binder == binder) {
xinheac11ae92014-12-18 10:02:14 -0800690 if (DBG) {
691 Record r = mRecords.get(i);
Svet Ganov16a16892015-04-16 10:32:04 -0700692 log("remove: binder=" + binder + "r.callingPackage" + r.callingPackage
xinheac11ae92014-12-18 10:02:14 -0800693 + "r.callback" + r.callback);
694 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800695 mRecords.remove(i);
696 return;
697 }
698 }
699 }
700 }
701
702 public void notifyCallState(int state, String incomingNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700703 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700704 return;
705 }
xinhe43c50292014-09-18 17:56:48 -0700706
707 if (VDBG) {
708 log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber);
709 }
710
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800711 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700712 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800713 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800714 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800715 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700716 String incomingNumberOrEmpty = r.canReadPhoneState ? incomingNumber : "";
717 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800718 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400719 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800720 }
721 }
722 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400723 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800724 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800725 broadcastCallStateChanged(state, incomingNumber,
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -0700726 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 }
728
Wink Saville63f03dd2014-10-23 10:44:45 -0700729 public void notifyCallStateForSubscriber(int subId, int state, String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700730 if (!checkNotifyPermission("notifyCallState()")) {
731 return;
732 }
Wink Savillee380b982014-07-26 18:24:22 -0700733 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700734 log("notifyCallStateForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700735 + " state=" + state + " incomingNumber=" + incomingNumber);
736 }
737 synchronized (mRecords) {
738 int phoneId = SubscriptionManager.getPhoneId(subId);
739 if (validatePhoneId(phoneId)) {
740 mCallState[phoneId] = state;
741 mCallIncomingNumber[phoneId] = incomingNumber;
742 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800743 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
xinhe43c50292014-09-18 17:56:48 -0700744 (r.subId == subId) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800745 (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700746 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700747 String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId);
748 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
Wink Savillefb40dd42014-06-12 17:02:31 -0700749 } catch (RemoteException ex) {
750 mRemoveList.add(r.binder);
751 }
752 }
753 }
754 }
755 handleRemoveListLocked();
756 }
757 broadcastCallStateChanged(state, incomingNumber, subId);
758 }
759
Wink Saville63f03dd2014-10-23 10:44:45 -0700760 public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700761 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700762 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700763 }
xinhe43c50292014-09-18 17:56:48 -0700764
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800765 synchronized (mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700766 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700767 log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
Wink Saville47d8d1b2014-07-10 13:01:52 -0700768 + " state=" + state);
769 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700770 if (validatePhoneId(phoneId)) {
771 mServiceState[phoneId] = state;
Wink Savillebc027272014-09-08 14:50:58 -0700772 logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state);
773 if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber");
Wink Saville47d8d1b2014-07-10 13:01:52 -0700774
Wink Savillefb40dd42014-06-12 17:02:31 -0700775 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700776 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700777 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700778 + " phoneId=" + phoneId + " state=" + state);
779 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800780 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) &&
xinhe8b79fb62014-11-05 14:55:03 -0800781 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700782 try {
Wink Savillee380b982014-07-26 18:24:22 -0700783 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700784 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700785 + " subId=" + subId + " phoneId=" + phoneId
786 + " state=" + state);
787 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700788 r.callback.onServiceStateChanged(new ServiceState(state));
789 } catch (RemoteException ex) {
790 mRemoveList.add(r.binder);
791 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400792 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800793 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700794 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700795 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800796 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400797 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800798 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700799 broadcastServiceStateChanged(state, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800800 }
801
Wink Savillee9b06d72009-05-18 21:47:50 -0700802 public void notifySignalStrength(SignalStrength signalStrength) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800803 notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
804 signalStrength);
Wink Savillefb40dd42014-06-12 17:02:31 -0700805 }
806
Wink Saville63f03dd2014-10-23 10:44:45 -0700807 public void notifySignalStrengthForSubscriber(int subId, SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700808 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700809 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700810 }
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000811 if (VDBG) {
812 log("notifySignalStrengthForSubscriber: subId=" + subId
813 + " signalStrength=" + signalStrength);
814 toStringLogSSC("notifySignalStrengthForSubscriber");
815 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800816 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700817 int phoneId = SubscriptionManager.getPhoneId(subId);
818 if (validatePhoneId(phoneId)) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000819 if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700820 mSignalStrength[phoneId] = signalStrength;
821 for (Record r : mRecords) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000822 if (VDBG) {
823 log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId
824 + " phoneId=" + phoneId + " ss=" + signalStrength);
825 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800826 if (r.matchPhoneStateListenerEvent(
827 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) &&
xinhe8b79fb62014-11-05 14:55:03 -0800828 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700829 try {
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000830 if (DBG) {
831 log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r
832 + " subId=" + subId + " phoneId=" + phoneId
833 + " ss=" + signalStrength);
834 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700835 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
836 } catch (RemoteException ex) {
837 mRemoveList.add(r.binder);
838 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400839 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800840 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) &&
xinhe8b79fb62014-11-05 14:55:03 -0800841 idMatch(r.subId, subId, phoneId)){
Wink Savillefb40dd42014-06-12 17:02:31 -0700842 try {
843 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -0700844 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +0000845 if (DBG) {
846 log("notifySignalStrengthForSubscriber: callback.onSS r=" + r
847 + " subId=" + subId + " phoneId=" + phoneId
848 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
849 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700850 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -0700851 } catch (RemoteException ex) {
852 mRemoveList.add(r.binder);
853 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 }
855 }
Wink Savillef4cd25b2014-07-08 19:03:20 -0700856 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700857 log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800858 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400859 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800860 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700861 broadcastSignalStrengthChanged(signalStrength, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800862 }
863
Andrew Flynn1f452642015-04-14 22:16:04 -0400864 @Override
865 public void notifyCarrierNetworkChange(boolean active) {
Andrew Flynnceaed682015-06-09 12:36:58 +0000866 enforceNotifyPermissionOrCarrierPrivilege("notifyCarrierNetworkChange()");
867
Andrew Flynn1f452642015-04-14 22:16:04 -0400868 if (VDBG) {
869 log("notifyCarrierNetworkChange: active=" + active);
870 }
871
872 synchronized (mRecords) {
873 mCarrierNetworkChangeState = active;
874 for (Record r : mRecords) {
875 if (r.matchPhoneStateListenerEvent(
876 PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE)) {
877 try {
878 r.callback.onCarrierNetworkChange(active);
879 } catch (RemoteException ex) {
880 mRemoveList.add(r.binder);
881 }
882 }
883 }
884 handleRemoveListLocked();
885 }
886 }
887
Wink Savilleb208a242012-07-25 14:08:09 -0700888 public void notifyCellInfo(List<CellInfo> cellInfo) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800889 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -0700890 }
891
Wink Saville63f03dd2014-10-23 10:44:45 -0700892 public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -0700893 if (!checkNotifyPermission("notifyCellInfo()")) {
894 return;
895 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700896 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700897 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700898 + " cellInfo=" + cellInfo);
899 }
John Wang963db55d2012-03-30 16:04:06 -0700900
901 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700902 int phoneId = SubscriptionManager.getPhoneId(subId);
903 if (validatePhoneId(phoneId)) {
904 mCellInfo.set(phoneId, cellInfo);
905 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -0700906 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
xinhe8b79fb62014-11-05 14:55:03 -0800907 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700908 try {
909 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700910 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -0700911 }
912 r.callback.onCellInfoChanged(cellInfo);
913 } catch (RemoteException ex) {
914 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -0700915 }
John Wang963db55d2012-03-30 16:04:06 -0700916 }
917 }
918 }
919 handleRemoveListLocked();
920 }
921 }
922
Wink Saville070e0612014-04-15 22:04:10 -0700923 public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) {
924 if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) {
925 return;
926 }
927
928 synchronized (mRecords) {
929 mDcRtInfo = dcRtInfo;
930 for (Record r : mRecords) {
931 if (validateEventsAndUserLocked(r,
932 PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) {
933 try {
934 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700935 log("notifyDataConnectionRealTimeInfo: mDcRtInfo="
Wink Saville070e0612014-04-15 22:04:10 -0700936 + mDcRtInfo + " r=" + r);
937 }
938 r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo);
939 } catch (RemoteException ex) {
940 mRemoveList.add(r.binder);
941 }
942 }
943 }
944 handleRemoveListLocked();
945 }
946 }
947
xinhe43c50292014-09-18 17:56:48 -0700948 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700949 public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700950 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700951 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700952 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700953 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -0700954 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -0700955 + " mwi=" + mwi);
956 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800957 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700958 if (validatePhoneId(phoneId)) {
959 mMessageWaiting[phoneId] = mwi;
960 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800961 if (r.matchPhoneStateListenerEvent(
962 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800963 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700964 try {
965 r.callback.onMessageWaitingIndicatorChanged(mwi);
966 } catch (RemoteException ex) {
967 mRemoveList.add(r.binder);
968 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800969 }
970 }
971 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400972 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800973 }
974 }
975
976 public void notifyCallForwardingChanged(boolean cfi) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800977 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -0700978 }
979
Wink Saville63f03dd2014-10-23 10:44:45 -0700980 public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700981 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700982 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700983 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700984 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700985 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700986 + " cfi=" + cfi);
987 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800988 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700989 int phoneId = SubscriptionManager.getPhoneId(subId);
990 if (validatePhoneId(phoneId)) {
991 mCallForwarding[phoneId] = cfi;
992 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800993 if (r.matchPhoneStateListenerEvent(
994 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -0800995 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700996 try {
997 r.callback.onCallForwardingIndicatorChanged(cfi);
998 } catch (RemoteException ex) {
999 mRemoveList.add(r.binder);
1000 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001001 }
1002 }
1003 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001004 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001005 }
1006 }
1007
1008 public void notifyDataActivity(int state) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001009 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -07001010 }
1011
Wink Saville63f03dd2014-10-23 10:44:45 -07001012 public void notifyDataActivityForSubscriber(int subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001013 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001014 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001015 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001016 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001017 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001018 if (validatePhoneId(phoneId)) {
1019 mDataActivity[phoneId] = state;
1020 for (Record r : mRecords) {
1021 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY)) {
1022 try {
1023 r.callback.onDataActivity(state);
1024 } catch (RemoteException ex) {
1025 mRemoveList.add(r.binder);
1026 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001027 }
1028 }
1029 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001030 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001031 }
1032 }
1033
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001034 public void notifyDataConnection(int state, boolean isDataConnectivityPossible,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001035 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001036 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001037 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
xinhe43c50292014-09-18 17:56:48 -07001038 isDataConnectivityPossible,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001039 networkCapabilities, networkType, roaming);
1040 }
1041
Wink Saville63f03dd2014-10-23 10:44:45 -07001042 public void notifyDataConnectionForSubscriber(int subId, int state,
Wink Savillefb40dd42014-06-12 17:02:31 -07001043 boolean isDataConnectivityPossible, String reason, String apn, String apnType,
1044 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
1045 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001046 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001047 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001048 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001049 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001050 log("notifyDataConnectionForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001051 + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible
1052 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -07001053 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
xinheac11ae92014-12-18 10:02:14 -08001054 + " mRecords.size()=" + mRecords.size());
Wink Savillec9acde92011-09-21 11:05:43 -07001055 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001057 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001058 if (validatePhoneId(phoneId)) {
1059 boolean modified = false;
1060 if (state == TelephonyManager.DATA_CONNECTED) {
1061 if (!mConnectedApns.contains(apnType)) {
1062 mConnectedApns.add(apnType);
1063 if (mDataConnectionState[phoneId] != state) {
1064 mDataConnectionState[phoneId] = state;
1065 modified = true;
1066 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001067 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001068 } else {
1069 if (mConnectedApns.remove(apnType)) {
1070 if (mConnectedApns.isEmpty()) {
1071 mDataConnectionState[phoneId] = state;
1072 modified = true;
1073 } else {
1074 // leave mDataConnectionState as is and
1075 // send out the new status for the APN in question.
Wink Savillebaf21da2014-11-19 16:03:09 -08001076 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001077 }
1078 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001079 mDataConnectionPossible[phoneId] = isDataConnectivityPossible;
1080 mDataConnectionReason[phoneId] = reason;
1081 mDataConnectionLinkProperties[phoneId] = linkProperties;
1082 mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities;
1083 if (mDataConnectionNetworkType[phoneId] != networkType) {
1084 mDataConnectionNetworkType[phoneId] = networkType;
1085 // need to tell registered listeners about the new network type
1086 modified = true;
1087 }
1088 if (modified) {
1089 if (DBG) {
1090 log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId]
1091 + ", " + mDataConnectionNetworkType[phoneId] + ")");
1092 }
1093 for (Record r : mRecords) {
1094 if (r.matchPhoneStateListenerEvent(
1095 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) &&
1096 idMatch(r.subId, subId, phoneId)) {
1097 try {
1098 log("Notify data connection state changed on sub: " +
1099 subId);
1100 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1101 mDataConnectionNetworkType[phoneId]);
1102 } catch (RemoteException ex) {
1103 mRemoveList.add(r.binder);
1104 }
1105 }
1106 }
1107 handleRemoveListLocked();
1108 }
1109 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
1110 apnType, apn, reason, linkProperties, "");
1111 for (Record r : mRecords) {
1112 if (r.matchPhoneStateListenerEvent(
1113 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
1114 try {
1115 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1116 } catch (RemoteException ex) {
1117 mRemoveList.add(r.binder);
1118 }
Wink Saville2d1ee982014-11-20 20:29:51 +00001119 }
1120 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001121 }
1122 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001123 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001124 broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -07001125 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001126 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
1127 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001128 }
1129
Robert Greenwalt02648a42010-05-18 10:52:51 -07001130 public void notifyDataConnectionFailed(String reason, String apnType) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001131 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
xinhe43c50292014-09-18 17:56:48 -07001132 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001133 }
1134
Wink Saville63f03dd2014-10-23 10:44:45 -07001135 public void notifyDataConnectionFailedForSubscriber(int subId,
Wink Savillefb40dd42014-06-12 17:02:31 -07001136 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001137 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001138 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001139 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001140 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001141 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001142 + " reason=" + reason + " apnType=" + apnType);
1143 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001144 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001145 mPreciseDataConnectionState = new PreciseDataConnectionState(
1146 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
1147 apnType, "", reason, null, "");
1148 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001149 if (r.matchPhoneStateListenerEvent(
1150 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001151 try {
1152 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1153 } catch (RemoteException ex) {
1154 mRemoveList.add(r.binder);
1155 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001156 }
1157 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001158 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001159 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001160 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001161 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1162 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001163 }
1164
1165 public void notifyCellLocation(Bundle cellLocation) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001166 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -07001167 }
1168
Wink Saville63f03dd2014-10-23 10:44:45 -07001169 public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) {
Wink Savillebc027272014-09-08 14:50:58 -07001170 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001171 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001172 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001173 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001174 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001175 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001176 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001177 + " cellLocation=" + cellLocation);
1178 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001179 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001180 int phoneId = SubscriptionManager.getPhoneId(subId);
1181 if (validatePhoneId(phoneId)) {
1182 mCellLocation[phoneId] = cellLocation;
1183 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001184 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
xinhe8b79fb62014-11-05 14:55:03 -08001185 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001186 try {
1187 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001188 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -07001189 + " r=" + r);
1190 }
1191 r.callback.onCellLocationChanged(new Bundle(cellLocation));
1192 } catch (RemoteException ex) {
1193 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001194 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001195 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001196 }
1197 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001198 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -07001199 }
1200 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001201
Wink Savillefd2d0132010-10-28 14:22:26 -07001202 public void notifyOtaspChanged(int otaspMode) {
1203 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
1204 return;
1205 }
1206 synchronized (mRecords) {
1207 mOtaspMode = otaspMode;
1208 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001209 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) {
Wink Savillefd2d0132010-10-28 14:22:26 -07001210 try {
1211 r.callback.onOtaspChanged(otaspMode);
1212 } catch (RemoteException ex) {
1213 mRemoveList.add(r.binder);
1214 }
1215 }
1216 }
1217 handleRemoveListLocked();
1218 }
1219 }
1220
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001221 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1222 int backgroundCallState) {
1223 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1224 return;
1225 }
1226 synchronized (mRecords) {
1227 mRingingCallState = ringingCallState;
1228 mForegroundCallState = foregroundCallState;
1229 mBackgroundCallState = backgroundCallState;
1230 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1231 backgroundCallState,
1232 DisconnectCause.NOT_VALID,
1233 PreciseDisconnectCause.NOT_VALID);
1234 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001235 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001236 try {
1237 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1238 } catch (RemoteException ex) {
1239 mRemoveList.add(r.binder);
1240 }
1241 }
1242 }
1243 handleRemoveListLocked();
1244 }
1245 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState,
1246 DisconnectCause.NOT_VALID,
1247 PreciseDisconnectCause.NOT_VALID);
1248 }
1249
1250 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1251 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1252 return;
1253 }
1254 synchronized (mRecords) {
1255 mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState,
1256 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1257 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001258 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001259 try {
1260 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1261 } catch (RemoteException ex) {
1262 mRemoveList.add(r.binder);
1263 }
1264 }
1265 }
1266 handleRemoveListLocked();
1267 }
1268 broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState,
1269 mBackgroundCallState, disconnectCause, preciseDisconnectCause);
1270 }
1271
1272 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1273 String apn, String failCause) {
1274 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1275 return;
1276 }
1277 synchronized (mRecords) {
1278 mPreciseDataConnectionState = new PreciseDataConnectionState(
1279 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1280 apnType, apn, reason, null, failCause);
1281 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001282 if (r.matchPhoneStateListenerEvent(
1283 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001284 try {
1285 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1286 } catch (RemoteException ex) {
1287 mRemoveList.add(r.binder);
1288 }
1289 }
1290 }
1291 handleRemoveListLocked();
1292 }
1293 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1294 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1295 }
1296
Wink Savillefb40dd42014-06-12 17:02:31 -07001297 public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) {
1298 if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) {
1299 return;
1300 }
1301 synchronized (mRecords) {
1302 mVoLteServiceState = lteState;
1303 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001304 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_VOLTE_STATE)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001305 try {
1306 r.callback.onVoLteServiceStateChanged(
1307 new VoLteServiceState(mVoLteServiceState));
1308 } catch (RemoteException ex) {
1309 mRemoveList.add(r.binder);
1310 }
1311 }
1312 }
1313 handleRemoveListLocked();
1314 }
1315 }
1316
Wink Saville63f03dd2014-10-23 10:44:45 -07001317 public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001318 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1319 return;
1320 }
1321
1322 synchronized (mRecords) {
1323 for (Record r : mRecords) {
1324 if (VDBG) {
1325 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1326 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001327 if ((r.matchPhoneStateListenerEvent(
1328 PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) &&
New Author Steven Liu485f2092014-09-11 10:18:45 -05001329 ((r.subId == subId) ||
Wink Savilled09c4ca2014-11-22 10:08:16 -08001330 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) {
New Author Steven Liu485f2092014-09-11 10:18:45 -05001331 try {
1332 r.callback.onOemHookRawEvent(rawData);
1333 } catch (RemoteException ex) {
1334 mRemoveList.add(r.binder);
1335 }
1336 }
1337 }
1338 handleRemoveListLocked();
1339 }
1340 }
1341
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001342 @Override
1343 public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1344 if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP)
1345 != PackageManager.PERMISSION_GRANTED) {
1346 pw.println("Permission Denial: can't dump telephony.registry from from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001347 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001348 return;
1349 }
1350 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001351 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001352 pw.println("last known state:");
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301353 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
1354 pw.println(" Phone Id=" + i);
1355 pw.println(" mCallState=" + mCallState[i]);
1356 pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]);
1357 pw.println(" mServiceState=" + mServiceState[i]);
1358 pw.println(" mSignalStrength=" + mSignalStrength[i]);
1359 pw.println(" mMessageWaiting=" + mMessageWaiting[i]);
1360 pw.println(" mCallForwarding=" + mCallForwarding[i]);
1361 pw.println(" mDataActivity=" + mDataActivity[i]);
1362 pw.println(" mDataConnectionState=" + mDataConnectionState[i]);
1363 pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]);
1364 pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]);
1365 pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]);
1366 pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]);
1367 pw.println(" mDataConnectionNetworkCapabilities=" +
1368 mDataConnectionNetworkCapabilities[i]);
1369 pw.println(" mCellLocation=" + mCellLocation[i]);
1370 pw.println(" mCellInfo=" + mCellInfo.get(i));
1371 }
Wink Saville070e0612014-04-15 22:04:10 -07001372 pw.println(" mDcRtInfo=" + mDcRtInfo);
Wink Savillee9b06d72009-05-18 21:47:50 -07001373 pw.println("registrations: count=" + recordCount);
Robert Greenwalt02648a42010-05-18 10:52:51 -07001374 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001375 pw.println(" " + r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001376 }
1377 }
1378 }
1379
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001380 //
1381 // the legacy intent broadcasting
1382 //
1383
Wink Saville63f03dd2014-10-23 10:44:45 -07001384 private void broadcastServiceStateChanged(ServiceState state, int subId) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001385 long ident = Binder.clearCallingIdentity();
1386 try {
1387 mBatteryStats.notePhoneState(state.getState());
1388 } catch (RemoteException re) {
1389 // Can't do much
1390 } finally {
1391 Binder.restoreCallingIdentity(ident);
1392 }
1393
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001394 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
1395 Bundle data = new Bundle();
1396 state.fillInNotifierBundle(data);
1397 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001398 // Pass the subscription along with the intent.
1399 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001400 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001401 }
1402
Wink Saville63f03dd2014-10-23 10:44:45 -07001403 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001404 long ident = Binder.clearCallingIdentity();
1405 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001406 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001407 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001408 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001409 } finally {
1410 Binder.restoreCallingIdentity(ident);
1411 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001412
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001413 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Dianne Hackborn1c633fc2009-12-08 19:45:14 -08001414 intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
Wink Savillee9b06d72009-05-18 21:47:50 -07001415 Bundle data = new Bundle();
1416 signalStrength.fillInNotifierBundle(data);
1417 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001418 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001419 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001420 }
1421
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001422 /**
1423 * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
1424 * a valid subId, in which case this function fires a subId-specific intent, or it
1425 * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
1426 * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
1427 */
Wink Saville63f03dd2014-10-23 10:44:45 -07001428 private void broadcastCallStateChanged(int state, String incomingNumber, int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001429 long ident = Binder.clearCallingIdentity();
1430 try {
1431 if (state == TelephonyManager.CALL_STATE_IDLE) {
1432 mBatteryStats.notePhoneOff();
1433 } else {
1434 mBatteryStats.notePhoneOn();
1435 }
1436 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001437 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001438 } finally {
1439 Binder.restoreCallingIdentity(ident);
1440 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001441
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001442 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001443 intent.putExtra(PhoneConstants.STATE_KEY,
1444 DefaultPhoneNotifier.convertCallState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001445 if (!TextUtils.isEmpty(incomingNumber)) {
1446 intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1447 }
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001448
1449 // If a valid subId was specified, we should fire off a subId-specific state
1450 // change intent and include the subId.
1451 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
1452 intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
1453 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
1454 }
1455
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001456 // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
1457 // that have the runtime one
1458 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1459 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001460 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Svet Ganov16a16892015-04-16 10:32:04 -07001461 android.Manifest.permission.READ_PHONE_STATE,
1462 AppOpsManager.OP_READ_PHONE_STATE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001463 }
1464
Robert Greenwalt42acef32009-08-12 16:08:25 -07001465 private void broadcastDataConnectionStateChanged(int state,
1466 boolean isDataConnectivityPossible,
Wink Savillef61101f2010-09-16 16:36:42 -07001467 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Saville63f03dd2014-10-23 10:44:45 -07001468 NetworkCapabilities networkCapabilities, boolean roaming, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001469 // Note: not reporting to the battery stats service here, because the
1470 // status bar takes care of that after taking into account all of the
1471 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001472 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001473 intent.putExtra(PhoneConstants.STATE_KEY,
1474 DefaultPhoneNotifier.convertDataState(state).toString());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001475 if (!isDataConnectivityPossible) {
Wink Savillea639b312012-07-10 12:37:54 -07001476 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001477 }
1478 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001479 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001480 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001481 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001482 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001483 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001484 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001485 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001486 }
1487 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001488 if (networkCapabilities != null) {
1489 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001490 }
Wink Savillea639b312012-07-10 12:37:54 -07001491 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001492
Wink Savillea639b312012-07-10 12:37:54 -07001493 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1494 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001495 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001496 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001497 }
1498
Wink Savillefb40dd42014-06-12 17:02:31 -07001499 private void broadcastDataConnectionFailed(String reason, String apnType,
Wink Saville63f03dd2014-10-23 10:44:45 -07001500 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001501 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001502 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1503 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001504 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001505 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001506 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001507
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001508 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
1509 int backgroundCallState, int disconnectCause, int preciseDisconnectCause) {
1510 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1511 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1512 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1513 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
1514 intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause);
1515 intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause);
1516 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1517 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1518 }
1519
1520 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
Wink Savilled09c4ca2014-11-22 10:08:16 -08001521 String apnType, String apn, String reason, LinkProperties linkProperties,
1522 String failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001523 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1524 intent.putExtra(PhoneConstants.STATE_KEY, state);
1525 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1526 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1527 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1528 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001529 if (linkProperties != null) {
1530 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties);
1531 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001532 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1533
1534 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1535 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1536 }
1537
Andrew Flynnceaed682015-06-09 12:36:58 +00001538 private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
1539 if (checkNotifyPermission()) {
1540 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001541 }
1542
Andrew Flynnceaed682015-06-09 12:36:58 +00001543 enforceCarrierPrivilege();
Andrew Flynn1f452642015-04-14 22:16:04 -04001544 }
1545
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001546 private boolean checkNotifyPermission(String method) {
Andrew Flynn1f452642015-04-14 22:16:04 -04001547 if (checkNotifyPermission()) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001548 return true;
1549 }
1550 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001551 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001552 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001553 return false;
1554 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001555
Andrew Flynn1f452642015-04-14 22:16:04 -04001556 private boolean checkNotifyPermission() {
1557 return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1558 == PackageManager.PERMISSION_GRANTED;
1559 }
1560
Andrew Flynnceaed682015-06-09 12:36:58 +00001561 private void enforceCarrierPrivilege() {
Andrew Flynn1f452642015-04-14 22:16:04 -04001562 TelephonyManager tm = TelephonyManager.getDefault();
1563 String[] pkgs = mContext.getPackageManager().getPackagesForUid(Binder.getCallingUid());
1564 for (String pkg : pkgs) {
1565 if (tm.checkCarrierPrivilegesForPackage(pkg) ==
1566 TelephonyManager.CARRIER_PRIVILEGE_STATUS_HAS_ACCESS) {
Andrew Flynnceaed682015-06-09 12:36:58 +00001567 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001568 }
1569 }
1570
Andrew Flynnceaed682015-06-09 12:36:58 +00001571 String msg = "Carrier Privilege Permission Denial: from pid=" + Binder.getCallingPid()
1572 + ", uid=" + Binder.getCallingUid();
1573 if (DBG) log(msg);
1574 throw new SecurityException(msg);
Andrew Flynn1f452642015-04-14 22:16:04 -04001575 }
1576
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001577 private void checkListenerPermission(int events) {
1578 if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) {
1579 mContext.enforceCallingOrSelfPermission(
1580 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1581
1582 }
1583
John Wang963db55d2012-03-30 16:04:06 -07001584 if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) {
1585 mContext.enforceCallingOrSelfPermission(
1586 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
1587
1588 }
1589
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001590 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001591 try {
1592 mContext.enforceCallingPermission(
1593 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1594 // SKIP checking for run-time permission since obtained PRIVILEGED
1595 } catch (SecurityException e) {
1596 mContext.enforceCallingOrSelfPermission(
1597 android.Manifest.permission.READ_PHONE_STATE, null);
1598 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001599 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001600
1601 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1602 mContext.enforceCallingOrSelfPermission(
1603 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
1604
1605 }
New Author Steven Liu485f2092014-09-11 10:18:45 -05001606
1607 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
1608 mContext.enforceCallingOrSelfPermission(
1609 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
1610 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001611 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001612
1613 private void handleRemoveListLocked() {
Wink Savillea374c3d2014-11-11 11:48:04 -08001614 int size = mRemoveList.size();
1615 if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size);
1616 if (size > 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -04001617 for (IBinder b: mRemoveList) {
1618 remove(b);
1619 }
1620 mRemoveList.clear();
1621 }
1622 }
Wink Savillea12a7b32012-09-20 10:09:45 -07001623
1624 private boolean validateEventsAndUserLocked(Record r, int events) {
1625 int foregroundUser;
1626 long callingIdentity = Binder.clearCallingIdentity();
1627 boolean valid = false;
1628 try {
1629 foregroundUser = ActivityManager.getCurrentUser();
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001630 valid = r.callerUserId == foregroundUser && r.matchPhoneStateListenerEvent(events);
Wink Savillea12a7b32012-09-20 10:09:45 -07001631 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001632 log("validateEventsAndUserLocked: valid=" + valid
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001633 + " r.callerUserId=" + r.callerUserId + " foregroundUser=" + foregroundUser
Wink Savillea12a7b32012-09-20 10:09:45 -07001634 + " r.events=" + r.events + " events=" + events);
1635 }
1636 } finally {
1637 Binder.restoreCallingIdentity(callingIdentity);
1638 }
1639 return valid;
1640 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001641
1642 private boolean validatePhoneId(int phoneId) {
1643 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07001644 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07001645 return valid;
1646 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001647
1648 private static void log(String s) {
1649 Rlog.d(TAG, s);
1650 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07001651
1652 private static class LogSSC {
1653 private Time mTime;
1654 private String mS;
Wink Saville63f03dd2014-10-23 10:44:45 -07001655 private int mSubId;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001656 private int mPhoneId;
1657 private ServiceState mState;
1658
Wink Saville63f03dd2014-10-23 10:44:45 -07001659 public void set(Time t, String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001660 mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state;
1661 }
1662
1663 @Override
1664 public String toString() {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001665 return mS + " Time " + mTime.toString() + " mSubId " + mSubId + " mPhoneId "
1666 + mPhoneId + " mState " + mState;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001667 }
1668 }
1669
1670 private LogSSC logSSC [] = new LogSSC[10];
1671 private int next = 0;
1672
Wink Saville63f03dd2014-10-23 10:44:45 -07001673 private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) {
Wink Saville47d8d1b2014-07-10 13:01:52 -07001674 if (logSSC == null || logSSC.length == 0) {
1675 return;
1676 }
1677 if (logSSC[next] == null) {
1678 logSSC[next] = new LogSSC();
1679 }
1680 Time t = new Time();
1681 t.setToNow();
1682 logSSC[next].set(t, s, subId, phoneId, state);
1683 if (++next >= logSSC.length) {
1684 next = 0;
1685 }
1686 }
1687
1688 private void toStringLogSSC(String prompt) {
1689 if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) {
1690 log(prompt + ": logSSC is empty");
1691 } else {
1692 // There is at least one element
1693 log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next);
1694 int i = next;
1695 if (logSSC[i] == null) {
1696 // logSSC is not full so back to the beginning
1697 i = 0;
1698 }
1699 do {
1700 log(logSSC[i].toString());
1701 if (++i >= logSSC.length) {
1702 i = 0;
1703 }
1704 } while (i != next);
Wink Savillee380b982014-07-26 18:24:22 -07001705 log(prompt + ": ----------------");
Wink Saville47d8d1b2014-07-10 13:01:52 -07001706 }
1707 }
xinhee9f16402014-09-25 16:39:28 -07001708
xinhe8b79fb62014-11-05 14:55:03 -08001709 boolean idMatch(int rSubId, int subId, int phoneId) {
xinheac11ae92014-12-18 10:02:14 -08001710
1711 if(subId < 0) {
1712 // Invalid case, we need compare phoneId with default one.
1713 return (mDefaultPhoneId == phoneId);
1714 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08001715 if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
xinhee9f16402014-09-25 16:39:28 -07001716 return (subId == mDefaultSubId);
1717 } else {
1718 return (rSubId == subId);
1719 }
1720 }
1721
1722 private void checkPossibleMissNotify(Record r, int phoneId) {
1723 int events = r.events;
1724
1725 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
1726 try {
1727 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
1728 mServiceState[phoneId]);
1729 r.callback.onServiceStateChanged(
1730 new ServiceState(mServiceState[phoneId]));
1731 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001732 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001733 }
1734 }
1735
1736 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
1737 try {
1738 SignalStrength signalStrength = mSignalStrength[phoneId];
1739 if (DBG) {
1740 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
1741 }
1742 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1743 } catch (RemoteException ex) {
1744 mRemoveList.add(r.binder);
1745 }
1746 }
1747
1748 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
1749 try {
1750 int gsmSignalStrength = mSignalStrength[phoneId]
1751 .getGsmSignalStrength();
1752 if (DBG) {
1753 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
1754 gsmSignalStrength);
1755 }
1756 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
1757 : gsmSignalStrength));
1758 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001759 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001760 }
1761 }
1762
1763 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
1764 try {
1765 if (DBG_LOC) {
1766 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
1767 + mCellInfo.get(phoneId));
1768 }
1769 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
1770 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001771 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001772 }
1773 }
1774
1775 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
1776 try {
1777 if (VDBG) {
1778 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
1779 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
1780 }
1781 r.callback.onMessageWaitingIndicatorChanged(
1782 mMessageWaiting[phoneId]);
1783 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001784 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001785 }
1786 }
1787
1788 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
1789 try {
1790 if (VDBG) {
1791 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
1792 + phoneId + " cfi=" + mCallForwarding[phoneId]);
1793 }
1794 r.callback.onCallForwardingIndicatorChanged(
1795 mCallForwarding[phoneId]);
1796 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001797 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001798 }
1799 }
1800
1801 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
1802 try {
1803 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
1804 + mCellLocation[phoneId]);
1805 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
1806 } catch (RemoteException ex) {
1807 mRemoveList.add(r.binder);
1808 }
1809 }
1810
1811 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
1812 try {
1813 if (DBG) {
1814 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
1815 + "=" + mDataConnectionState[phoneId]
1816 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
1817 + ")");
1818 }
1819 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
1820 mDataConnectionNetworkType[phoneId]);
1821 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07001822 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07001823 }
1824 }
1825 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001826}