blob: d07cf78e47ed875f1c3ff7d169bc21b138aa30f8 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
Wink Savillea12a7b32012-09-20 10:09:45 -070019import android.app.ActivityManager;
Svet Ganov16a16892015-04-16 10:32:04 -070020import android.app.AppOpsManager;
Wink Savillea12a7b32012-09-20 10:09:45 -070021import android.content.BroadcastReceiver;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022import android.content.Context;
23import android.content.Intent;
Wink Savillea12a7b32012-09-20 10:09:45 -070024import android.content.IntentFilter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080025import android.content.pm.PackageManager;
Robert Greenwalt37e65eb2010-08-30 10:56:47 -070026import android.net.LinkProperties;
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -070027import android.net.NetworkCapabilities;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080028import android.os.Binder;
29import android.os.Bundle;
Wink Savillea12a7b32012-09-20 10:09:45 -070030import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080031import android.os.IBinder;
Wink Savillea12a7b32012-09-20 10:09:45 -070032import android.os.Message;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033import android.os.RemoteException;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070034import android.os.UserHandle;
John Wang963db55d2012-03-30 16:04:06 -070035import android.telephony.CellInfo;
Jack Yud19b6ae2017-04-05 14:12:09 -070036import android.telephony.CellLocation;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020037import android.telephony.DisconnectCause;
Hall Liu5fb337f2017-11-22 17:38:15 -080038import android.telephony.LocationAccessPolicy;
Malcolm Chene1623652018-08-08 20:27:45 -070039import android.telephony.PhoneCapability;
Jack Yud19b6ae2017-04-05 14:12:09 -070040import android.telephony.PhoneStateListener;
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -080041import android.telephony.PhysicalChannelConfig;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020042import android.telephony.PreciseCallState;
43import android.telephony.PreciseDataConnectionState;
44import android.telephony.PreciseDisconnectCause;
Jack Yud19b6ae2017-04-05 14:12:09 -070045import android.telephony.Rlog;
46import android.telephony.ServiceState;
47import android.telephony.SignalStrength;
48import android.telephony.SubscriptionManager;
49import android.telephony.TelephonyManager;
sqianbdc5a732018-10-26 13:27:51 -070050import android.telephony.emergency.EmergencyNumber;
Jack Yud19b6ae2017-04-05 14:12:09 -070051import android.util.LocalLog;
Yangster4ccebea2018-10-09 17:09:02 -070052import android.util.StatsLog;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080053
Malcolm Chen3ceeedd2018-08-27 20:38:29 -070054import com.android.internal.annotations.VisibleForTesting;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055import com.android.internal.app.IBatteryStats;
Wink Savilled09c4ca2014-11-22 10:08:16 -080056import com.android.internal.telephony.IOnSubscriptionsChangedListener;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057import com.android.internal.telephony.IPhoneStateListener;
Jack Yud19b6ae2017-04-05 14:12:09 -070058import com.android.internal.telephony.ITelephonyRegistry;
Nathan Harold5a0618e2016-12-14 10:48:00 -080059import com.android.internal.telephony.PhoneConstantConversions;
Wink Savillea639b312012-07-10 12:37:54 -070060import com.android.internal.telephony.PhoneConstants;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061import com.android.internal.telephony.TelephonyIntents;
Jeff Davidsond7bf38a2018-02-13 18:11:37 -080062import com.android.internal.telephony.TelephonyPermissions;
Jeff Sharkeyfe9a53b2017-03-31 14:08:23 -060063import com.android.internal.util.DumpUtils;
Jack Yud19b6ae2017-04-05 14:12:09 -070064import com.android.internal.util.IndentingPrintWriter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065import com.android.server.am.BatteryStatsService;
66
Jack Yud19b6ae2017-04-05 14:12:09 -070067import java.io.FileDescriptor;
68import java.io.PrintWriter;
69import java.util.ArrayList;
sqian9f93a122018-12-03 22:40:41 -080070import java.util.HashMap;
Jack Yud19b6ae2017-04-05 14:12:09 -070071import java.util.List;
sqian9f93a122018-12-03 22:40:41 -080072import java.util.Map;
Malcolm Chenabbfac22018-02-12 19:15:59 -080073import java.util.NoSuchElementException;
Jack Yud19b6ae2017-04-05 14:12:09 -070074
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075/**
Wink Savillee9b06d72009-05-18 21:47:50 -070076 * Since phone process can be restarted, this class provides a centralized place
77 * that applications can register and be called back from.
Wink Savillee380b982014-07-26 18:24:22 -070078 *
79 * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026
80 * and 15973975 by saving the phoneId of the registrant and then using the
81 * phoneId when deciding to to make a callback. This is necessary because
82 * a subId changes from to a dummy value when a SIM is removed and thus won't
Wink Saville63f03dd2014-10-23 10:44:45 -070083 * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles
Wink Savillee380b982014-07-26 18:24:22 -070084 * the dummy value conversion we properly do the callbacks.
85 *
86 * Eventually we may want to remove the notion of dummy value but for now this
87 * looks like the best approach.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 */
Malcolm Chen3ceeedd2018-08-27 20:38:29 -070089@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
90public class TelephonyRegistry extends ITelephonyRegistry.Stub {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080091 private static final String TAG = "TelephonyRegistry";
Wink Saville6d13bc82014-08-01 11:13:40 -070092 private static final boolean DBG = false; // STOPSHIP if true
Wink Savillefb40dd42014-06-12 17:02:31 -070093 private static final boolean DBG_LOC = false; // STOPSHIP if true
Wink Saville6d13bc82014-08-01 11:13:40 -070094 private static final boolean VDBG = false; // STOPSHIP if true
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080095
96 private static class Record {
Jeff Davidson29da89f2018-02-28 17:50:16 -080097 Context context;
98
Svet Ganov16a16892015-04-16 10:32:04 -070099 String callingPackage;
Wink Savillee9b06d72009-05-18 21:47:50 -0700100
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800101 IBinder binder;
Wink Savillee9b06d72009-05-18 21:47:50 -0700102
Malcolm Chenabbfac22018-02-12 19:15:59 -0800103 TelephonyRegistryDeathRecipient deathRecipient;
104
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800105 IPhoneStateListener callback;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800106 IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback;
Malcolm Chen13f31af2018-09-04 22:12:31 -0700107 IOnSubscriptionsChangedListener onOpportunisticSubscriptionsChangedListenerCallback;
Wink Savillee9b06d72009-05-18 21:47:50 -0700108
Hall Liu5fb337f2017-11-22 17:38:15 -0800109 int callerUid;
110 int callerPid;
Wink Savillea12a7b32012-09-20 10:09:45 -0700111
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800112 int events;
Wink Savillea12a7b32012-09-20 10:09:45 -0700113
Wink Savilled09c4ca2014-11-22 10:08:16 -0800114 int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Wink Savillefb40dd42014-06-12 17:02:31 -0700115
Wink Savilled09c4ca2014-11-22 10:08:16 -0800116 int phoneId = SubscriptionManager.INVALID_PHONE_INDEX;
Wink Savillea374c3d2014-11-11 11:48:04 -0800117
118 boolean matchPhoneStateListenerEvent(int events) {
119 return (callback != null) && ((events & this.events) != 0);
120 }
121
Wink Savilled09c4ca2014-11-22 10:08:16 -0800122 boolean matchOnSubscriptionsChangedListener() {
123 return (onSubscriptionsChangedListenerCallback != null);
Wink Savillea374c3d2014-11-11 11:48:04 -0800124 }
Wink Savillee380b982014-07-26 18:24:22 -0700125
Malcolm Chen13f31af2018-09-04 22:12:31 -0700126 boolean matchOnOpportunisticSubscriptionsChangedListener() {
127 return (onOpportunisticSubscriptionsChangedListenerCallback != null);
128 }
129
Tyler Gunnf955e562018-04-26 14:43:31 -0700130 boolean canReadCallLog() {
Jeff Davidson29da89f2018-02-28 17:50:16 -0800131 try {
Tyler Gunnf955e562018-04-26 14:43:31 -0700132 return TelephonyPermissions.checkReadCallLog(
133 context, subId, callerPid, callerUid, callingPackage);
Jeff Davidson29da89f2018-02-28 17:50:16 -0800134 } catch (SecurityException e) {
135 return false;
136 }
137 }
138
Wink Savillea12a7b32012-09-20 10:09:45 -0700139 @Override
140 public String toString() {
Svet Ganov16a16892015-04-16 10:32:04 -0700141 return "{callingPackage=" + callingPackage + " binder=" + binder
142 + " callback=" + callback
Wink Savilled09c4ca2014-11-22 10:08:16 -0800143 + " onSubscriptionsChangedListenererCallback="
Malcolm Chen13f31af2018-09-04 22:12:31 -0700144 + onSubscriptionsChangedListenerCallback
145 + " onOpportunisticSubscriptionsChangedListenererCallback="
146 + onOpportunisticSubscriptionsChangedListenerCallback
Hall Liu5fb337f2017-11-22 17:38:15 -0800147 + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId
Jeff Davidson29da89f2018-02-28 17:50:16 -0800148 + " events=" + Integer.toHexString(events) + "}";
Wink Savillea12a7b32012-09-20 10:09:45 -0700149 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800150 }
151
152 private final Context mContext;
Wink Savillee9b06d72009-05-18 21:47:50 -0700153
Joe Onorato163d8d92010-10-21 13:21:20 -0400154 // access should be inside synchronized (mRecords) for these two fields
155 private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>();
156 private final ArrayList<Record> mRecords = new ArrayList<Record>();
Wink Savillee9b06d72009-05-18 21:47:50 -0700157
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800158 private final IBatteryStats mBatteryStats;
159
Svet Ganov16a16892015-04-16 10:32:04 -0700160 private final AppOpsManager mAppOps;
161
Malcolm Chen13f31af2018-09-04 22:12:31 -0700162 private boolean mHasNotifySubscriptionInfoChangedOccurred = false;
163
164 private boolean mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = false;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800165
Wink Savillefb40dd42014-06-12 17:02:31 -0700166 private int mNumPhones;
Wink Savillee9b06d72009-05-18 21:47:50 -0700167
Wink Savillefb40dd42014-06-12 17:02:31 -0700168 private int[] mCallState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700169
Wink Savillefb40dd42014-06-12 17:02:31 -0700170 private String[] mCallIncomingNumber;
Wink Savillee9b06d72009-05-18 21:47:50 -0700171
Wink Savillefb40dd42014-06-12 17:02:31 -0700172 private ServiceState[] mServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700173
fionaxu12312f62016-11-14 13:32:14 -0800174 private int[] mVoiceActivationState;
175
176 private int[] mDataActivationState;
177
zxuan35a47022018-01-04 11:24:04 -0800178 private boolean[] mUserMobileDataState;
179
Wink Savillefb40dd42014-06-12 17:02:31 -0700180 private SignalStrength[] mSignalStrength;
Wink Savillee9b06d72009-05-18 21:47:50 -0700181
Wink Savillefb40dd42014-06-12 17:02:31 -0700182 private boolean[] mMessageWaiting;
Wink Savillee9b06d72009-05-18 21:47:50 -0700183
Wink Savillefb40dd42014-06-12 17:02:31 -0700184 private boolean[] mCallForwarding;
Wink Savillee9b06d72009-05-18 21:47:50 -0700185
Wink Savillefb40dd42014-06-12 17:02:31 -0700186 private int[] mDataActivity;
Wink Savillee9b06d72009-05-18 21:47:50 -0700187
Jack Yub1bac542018-03-14 16:23:38 -0700188 // Connection state of default APN type data (i.e. internet) of phones
Wink Savillefb40dd42014-06-12 17:02:31 -0700189 private int[] mDataConnectionState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700190
Wink Savillefb40dd42014-06-12 17:02:31 -0700191 private Bundle[] mCellLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800192
Wink Savillefb40dd42014-06-12 17:02:31 -0700193 private int[] mDataConnectionNetworkType;
Robert Greenwalt98e0b142009-10-08 21:15:52 -0700194
Nathan Harold016e9c62016-12-14 11:24:48 -0800195 private int mOtaspMode = TelephonyManager.OTASP_UNKNOWN;
Wink Savillefd2d0132010-10-28 14:22:26 -0700196
Wink Savillefb40dd42014-06-12 17:02:31 -0700197 private ArrayList<List<CellInfo>> mCellInfo = null;
198
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -0800199 private ArrayList<List<PhysicalChannelConfig>> mPhysicalChannelConfigs;
200
sqian9f93a122018-12-03 22:40:41 -0800201 private Map<Integer, List<EmergencyNumber>> mEmergencyNumberList;
202
Brad Ebingerefed9822018-10-26 10:25:57 -0700203 private int[] mSrvccState;
Wink Savillefb40dd42014-06-12 17:02:31 -0700204
Wink Savilled09c4ca2014-11-22 10:08:16 -0800205 private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
xinhee9f16402014-09-25 16:39:28 -0700206
Wink Savilled09c4ca2014-11-22 10:08:16 -0800207 private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX;
xinhee9f16402014-09-25 16:39:28 -0700208
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200209 private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
210
211 private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
212
213 private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE;
214
215 private PreciseCallState mPreciseCallState = new PreciseCallState();
216
chen xu6a942d482018-12-12 19:59:30 -0800217 private int mCallDisconnectCause = DisconnectCause.NOT_VALID;
218
219 private int mCallPreciseDisconnectCause = PreciseDisconnectCause.NOT_VALID;
220
Andrew Flynn1f452642015-04-14 22:16:04 -0400221 private boolean mCarrierNetworkChangeState = false;
222
Malcolm Chene1623652018-08-08 20:27:45 -0700223 private PhoneCapability mPhoneCapability = null;
224
Malcolm Chen8b53afe2018-09-24 20:01:32 -0700225 private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
226
Chen Xu7395c632018-10-17 17:53:47 +0000227 @TelephonyManager.RadioPowerState
228 private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
229
Jack Yud19b6ae2017-04-05 14:12:09 -0700230 private final LocalLog mLocalLog = new LocalLog(100);
231
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200232 private PreciseDataConnectionState mPreciseDataConnectionState =
233 new PreciseDataConnectionState();
234
Hall Liu70bbc162018-03-02 17:44:46 -0800235 static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK =
236 PhoneStateListener.LISTEN_CELL_LOCATION
237 | PhoneStateListener.LISTEN_CELL_INFO;
238
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700239 static final int ENFORCE_PHONE_STATE_PERMISSION_MASK =
sqian9f93a122018-12-03 22:40:41 -0800240 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
241 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
242 | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700243
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200244 static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
245 PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
246 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
247
Wink Savillea12a7b32012-09-20 10:09:45 -0700248 private static final int MSG_USER_SWITCHED = 1;
Wink Savillefb40dd42014-06-12 17:02:31 -0700249 private static final int MSG_UPDATE_DEFAULT_SUB = 2;
Wink Savillea12a7b32012-09-20 10:09:45 -0700250
251 private final Handler mHandler = new Handler() {
252 @Override
253 public void handleMessage(Message msg) {
254 switch (msg.what) {
255 case MSG_USER_SWITCHED: {
Wink Savillee380b982014-07-26 18:24:22 -0700256 if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
Wink Savillefb40dd42014-06-12 17:02:31 -0700257 int numPhones = TelephonyManager.getDefault().getPhoneCount();
258 for (int sub = 0; sub < numPhones; sub++) {
Wink Savillebc027272014-09-08 14:50:58 -0700259 TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
Wink Savillee380b982014-07-26 18:24:22 -0700260 mCellLocation[sub]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700261 }
262 break;
263 }
xinhee9f16402014-09-25 16:39:28 -0700264 case MSG_UPDATE_DEFAULT_SUB: {
265 int newDefaultPhoneId = msg.arg1;
Wink Saville63f03dd2014-10-23 10:44:45 -0700266 int newDefaultSubId = (Integer)(msg.obj);
xinhee9f16402014-09-25 16:39:28 -0700267 if (VDBG) {
268 log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId
269 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
270 + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId);
271 }
272
273 //Due to possible risk condition,(notify call back using the new
274 //defaultSubId comes before new defaultSubId update) we need to recall all
275 //possible missed notify callback
276 synchronized (mRecords) {
Etan Cohena33cf072014-09-30 10:35:24 -0700277 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800278 if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
Etan Cohena33cf072014-09-30 10:35:24 -0700279 checkPossibleMissNotify(r, newDefaultPhoneId);
280 }
281 }
282 handleRemoveListLocked();
xinhee9f16402014-09-25 16:39:28 -0700283 }
284 mDefaultSubId = newDefaultSubId;
285 mDefaultPhoneId = newDefaultPhoneId;
Wink Savillea12a7b32012-09-20 10:09:45 -0700286 }
287 }
288 }
289 };
290
Malcolm Chenabbfac22018-02-12 19:15:59 -0800291 private class TelephonyRegistryDeathRecipient implements IBinder.DeathRecipient {
292
293 private final IBinder binder;
294
295 TelephonyRegistryDeathRecipient(IBinder binder) {
296 this.binder = binder;
297 }
298
299 @Override
300 public void binderDied() {
301 if (DBG) log("binderDied " + binder);
302 remove(binder);
303 }
304 }
305
Wink Savillea12a7b32012-09-20 10:09:45 -0700306 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
307 @Override
308 public void onReceive(Context context, Intent intent) {
309 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700310 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700311 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700312 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700313 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700314 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700315 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
Wink Saville63f03dd2014-10-23 10:44:45 -0700316 Integer newDefaultSubIdObj = new Integer(intent.getIntExtra(
Shishir Agrawal7ea3e8b2016-01-25 13:03:07 -0800317 PhoneConstants.SUBSCRIPTION_KEY,
318 SubscriptionManager.getDefaultSubscriptionId()));
xinhee9f16402014-09-25 16:39:28 -0700319 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY,
320 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700321 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700322 log("onReceive:current mDefaultSubId=" + mDefaultSubId
323 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
324 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700325 }
xinhee9f16402014-09-25 16:39:28 -0700326
Junda Liu985f52c2015-02-23 16:06:51 -0800327 if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId)
xinhee9f16402014-09-25 16:39:28 -0700328 || (newDefaultPhoneId != mDefaultPhoneId))) {
329 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
330 newDefaultPhoneId, 0, newDefaultSubIdObj));
331 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700332 }
333 }
334 };
335
Wink Savillee9b06d72009-05-18 21:47:50 -0700336 // we keep a copy of all of the state so we can send it out when folks
337 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800338 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700339 // In these calls we call with the lock held. This is safe becasuse remote
340 // calls go through a oneway interface and local calls going through a
341 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800342
Malcolm Chen3ceeedd2018-08-27 20:38:29 -0700343 @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
344 public TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700345 CellLocation location = CellLocation.getEmpty();
346
Wink Savillefb40dd42014-06-12 17:02:31 -0700347 mContext = context;
348 mBatteryStats = BatteryStatsService.getService();
Wink Savillefb40dd42014-06-12 17:02:31 -0700349
Wink Savillefb40dd42014-06-12 17:02:31 -0700350 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Jack Yub1bac542018-03-14 16:23:38 -0700351 if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700352 mNumPhones = numPhones;
353 mCallState = new int[numPhones];
354 mDataActivity = new int[numPhones];
355 mDataConnectionState = new int[numPhones];
356 mDataConnectionNetworkType = new int[numPhones];
357 mCallIncomingNumber = new String[numPhones];
358 mServiceState = new ServiceState[numPhones];
fionaxu12312f62016-11-14 13:32:14 -0800359 mVoiceActivationState = new int[numPhones];
360 mDataActivationState = new int[numPhones];
zxuan35a47022018-01-04 11:24:04 -0800361 mUserMobileDataState = new boolean[numPhones];
Wink Savillefb40dd42014-06-12 17:02:31 -0700362 mSignalStrength = new SignalStrength[numPhones];
363 mMessageWaiting = new boolean[numPhones];
Wink Savillefb40dd42014-06-12 17:02:31 -0700364 mCallForwarding = new boolean[numPhones];
365 mCellLocation = new Bundle[numPhones];
Wink Savillefb40dd42014-06-12 17:02:31 -0700366 mCellInfo = new ArrayList<List<CellInfo>>();
Brad Ebingerefed9822018-10-26 10:25:57 -0700367 mSrvccState = new int[numPhones];
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -0800368 mPhysicalChannelConfigs = new ArrayList<List<PhysicalChannelConfig>>();
sqian9f93a122018-12-03 22:40:41 -0800369 mEmergencyNumberList = new HashMap<>();
Wink Savillefb40dd42014-06-12 17:02:31 -0700370 for (int i = 0; i < numPhones; i++) {
371 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
372 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
373 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
fionaxu12312f62016-11-14 13:32:14 -0800374 mVoiceActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
375 mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
Wink Savillefb40dd42014-06-12 17:02:31 -0700376 mCallIncomingNumber[i] = "";
377 mServiceState[i] = new ServiceState();
378 mSignalStrength[i] = new SignalStrength();
zxuan35a47022018-01-04 11:24:04 -0800379 mUserMobileDataState[i] = false;
Wink Savillefb40dd42014-06-12 17:02:31 -0700380 mMessageWaiting[i] = false;
381 mCallForwarding[i] = false;
Wink Savillefb40dd42014-06-12 17:02:31 -0700382 mCellLocation[i] = new Bundle();
383 mCellInfo.add(i, null);
Brad Ebingerefed9822018-10-26 10:25:57 -0700384 mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
Nathan Haroldc9bad6e2018-04-25 12:53:04 -0700385 mPhysicalChannelConfigs.add(i, new ArrayList<PhysicalChannelConfig>());
Wink Savillefb40dd42014-06-12 17:02:31 -0700386 }
387
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700388 // Note that location can be null for non-phone builds like
389 // like the generic one.
390 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700391 for (int i = 0; i < numPhones; i++) {
392 location.fillInNotifierBundle(mCellLocation[i]);
393 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700394 }
Svet Ganov16a16892015-04-16 10:32:04 -0700395
396 mAppOps = mContext.getSystemService(AppOpsManager.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800397 }
398
Svetoslav Ganova0027152013-06-25 14:59:53 -0700399 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700400 // Watch for interesting updates
401 final IntentFilter filter = new IntentFilter();
402 filter.addAction(Intent.ACTION_USER_SWITCHED);
403 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700404 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700405 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700406 mContext.registerReceiver(mBroadcastReceiver, filter);
407 }
408
409 @Override
Svet Ganov16a16892015-04-16 10:32:04 -0700410 public void addOnSubscriptionsChangedListener(String callingPackage,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800411 IOnSubscriptionsChangedListener callback) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700412 int callerUserId = UserHandle.getCallingUserId();
Jeff Davidson29da89f2018-02-28 17:50:16 -0800413 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
Wink Savillea374c3d2014-11-11 11:48:04 -0800414 if (VDBG) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700415 log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
416 + " callerUserId=" + callerUserId + " callback=" + callback
Wink Savillea374c3d2014-11-11 11:48:04 -0800417 + " callback.asBinder=" + callback.asBinder());
418 }
419
Wink Savilled09c4ca2014-11-22 10:08:16 -0800420 synchronized (mRecords) {
421 // register
Malcolm Chenabbfac22018-02-12 19:15:59 -0800422 IBinder b = callback.asBinder();
423 Record r = add(b);
424
425 if (r == null) {
426 return;
Wink Savillea374c3d2014-11-11 11:48:04 -0800427 }
428
Jeff Davidson29da89f2018-02-28 17:50:16 -0800429 r.context = mContext;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800430 r.onSubscriptionsChangedListenerCallback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700431 r.callingPackage = callingPackage;
Hall Liu5fb337f2017-11-22 17:38:15 -0800432 r.callerUid = Binder.getCallingUid();
433 r.callerPid = Binder.getCallingPid();
Wink Savilled09c4ca2014-11-22 10:08:16 -0800434 r.events = 0;
435 if (DBG) {
436 log("listen oscl: Register r=" + r);
437 }
438 // Always notify when registration occurs if there has been a notification.
Malcolm Chen13f31af2018-09-04 22:12:31 -0700439 if (mHasNotifySubscriptionInfoChangedOccurred) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800440 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800441 if (VDBG) log("listen oscl: send to r=" + r);
442 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
443 if (VDBG) log("listen oscl: sent to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800444 } catch (RemoteException e) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800445 if (VDBG) log("listen oscl: remote exception sending to r=" + r + " e=" + e);
Wink Savillea374c3d2014-11-11 11:48:04 -0800446 remove(r.binder);
447 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800448 } else {
Malcolm Chen13f31af2018-09-04 22:12:31 -0700449 log("listen oscl: mHasNotifySubscriptionInfoChangedOccurred==false no callback");
Wink Savillea374c3d2014-11-11 11:48:04 -0800450 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800451 }
452 }
453
454 @Override
Wink Saville071743f2015-01-12 17:11:04 -0800455 public void removeOnSubscriptionsChangedListener(String pkgForDebug,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800456 IOnSubscriptionsChangedListener callback) {
457 if (DBG) log("listen oscl: Unregister");
Wink Savillea374c3d2014-11-11 11:48:04 -0800458 remove(callback.asBinder());
459 }
460
Malcolm Chen13f31af2018-09-04 22:12:31 -0700461
462 @Override
463 public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage,
464 IOnSubscriptionsChangedListener callback) {
465 int callerUserId = UserHandle.getCallingUserId();
466 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
467 if (VDBG) {
468 log("listen ooscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
469 + " callerUserId=" + callerUserId + " callback=" + callback
470 + " callback.asBinder=" + callback.asBinder());
471 }
472
473 synchronized (mRecords) {
474 // register
475 IBinder b = callback.asBinder();
476 Record r = add(b);
477
478 if (r == null) {
479 return;
480 }
481
482 r.context = mContext;
483 r.onOpportunisticSubscriptionsChangedListenerCallback = callback;
484 r.callingPackage = callingPackage;
485 r.callerUid = Binder.getCallingUid();
486 r.callerPid = Binder.getCallingPid();
487 r.events = 0;
488 if (DBG) {
489 log("listen ooscl: Register r=" + r);
490 }
491 // Always notify when registration occurs if there has been a notification.
492 if (mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) {
493 try {
494 if (VDBG) log("listen ooscl: send to r=" + r);
495 r.onOpportunisticSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
496 if (VDBG) log("listen ooscl: sent to r=" + r);
497 } catch (RemoteException e) {
498 if (VDBG) log("listen ooscl: remote exception sending to r=" + r + " e=" + e);
499 remove(r.binder);
500 }
501 } else {
502 log("listen ooscl: hasNotifyOpptSubInfoChangedOccurred==false no callback");
503 }
504 }
505 }
506
Wink Savillea374c3d2014-11-11 11:48:04 -0800507 @Override
508 public void notifySubscriptionInfoChanged() {
509 if (VDBG) log("notifySubscriptionInfoChanged:");
510 synchronized (mRecords) {
Malcolm Chen13f31af2018-09-04 22:12:31 -0700511 if (!mHasNotifySubscriptionInfoChangedOccurred) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800512 log("notifySubscriptionInfoChanged: first invocation mRecords.size="
513 + mRecords.size());
514 }
Malcolm Chen13f31af2018-09-04 22:12:31 -0700515 mHasNotifySubscriptionInfoChangedOccurred = true;
Wink Savillea374c3d2014-11-11 11:48:04 -0800516 mRemoveList.clear();
517 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800518 if (r.matchOnSubscriptionsChangedListener()) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800519 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800520 if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r);
521 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
522 if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800523 } catch (RemoteException ex) {
524 if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r);
525 mRemoveList.add(r.binder);
526 }
527 }
528 }
529 handleRemoveListLocked();
530 }
531 }
532
533 @Override
Malcolm Chen13f31af2018-09-04 22:12:31 -0700534 public void notifyOpportunisticSubscriptionInfoChanged() {
535 if (VDBG) log("notifyOpptSubscriptionInfoChanged:");
536 synchronized (mRecords) {
537 if (!mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) {
538 log("notifyOpptSubscriptionInfoChanged: first invocation mRecords.size="
539 + mRecords.size());
540 }
541 mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = true;
542 mRemoveList.clear();
543 for (Record r : mRecords) {
544 if (r.matchOnOpportunisticSubscriptionsChangedListener()) {
545 try {
546 if (VDBG) log("notifyOpptSubChanged: call oosc to r=" + r);
547 r.onOpportunisticSubscriptionsChangedListenerCallback
548 .onSubscriptionsChanged();
549 if (VDBG) log("notifyOpptSubChanged: done oosc to r=" + r);
550 } catch (RemoteException ex) {
551 if (VDBG) log("notifyOpptSubChanged: RemoteException r=" + r);
552 mRemoveList.add(r.binder);
553 }
554 }
555 }
556 handleRemoveListLocked();
557 }
558 }
559
560 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800561 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
562 boolean notifyNow) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800563 listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback,
564 events, notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700565 }
566
567 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700568 public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700569 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700570 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700571 }
572
Svet Ganov16a16892015-04-16 10:32:04 -0700573 private void listen(String callingPackage, IPhoneStateListener callback, int events,
Wink Saville63f03dd2014-10-23 10:44:45 -0700574 boolean notifyNow, int subId) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700575 int callerUserId = UserHandle.getCallingUserId();
Jeff Davidson29da89f2018-02-28 17:50:16 -0800576 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
Wink Savillee380b982014-07-26 18:24:22 -0700577 if (VDBG) {
Svet Ganov16a16892015-04-16 10:32:04 -0700578 log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700579 + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
580 + UserHandle.myUserId() + " callerUserId=" + callerUserId);
Wink Savillea12a7b32012-09-20 10:09:45 -0700581 }
xinhe75c2c152014-10-16 11:49:45 -0700582
583 if (events != PhoneStateListener.LISTEN_NONE) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -0800584 // Checks permission and throws SecurityException for disallowed operations. For pre-M
585 // apps whose runtime permission has been revoked, we return immediately to skip sending
586 // events to the app without crashing it.
Jeff Davidson29da89f2018-02-28 17:50:16 -0800587 if (!checkListenerPermission(events, subId, callingPackage, "listen")) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -0800588 return;
Svet Ganov16a16892015-04-16 10:32:04 -0700589 }
590
yifan.baie620ce72017-12-22 14:59:57 +0800591 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800592 synchronized (mRecords) {
593 // register
Malcolm Chenabbfac22018-02-12 19:15:59 -0800594 IBinder b = callback.asBinder();
595 Record r = add(b);
596
597 if (r == null) {
598 return;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800599 }
xinhe43c50292014-09-18 17:56:48 -0700600
Jeff Davidson29da89f2018-02-28 17:50:16 -0800601 r.context = mContext;
xinhe75c2c152014-10-16 11:49:45 -0700602 r.callback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700603 r.callingPackage = callingPackage;
Hall Liu5fb337f2017-11-22 17:38:15 -0800604 r.callerUid = Binder.getCallingUid();
605 r.callerPid = Binder.getCallingPid();
xinhe75c2c152014-10-16 11:49:45 -0700606 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
607 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
Wink Savillea54bf652014-12-11 13:37:50 -0800608 if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800609 r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
xinhe75c2c152014-10-16 11:49:45 -0700610 } else {//APP specify subID
611 r.subId = subId;
612 }
yifan.baie620ce72017-12-22 14:59:57 +0800613 r.phoneId = phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800614 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700615 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700616 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700617 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700618 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800619 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400620 try {
Wink Savillee380b982014-07-26 18:24:22 -0700621 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700622 r.callback.onServiceStateChanged(
623 new ServiceState(mServiceState[phoneId]));
Joe Onorato163d8d92010-10-21 13:21:20 -0400624 } catch (RemoteException ex) {
625 remove(r.binder);
626 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800627 }
628 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
629 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700630 int gsmSignalStrength = mSignalStrength[phoneId]
631 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700632 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
633 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800634 } catch (RemoteException ex) {
635 remove(r.binder);
636 }
637 }
638 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
639 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700640 r.callback.onMessageWaitingIndicatorChanged(
641 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800642 } catch (RemoteException ex) {
643 remove(r.binder);
644 }
645 }
646 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
647 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700648 r.callback.onCallForwardingIndicatorChanged(
649 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800650 } catch (RemoteException ex) {
651 remove(r.binder);
652 }
653 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700654 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400655 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700656 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700657 + mCellLocation[phoneId]);
Hall Liu5fb337f2017-11-22 17:38:15 -0800658 if (checkLocationAccess(r)) {
659 r.callback.onCellLocationChanged(
660 new Bundle(mCellLocation[phoneId]));
661 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400662 } catch (RemoteException ex) {
663 remove(r.binder);
664 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800665 }
666 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
667 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700668 r.callback.onCallStateChanged(mCallState[phoneId],
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700669 getCallIncomingNumber(r, phoneId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 } catch (RemoteException ex) {
671 remove(r.binder);
672 }
673 }
674 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
675 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700676 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
677 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800678 } catch (RemoteException ex) {
679 remove(r.binder);
680 }
681 }
682 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
683 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700684 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800685 } catch (RemoteException ex) {
686 remove(r.binder);
687 }
688 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700689 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
690 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700691 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700692 } catch (RemoteException ex) {
693 remove(r.binder);
694 }
695 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700696 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
697 try {
698 r.callback.onOtaspChanged(mOtaspMode);
699 } catch (RemoteException ex) {
700 remove(r.binder);
701 }
702 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700703 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700704 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700705 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700706 + mCellInfo.get(phoneId));
Hall Liu5fb337f2017-11-22 17:38:15 -0800707 if (checkLocationAccess(r)) {
708 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
709 }
John Wang963db55d2012-03-30 16:04:06 -0700710 } catch (RemoteException ex) {
711 remove(r.binder);
712 }
713 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200714 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
715 try {
716 r.callback.onPreciseCallStateChanged(mPreciseCallState);
717 } catch (RemoteException ex) {
718 remove(r.binder);
719 }
720 }
chen xu6a942d482018-12-12 19:59:30 -0800721 if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) {
722 try {
723 r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause,
724 mCallPreciseDisconnectCause);
725 } catch (RemoteException ex) {
726 remove(r.binder);
727 }
728 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200729 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
730 try {
731 r.callback.onPreciseDataConnectionStateChanged(
732 mPreciseDataConnectionState);
733 } catch (RemoteException ex) {
734 remove(r.binder);
735 }
736 }
Andrew Flynn1f452642015-04-14 22:16:04 -0400737 if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) {
738 try {
739 r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
740 } catch (RemoteException ex) {
741 remove(r.binder);
742 }
743 }
fionaxu12312f62016-11-14 13:32:14 -0800744 if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) !=0) {
745 try {
746 r.callback.onVoiceActivationStateChanged(mVoiceActivationState[phoneId]);
747 } catch (RemoteException ex) {
748 remove(r.binder);
749 }
750 }
751 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) !=0) {
752 try {
753 r.callback.onDataActivationStateChanged(mDataActivationState[phoneId]);
754 } catch (RemoteException ex) {
755 remove(r.binder);
756 }
757 }
zxuan35a47022018-01-04 11:24:04 -0800758 if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
759 try {
760 r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
761 } catch (RemoteException ex) {
762 remove(r.binder);
763 }
764 }
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -0800765 if ((events & PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) != 0) {
766 try {
767 r.callback.onPhysicalChannelConfigurationChanged(
768 mPhysicalChannelConfigs.get(phoneId));
769 } catch (RemoteException ex) {
770 remove(r.binder);
771 }
772 }
sqian9f93a122018-12-03 22:40:41 -0800773 if ((events & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) {
774 try {
775 r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
776 } catch (RemoteException ex) {
777 remove(r.binder);
778 }
779 }
Malcolm Chene1623652018-08-08 20:27:45 -0700780 if ((events & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) {
781 try {
782 r.callback.onPhoneCapabilityChanged(mPhoneCapability);
783 } catch (RemoteException ex) {
784 remove(r.binder);
785 }
786 }
Malcolm Chen8b53afe2018-09-24 20:01:32 -0700787 if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) {
788 try {
789 r.callback.onPreferredDataSubIdChanged(mPreferredDataSubId);
790 } catch (RemoteException ex) {
791 remove(r.binder);
792 }
793 }
Chen Xu7395c632018-10-17 17:53:47 +0000794 if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) {
795 try {
796 r.callback.onRadioPowerStateChanged(mRadioPowerState);
797 } catch (RemoteException ex) {
798 remove(r.binder);
799 }
800 }
Brad Ebingerefed9822018-10-26 10:25:57 -0700801 if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
802 try {
803 r.callback.onSrvccStateChanged(mSrvccState[phoneId]);
804 } catch (RemoteException ex) {
805 remove(r.binder);
806 }
807 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800808 }
809 }
810 } else {
xinhe75c2c152014-10-16 11:49:45 -0700811 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800812 remove(callback.asBinder());
813 }
814 }
815
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700816 private String getCallIncomingNumber(Record record, int phoneId) {
Tyler Gunnf955e562018-04-26 14:43:31 -0700817 // Only reveal the incoming number if the record has read call log permission.
818 return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : "";
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700819 }
820
Malcolm Chenabbfac22018-02-12 19:15:59 -0800821 private Record add(IBinder binder) {
822 Record r;
823
824 synchronized (mRecords) {
825 final int N = mRecords.size();
826 for (int i = 0; i < N; i++) {
827 r = mRecords.get(i);
828 if (binder == r.binder) {
829 // Already existed.
830 return r;
831 }
832 }
833 r = new Record();
834 r.binder = binder;
835 r.deathRecipient = new TelephonyRegistryDeathRecipient(binder);
836
837 try {
838 binder.linkToDeath(r.deathRecipient, 0);
839 } catch (RemoteException e) {
840 if (VDBG) log("LinkToDeath remote exception sending to r=" + r + " e=" + e);
841 // Binder already died. Return null.
842 return null;
843 }
844
845 mRecords.add(r);
846 if (DBG) log("add new record");
847 }
848
849 return r;
850 }
851
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800852 private void remove(IBinder binder) {
853 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700854 final int recordCount = mRecords.size();
855 for (int i = 0; i < recordCount; i++) {
Malcolm Chenabbfac22018-02-12 19:15:59 -0800856 Record r = mRecords.get(i);
857 if (r.binder == binder) {
xinheac11ae92014-12-18 10:02:14 -0800858 if (DBG) {
Malcolm Chenabbfac22018-02-12 19:15:59 -0800859 log("remove: binder=" + binder + " r.callingPackage " + r.callingPackage
860 + " r.callback " + r.callback);
xinheac11ae92014-12-18 10:02:14 -0800861 }
Malcolm Chenabbfac22018-02-12 19:15:59 -0800862
863 if (r.deathRecipient != null) {
864 try {
865 binder.unlinkToDeath(r.deathRecipient, 0);
866 } catch (NoSuchElementException e) {
867 if (VDBG) log("UnlinkToDeath NoSuchElementException sending to r="
868 + r + " e=" + e);
869 }
870 }
871
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800872 mRecords.remove(i);
873 return;
874 }
875 }
876 }
877 }
878
Tyler Gunnf955e562018-04-26 14:43:31 -0700879 public void notifyCallState(int state, String phoneNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700880 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700881 return;
882 }
xinhe43c50292014-09-18 17:56:48 -0700883
884 if (VDBG) {
Tyler Gunnf955e562018-04-26 14:43:31 -0700885 log("notifyCallState: state=" + state + " phoneNumber=" + phoneNumber);
xinhe43c50292014-09-18 17:56:48 -0700886 }
887
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800888 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700889 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800890 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800891 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800892 try {
Tyler Gunnf955e562018-04-26 14:43:31 -0700893 // Ensure the listener has read call log permission; if they do not return
894 // an empty phone number.
895 String phoneNumberOrEmpty = r.canReadCallLog() ? phoneNumber : "";
896 r.callback.onCallStateChanged(state, phoneNumberOrEmpty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800897 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400898 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800899 }
900 }
901 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400902 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800903 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700904
905 // Called only by Telecomm to communicate call state across different phone accounts. So
906 // there is no need to add a valid subId or slotId.
Tyler Gunnf955e562018-04-26 14:43:31 -0700907 broadcastCallStateChanged(state, phoneNumber,
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700908 SubscriptionManager.INVALID_PHONE_INDEX,
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -0700909 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800910 }
911
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700912 public void notifyCallStateForPhoneId(int phoneId, int subId, int state,
913 String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700914 if (!checkNotifyPermission("notifyCallState()")) {
915 return;
916 }
Wink Savillee380b982014-07-26 18:24:22 -0700917 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700918 log("notifyCallStateForPhoneId: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700919 + " state=" + state + " incomingNumber=" + incomingNumber);
920 }
921 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700922 if (validatePhoneId(phoneId)) {
923 mCallState[phoneId] = state;
924 mCallIncomingNumber[phoneId] = incomingNumber;
925 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800926 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
xinhe43c50292014-09-18 17:56:48 -0700927 (r.subId == subId) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800928 (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700929 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700930 String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId);
931 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
Wink Savillefb40dd42014-06-12 17:02:31 -0700932 } catch (RemoteException ex) {
933 mRemoveList.add(r.binder);
934 }
935 }
936 }
937 }
938 handleRemoveListLocked();
939 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700940 broadcastCallStateChanged(state, incomingNumber, phoneId, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700941 }
942
Wink Saville63f03dd2014-10-23 10:44:45 -0700943 public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700944 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700945 return;
Wink Savillee9b06d72009-05-18 21:47:50 -0700946 }
xinhe43c50292014-09-18 17:56:48 -0700947
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800948 synchronized (mRecords) {
Jack Yud19b6ae2017-04-05 14:12:09 -0700949 String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
950 + " state=" + state;
Wink Savillee380b982014-07-26 18:24:22 -0700951 if (VDBG) {
Jack Yud19b6ae2017-04-05 14:12:09 -0700952 log(str);
Wink Saville47d8d1b2014-07-10 13:01:52 -0700953 }
Jack Yud19b6ae2017-04-05 14:12:09 -0700954 mLocalLog.log(str);
Wink Savillefb40dd42014-06-12 17:02:31 -0700955 if (validatePhoneId(phoneId)) {
956 mServiceState[phoneId] = state;
Wink Saville47d8d1b2014-07-10 13:01:52 -0700957
Wink Savillefb40dd42014-06-12 17:02:31 -0700958 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -0700959 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700960 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -0700961 + " phoneId=" + phoneId + " state=" + state);
962 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800963 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) &&
xinhe8b79fb62014-11-05 14:55:03 -0800964 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700965 try {
Wink Savillee380b982014-07-26 18:24:22 -0700966 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -0700967 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -0700968 + " subId=" + subId + " phoneId=" + phoneId
969 + " state=" + state);
970 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700971 r.callback.onServiceStateChanged(new ServiceState(state));
972 } catch (RemoteException ex) {
973 mRemoveList.add(r.binder);
974 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400975 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800976 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700977 } else {
Wink Savillebc027272014-09-08 14:50:58 -0700978 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800979 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400980 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800981 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700982 broadcastServiceStateChanged(state, phoneId, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800983 }
984
fionaxu12312f62016-11-14 13:32:14 -0800985 public void notifySimActivationStateChangedForPhoneId(int phoneId, int subId,
986 int activationType, int activationState) {
987 if (!checkNotifyPermission("notifySimActivationState()")){
988 return;
989 }
990 if (VDBG) {
991 log("notifySimActivationStateForPhoneId: subId=" + subId + " phoneId=" + phoneId
992 + "type=" + activationType + " state=" + activationState);
993 }
994 synchronized (mRecords) {
995 if (validatePhoneId(phoneId)) {
996 switch (activationType) {
997 case PhoneConstants.SIM_ACTIVATION_TYPE_VOICE:
998 mVoiceActivationState[phoneId] = activationState;
999 break;
1000 case PhoneConstants.SIM_ACTIVATION_TYPE_DATA:
1001 mDataActivationState[phoneId] = activationState;
1002 break;
1003 default:
1004 return;
1005 }
1006 for (Record r : mRecords) {
1007 if (VDBG) {
1008 log("notifySimActivationStateForPhoneId: r=" + r + " subId=" + subId
1009 + " phoneId=" + phoneId + "type=" + activationType
1010 + " state=" + activationState);
1011 }
1012 try {
1013 if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_VOICE) &&
1014 r.matchPhoneStateListenerEvent(
1015 PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) &&
1016 idMatch(r.subId, subId, phoneId)) {
1017 if (DBG) {
1018 log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r
1019 + " subId=" + subId + " phoneId=" + phoneId
1020 + " state=" + activationState);
1021 }
1022 r.callback.onVoiceActivationStateChanged(activationState);
1023 }
1024 if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_DATA) &&
1025 r.matchPhoneStateListenerEvent(
1026 PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) &&
1027 idMatch(r.subId, subId, phoneId)) {
1028 if (DBG) {
1029 log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r
1030 + " subId=" + subId + " phoneId=" + phoneId
1031 + " state=" + activationState);
1032 }
1033 r.callback.onDataActivationStateChanged(activationState);
1034 }
1035 } catch (RemoteException ex) {
1036 mRemoveList.add(r.binder);
1037 }
1038 }
1039 } else {
1040 log("notifySimActivationStateForPhoneId: INVALID phoneId=" + phoneId);
1041 }
1042 handleRemoveListLocked();
1043 }
1044 }
1045
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001046 public void notifySignalStrengthForPhoneId(int phoneId, int subId,
1047 SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001048 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001049 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001050 }
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001051 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001052 log("notifySignalStrengthForPhoneId: subId=" + subId
1053 +" phoneId=" + phoneId + " signalStrength=" + signalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001054 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001055
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001056 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001057 if (validatePhoneId(phoneId)) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001058 if (VDBG) log("notifySignalStrengthForPhoneId: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -07001059 mSignalStrength[phoneId] = signalStrength;
1060 for (Record r : mRecords) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001061 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001062 log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001063 + " phoneId=" + phoneId + " ss=" + signalStrength);
1064 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001065 if (r.matchPhoneStateListenerEvent(
1066 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) &&
xinhe8b79fb62014-11-05 14:55:03 -08001067 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001068 try {
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001069 if (DBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001070 log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001071 + " subId=" + subId + " phoneId=" + phoneId
1072 + " ss=" + signalStrength);
1073 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001074 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1075 } catch (RemoteException ex) {
1076 mRemoveList.add(r.binder);
1077 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001078 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001079 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) &&
xinhe8b79fb62014-11-05 14:55:03 -08001080 idMatch(r.subId, subId, phoneId)){
Wink Savillefb40dd42014-06-12 17:02:31 -07001081 try {
1082 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001083 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001084 if (DBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001085 log("notifySignalStrengthForPhoneId: callback.onSS r=" + r
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001086 + " subId=" + subId + " phoneId=" + phoneId
1087 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
1088 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001089 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -07001090 } catch (RemoteException ex) {
1091 mRemoveList.add(r.binder);
1092 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001093 }
1094 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001095 } else {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001096 log("notifySignalStrengthForPhoneId: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001097 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001098 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001099 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001100 broadcastSignalStrengthChanged(signalStrength, phoneId, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001101 }
1102
Andrew Flynn1f452642015-04-14 22:16:04 -04001103 @Override
1104 public void notifyCarrierNetworkChange(boolean active) {
Andrew Flynnceaed682015-06-09 12:36:58 +00001105 enforceNotifyPermissionOrCarrierPrivilege("notifyCarrierNetworkChange()");
1106
Andrew Flynn1f452642015-04-14 22:16:04 -04001107 if (VDBG) {
1108 log("notifyCarrierNetworkChange: active=" + active);
1109 }
1110
1111 synchronized (mRecords) {
1112 mCarrierNetworkChangeState = active;
1113 for (Record r : mRecords) {
1114 if (r.matchPhoneStateListenerEvent(
1115 PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE)) {
1116 try {
1117 r.callback.onCarrierNetworkChange(active);
1118 } catch (RemoteException ex) {
1119 mRemoveList.add(r.binder);
1120 }
1121 }
1122 }
1123 handleRemoveListLocked();
1124 }
1125 }
1126
Wink Savilleb208a242012-07-25 14:08:09 -07001127 public void notifyCellInfo(List<CellInfo> cellInfo) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001128 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -07001129 }
1130
Wink Saville63f03dd2014-10-23 10:44:45 -07001131 public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -07001132 if (!checkNotifyPermission("notifyCellInfo()")) {
1133 return;
1134 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001135 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001136 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001137 + " cellInfo=" + cellInfo);
1138 }
yifan.baie620ce72017-12-22 14:59:57 +08001139 int phoneId = SubscriptionManager.getPhoneId(subId);
John Wang963db55d2012-03-30 16:04:06 -07001140 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001141 if (validatePhoneId(phoneId)) {
1142 mCellInfo.set(phoneId, cellInfo);
1143 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001144 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
Hall Liu5fb337f2017-11-22 17:38:15 -08001145 idMatch(r.subId, subId, phoneId) &&
1146 checkLocationAccess(r)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001147 try {
1148 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001149 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -07001150 }
1151 r.callback.onCellInfoChanged(cellInfo);
1152 } catch (RemoteException ex) {
1153 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001154 }
John Wang963db55d2012-03-30 16:04:06 -07001155 }
1156 }
1157 }
1158 handleRemoveListLocked();
1159 }
1160 }
1161
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -08001162 public void notifyPhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
1163 notifyPhysicalChannelConfigurationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
1164 configs);
1165 }
1166
1167 public void notifyPhysicalChannelConfigurationForSubscriber(int subId,
1168 List<PhysicalChannelConfig> configs) {
1169 if (!checkNotifyPermission("notifyPhysicalChannelConfiguration()")) {
1170 return;
1171 }
1172
1173 if (VDBG) {
1174 log("notifyPhysicalChannelConfiguration: subId=" + subId + " configs=" + configs);
1175 }
1176
1177 synchronized (mRecords) {
1178 int phoneId = SubscriptionManager.getPhoneId(subId);
1179 if (validatePhoneId(phoneId)) {
1180 mPhysicalChannelConfigs.set(phoneId, configs);
1181 for (Record r : mRecords) {
1182 if (r.matchPhoneStateListenerEvent(
1183 PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION)
1184 && idMatch(r.subId, subId, phoneId)) {
1185 try {
1186 if (DBG_LOC) {
1187 log("notifyPhysicalChannelConfiguration: mPhysicalChannelConfigs="
1188 + configs + " r=" + r);
1189 }
1190 r.callback.onPhysicalChannelConfigurationChanged(configs);
1191 } catch (RemoteException ex) {
1192 mRemoveList.add(r.binder);
1193 }
1194 }
1195 }
1196 }
1197 handleRemoveListLocked();
1198 }
1199 }
1200
xinhe43c50292014-09-18 17:56:48 -07001201 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -07001202 public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001203 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001204 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001205 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001206 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -07001207 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -07001208 + " mwi=" + mwi);
1209 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001210 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001211 if (validatePhoneId(phoneId)) {
1212 mMessageWaiting[phoneId] = mwi;
1213 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001214 if (r.matchPhoneStateListenerEvent(
1215 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -08001216 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001217 try {
1218 r.callback.onMessageWaitingIndicatorChanged(mwi);
1219 } catch (RemoteException ex) {
1220 mRemoveList.add(r.binder);
1221 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001222 }
1223 }
1224 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001225 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001226 }
1227 }
1228
zxuan35a47022018-01-04 11:24:04 -08001229 public void notifyUserMobileDataStateChangedForPhoneId(int phoneId, int subId, boolean state) {
1230 if (!checkNotifyPermission("notifyUserMobileDataStateChanged()")) {
1231 return;
1232 }
1233 if (VDBG) {
1234 log("notifyUserMobileDataStateChangedForSubscriberPhoneID: subId=" + phoneId
1235 + " state=" + state);
1236 }
1237 synchronized (mRecords) {
1238 if (validatePhoneId(phoneId)) {
1239 mMessageWaiting[phoneId] = state;
1240 for (Record r : mRecords) {
1241 if (r.matchPhoneStateListenerEvent(
1242 PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) &&
1243 idMatch(r.subId, subId, phoneId)) {
1244 try {
1245 r.callback.onUserMobileDataStateChanged(state);
1246 } catch (RemoteException ex) {
1247 mRemoveList.add(r.binder);
1248 }
1249 }
1250 }
1251 }
1252 handleRemoveListLocked();
1253 }
1254 }
1255
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001256 public void notifyCallForwardingChanged(boolean cfi) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001257 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -07001258 }
1259
Wink Saville63f03dd2014-10-23 10:44:45 -07001260 public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001261 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001262 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001263 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001264 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001265 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001266 + " cfi=" + cfi);
1267 }
yifan.baie620ce72017-12-22 14:59:57 +08001268 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001269 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001270 if (validatePhoneId(phoneId)) {
1271 mCallForwarding[phoneId] = cfi;
1272 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001273 if (r.matchPhoneStateListenerEvent(
1274 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -08001275 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001276 try {
1277 r.callback.onCallForwardingIndicatorChanged(cfi);
1278 } catch (RemoteException ex) {
1279 mRemoveList.add(r.binder);
1280 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001281 }
1282 }
1283 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001284 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001285 }
1286 }
1287
1288 public void notifyDataActivity(int state) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001289 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -07001290 }
1291
Wink Saville63f03dd2014-10-23 10:44:45 -07001292 public void notifyDataActivityForSubscriber(int subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001293 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001294 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001295 }
yifan.baie620ce72017-12-22 14:59:57 +08001296 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001297 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001298 if (validatePhoneId(phoneId)) {
1299 mDataActivity[phoneId] = state;
1300 for (Record r : mRecords) {
xu.peng9071ced2016-03-22 18:21:28 +08001301 // Notify by correct subId.
1302 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY) &&
1303 idMatch(r.subId, subId, phoneId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001304 try {
1305 r.callback.onDataActivity(state);
1306 } catch (RemoteException ex) {
1307 mRemoveList.add(r.binder);
1308 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001309 }
1310 }
1311 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001312 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001313 }
1314 }
1315
Jack Yubaeec622017-05-01 17:01:11 -07001316 public void notifyDataConnection(int state, boolean isDataAllowed,
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001317 String reason, String apn, String apnType, LinkProperties linkProperties,
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001318 NetworkCapabilities networkCapabilities, int networkType, boolean roaming) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001319 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
Jack Yubaeec622017-05-01 17:01:11 -07001320 isDataAllowed,reason, apn, apnType, linkProperties,
Wink Savillefb40dd42014-06-12 17:02:31 -07001321 networkCapabilities, networkType, roaming);
1322 }
1323
Wink Saville63f03dd2014-10-23 10:44:45 -07001324 public void notifyDataConnectionForSubscriber(int subId, int state,
Jack Yubaeec622017-05-01 17:01:11 -07001325 boolean isDataAllowed, String reason, String apn, String apnType,
Wink Savillefb40dd42014-06-12 17:02:31 -07001326 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
1327 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001328 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001329 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001330 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001331 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001332 log("notifyDataConnectionForSubscriber: subId=" + subId
Jack Yubaeec622017-05-01 17:01:11 -07001333 + " state=" + state + " isDataAllowed=" + isDataAllowed
Wink Savillefb40dd42014-06-12 17:02:31 -07001334 + " reason='" + reason
Wink Savillea12a7b32012-09-20 10:09:45 -07001335 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
xinheac11ae92014-12-18 10:02:14 -08001336 + " mRecords.size()=" + mRecords.size());
Wink Savillec9acde92011-09-21 11:05:43 -07001337 }
yifan.baie620ce72017-12-22 14:59:57 +08001338 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001339 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001340 if (validatePhoneId(phoneId)) {
Jack Yub1bac542018-03-14 16:23:38 -07001341 // We only call the callback when the change is for default APN type.
1342 if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType)
1343 && (mDataConnectionState[phoneId] != state
1344 || mDataConnectionNetworkType[phoneId] != networkType)) {
1345 String str = "onDataConnectionStateChanged(" + state
1346 + ", " + networkType + ")";
Jack Yud19b6ae2017-04-05 14:12:09 -07001347 log(str);
1348 mLocalLog.log(str);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001349 for (Record r : mRecords) {
1350 if (r.matchPhoneStateListenerEvent(
1351 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) &&
1352 idMatch(r.subId, subId, phoneId)) {
1353 try {
Jack Yud19b6ae2017-04-05 14:12:09 -07001354 if (DBG) {
1355 log("Notify data connection state changed on sub: " + subId);
1356 }
Jack Yub1bac542018-03-14 16:23:38 -07001357 r.callback.onDataConnectionStateChanged(state, networkType);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001358 } catch (RemoteException ex) {
1359 mRemoveList.add(r.binder);
1360 }
1361 }
1362 }
1363 handleRemoveListLocked();
Jack Yub1bac542018-03-14 16:23:38 -07001364
1365 mDataConnectionState[phoneId] = state;
1366 mDataConnectionNetworkType[phoneId] = networkType;
Wink Savilled09c4ca2014-11-22 10:08:16 -08001367 }
1368 mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType,
1369 apnType, apn, reason, linkProperties, "");
1370 for (Record r : mRecords) {
1371 if (r.matchPhoneStateListenerEvent(
1372 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
1373 try {
Jack Yud19b6ae2017-04-05 14:12:09 -07001374 r.callback.onPreciseDataConnectionStateChanged(
1375 mPreciseDataConnectionState);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001376 } catch (RemoteException ex) {
1377 mRemoveList.add(r.binder);
1378 }
Wink Saville2d1ee982014-11-20 20:29:51 +00001379 }
1380 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001381 }
1382 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001383 }
Jack Yubaeec622017-05-01 17:01:11 -07001384 broadcastDataConnectionStateChanged(state, isDataAllowed, reason, apn,
Wink Savillefb40dd42014-06-12 17:02:31 -07001385 apnType, linkProperties, networkCapabilities, roaming, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001386 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason,
1387 linkProperties, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001388 }
1389
Robert Greenwalt02648a42010-05-18 10:52:51 -07001390 public void notifyDataConnectionFailed(String reason, String apnType) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001391 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
xinhe43c50292014-09-18 17:56:48 -07001392 reason, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001393 }
1394
Wink Saville63f03dd2014-10-23 10:44:45 -07001395 public void notifyDataConnectionFailedForSubscriber(int subId,
Wink Savillefb40dd42014-06-12 17:02:31 -07001396 String reason, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001397 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001398 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001399 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001400 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001401 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001402 + " reason=" + reason + " apnType=" + apnType);
1403 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001404 synchronized (mRecords) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001405 mPreciseDataConnectionState = new PreciseDataConnectionState(
1406 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
1407 apnType, "", reason, null, "");
1408 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001409 if (r.matchPhoneStateListenerEvent(
1410 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001411 try {
1412 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1413 } catch (RemoteException ex) {
1414 mRemoveList.add(r.binder);
1415 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001416 }
1417 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001418 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001419 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001420 broadcastDataConnectionFailed(reason, apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001421 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1422 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, "");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001423 }
1424
1425 public void notifyCellLocation(Bundle cellLocation) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001426 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -07001427 }
1428
Wink Saville63f03dd2014-10-23 10:44:45 -07001429 public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) {
Wink Savillebc027272014-09-08 14:50:58 -07001430 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001431 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001432 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001433 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001434 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001435 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001436 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001437 + " cellLocation=" + cellLocation);
1438 }
yifan.baie620ce72017-12-22 14:59:57 +08001439 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001440 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001441 if (validatePhoneId(phoneId)) {
1442 mCellLocation[phoneId] = cellLocation;
1443 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001444 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
Hall Liu5fb337f2017-11-22 17:38:15 -08001445 idMatch(r.subId, subId, phoneId) &&
1446 checkLocationAccess(r)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001447 try {
1448 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001449 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -07001450 + " r=" + r);
1451 }
1452 r.callback.onCellLocationChanged(new Bundle(cellLocation));
1453 } catch (RemoteException ex) {
1454 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001455 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001456 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001457 }
1458 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001459 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -07001460 }
1461 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001462
Wink Savillefd2d0132010-10-28 14:22:26 -07001463 public void notifyOtaspChanged(int otaspMode) {
1464 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
1465 return;
1466 }
1467 synchronized (mRecords) {
1468 mOtaspMode = otaspMode;
1469 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001470 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) {
Wink Savillefd2d0132010-10-28 14:22:26 -07001471 try {
1472 r.callback.onOtaspChanged(otaspMode);
1473 } catch (RemoteException ex) {
1474 mRemoveList.add(r.binder);
1475 }
1476 }
1477 }
1478 handleRemoveListLocked();
1479 }
1480 }
1481
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001482 public void notifyPreciseCallState(int ringingCallState, int foregroundCallState,
1483 int backgroundCallState) {
1484 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1485 return;
1486 }
1487 synchronized (mRecords) {
1488 mRingingCallState = ringingCallState;
1489 mForegroundCallState = foregroundCallState;
1490 mBackgroundCallState = backgroundCallState;
1491 mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState,
1492 backgroundCallState,
1493 DisconnectCause.NOT_VALID,
1494 PreciseDisconnectCause.NOT_VALID);
1495 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001496 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001497 try {
1498 r.callback.onPreciseCallStateChanged(mPreciseCallState);
1499 } catch (RemoteException ex) {
1500 mRemoveList.add(r.binder);
1501 }
1502 }
1503 }
1504 handleRemoveListLocked();
1505 }
chen xu6a942d482018-12-12 19:59:30 -08001506 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState,
1507 backgroundCallState);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001508 }
1509
1510 public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) {
1511 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1512 return;
1513 }
1514 synchronized (mRecords) {
chen xu6a942d482018-12-12 19:59:30 -08001515 mCallDisconnectCause = disconnectCause;
1516 mCallPreciseDisconnectCause = preciseDisconnectCause;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001517 for (Record r : mRecords) {
chen xu6a942d482018-12-12 19:59:30 -08001518 if (r.matchPhoneStateListenerEvent(PhoneStateListener
1519 .LISTEN_CALL_DISCONNECT_CAUSES)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001520 try {
chen xu6a942d482018-12-12 19:59:30 -08001521 r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause,
1522 mCallPreciseDisconnectCause);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001523 } catch (RemoteException ex) {
1524 mRemoveList.add(r.binder);
1525 }
1526 }
1527 }
1528 handleRemoveListLocked();
1529 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001530 }
1531
1532 public void notifyPreciseDataConnectionFailed(String reason, String apnType,
1533 String apn, String failCause) {
1534 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1535 return;
1536 }
1537 synchronized (mRecords) {
1538 mPreciseDataConnectionState = new PreciseDataConnectionState(
1539 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1540 apnType, apn, reason, null, failCause);
1541 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001542 if (r.matchPhoneStateListenerEvent(
1543 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001544 try {
1545 r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState);
1546 } catch (RemoteException ex) {
1547 mRemoveList.add(r.binder);
1548 }
1549 }
1550 }
1551 handleRemoveListLocked();
1552 }
1553 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
1554 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause);
1555 }
1556
Brad Ebingerefed9822018-10-26 10:25:57 -07001557 @Override
1558 public void notifySrvccStateChanged(int subId, @TelephonyManager.SrvccState int state) {
1559 if (!checkNotifyPermission("notifySrvccStateChanged()")) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001560 return;
1561 }
Brad Ebingerefed9822018-10-26 10:25:57 -07001562 if (VDBG) {
1563 log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state);
1564 }
1565 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savillefb40dd42014-06-12 17:02:31 -07001566 synchronized (mRecords) {
Brad Ebingerefed9822018-10-26 10:25:57 -07001567 if (validatePhoneId(phoneId)) {
1568 mSrvccState[phoneId] = state;
1569 for (Record r : mRecords) {
1570 if (r.matchPhoneStateListenerEvent(
1571 PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) &&
1572 idMatch(r.subId, subId, phoneId)) {
1573 try {
1574 if (DBG_LOC) {
1575 log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r);
1576 }
1577 r.callback.onSrvccStateChanged(state);
1578 } catch (RemoteException ex) {
1579 mRemoveList.add(r.binder);
1580 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001581 }
1582 }
1583 }
1584 handleRemoveListLocked();
1585 }
1586 }
1587
Shuo Qian066e8652018-04-25 21:02:35 +00001588 public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) {
1589 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1590 return;
1591 }
1592
1593 synchronized (mRecords) {
1594 for (Record r : mRecords) {
1595 if (VDBG) {
1596 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1597 }
1598 if ((r.matchPhoneStateListenerEvent(
1599 PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) &&
1600 ((r.subId == subId) ||
1601 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) {
1602 try {
1603 r.callback.onOemHookRawEvent(rawData);
1604 } catch (RemoteException ex) {
1605 mRemoveList.add(r.binder);
1606 }
1607 }
1608 }
1609 handleRemoveListLocked();
1610 }
1611 }
1612
Malcolm Chene1623652018-08-08 20:27:45 -07001613 public void notifyPhoneCapabilityChanged(PhoneCapability capability) {
1614 if (!checkNotifyPermission("notifyPhoneCapabilityChanged()")) {
1615 return;
1616 }
1617
1618 if (VDBG) {
1619 log("notifyPhoneCapabilityChanged: capability=" + capability);
1620 }
1621
1622 synchronized (mRecords) {
1623 mPhoneCapability = capability;
1624
1625 for (Record r : mRecords) {
1626 if (r.matchPhoneStateListenerEvent(
1627 PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE)) {
1628 try {
1629 r.callback.onPhoneCapabilityChanged(capability);
1630 } catch (RemoteException ex) {
1631 mRemoveList.add(r.binder);
1632 }
1633 }
1634 }
1635 handleRemoveListLocked();
1636 }
1637 }
1638
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001639 public void notifyPreferredDataSubIdChanged(int preferredSubId) {
1640 if (!checkNotifyPermission("notifyPreferredDataSubIdChanged()")) {
1641 return;
1642 }
1643
1644 if (VDBG) {
1645 log("notifyPreferredDataSubIdChanged: preferredSubId=" + preferredSubId);
1646 }
1647
1648 synchronized (mRecords) {
1649 mPreferredDataSubId = preferredSubId;
1650
1651 for (Record r : mRecords) {
1652 if (r.matchPhoneStateListenerEvent(
1653 PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE)) {
1654 try {
1655 r.callback.onPreferredDataSubIdChanged(preferredSubId);
1656 } catch (RemoteException ex) {
1657 mRemoveList.add(r.binder);
1658 }
1659 }
1660 }
1661 handleRemoveListLocked();
1662 }
1663 }
Malcolm Chene1623652018-08-08 20:27:45 -07001664
Chen Xu7395c632018-10-17 17:53:47 +00001665 public void notifyRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) {
1666 if (!checkNotifyPermission("notifyRadioPowerStateChanged()")) {
1667 return;
1668 }
1669
1670 if (VDBG) {
1671 log("notifyRadioPowerStateChanged: state= " + state);
1672 }
1673
1674 synchronized (mRecords) {
1675 mRadioPowerState = state;
1676
1677 for (Record r : mRecords) {
1678 if (r.matchPhoneStateListenerEvent(
1679 PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED)) {
1680 try {
1681 r.callback.onRadioPowerStateChanged(state);
1682 } catch (RemoteException ex) {
1683 mRemoveList.add(r.binder);
1684 }
1685 }
1686 }
1687 handleRemoveListLocked();
1688 }
1689 }
1690
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001691 @Override
sqian9f93a122018-12-03 22:40:41 -08001692 public void notifyEmergencyNumberList() {
1693 if (!checkNotifyPermission("notifyEmergencyNumberList()")) {
1694 return;
1695 }
1696
1697 synchronized (mRecords) {
sqianb0ae02b2018-12-14 21:47:49 -08001698 TelephonyManager tm = (TelephonyManager) mContext.getSystemService(
1699 Context.TELEPHONY_SERVICE);
1700 mEmergencyNumberList = tm.getCurrentEmergencyNumberList();
sqian9f93a122018-12-03 22:40:41 -08001701
1702 for (Record r : mRecords) {
1703 if (r.matchPhoneStateListenerEvent(
1704 PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST)) {
1705 try {
1706 r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
1707 if (VDBG) {
1708 log("notifyEmergencyNumberList: emergencyNumberList= "
1709 + mEmergencyNumberList);
1710 }
1711 } catch (RemoteException ex) {
1712 mRemoveList.add(r.binder);
1713 }
1714 }
1715 }
1716 handleRemoveListLocked();
1717 }
sqianbdc5a732018-10-26 13:27:51 -07001718 }
1719
1720
1721 @Override
Jack Yud19b6ae2017-04-05 14:12:09 -07001722 public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
1723 final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
1724
Jeff Sharkeyfe9a53b2017-03-31 14:08:23 -06001725 if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
Jack Yud19b6ae2017-04-05 14:12:09 -07001726
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001727 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001728 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001729 pw.println("last known state:");
Jack Yud19b6ae2017-04-05 14:12:09 -07001730 pw.increaseIndent();
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301731 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
Jack Yud19b6ae2017-04-05 14:12:09 -07001732 pw.println("Phone Id=" + i);
1733 pw.increaseIndent();
1734 pw.println("mCallState=" + mCallState[i]);
1735 pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]);
1736 pw.println("mServiceState=" + mServiceState[i]);
1737 pw.println("mVoiceActivationState= " + mVoiceActivationState[i]);
1738 pw.println("mDataActivationState= " + mDataActivationState[i]);
zxuan35a47022018-01-04 11:24:04 -08001739 pw.println("mUserMobileDataState= " + mUserMobileDataState[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001740 pw.println("mSignalStrength=" + mSignalStrength[i]);
1741 pw.println("mMessageWaiting=" + mMessageWaiting[i]);
1742 pw.println("mCallForwarding=" + mCallForwarding[i]);
1743 pw.println("mDataActivity=" + mDataActivity[i]);
1744 pw.println("mDataConnectionState=" + mDataConnectionState[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001745 pw.println("mCellLocation=" + mCellLocation[i]);
1746 pw.println("mCellInfo=" + mCellInfo.get(i));
1747 pw.decreaseIndent();
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301748 }
Jack Yud19b6ae2017-04-05 14:12:09 -07001749 pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState);
1750 pw.println("mPreciseCallState=" + mPreciseCallState);
chen xu6a942d482018-12-12 19:59:30 -08001751 pw.println("mCallDisconnectCause=" + mCallDisconnectCause);
1752 pw.println("mCallPreciseDisconnectCause=" + mCallPreciseDisconnectCause);
Jack Yud19b6ae2017-04-05 14:12:09 -07001753 pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
1754 pw.println("mRingingCallState=" + mRingingCallState);
1755 pw.println("mForegroundCallState=" + mForegroundCallState);
1756 pw.println("mBackgroundCallState=" + mBackgroundCallState);
Brad Ebingerefed9822018-10-26 10:25:57 -07001757 pw.println("mSrvccState=" + mSrvccState);
Malcolm Chene1623652018-08-08 20:27:45 -07001758 pw.println("mPhoneCapability=" + mPhoneCapability);
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001759 pw.println("mPreferredDataSubId=" + mPreferredDataSubId);
Chen Xu7395c632018-10-17 17:53:47 +00001760 pw.println("mRadioPowerState=" + mRadioPowerState);
sqian9f93a122018-12-03 22:40:41 -08001761 pw.println("mEmergencyNumberList=" + mEmergencyNumberList);
Jack Yud19b6ae2017-04-05 14:12:09 -07001762
1763 pw.decreaseIndent();
1764
1765 pw.println("local logs:");
1766 pw.increaseIndent();
1767 mLocalLog.dump(fd, pw, args);
1768 pw.decreaseIndent();
Wink Savillee9b06d72009-05-18 21:47:50 -07001769 pw.println("registrations: count=" + recordCount);
Jack Yud19b6ae2017-04-05 14:12:09 -07001770 pw.increaseIndent();
Robert Greenwalt02648a42010-05-18 10:52:51 -07001771 for (Record r : mRecords) {
Jack Yud19b6ae2017-04-05 14:12:09 -07001772 pw.println(r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001773 }
Jack Yud19b6ae2017-04-05 14:12:09 -07001774 pw.decreaseIndent();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001775 }
1776 }
1777
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001778 //
1779 // the legacy intent broadcasting
1780 //
1781
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001782 private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001783 long ident = Binder.clearCallingIdentity();
1784 try {
1785 mBatteryStats.notePhoneState(state.getState());
1786 } catch (RemoteException re) {
1787 // Can't do much
1788 } finally {
1789 Binder.restoreCallingIdentity(ident);
1790 }
1791
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001792 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
Christopher Tate42a386b2016-11-07 12:21:21 -08001793 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001794 Bundle data = new Bundle();
1795 state.fillInNotifierBundle(data);
1796 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001797 // Pass the subscription along with the intent.
1798 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
chen xu379e5312018-09-28 15:53:43 -07001799 intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001800 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001801 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001802 }
1803
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001804 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId,
1805 int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001806 long ident = Binder.clearCallingIdentity();
1807 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07001808 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07001809 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001810 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07001811 } finally {
1812 Binder.restoreCallingIdentity(ident);
1813 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001814
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001815 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Wink Savillee9b06d72009-05-18 21:47:50 -07001816 Bundle data = new Bundle();
1817 signalStrength.fillInNotifierBundle(data);
1818 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07001819 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001820 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001821 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001822 }
1823
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001824 /**
1825 * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
1826 * a valid subId, in which case this function fires a subId-specific intent, or it
1827 * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
1828 * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
1829 */
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001830 private void broadcastCallStateChanged(int state, String incomingNumber, int phoneId,
1831 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001832 long ident = Binder.clearCallingIdentity();
1833 try {
1834 if (state == TelephonyManager.CALL_STATE_IDLE) {
1835 mBatteryStats.notePhoneOff();
Yangster4ccebea2018-10-09 17:09:02 -07001836 StatsLog.write(StatsLog.PHONE_STATE_CHANGED,
1837 StatsLog.PHONE_STATE_CHANGED__STATE__OFF);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001838 } else {
1839 mBatteryStats.notePhoneOn();
Yangster4ccebea2018-10-09 17:09:02 -07001840 StatsLog.write(StatsLog.PHONE_STATE_CHANGED,
1841 StatsLog.PHONE_STATE_CHANGED__STATE__ON);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001842 }
1843 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001844 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001845 } finally {
1846 Binder.restoreCallingIdentity(ident);
1847 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001848
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001849 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001850 intent.putExtra(PhoneConstants.STATE_KEY,
Nathan Harold5a0618e2016-12-14 10:48:00 -08001851 PhoneConstantConversions.convertCallState(state).toString());
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001852
1853 // If a valid subId was specified, we should fire off a subId-specific state
1854 // change intent and include the subId.
1855 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
1856 intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
1857 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
chen xu379e5312018-09-28 15:53:43 -07001858 intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001859 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001860 // If the phoneId is invalid, the broadcast is for overall call state.
1861 if (phoneId != SubscriptionManager.INVALID_PHONE_INDEX) {
1862 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
1863 }
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07001864
Brad Ebinger51de96a2017-04-21 17:05:18 -07001865 // Wakeup apps for the (SUBSCRIPTION_)PHONE_STATE broadcast.
1866 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
1867
Tyler Gunn1c27bb72018-06-19 09:55:43 -07001868 // Create a version of the intent with the number always populated.
Tyler Gunnf955e562018-04-26 14:43:31 -07001869 Intent intentWithPhoneNumber = new Intent(intent);
Tyler Gunn1c27bb72018-06-19 09:55:43 -07001870 intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
1871
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001872 // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
1873 // that have the runtime one
Tyler Gunnf955e562018-04-26 14:43:31 -07001874 mContext.sendBroadcastAsUser(intentWithPhoneNumber, UserHandle.ALL,
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001875 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001876 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Svet Ganov16a16892015-04-16 10:32:04 -07001877 android.Manifest.permission.READ_PHONE_STATE,
1878 AppOpsManager.OP_READ_PHONE_STATE);
Tyler Gunnf955e562018-04-26 14:43:31 -07001879 mContext.sendBroadcastAsUserMultiplePermissions(intentWithPhoneNumber, UserHandle.ALL,
1880 new String[] { android.Manifest.permission.READ_PHONE_STATE,
1881 android.Manifest.permission.READ_CALL_LOG});
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001882 }
1883
Robert Greenwalt42acef32009-08-12 16:08:25 -07001884 private void broadcastDataConnectionStateChanged(int state,
Jack Yubaeec622017-05-01 17:01:11 -07001885 boolean isDataAllowed,
Wink Savillef61101f2010-09-16 16:36:42 -07001886 String reason, String apn, String apnType, LinkProperties linkProperties,
Wink Saville63f03dd2014-10-23 10:44:45 -07001887 NetworkCapabilities networkCapabilities, boolean roaming, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07001888 // Note: not reporting to the battery stats service here, because the
1889 // status bar takes care of that after taking into account all of the
1890 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001891 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07001892 intent.putExtra(PhoneConstants.STATE_KEY,
Nathan Harold5a0618e2016-12-14 10:48:00 -08001893 PhoneConstantConversions.convertDataState(state).toString());
Jack Yubaeec622017-05-01 17:01:11 -07001894 if (!isDataAllowed) {
Wink Savillea639b312012-07-10 12:37:54 -07001895 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001896 }
1897 if (reason != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001898 intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001899 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07001900 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001901 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07001902 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001903 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07001904 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07001905 }
1906 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07001907 if (networkCapabilities != null) {
1908 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07001909 }
Wink Savillea639b312012-07-10 12:37:54 -07001910 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07001911
Wink Savillea639b312012-07-10 12:37:54 -07001912 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
1913 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001914 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001915 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001916 }
1917
Wink Savillefb40dd42014-06-12 17:02:31 -07001918 private void broadcastDataConnectionFailed(String reason, String apnType,
Wink Saville63f03dd2014-10-23 10:44:45 -07001919 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001920 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07001921 intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason);
1922 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001923 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07001924 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001925 }
Wink Savillee9b06d72009-05-18 21:47:50 -07001926
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001927 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
chen xu6a942d482018-12-12 19:59:30 -08001928 int backgroundCallState) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001929 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
1930 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
1931 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
1932 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001933 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1934 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1935 }
1936
1937 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
Wink Savilled09c4ca2014-11-22 10:08:16 -08001938 String apnType, String apn, String reason, LinkProperties linkProperties,
1939 String failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001940 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
1941 intent.putExtra(PhoneConstants.STATE_KEY, state);
1942 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
1943 if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason);
1944 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
1945 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001946 if (linkProperties != null) {
1947 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties);
1948 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001949 if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
1950
1951 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
1952 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
1953 }
1954
Andrew Flynnceaed682015-06-09 12:36:58 +00001955 private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08001956 if (checkNotifyPermission()) {
Andrew Flynnceaed682015-06-09 12:36:58 +00001957 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04001958 }
1959
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08001960 TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(
1961 SubscriptionManager.getDefaultSubscriptionId(), method);
Andrew Flynn1f452642015-04-14 22:16:04 -04001962 }
1963
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001964 private boolean checkNotifyPermission(String method) {
Andrew Flynn1f452642015-04-14 22:16:04 -04001965 if (checkNotifyPermission()) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001966 return true;
1967 }
1968 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07001969 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001970 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001971 return false;
1972 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001973
Andrew Flynn1f452642015-04-14 22:16:04 -04001974 private boolean checkNotifyPermission() {
1975 return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
1976 == PackageManager.PERMISSION_GRANTED;
1977 }
1978
Jeff Davidson29da89f2018-02-28 17:50:16 -08001979 private boolean checkListenerPermission(
1980 int events, int subId, String callingPackage, String message) {
Hall Liu70bbc162018-03-02 17:44:46 -08001981 if ((events & ENFORCE_COARSE_LOCATION_PERMISSION_MASK) != 0) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001982 mContext.enforceCallingOrSelfPermission(
1983 android.Manifest.permission.ACCESS_COARSE_LOCATION, null);
Hall Liu70bbc162018-03-02 17:44:46 -08001984 if (mAppOps.noteOp(AppOpsManager.OP_COARSE_LOCATION, Binder.getCallingUid(),
1985 callingPackage) != AppOpsManager.MODE_ALLOWED) {
1986 return false;
1987 }
John Wang963db55d2012-03-30 16:04:06 -07001988 }
1989
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001990 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Jeff Davidson29da89f2018-02-28 17:50:16 -08001991 if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
1992 mContext, subId, callingPackage, message)) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08001993 return false;
Amit Mahajan1cfd4572015-07-09 11:12:19 -07001994 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001995 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001996
1997 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
1998 mContext.enforceCallingOrSelfPermission(
1999 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002000 }
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002001
Shuo Qian066e8652018-04-25 21:02:35 +00002002 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
2003 mContext.enforceCallingOrSelfPermission(
2004 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2005 }
2006
Brad Ebingerefed9822018-10-26 10:25:57 -07002007 if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
2008 mContext.enforceCallingOrSelfPermission(
2009 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2010 }
2011
Malcolm Chen7e22ba62018-12-11 13:56:53 -08002012 if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) {
2013 // It can have either READ_PHONE_STATE or READ_PRIVILEGED_PHONE_STATE.
2014 TelephonyPermissions.checkReadPhoneState(mContext,
2015 SubscriptionManager.INVALID_SUBSCRIPTION_ID, Binder.getCallingPid(),
2016 Binder.getCallingUid(), callingPackage, "listen to "
2017 + "LISTEN_PREFERRED_DATA_SUBID_CHANGE");
2018 }
Brad Ebingerefed9822018-10-26 10:25:57 -07002019
chen xu6a942d482018-12-12 19:59:30 -08002020 if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) {
2021 mContext.enforceCallingOrSelfPermission(
2022 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
2023 }
2024
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002025 return true;
Jaikumar Ganesh45515652009-04-23 15:20:21 -07002026 }
Joe Onorato163d8d92010-10-21 13:21:20 -04002027
2028 private void handleRemoveListLocked() {
Wink Savillea374c3d2014-11-11 11:48:04 -08002029 int size = mRemoveList.size();
2030 if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size);
2031 if (size > 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -04002032 for (IBinder b: mRemoveList) {
2033 remove(b);
2034 }
2035 mRemoveList.clear();
2036 }
2037 }
Wink Savillea12a7b32012-09-20 10:09:45 -07002038
2039 private boolean validateEventsAndUserLocked(Record r, int events) {
2040 int foregroundUser;
2041 long callingIdentity = Binder.clearCallingIdentity();
2042 boolean valid = false;
2043 try {
2044 foregroundUser = ActivityManager.getCurrentUser();
Hall Liu5fb337f2017-11-22 17:38:15 -08002045 valid = UserHandle.getUserId(r.callerUid) == foregroundUser
2046 && r.matchPhoneStateListenerEvent(events);
Wink Savillea12a7b32012-09-20 10:09:45 -07002047 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07002048 log("validateEventsAndUserLocked: valid=" + valid
Hall Liu5fb337f2017-11-22 17:38:15 -08002049 + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser
Wink Savillea12a7b32012-09-20 10:09:45 -07002050 + " r.events=" + r.events + " events=" + events);
2051 }
2052 } finally {
2053 Binder.restoreCallingIdentity(callingIdentity);
2054 }
2055 return valid;
2056 }
Wink Savillefb40dd42014-06-12 17:02:31 -07002057
2058 private boolean validatePhoneId(int phoneId) {
2059 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07002060 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07002061 return valid;
2062 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07002063
2064 private static void log(String s) {
2065 Rlog.d(TAG, s);
2066 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07002067
xinhe8b79fb62014-11-05 14:55:03 -08002068 boolean idMatch(int rSubId, int subId, int phoneId) {
xinheac11ae92014-12-18 10:02:14 -08002069
2070 if(subId < 0) {
2071 // Invalid case, we need compare phoneId with default one.
2072 return (mDefaultPhoneId == phoneId);
2073 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08002074 if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
xinhee9f16402014-09-25 16:39:28 -07002075 return (subId == mDefaultSubId);
2076 } else {
2077 return (rSubId == subId);
2078 }
2079 }
2080
Hall Liu5fb337f2017-11-22 17:38:15 -08002081 private boolean checkLocationAccess(Record r) {
2082 long token = Binder.clearCallingIdentity();
2083 try {
2084 return LocationAccessPolicy.canAccessCellLocation(mContext,
Svet Ganov33b15092018-03-07 19:53:43 -08002085 r.callingPackage, r.callerUid, r.callerPid,
2086 /*throwOnDeniedPermission*/ false);
Hall Liu5fb337f2017-11-22 17:38:15 -08002087 } finally {
2088 Binder.restoreCallingIdentity(token);
2089 }
2090 }
2091
xinhee9f16402014-09-25 16:39:28 -07002092 private void checkPossibleMissNotify(Record r, int phoneId) {
2093 int events = r.events;
2094
2095 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
2096 try {
2097 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
2098 mServiceState[phoneId]);
2099 r.callback.onServiceStateChanged(
2100 new ServiceState(mServiceState[phoneId]));
2101 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002102 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002103 }
2104 }
2105
2106 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
2107 try {
2108 SignalStrength signalStrength = mSignalStrength[phoneId];
2109 if (DBG) {
2110 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
2111 }
2112 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
2113 } catch (RemoteException ex) {
2114 mRemoveList.add(r.binder);
2115 }
2116 }
2117
2118 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
2119 try {
2120 int gsmSignalStrength = mSignalStrength[phoneId]
2121 .getGsmSignalStrength();
2122 if (DBG) {
2123 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
2124 gsmSignalStrength);
2125 }
2126 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
2127 : gsmSignalStrength));
2128 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002129 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002130 }
2131 }
2132
2133 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
2134 try {
2135 if (DBG_LOC) {
2136 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
2137 + mCellInfo.get(phoneId));
2138 }
Hall Liu5fb337f2017-11-22 17:38:15 -08002139 if (checkLocationAccess(r)) {
2140 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
2141 }
xinhee9f16402014-09-25 16:39:28 -07002142 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002143 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002144 }
2145 }
2146
zxuan35a47022018-01-04 11:24:04 -08002147 if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
2148 try {
2149 if (VDBG) {
2150 log("checkPossibleMissNotify: onUserMobileDataStateChanged phoneId="
2151 + phoneId + " umds=" + mUserMobileDataState[phoneId]);
2152 }
2153 r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
2154 } catch (RemoteException ex) {
2155 mRemoveList.add(r.binder);
2156 }
2157 }
2158
xinhee9f16402014-09-25 16:39:28 -07002159 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
2160 try {
2161 if (VDBG) {
2162 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
2163 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
2164 }
2165 r.callback.onMessageWaitingIndicatorChanged(
2166 mMessageWaiting[phoneId]);
2167 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002168 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002169 }
2170 }
2171
2172 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
2173 try {
2174 if (VDBG) {
2175 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
2176 + phoneId + " cfi=" + mCallForwarding[phoneId]);
2177 }
2178 r.callback.onCallForwardingIndicatorChanged(
2179 mCallForwarding[phoneId]);
2180 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002181 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002182 }
2183 }
2184
2185 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
2186 try {
2187 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
2188 + mCellLocation[phoneId]);
Hall Liu5fb337f2017-11-22 17:38:15 -08002189 if (checkLocationAccess(r)) {
2190 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
2191 }
xinhee9f16402014-09-25 16:39:28 -07002192 } catch (RemoteException ex) {
2193 mRemoveList.add(r.binder);
2194 }
2195 }
2196
2197 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
2198 try {
2199 if (DBG) {
2200 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
2201 + "=" + mDataConnectionState[phoneId]
2202 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
2203 + ")");
2204 }
2205 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
2206 mDataConnectionNetworkType[phoneId]);
2207 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002208 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002209 }
2210 }
2211 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002212}