blob: 1a6faecaecfd64fbd0582b4493b605da9ecd1f6a [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;
Hall Liuee313732018-11-27 14:36:51 -080029import android.os.Build;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030import android.os.Bundle;
Wink Savillea12a7b32012-09-20 10:09:45 -070031import android.os.Handler;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032import android.os.IBinder;
Wink Savillea12a7b32012-09-20 10:09:45 -070033import android.os.Message;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034import android.os.RemoteException;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070035import android.os.UserHandle;
Jordan Liu8218ddd2018-11-28 11:22:39 -080036import android.telephony.CallAttributes;
37import android.telephony.CallQuality;
John Wang963db55d2012-03-30 16:04:06 -070038import android.telephony.CellInfo;
Jack Yud19b6ae2017-04-05 14:12:09 -070039import android.telephony.CellLocation;
chen xu16e24cd2018-12-11 18:09:41 -080040import android.telephony.DataFailCause;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020041import android.telephony.DisconnectCause;
Hall Liu5fb337f2017-11-22 17:38:15 -080042import android.telephony.LocationAccessPolicy;
Malcolm Chene1623652018-08-08 20:27:45 -070043import android.telephony.PhoneCapability;
Jack Yud19b6ae2017-04-05 14:12:09 -070044import android.telephony.PhoneStateListener;
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -080045import android.telephony.PhysicalChannelConfig;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +020046import android.telephony.PreciseCallState;
47import android.telephony.PreciseDataConnectionState;
48import android.telephony.PreciseDisconnectCause;
Jack Yud19b6ae2017-04-05 14:12:09 -070049import android.telephony.Rlog;
50import android.telephony.ServiceState;
51import android.telephony.SignalStrength;
52import android.telephony.SubscriptionManager;
53import android.telephony.TelephonyManager;
chen xu16e24cd2018-12-11 18:09:41 -080054import android.telephony.data.ApnSetting;
sqianbdc5a732018-10-26 13:27:51 -070055import android.telephony.emergency.EmergencyNumber;
chen xu6ac5fc12019-01-24 14:14:13 -080056import android.telephony.ims.ImsReasonInfo;
Jack Yud19b6ae2017-04-05 14:12:09 -070057import android.util.LocalLog;
Yangster4ccebea2018-10-09 17:09:02 -070058import android.util.StatsLog;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059
Malcolm Chen3ceeedd2018-08-27 20:38:29 -070060import com.android.internal.annotations.VisibleForTesting;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080061import com.android.internal.app.IBatteryStats;
Wink Savilled09c4ca2014-11-22 10:08:16 -080062import com.android.internal.telephony.IOnSubscriptionsChangedListener;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063import com.android.internal.telephony.IPhoneStateListener;
Jack Yud19b6ae2017-04-05 14:12:09 -070064import com.android.internal.telephony.ITelephonyRegistry;
Nathan Harold5a0618e2016-12-14 10:48:00 -080065import com.android.internal.telephony.PhoneConstantConversions;
Wink Savillea639b312012-07-10 12:37:54 -070066import com.android.internal.telephony.PhoneConstants;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067import com.android.internal.telephony.TelephonyIntents;
Jeff Davidsond7bf38a2018-02-13 18:11:37 -080068import com.android.internal.telephony.TelephonyPermissions;
chen xubadf2b02019-04-26 17:45:26 -070069import com.android.internal.util.ArrayUtils;
Jeff Sharkeyfe9a53b2017-03-31 14:08:23 -060070import com.android.internal.util.DumpUtils;
Jack Yud19b6ae2017-04-05 14:12:09 -070071import com.android.internal.util.IndentingPrintWriter;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080072import com.android.server.am.BatteryStatsService;
73
Jack Yud19b6ae2017-04-05 14:12:09 -070074import java.io.FileDescriptor;
75import java.io.PrintWriter;
76import java.util.ArrayList;
chen xu5b98d402019-03-22 16:56:34 -070077import java.util.Arrays;
sqian9f93a122018-12-03 22:40:41 -080078import java.util.HashMap;
Jack Yud19b6ae2017-04-05 14:12:09 -070079import java.util.List;
sqian9f93a122018-12-03 22:40:41 -080080import java.util.Map;
Malcolm Chenabbfac22018-02-12 19:15:59 -080081import java.util.NoSuchElementException;
sqian9e9ed182019-03-20 16:17:09 -070082import java.util.stream.Collectors;
Jack Yud19b6ae2017-04-05 14:12:09 -070083
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080084/**
Wink Savillee9b06d72009-05-18 21:47:50 -070085 * Since phone process can be restarted, this class provides a centralized place
86 * that applications can register and be called back from.
Wink Savillee380b982014-07-26 18:24:22 -070087 *
88 * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026
89 * and 15973975 by saving the phoneId of the registrant and then using the
90 * phoneId when deciding to to make a callback. This is necessary because
91 * a subId changes from to a dummy value when a SIM is removed and thus won't
Wink Saville63f03dd2014-10-23 10:44:45 -070092 * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles
Wink Savillee380b982014-07-26 18:24:22 -070093 * the dummy value conversion we properly do the callbacks.
94 *
95 * Eventually we may want to remove the notion of dummy value but for now this
96 * looks like the best approach.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097 */
Malcolm Chen3ceeedd2018-08-27 20:38:29 -070098@VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
99public class TelephonyRegistry extends ITelephonyRegistry.Stub {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 private static final String TAG = "TelephonyRegistry";
Wink Saville6d13bc82014-08-01 11:13:40 -0700101 private static final boolean DBG = false; // STOPSHIP if true
Wink Savillefb40dd42014-06-12 17:02:31 -0700102 private static final boolean DBG_LOC = false; // STOPSHIP if true
Wink Saville6d13bc82014-08-01 11:13:40 -0700103 private static final boolean VDBG = false; // STOPSHIP if true
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800104
105 private static class Record {
Jeff Davidson29da89f2018-02-28 17:50:16 -0800106 Context context;
107
Svet Ganov16a16892015-04-16 10:32:04 -0700108 String callingPackage;
Wink Savillee9b06d72009-05-18 21:47:50 -0700109
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110 IBinder binder;
Wink Savillee9b06d72009-05-18 21:47:50 -0700111
Malcolm Chenabbfac22018-02-12 19:15:59 -0800112 TelephonyRegistryDeathRecipient deathRecipient;
113
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 IPhoneStateListener callback;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800115 IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback;
Malcolm Chen13f31af2018-09-04 22:12:31 -0700116 IOnSubscriptionsChangedListener onOpportunisticSubscriptionsChangedListenerCallback;
Wink Savillee9b06d72009-05-18 21:47:50 -0700117
Hall Liu5fb337f2017-11-22 17:38:15 -0800118 int callerUid;
119 int callerPid;
Wink Savillea12a7b32012-09-20 10:09:45 -0700120
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800121 int events;
Wink Savillea12a7b32012-09-20 10:09:45 -0700122
Wink Savilled09c4ca2014-11-22 10:08:16 -0800123 int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Wink Savillefb40dd42014-06-12 17:02:31 -0700124
Wink Savilled09c4ca2014-11-22 10:08:16 -0800125 int phoneId = SubscriptionManager.INVALID_PHONE_INDEX;
Wink Savillea374c3d2014-11-11 11:48:04 -0800126
127 boolean matchPhoneStateListenerEvent(int events) {
128 return (callback != null) && ((events & this.events) != 0);
129 }
130
Wink Savilled09c4ca2014-11-22 10:08:16 -0800131 boolean matchOnSubscriptionsChangedListener() {
132 return (onSubscriptionsChangedListenerCallback != null);
Wink Savillea374c3d2014-11-11 11:48:04 -0800133 }
Wink Savillee380b982014-07-26 18:24:22 -0700134
Malcolm Chen13f31af2018-09-04 22:12:31 -0700135 boolean matchOnOpportunisticSubscriptionsChangedListener() {
136 return (onOpportunisticSubscriptionsChangedListenerCallback != null);
137 }
138
Tyler Gunnf955e562018-04-26 14:43:31 -0700139 boolean canReadCallLog() {
Jeff Davidson29da89f2018-02-28 17:50:16 -0800140 try {
Tyler Gunnf955e562018-04-26 14:43:31 -0700141 return TelephonyPermissions.checkReadCallLog(
142 context, subId, callerPid, callerUid, callingPackage);
Jeff Davidson29da89f2018-02-28 17:50:16 -0800143 } catch (SecurityException e) {
144 return false;
145 }
146 }
147
Wink Savillea12a7b32012-09-20 10:09:45 -0700148 @Override
149 public String toString() {
Svet Ganov16a16892015-04-16 10:32:04 -0700150 return "{callingPackage=" + callingPackage + " binder=" + binder
151 + " callback=" + callback
Wink Savilled09c4ca2014-11-22 10:08:16 -0800152 + " onSubscriptionsChangedListenererCallback="
Malcolm Chen13f31af2018-09-04 22:12:31 -0700153 + onSubscriptionsChangedListenerCallback
154 + " onOpportunisticSubscriptionsChangedListenererCallback="
155 + onOpportunisticSubscriptionsChangedListenerCallback
Hall Liu5fb337f2017-11-22 17:38:15 -0800156 + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId
Jeff Davidson29da89f2018-02-28 17:50:16 -0800157 + " events=" + Integer.toHexString(events) + "}";
Wink Savillea12a7b32012-09-20 10:09:45 -0700158 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 }
160
161 private final Context mContext;
Wink Savillee9b06d72009-05-18 21:47:50 -0700162
Joe Onorato163d8d92010-10-21 13:21:20 -0400163 // access should be inside synchronized (mRecords) for these two fields
164 private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>();
165 private final ArrayList<Record> mRecords = new ArrayList<Record>();
Wink Savillee9b06d72009-05-18 21:47:50 -0700166
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800167 private final IBatteryStats mBatteryStats;
168
Svet Ganov16a16892015-04-16 10:32:04 -0700169 private final AppOpsManager mAppOps;
170
Malcolm Chen13f31af2018-09-04 22:12:31 -0700171 private boolean mHasNotifySubscriptionInfoChangedOccurred = false;
172
173 private boolean mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = false;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800174
Wink Savillefb40dd42014-06-12 17:02:31 -0700175 private int mNumPhones;
Wink Savillee9b06d72009-05-18 21:47:50 -0700176
Wink Savillefb40dd42014-06-12 17:02:31 -0700177 private int[] mCallState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700178
Wink Savillefb40dd42014-06-12 17:02:31 -0700179 private String[] mCallIncomingNumber;
Wink Savillee9b06d72009-05-18 21:47:50 -0700180
Wink Savillefb40dd42014-06-12 17:02:31 -0700181 private ServiceState[] mServiceState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700182
fionaxu12312f62016-11-14 13:32:14 -0800183 private int[] mVoiceActivationState;
184
185 private int[] mDataActivationState;
186
zxuan35a47022018-01-04 11:24:04 -0800187 private boolean[] mUserMobileDataState;
188
Wink Savillefb40dd42014-06-12 17:02:31 -0700189 private SignalStrength[] mSignalStrength;
Wink Savillee9b06d72009-05-18 21:47:50 -0700190
Wink Savillefb40dd42014-06-12 17:02:31 -0700191 private boolean[] mMessageWaiting;
Wink Savillee9b06d72009-05-18 21:47:50 -0700192
Wink Savillefb40dd42014-06-12 17:02:31 -0700193 private boolean[] mCallForwarding;
Wink Savillee9b06d72009-05-18 21:47:50 -0700194
Wink Savillefb40dd42014-06-12 17:02:31 -0700195 private int[] mDataActivity;
Wink Savillee9b06d72009-05-18 21:47:50 -0700196
Jack Yub1bac542018-03-14 16:23:38 -0700197 // Connection state of default APN type data (i.e. internet) of phones
Wink Savillefb40dd42014-06-12 17:02:31 -0700198 private int[] mDataConnectionState;
Wink Savillee9b06d72009-05-18 21:47:50 -0700199
Wink Savillefb40dd42014-06-12 17:02:31 -0700200 private Bundle[] mCellLocation;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800201
Wink Savillefb40dd42014-06-12 17:02:31 -0700202 private int[] mDataConnectionNetworkType;
Robert Greenwalt98e0b142009-10-08 21:15:52 -0700203
chen xud5deeb12019-04-29 13:57:42 -0700204 private int[] mOtaspMode;
Wink Savillefd2d0132010-10-28 14:22:26 -0700205
Wink Savillefb40dd42014-06-12 17:02:31 -0700206 private ArrayList<List<CellInfo>> mCellInfo = null;
207
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -0800208 private ArrayList<List<PhysicalChannelConfig>> mPhysicalChannelConfigs;
209
sqian9f93a122018-12-03 22:40:41 -0800210 private Map<Integer, List<EmergencyNumber>> mEmergencyNumberList;
211
chen xud5deeb12019-04-29 13:57:42 -0700212 private CallQuality[] mCallQuality;
Jordan Liu8218ddd2018-11-28 11:22:39 -0800213
chen xud5deeb12019-04-29 13:57:42 -0700214 private CallAttributes[] mCallAttributes;
Jordan Liu8218ddd2018-11-28 11:22:39 -0800215
Jordan Liu65ed9d92019-02-19 14:42:07 -0800216 // network type of the call associated with the mCallAttributes and mCallQuality
chen xud5deeb12019-04-29 13:57:42 -0700217 private int[] mCallNetworkType;
Jordan Liu65ed9d92019-02-19 14:42:07 -0800218
Brad Ebingerefed9822018-10-26 10:25:57 -0700219 private int[] mSrvccState;
Wink Savillefb40dd42014-06-12 17:02:31 -0700220
Wink Savilled09c4ca2014-11-22 10:08:16 -0800221 private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
xinhee9f16402014-09-25 16:39:28 -0700222
Wink Savilled09c4ca2014-11-22 10:08:16 -0800223 private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX;
xinhee9f16402014-09-25 16:39:28 -0700224
chen xud5deeb12019-04-29 13:57:42 -0700225 private int[] mRingingCallState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200226
chen xud5deeb12019-04-29 13:57:42 -0700227 private int[] mForegroundCallState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200228
chen xud5deeb12019-04-29 13:57:42 -0700229 private int[] mBackgroundCallState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200230
chen xud5deeb12019-04-29 13:57:42 -0700231 private PreciseCallState[] mPreciseCallState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200232
chen xud5deeb12019-04-29 13:57:42 -0700233 private int[] mCallDisconnectCause;
chen xu6a942d482018-12-12 19:59:30 -0800234
chen xu6ac5fc12019-01-24 14:14:13 -0800235 private List<ImsReasonInfo> mImsReasonInfo = null;
236
chen xud5deeb12019-04-29 13:57:42 -0700237 private int[] mCallPreciseDisconnectCause;
chen xu6a942d482018-12-12 19:59:30 -0800238
Andrew Flynn1f452642015-04-14 22:16:04 -0400239 private boolean mCarrierNetworkChangeState = false;
240
Malcolm Chene1623652018-08-08 20:27:45 -0700241 private PhoneCapability mPhoneCapability = null;
242
Malcolm Chen026451d2019-02-14 19:50:19 -0800243 private int mActiveDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
Malcolm Chen8b53afe2018-09-24 20:01:32 -0700244
Chen Xu7395c632018-10-17 17:53:47 +0000245 @TelephonyManager.RadioPowerState
246 private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE;
247
Jack Yud19b6ae2017-04-05 14:12:09 -0700248 private final LocalLog mLocalLog = new LocalLog(100);
249
Jack Yu0c92c232019-04-04 15:10:17 -0700250 private final LocalLog mListenLog = new LocalLog(100);
251
chen xud5deeb12019-04-29 13:57:42 -0700252 private PreciseDataConnectionState[] mPreciseDataConnectionState;
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200253
Hall Liuee313732018-11-27 14:36:51 -0800254 // Nothing here yet, but putting it here in case we want to add more in the future.
255 static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK = 0;
256
257 static final int ENFORCE_FINE_LOCATION_PERMISSION_MASK =
Hall Liu70bbc162018-03-02 17:44:46 -0800258 PhoneStateListener.LISTEN_CELL_LOCATION
259 | PhoneStateListener.LISTEN_CELL_INFO;
260
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700261 static final int ENFORCE_PHONE_STATE_PERMISSION_MASK =
sqian9f93a122018-12-03 22:40:41 -0800262 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR
263 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR
sqian9e9ed182019-03-20 16:17:09 -0700264 | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST;
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700265
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200266 static final int PRECISE_PHONE_STATE_PERMISSION_MASK =
267 PhoneStateListener.LISTEN_PRECISE_CALL_STATE |
268 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE;
269
Wink Savillea12a7b32012-09-20 10:09:45 -0700270 private static final int MSG_USER_SWITCHED = 1;
Wink Savillefb40dd42014-06-12 17:02:31 -0700271 private static final int MSG_UPDATE_DEFAULT_SUB = 2;
Wink Savillea12a7b32012-09-20 10:09:45 -0700272
273 private final Handler mHandler = new Handler() {
274 @Override
275 public void handleMessage(Message msg) {
276 switch (msg.what) {
277 case MSG_USER_SWITCHED: {
Wink Savillee380b982014-07-26 18:24:22 -0700278 if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1);
Wink Savillefb40dd42014-06-12 17:02:31 -0700279 int numPhones = TelephonyManager.getDefault().getPhoneCount();
280 for (int sub = 0; sub < numPhones; sub++) {
Wink Savillebc027272014-09-08 14:50:58 -0700281 TelephonyRegistry.this.notifyCellLocationForSubscriber(sub,
Wink Savillee380b982014-07-26 18:24:22 -0700282 mCellLocation[sub]);
Wink Savillefb40dd42014-06-12 17:02:31 -0700283 }
284 break;
285 }
xinhee9f16402014-09-25 16:39:28 -0700286 case MSG_UPDATE_DEFAULT_SUB: {
287 int newDefaultPhoneId = msg.arg1;
Wink Saville63f03dd2014-10-23 10:44:45 -0700288 int newDefaultSubId = (Integer)(msg.obj);
xinhee9f16402014-09-25 16:39:28 -0700289 if (VDBG) {
290 log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId
291 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
292 + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId);
293 }
294
295 //Due to possible risk condition,(notify call back using the new
296 //defaultSubId comes before new defaultSubId update) we need to recall all
297 //possible missed notify callback
298 synchronized (mRecords) {
Etan Cohena33cf072014-09-30 10:35:24 -0700299 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800300 if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
Etan Cohena33cf072014-09-30 10:35:24 -0700301 checkPossibleMissNotify(r, newDefaultPhoneId);
302 }
303 }
304 handleRemoveListLocked();
xinhee9f16402014-09-25 16:39:28 -0700305 }
306 mDefaultSubId = newDefaultSubId;
307 mDefaultPhoneId = newDefaultPhoneId;
Jack Yu0c92c232019-04-04 15:10:17 -0700308 mLocalLog.log("Default subscription updated: mDefaultPhoneId="
309 + mDefaultPhoneId + ", mDefaultSubId" + mDefaultSubId);
Wink Savillea12a7b32012-09-20 10:09:45 -0700310 }
311 }
312 }
313 };
314
Malcolm Chenabbfac22018-02-12 19:15:59 -0800315 private class TelephonyRegistryDeathRecipient implements IBinder.DeathRecipient {
316
317 private final IBinder binder;
318
319 TelephonyRegistryDeathRecipient(IBinder binder) {
320 this.binder = binder;
321 }
322
323 @Override
324 public void binderDied() {
325 if (DBG) log("binderDied " + binder);
326 remove(binder);
327 }
328 }
329
Wink Savillea12a7b32012-09-20 10:09:45 -0700330 private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
331 @Override
332 public void onReceive(Context context, Intent intent) {
333 String action = intent.getAction();
Wink Savillee380b982014-07-26 18:24:22 -0700334 if (VDBG) log("mBroadcastReceiver: action=" + action);
Wink Savillea12a7b32012-09-20 10:09:45 -0700335 if (Intent.ACTION_USER_SWITCHED.equals(action)) {
Wink Savilleeeacf932014-06-18 01:07:10 -0700336 int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700337 if (DBG) log("onReceive: userHandle=" + userHandle);
Wink Savilleeeacf932014-06-18 01:07:10 -0700338 mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0));
Wink Savillefb40dd42014-06-12 17:02:31 -0700339 } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) {
Wink Saville63f03dd2014-10-23 10:44:45 -0700340 Integer newDefaultSubIdObj = new Integer(intent.getIntExtra(
Shishir Agrawal7ea3e8b2016-01-25 13:03:07 -0800341 PhoneConstants.SUBSCRIPTION_KEY,
342 SubscriptionManager.getDefaultSubscriptionId()));
chen xuaddc2702019-05-07 16:25:12 -0700343 int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.PHONE_KEY,
xinhee9f16402014-09-25 16:39:28 -0700344 SubscriptionManager.getPhoneId(mDefaultSubId));
Wink Savillee380b982014-07-26 18:24:22 -0700345 if (DBG) {
xinhee9f16402014-09-25 16:39:28 -0700346 log("onReceive:current mDefaultSubId=" + mDefaultSubId
347 + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= "
348 + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700349 }
xinhee9f16402014-09-25 16:39:28 -0700350
Junda Liu985f52c2015-02-23 16:06:51 -0800351 if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId)
xinhee9f16402014-09-25 16:39:28 -0700352 || (newDefaultPhoneId != mDefaultPhoneId))) {
353 mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB,
354 newDefaultPhoneId, 0, newDefaultSubIdObj));
355 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700356 }
357 }
358 };
359
Wink Savillee9b06d72009-05-18 21:47:50 -0700360 // we keep a copy of all of the state so we can send it out when folks
361 // register for it
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800362 //
Wink Savillee9b06d72009-05-18 21:47:50 -0700363 // In these calls we call with the lock held. This is safe becasuse remote
364 // calls go through a oneway interface and local calls going through a
365 // handler before they get to app code.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800366
Malcolm Chen3ceeedd2018-08-27 20:38:29 -0700367 @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
368 public TelephonyRegistry(Context context) {
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700369 CellLocation location = CellLocation.getEmpty();
370
Wink Savillefb40dd42014-06-12 17:02:31 -0700371 mContext = context;
372 mBatteryStats = BatteryStatsService.getService();
Wink Savillefb40dd42014-06-12 17:02:31 -0700373
Wink Savillefb40dd42014-06-12 17:02:31 -0700374 int numPhones = TelephonyManager.getDefault().getPhoneCount();
Jack Yub1bac542018-03-14 16:23:38 -0700375 if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones);
Wink Savillefb40dd42014-06-12 17:02:31 -0700376 mNumPhones = numPhones;
377 mCallState = new int[numPhones];
378 mDataActivity = new int[numPhones];
379 mDataConnectionState = new int[numPhones];
380 mDataConnectionNetworkType = new int[numPhones];
381 mCallIncomingNumber = new String[numPhones];
382 mServiceState = new ServiceState[numPhones];
fionaxu12312f62016-11-14 13:32:14 -0800383 mVoiceActivationState = new int[numPhones];
384 mDataActivationState = new int[numPhones];
zxuan35a47022018-01-04 11:24:04 -0800385 mUserMobileDataState = new boolean[numPhones];
Wink Savillefb40dd42014-06-12 17:02:31 -0700386 mSignalStrength = new SignalStrength[numPhones];
387 mMessageWaiting = new boolean[numPhones];
Wink Savillefb40dd42014-06-12 17:02:31 -0700388 mCallForwarding = new boolean[numPhones];
389 mCellLocation = new Bundle[numPhones];
Brad Ebingerefed9822018-10-26 10:25:57 -0700390 mSrvccState = new int[numPhones];
chen xud5deeb12019-04-29 13:57:42 -0700391 mOtaspMode = new int[numPhones];
392 mPreciseCallState = new PreciseCallState[numPhones];
393 mForegroundCallState = new int[numPhones];
394 mBackgroundCallState = new int[numPhones];
395 mRingingCallState = new int[numPhones];
396 mCallDisconnectCause = new int[numPhones];
397 mCallPreciseDisconnectCause = new int[numPhones];
398 mCallQuality = new CallQuality[numPhones];
399 mCallNetworkType = new int[numPhones];
400 mCallAttributes = new CallAttributes[numPhones];
401 mPreciseDataConnectionState = new PreciseDataConnectionState[numPhones];
402 mCellInfo = new ArrayList<>();
403 mImsReasonInfo = new ArrayList<>();
404 mPhysicalChannelConfigs = new ArrayList<>();
sqian9f93a122018-12-03 22:40:41 -0800405 mEmergencyNumberList = new HashMap<>();
Wink Savillefb40dd42014-06-12 17:02:31 -0700406 for (int i = 0; i < numPhones; i++) {
407 mCallState[i] = TelephonyManager.CALL_STATE_IDLE;
408 mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE;
409 mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN;
fionaxu12312f62016-11-14 13:32:14 -0800410 mVoiceActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
411 mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN;
Wink Savillefb40dd42014-06-12 17:02:31 -0700412 mCallIncomingNumber[i] = "";
413 mServiceState[i] = new ServiceState();
414 mSignalStrength[i] = new SignalStrength();
zxuan35a47022018-01-04 11:24:04 -0800415 mUserMobileDataState[i] = false;
Wink Savillefb40dd42014-06-12 17:02:31 -0700416 mMessageWaiting[i] = false;
417 mCallForwarding[i] = false;
Wink Savillefb40dd42014-06-12 17:02:31 -0700418 mCellLocation[i] = new Bundle();
419 mCellInfo.add(i, null);
chen xu6ac5fc12019-01-24 14:14:13 -0800420 mImsReasonInfo.add(i, null);
Brad Ebingerefed9822018-10-26 10:25:57 -0700421 mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE;
chen xud5deeb12019-04-29 13:57:42 -0700422 mPhysicalChannelConfigs.add(i, new ArrayList<>());
423 mOtaspMode[i] = TelephonyManager.OTASP_UNKNOWN;
424 mCallDisconnectCause[i] = DisconnectCause.NOT_VALID;
425 mCallPreciseDisconnectCause[i] = PreciseDisconnectCause.NOT_VALID;
426 mCallQuality[i] = new CallQuality();
427 mCallAttributes[i] = new CallAttributes(new PreciseCallState(),
428 TelephonyManager.NETWORK_TYPE_UNKNOWN, new CallQuality());
429 mCallNetworkType[i] = TelephonyManager.NETWORK_TYPE_UNKNOWN;
430 mPreciseCallState[i] = new PreciseCallState();
431 mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
432 mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
433 mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE;
434 mPreciseDataConnectionState[i] = new PreciseDataConnectionState();
Wink Savillefb40dd42014-06-12 17:02:31 -0700435 }
436
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700437 // Note that location can be null for non-phone builds like
438 // like the generic one.
439 if (location != null) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700440 for (int i = 0; i < numPhones; i++) {
441 location.fillInNotifierBundle(mCellLocation[i]);
442 }
David 'Digit' Turner4ef8ec32009-09-25 11:33:24 -0700443 }
Svet Ganov16a16892015-04-16 10:32:04 -0700444
445 mAppOps = mContext.getSystemService(AppOpsManager.class);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800446 }
447
Svetoslav Ganova0027152013-06-25 14:59:53 -0700448 public void systemRunning() {
Wink Savillea12a7b32012-09-20 10:09:45 -0700449 // Watch for interesting updates
450 final IntentFilter filter = new IntentFilter();
451 filter.addAction(Intent.ACTION_USER_SWITCHED);
452 filter.addAction(Intent.ACTION_USER_REMOVED);
Wink Savillefb40dd42014-06-12 17:02:31 -0700453 filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED);
Wink Savillef4cd25b2014-07-08 19:03:20 -0700454 log("systemRunning register for intents");
Wink Savillea12a7b32012-09-20 10:09:45 -0700455 mContext.registerReceiver(mBroadcastReceiver, filter);
456 }
457
458 @Override
Svet Ganov16a16892015-04-16 10:32:04 -0700459 public void addOnSubscriptionsChangedListener(String callingPackage,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800460 IOnSubscriptionsChangedListener callback) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700461 int callerUserId = UserHandle.getCallingUserId();
Jeff Davidson29da89f2018-02-28 17:50:16 -0800462 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
Wink Savillea374c3d2014-11-11 11:48:04 -0800463 if (VDBG) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700464 log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
465 + " callerUserId=" + callerUserId + " callback=" + callback
Wink Savillea374c3d2014-11-11 11:48:04 -0800466 + " callback.asBinder=" + callback.asBinder());
467 }
468
Wink Savilled09c4ca2014-11-22 10:08:16 -0800469 synchronized (mRecords) {
470 // register
Malcolm Chenabbfac22018-02-12 19:15:59 -0800471 IBinder b = callback.asBinder();
472 Record r = add(b);
473
474 if (r == null) {
475 return;
Wink Savillea374c3d2014-11-11 11:48:04 -0800476 }
477
Jeff Davidson29da89f2018-02-28 17:50:16 -0800478 r.context = mContext;
Wink Savilled09c4ca2014-11-22 10:08:16 -0800479 r.onSubscriptionsChangedListenerCallback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700480 r.callingPackage = callingPackage;
Hall Liu5fb337f2017-11-22 17:38:15 -0800481 r.callerUid = Binder.getCallingUid();
482 r.callerPid = Binder.getCallingPid();
Wink Savilled09c4ca2014-11-22 10:08:16 -0800483 r.events = 0;
484 if (DBG) {
485 log("listen oscl: Register r=" + r);
486 }
487 // Always notify when registration occurs if there has been a notification.
Malcolm Chen13f31af2018-09-04 22:12:31 -0700488 if (mHasNotifySubscriptionInfoChangedOccurred) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800489 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800490 if (VDBG) log("listen oscl: send to r=" + r);
491 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
492 if (VDBG) log("listen oscl: sent to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800493 } catch (RemoteException e) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800494 if (VDBG) log("listen oscl: remote exception sending to r=" + r + " e=" + e);
Wink Savillea374c3d2014-11-11 11:48:04 -0800495 remove(r.binder);
496 }
Wink Savilled09c4ca2014-11-22 10:08:16 -0800497 } else {
Malcolm Chen13f31af2018-09-04 22:12:31 -0700498 log("listen oscl: mHasNotifySubscriptionInfoChangedOccurred==false no callback");
Wink Savillea374c3d2014-11-11 11:48:04 -0800499 }
Wink Savillea374c3d2014-11-11 11:48:04 -0800500 }
501 }
502
503 @Override
Wink Saville071743f2015-01-12 17:11:04 -0800504 public void removeOnSubscriptionsChangedListener(String pkgForDebug,
Wink Savilled09c4ca2014-11-22 10:08:16 -0800505 IOnSubscriptionsChangedListener callback) {
506 if (DBG) log("listen oscl: Unregister");
Wink Savillea374c3d2014-11-11 11:48:04 -0800507 remove(callback.asBinder());
508 }
509
Malcolm Chen13f31af2018-09-04 22:12:31 -0700510
511 @Override
512 public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage,
513 IOnSubscriptionsChangedListener callback) {
514 int callerUserId = UserHandle.getCallingUserId();
515 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
516 if (VDBG) {
517 log("listen ooscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId()
518 + " callerUserId=" + callerUserId + " callback=" + callback
519 + " callback.asBinder=" + callback.asBinder());
520 }
521
522 synchronized (mRecords) {
523 // register
524 IBinder b = callback.asBinder();
525 Record r = add(b);
526
527 if (r == null) {
528 return;
529 }
530
531 r.context = mContext;
532 r.onOpportunisticSubscriptionsChangedListenerCallback = callback;
533 r.callingPackage = callingPackage;
534 r.callerUid = Binder.getCallingUid();
535 r.callerPid = Binder.getCallingPid();
536 r.events = 0;
537 if (DBG) {
538 log("listen ooscl: Register r=" + r);
539 }
540 // Always notify when registration occurs if there has been a notification.
541 if (mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) {
542 try {
543 if (VDBG) log("listen ooscl: send to r=" + r);
544 r.onOpportunisticSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
545 if (VDBG) log("listen ooscl: sent to r=" + r);
546 } catch (RemoteException e) {
547 if (VDBG) log("listen ooscl: remote exception sending to r=" + r + " e=" + e);
548 remove(r.binder);
549 }
550 } else {
551 log("listen ooscl: hasNotifyOpptSubInfoChangedOccurred==false no callback");
552 }
553 }
554 }
555
Wink Savillea374c3d2014-11-11 11:48:04 -0800556 @Override
557 public void notifySubscriptionInfoChanged() {
558 if (VDBG) log("notifySubscriptionInfoChanged:");
559 synchronized (mRecords) {
Malcolm Chen13f31af2018-09-04 22:12:31 -0700560 if (!mHasNotifySubscriptionInfoChangedOccurred) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800561 log("notifySubscriptionInfoChanged: first invocation mRecords.size="
562 + mRecords.size());
563 }
Malcolm Chen13f31af2018-09-04 22:12:31 -0700564 mHasNotifySubscriptionInfoChangedOccurred = true;
Wink Savillea374c3d2014-11-11 11:48:04 -0800565 mRemoveList.clear();
566 for (Record r : mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800567 if (r.matchOnSubscriptionsChangedListener()) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800568 try {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800569 if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r);
570 r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged();
571 if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r);
Wink Savillea374c3d2014-11-11 11:48:04 -0800572 } catch (RemoteException ex) {
573 if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r);
574 mRemoveList.add(r.binder);
575 }
576 }
577 }
578 handleRemoveListLocked();
579 }
580 }
581
582 @Override
Malcolm Chen13f31af2018-09-04 22:12:31 -0700583 public void notifyOpportunisticSubscriptionInfoChanged() {
584 if (VDBG) log("notifyOpptSubscriptionInfoChanged:");
585 synchronized (mRecords) {
586 if (!mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) {
587 log("notifyOpptSubscriptionInfoChanged: first invocation mRecords.size="
588 + mRecords.size());
589 }
590 mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = true;
591 mRemoveList.clear();
592 for (Record r : mRecords) {
593 if (r.matchOnOpportunisticSubscriptionsChangedListener()) {
594 try {
595 if (VDBG) log("notifyOpptSubChanged: call oosc to r=" + r);
596 r.onOpportunisticSubscriptionsChangedListenerCallback
597 .onSubscriptionsChanged();
598 if (VDBG) log("notifyOpptSubChanged: done oosc to r=" + r);
599 } catch (RemoteException ex) {
600 if (VDBG) log("notifyOpptSubChanged: RemoteException r=" + r);
601 mRemoveList.add(r.binder);
602 }
603 }
604 }
605 handleRemoveListLocked();
606 }
607 }
608
609 @Override
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800610 public void listen(String pkgForDebug, IPhoneStateListener callback, int events,
611 boolean notifyNow) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800612 listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback,
613 events, notifyNow);
Wink Savillefb40dd42014-06-12 17:02:31 -0700614 }
615
616 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -0700617 public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback,
Wink Savillefb40dd42014-06-12 17:02:31 -0700618 int events, boolean notifyNow) {
xinhe43c50292014-09-18 17:56:48 -0700619 listen(pkgForDebug, callback, events, notifyNow, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -0700620 }
621
Svet Ganov16a16892015-04-16 10:32:04 -0700622 private void listen(String callingPackage, IPhoneStateListener callback, int events,
Wink Saville63f03dd2014-10-23 10:44:45 -0700623 boolean notifyNow, int subId) {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700624 int callerUserId = UserHandle.getCallingUserId();
Jeff Davidson29da89f2018-02-28 17:50:16 -0800625 mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
Jack Yu0c92c232019-04-04 15:10:17 -0700626 String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events)
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700627 + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId="
Jack Yu0c92c232019-04-04 15:10:17 -0700628 + UserHandle.myUserId() + " callerUserId=" + callerUserId;
629 mListenLog.log(str);
630 if (VDBG) {
631 log(str);
Wink Savillea12a7b32012-09-20 10:09:45 -0700632 }
xinhe75c2c152014-10-16 11:49:45 -0700633
634 if (events != PhoneStateListener.LISTEN_NONE) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -0800635 // Checks permission and throws SecurityException for disallowed operations. For pre-M
636 // apps whose runtime permission has been revoked, we return immediately to skip sending
637 // events to the app without crashing it.
Jeff Davidson29da89f2018-02-28 17:50:16 -0800638 if (!checkListenerPermission(events, subId, callingPackage, "listen")) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -0800639 return;
Svet Ganov16a16892015-04-16 10:32:04 -0700640 }
641
yifan.baie620ce72017-12-22 14:59:57 +0800642 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800643 synchronized (mRecords) {
644 // register
Malcolm Chenabbfac22018-02-12 19:15:59 -0800645 IBinder b = callback.asBinder();
646 Record r = add(b);
647
648 if (r == null) {
649 return;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800650 }
xinhe43c50292014-09-18 17:56:48 -0700651
Jeff Davidson29da89f2018-02-28 17:50:16 -0800652 r.context = mContext;
xinhe75c2c152014-10-16 11:49:45 -0700653 r.callback = callback;
Svet Ganov16a16892015-04-16 10:32:04 -0700654 r.callingPackage = callingPackage;
Hall Liu5fb337f2017-11-22 17:38:15 -0800655 r.callerUid = Binder.getCallingUid();
656 r.callerPid = Binder.getCallingPid();
xinhe75c2c152014-10-16 11:49:45 -0700657 // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID,
658 // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID
Wink Savillea54bf652014-12-11 13:37:50 -0800659 if (!SubscriptionManager.isValidSubscriptionId(subId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -0800660 r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID;
xinhe75c2c152014-10-16 11:49:45 -0700661 } else {//APP specify subID
662 r.subId = subId;
663 }
yifan.baie620ce72017-12-22 14:59:57 +0800664 r.phoneId = phoneId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800665 r.events = events;
Wink Savillee380b982014-07-26 18:24:22 -0700666 if (DBG) {
xinhe75c2c152014-10-16 11:49:45 -0700667 log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId);
Wink Savillee380b982014-07-26 18:24:22 -0700668 }
Wink Savillefb40dd42014-06-12 17:02:31 -0700669 if (notifyNow && validatePhoneId(phoneId)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800670 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400671 try {
Wink Savillee380b982014-07-26 18:24:22 -0700672 if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]);
Hall Liuee313732018-11-27 14:36:51 -0800673 ServiceState rawSs = new ServiceState(mServiceState[phoneId]);
674 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
675 r.callback.onServiceStateChanged(rawSs);
676 } else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) {
677 r.callback.onServiceStateChanged(rawSs.sanitizeLocationInfo(false));
678 } else {
679 r.callback.onServiceStateChanged(rawSs.sanitizeLocationInfo(true));
680 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400681 } catch (RemoteException ex) {
682 remove(r.binder);
683 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800684 }
685 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
686 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700687 int gsmSignalStrength = mSignalStrength[phoneId]
688 .getGsmSignalStrength();
Wink Savillee9b06d72009-05-18 21:47:50 -0700689 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
690 : gsmSignalStrength));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800691 } catch (RemoteException ex) {
692 remove(r.binder);
693 }
694 }
695 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
696 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700697 r.callback.onMessageWaitingIndicatorChanged(
698 mMessageWaiting[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800699 } catch (RemoteException ex) {
700 remove(r.binder);
701 }
702 }
703 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
704 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700705 r.callback.onCallForwardingIndicatorChanged(
706 mCallForwarding[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800707 } catch (RemoteException ex) {
708 remove(r.binder);
709 }
710 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700711 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400712 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700713 if (DBG_LOC) log("listen: mCellLocation = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700714 + mCellLocation[phoneId]);
Hall Liuee313732018-11-27 14:36:51 -0800715 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Hall Liu5fb337f2017-11-22 17:38:15 -0800716 r.callback.onCellLocationChanged(
717 new Bundle(mCellLocation[phoneId]));
718 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400719 } catch (RemoteException ex) {
720 remove(r.binder);
721 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800722 }
723 if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) {
724 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700725 r.callback.onCallStateChanged(mCallState[phoneId],
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700726 getCallIncomingNumber(r, phoneId));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800727 } catch (RemoteException ex) {
728 remove(r.binder);
729 }
730 }
731 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
732 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700733 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
734 mDataConnectionNetworkType[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800735 } catch (RemoteException ex) {
736 remove(r.binder);
737 }
738 }
739 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) {
740 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700741 r.callback.onDataActivity(mDataActivity[phoneId]);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800742 } catch (RemoteException ex) {
743 remove(r.binder);
744 }
745 }
Wink Savillee9b06d72009-05-18 21:47:50 -0700746 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
747 try {
Wink Savillefb40dd42014-06-12 17:02:31 -0700748 r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]);
Wink Savillee9b06d72009-05-18 21:47:50 -0700749 } catch (RemoteException ex) {
750 remove(r.binder);
751 }
752 }
Wink Savillefd2d0132010-10-28 14:22:26 -0700753 if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) {
754 try {
chen xud5deeb12019-04-29 13:57:42 -0700755 r.callback.onOtaspChanged(mOtaspMode[phoneId]);
Wink Savillefd2d0132010-10-28 14:22:26 -0700756 } catch (RemoteException ex) {
757 remove(r.binder);
758 }
759 }
Wink Savillea12a7b32012-09-20 10:09:45 -0700760 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
John Wang963db55d2012-03-30 16:04:06 -0700761 try {
Wink Savillef4cd25b2014-07-08 19:03:20 -0700762 if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = "
Wink Savillefb40dd42014-06-12 17:02:31 -0700763 + mCellInfo.get(phoneId));
Hall Liuee313732018-11-27 14:36:51 -0800764 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Hall Liu5fb337f2017-11-22 17:38:15 -0800765 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
766 }
John Wang963db55d2012-03-30 16:04:06 -0700767 } catch (RemoteException ex) {
768 remove(r.binder);
769 }
770 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200771 if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) {
772 try {
chen xud5deeb12019-04-29 13:57:42 -0700773 r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200774 } catch (RemoteException ex) {
775 remove(r.binder);
776 }
777 }
chen xu6a942d482018-12-12 19:59:30 -0800778 if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) {
779 try {
chen xud5deeb12019-04-29 13:57:42 -0700780 r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId],
781 mCallPreciseDisconnectCause[phoneId]);
chen xu6a942d482018-12-12 19:59:30 -0800782 } catch (RemoteException ex) {
783 remove(r.binder);
784 }
785 }
chen xu6ac5fc12019-01-24 14:14:13 -0800786 if ((events & PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) != 0) {
787 try {
788 r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(phoneId));
789 } catch (RemoteException ex) {
790 remove(r.binder);
791 }
792 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200793 if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) {
794 try {
795 r.callback.onPreciseDataConnectionStateChanged(
chen xud5deeb12019-04-29 13:57:42 -0700796 mPreciseDataConnectionState[phoneId]);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +0200797 } catch (RemoteException ex) {
798 remove(r.binder);
799 }
800 }
Andrew Flynn1f452642015-04-14 22:16:04 -0400801 if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) {
802 try {
803 r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState);
804 } catch (RemoteException ex) {
805 remove(r.binder);
806 }
807 }
fionaxu12312f62016-11-14 13:32:14 -0800808 if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) !=0) {
809 try {
810 r.callback.onVoiceActivationStateChanged(mVoiceActivationState[phoneId]);
811 } catch (RemoteException ex) {
812 remove(r.binder);
813 }
814 }
815 if ((events & PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) !=0) {
816 try {
817 r.callback.onDataActivationStateChanged(mDataActivationState[phoneId]);
818 } catch (RemoteException ex) {
819 remove(r.binder);
820 }
821 }
zxuan35a47022018-01-04 11:24:04 -0800822 if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
823 try {
824 r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
825 } catch (RemoteException ex) {
826 remove(r.binder);
827 }
828 }
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -0800829 if ((events & PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) != 0) {
830 try {
831 r.callback.onPhysicalChannelConfigurationChanged(
832 mPhysicalChannelConfigs.get(phoneId));
833 } catch (RemoteException ex) {
834 remove(r.binder);
835 }
836 }
sqian9f93a122018-12-03 22:40:41 -0800837 if ((events & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) {
838 try {
839 r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
840 } catch (RemoteException ex) {
841 remove(r.binder);
842 }
843 }
Malcolm Chene1623652018-08-08 20:27:45 -0700844 if ((events & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) {
845 try {
846 r.callback.onPhoneCapabilityChanged(mPhoneCapability);
847 } catch (RemoteException ex) {
848 remove(r.binder);
849 }
850 }
Nazanin Bakhshi026c42d2019-03-01 10:10:22 -0800851 if ((events & PhoneStateListener
sqian9e9ed182019-03-20 16:17:09 -0700852 .LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0
853 && TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
854 r.context, r.callerPid, r.callerUid, r.callingPackage,
855 "listen_active_data_subid_change")) {
Malcolm Chen8b53afe2018-09-24 20:01:32 -0700856 try {
Malcolm Chen026451d2019-02-14 19:50:19 -0800857 r.callback.onActiveDataSubIdChanged(mActiveDataSubId);
Malcolm Chen8b53afe2018-09-24 20:01:32 -0700858 } catch (RemoteException ex) {
859 remove(r.binder);
860 }
861 }
Chen Xu7395c632018-10-17 17:53:47 +0000862 if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) {
863 try {
864 r.callback.onRadioPowerStateChanged(mRadioPowerState);
865 } catch (RemoteException ex) {
866 remove(r.binder);
867 }
868 }
Brad Ebingerefed9822018-10-26 10:25:57 -0700869 if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
870 try {
871 r.callback.onSrvccStateChanged(mSrvccState[phoneId]);
872 } catch (RemoteException ex) {
873 remove(r.binder);
874 }
875 }
Jordan Liu8218ddd2018-11-28 11:22:39 -0800876 if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) {
877 try {
chen xud5deeb12019-04-29 13:57:42 -0700878 r.callback.onCallAttributesChanged(mCallAttributes[phoneId]);
Jordan Liu8218ddd2018-11-28 11:22:39 -0800879 } catch (RemoteException ex) {
880 remove(r.binder);
881 }
882 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800883 }
884 }
885 } else {
xinhe75c2c152014-10-16 11:49:45 -0700886 if(DBG) log("listen: Unregister");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800887 remove(callback.asBinder());
888 }
889 }
890
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700891 private String getCallIncomingNumber(Record record, int phoneId) {
Tyler Gunnf955e562018-04-26 14:43:31 -0700892 // Only reveal the incoming number if the record has read call log permission.
893 return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : "";
Fyodor Kupolov309b2f632015-06-03 16:29:01 -0700894 }
895
Malcolm Chenabbfac22018-02-12 19:15:59 -0800896 private Record add(IBinder binder) {
897 Record r;
898
899 synchronized (mRecords) {
900 final int N = mRecords.size();
901 for (int i = 0; i < N; i++) {
902 r = mRecords.get(i);
903 if (binder == r.binder) {
904 // Already existed.
905 return r;
906 }
907 }
908 r = new Record();
909 r.binder = binder;
910 r.deathRecipient = new TelephonyRegistryDeathRecipient(binder);
911
912 try {
913 binder.linkToDeath(r.deathRecipient, 0);
914 } catch (RemoteException e) {
915 if (VDBG) log("LinkToDeath remote exception sending to r=" + r + " e=" + e);
916 // Binder already died. Return null.
917 return null;
918 }
919
920 mRecords.add(r);
921 if (DBG) log("add new record");
922 }
923
924 return r;
925 }
926
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800927 private void remove(IBinder binder) {
928 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -0700929 final int recordCount = mRecords.size();
930 for (int i = 0; i < recordCount; i++) {
Malcolm Chenabbfac22018-02-12 19:15:59 -0800931 Record r = mRecords.get(i);
932 if (r.binder == binder) {
xinheac11ae92014-12-18 10:02:14 -0800933 if (DBG) {
Malcolm Chenabbfac22018-02-12 19:15:59 -0800934 log("remove: binder=" + binder + " r.callingPackage " + r.callingPackage
935 + " r.callback " + r.callback);
xinheac11ae92014-12-18 10:02:14 -0800936 }
Malcolm Chenabbfac22018-02-12 19:15:59 -0800937
938 if (r.deathRecipient != null) {
939 try {
940 binder.unlinkToDeath(r.deathRecipient, 0);
941 } catch (NoSuchElementException e) {
942 if (VDBG) log("UnlinkToDeath NoSuchElementException sending to r="
943 + r + " e=" + e);
944 }
945 }
946
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800947 mRecords.remove(i);
948 return;
949 }
950 }
951 }
952 }
953
Tyler Gunnf955e562018-04-26 14:43:31 -0700954 public void notifyCallState(int state, String phoneNumber) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -0700955 if (!checkNotifyPermission("notifyCallState()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -0700956 return;
957 }
xinhe43c50292014-09-18 17:56:48 -0700958
959 if (VDBG) {
Tyler Gunnf955e562018-04-26 14:43:31 -0700960 log("notifyCallState: state=" + state + " phoneNumber=" + phoneNumber);
xinhe43c50292014-09-18 17:56:48 -0700961 }
962
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800963 synchronized (mRecords) {
Robert Greenwalt02648a42010-05-18 10:52:51 -0700964 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -0800965 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -0800966 (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800967 try {
Tyler Gunnf955e562018-04-26 14:43:31 -0700968 // Ensure the listener has read call log permission; if they do not return
969 // an empty phone number.
970 String phoneNumberOrEmpty = r.canReadCallLog() ? phoneNumber : "";
971 r.callback.onCallStateChanged(state, phoneNumberOrEmpty);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800972 } catch (RemoteException ex) {
Joe Onorato163d8d92010-10-21 13:21:20 -0400973 mRemoveList.add(r.binder);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800974 }
975 }
976 }
Joe Onorato163d8d92010-10-21 13:21:20 -0400977 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800978 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700979
980 // Called only by Telecomm to communicate call state across different phone accounts. So
981 // there is no need to add a valid subId or slotId.
Tyler Gunnf955e562018-04-26 14:43:31 -0700982 broadcastCallStateChanged(state, phoneNumber,
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700983 SubscriptionManager.INVALID_PHONE_INDEX,
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -0700984 SubscriptionManager.INVALID_SUBSCRIPTION_ID);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800985 }
986
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700987 public void notifyCallStateForPhoneId(int phoneId, int subId, int state,
988 String incomingNumber) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700989 if (!checkNotifyPermission("notifyCallState()")) {
990 return;
991 }
Wink Savillee380b982014-07-26 18:24:22 -0700992 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -0700993 log("notifyCallStateForPhoneId: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -0700994 + " state=" + state + " incomingNumber=" + incomingNumber);
995 }
996 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -0700997 if (validatePhoneId(phoneId)) {
998 mCallState[phoneId] = state;
999 mCallIncomingNumber[phoneId] = incomingNumber;
1000 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001001 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) &&
xinhe43c50292014-09-18 17:56:48 -07001002 (r.subId == subId) &&
Wink Savilled09c4ca2014-11-22 10:08:16 -08001003 (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001004 try {
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07001005 String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId);
1006 r.callback.onCallStateChanged(state, incomingNumberOrEmpty);
Wink Savillefb40dd42014-06-12 17:02:31 -07001007 } catch (RemoteException ex) {
1008 mRemoveList.add(r.binder);
1009 }
1010 }
1011 }
1012 }
1013 handleRemoveListLocked();
1014 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001015 broadcastCallStateChanged(state, incomingNumber, phoneId, subId);
Wink Savillefb40dd42014-06-12 17:02:31 -07001016 }
1017
Wink Saville63f03dd2014-10-23 10:44:45 -07001018 public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001019 if (!checkNotifyPermission("notifyServiceState()")){
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001020 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001021 }
xinhe43c50292014-09-18 17:56:48 -07001022
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001023 synchronized (mRecords) {
Jack Yud19b6ae2017-04-05 14:12:09 -07001024 String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId
1025 + " state=" + state;
Wink Savillee380b982014-07-26 18:24:22 -07001026 if (VDBG) {
Jack Yud19b6ae2017-04-05 14:12:09 -07001027 log(str);
Wink Saville47d8d1b2014-07-10 13:01:52 -07001028 }
Jack Yud19b6ae2017-04-05 14:12:09 -07001029 mLocalLog.log(str);
Wink Savillefb40dd42014-06-12 17:02:31 -07001030 if (validatePhoneId(phoneId)) {
1031 mServiceState[phoneId] = state;
Wink Saville47d8d1b2014-07-10 13:01:52 -07001032
Wink Savillefb40dd42014-06-12 17:02:31 -07001033 for (Record r : mRecords) {
Wink Savillee380b982014-07-26 18:24:22 -07001034 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001035 log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId
Wink Savillee380b982014-07-26 18:24:22 -07001036 + " phoneId=" + phoneId + " state=" + state);
1037 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001038 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) &&
xinhe8b79fb62014-11-05 14:55:03 -08001039 idMatch(r.subId, subId, phoneId)) {
Hall Liuee313732018-11-27 14:36:51 -08001040
Wink Savillefb40dd42014-06-12 17:02:31 -07001041 try {
Hall Liuee313732018-11-27 14:36:51 -08001042 ServiceState stateToSend;
1043 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
1044 stateToSend = new ServiceState(state);
1045 } else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) {
1046 stateToSend = state.sanitizeLocationInfo(false);
1047 } else {
1048 stateToSend = state.sanitizeLocationInfo(true);
1049 }
Wink Savillee380b982014-07-26 18:24:22 -07001050 if (DBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001051 log("notifyServiceStateForSubscriber: callback.onSSC r=" + r
Wink Savillee380b982014-07-26 18:24:22 -07001052 + " subId=" + subId + " phoneId=" + phoneId
1053 + " state=" + state);
1054 }
Hall Liuee313732018-11-27 14:36:51 -08001055 r.callback.onServiceStateChanged(stateToSend);
Wink Savillefb40dd42014-06-12 17:02:31 -07001056 } catch (RemoteException ex) {
1057 mRemoveList.add(r.binder);
1058 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001059 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001060 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001061 } else {
Wink Savillebc027272014-09-08 14:50:58 -07001062 log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001063 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001064 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001065 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001066 broadcastServiceStateChanged(state, phoneId, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001067 }
1068
fionaxu12312f62016-11-14 13:32:14 -08001069 public void notifySimActivationStateChangedForPhoneId(int phoneId, int subId,
1070 int activationType, int activationState) {
1071 if (!checkNotifyPermission("notifySimActivationState()")){
1072 return;
1073 }
1074 if (VDBG) {
1075 log("notifySimActivationStateForPhoneId: subId=" + subId + " phoneId=" + phoneId
1076 + "type=" + activationType + " state=" + activationState);
1077 }
1078 synchronized (mRecords) {
1079 if (validatePhoneId(phoneId)) {
1080 switch (activationType) {
1081 case PhoneConstants.SIM_ACTIVATION_TYPE_VOICE:
1082 mVoiceActivationState[phoneId] = activationState;
1083 break;
1084 case PhoneConstants.SIM_ACTIVATION_TYPE_DATA:
1085 mDataActivationState[phoneId] = activationState;
1086 break;
1087 default:
1088 return;
1089 }
1090 for (Record r : mRecords) {
1091 if (VDBG) {
1092 log("notifySimActivationStateForPhoneId: r=" + r + " subId=" + subId
1093 + " phoneId=" + phoneId + "type=" + activationType
1094 + " state=" + activationState);
1095 }
1096 try {
1097 if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_VOICE) &&
1098 r.matchPhoneStateListenerEvent(
1099 PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) &&
1100 idMatch(r.subId, subId, phoneId)) {
1101 if (DBG) {
1102 log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r
1103 + " subId=" + subId + " phoneId=" + phoneId
1104 + " state=" + activationState);
1105 }
1106 r.callback.onVoiceActivationStateChanged(activationState);
1107 }
1108 if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_DATA) &&
1109 r.matchPhoneStateListenerEvent(
1110 PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) &&
1111 idMatch(r.subId, subId, phoneId)) {
1112 if (DBG) {
1113 log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r
1114 + " subId=" + subId + " phoneId=" + phoneId
1115 + " state=" + activationState);
1116 }
1117 r.callback.onDataActivationStateChanged(activationState);
1118 }
1119 } catch (RemoteException ex) {
1120 mRemoveList.add(r.binder);
1121 }
1122 }
1123 } else {
1124 log("notifySimActivationStateForPhoneId: INVALID phoneId=" + phoneId);
1125 }
1126 handleRemoveListLocked();
1127 }
1128 }
1129
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001130 public void notifySignalStrengthForPhoneId(int phoneId, int subId,
1131 SignalStrength signalStrength) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001132 if (!checkNotifyPermission("notifySignalStrength()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001133 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001134 }
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001135 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001136 log("notifySignalStrengthForPhoneId: subId=" + subId
1137 +" phoneId=" + phoneId + " signalStrength=" + signalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001138 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001139
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001140 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001141 if (validatePhoneId(phoneId)) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001142 if (VDBG) log("notifySignalStrengthForPhoneId: valid phoneId=" + phoneId);
Wink Savillefb40dd42014-06-12 17:02:31 -07001143 mSignalStrength[phoneId] = signalStrength;
1144 for (Record r : mRecords) {
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001145 if (VDBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001146 log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001147 + " phoneId=" + phoneId + " ss=" + signalStrength);
1148 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001149 if (r.matchPhoneStateListenerEvent(
1150 PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) &&
xinhe8b79fb62014-11-05 14:55:03 -08001151 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001152 try {
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001153 if (DBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001154 log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001155 + " subId=" + subId + " phoneId=" + phoneId
1156 + " ss=" + signalStrength);
1157 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001158 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
1159 } catch (RemoteException ex) {
1160 mRemoveList.add(r.binder);
1161 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001162 }
Wink Savillea374c3d2014-11-11 11:48:04 -08001163 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) &&
xinhe8b79fb62014-11-05 14:55:03 -08001164 idMatch(r.subId, subId, phoneId)){
Wink Savillefb40dd42014-06-12 17:02:31 -07001165 try {
1166 int gsmSignalStrength = signalStrength.getGsmSignalStrength();
Wink Savillef4cd25b2014-07-08 19:03:20 -07001167 int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength);
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001168 if (DBG) {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001169 log("notifySignalStrengthForPhoneId: callback.onSS r=" + r
Amit Mahajan1466a9c2015-04-27 22:58:29 +00001170 + " subId=" + subId + " phoneId=" + phoneId
1171 + " gsmSS=" + gsmSignalStrength + " ss=" + ss);
1172 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001173 r.callback.onSignalStrengthChanged(ss);
Wink Savillefb40dd42014-06-12 17:02:31 -07001174 } catch (RemoteException ex) {
1175 mRemoveList.add(r.binder);
1176 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001177 }
1178 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07001179 } else {
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001180 log("notifySignalStrengthForPhoneId: invalid phoneId=" + phoneId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001181 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001182 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001183 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07001184 broadcastSignalStrengthChanged(signalStrength, phoneId, subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001185 }
1186
Andrew Flynn1f452642015-04-14 22:16:04 -04001187 @Override
1188 public void notifyCarrierNetworkChange(boolean active) {
chen xubadf2b02019-04-26 17:45:26 -07001189 // only CarrierService with carrier privilege rule should have the permission
1190 int[] subIds = Arrays.stream(SubscriptionManager.from(mContext)
chen xu5b98d402019-03-22 16:56:34 -07001191 .getActiveSubscriptionIdList())
chen xubadf2b02019-04-26 17:45:26 -07001192 .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(i)).toArray();
1193 if (ArrayUtils.isEmpty(subIds)) {
chen xu627d1b22019-04-11 02:16:19 -07001194 loge("notifyCarrierNetworkChange without carrier privilege");
chen xubadf2b02019-04-26 17:45:26 -07001195 // the active subId does not have carrier privilege.
chen xu627d1b22019-04-11 02:16:19 -07001196 throw new SecurityException("notifyCarrierNetworkChange without carrier privilege");
chen xu5b98d402019-03-22 16:56:34 -07001197 }
Andrew Flynn1f452642015-04-14 22:16:04 -04001198
1199 synchronized (mRecords) {
1200 mCarrierNetworkChangeState = active;
chen xubadf2b02019-04-26 17:45:26 -07001201 for (int subId : subIds) {
1202 int phoneId = SubscriptionManager.getPhoneId(subId);
1203
1204 if (VDBG) {
1205 log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId);
1206 }
1207 for (Record r : mRecords) {
1208 if (r.matchPhoneStateListenerEvent(
1209 PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) &&
1210 idMatch(r.subId, subId, phoneId)) {
1211 try {
1212 r.callback.onCarrierNetworkChange(active);
1213 } catch (RemoteException ex) {
1214 mRemoveList.add(r.binder);
1215 }
Andrew Flynn1f452642015-04-14 22:16:04 -04001216 }
1217 }
1218 }
1219 handleRemoveListLocked();
1220 }
1221 }
1222
Wink Savilleb208a242012-07-25 14:08:09 -07001223 public void notifyCellInfo(List<CellInfo> cellInfo) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001224 notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo);
Wink Savillefb40dd42014-06-12 17:02:31 -07001225 }
1226
Wink Saville63f03dd2014-10-23 10:44:45 -07001227 public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) {
John Wang963db55d2012-03-30 16:04:06 -07001228 if (!checkNotifyPermission("notifyCellInfo()")) {
1229 return;
1230 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001231 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001232 log("notifyCellInfoForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001233 + " cellInfo=" + cellInfo);
1234 }
yifan.baie620ce72017-12-22 14:59:57 +08001235 int phoneId = SubscriptionManager.getPhoneId(subId);
John Wang963db55d2012-03-30 16:04:06 -07001236 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001237 if (validatePhoneId(phoneId)) {
1238 mCellInfo.set(phoneId, cellInfo);
1239 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001240 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) &&
Hall Liu5fb337f2017-11-22 17:38:15 -08001241 idMatch(r.subId, subId, phoneId) &&
Hall Liuee313732018-11-27 14:36:51 -08001242 checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001243 try {
1244 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001245 log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r);
Wink Savillefb40dd42014-06-12 17:02:31 -07001246 }
1247 r.callback.onCellInfoChanged(cellInfo);
1248 } catch (RemoteException ex) {
1249 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001250 }
John Wang963db55d2012-03-30 16:04:06 -07001251 }
1252 }
1253 }
1254 handleRemoveListLocked();
1255 }
1256 }
1257
Eric Schwarzenbach4ce04dd2018-01-24 13:21:27 -08001258 public void notifyPhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) {
1259 notifyPhysicalChannelConfigurationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
1260 configs);
1261 }
1262
1263 public void notifyPhysicalChannelConfigurationForSubscriber(int subId,
1264 List<PhysicalChannelConfig> configs) {
1265 if (!checkNotifyPermission("notifyPhysicalChannelConfiguration()")) {
1266 return;
1267 }
1268
1269 if (VDBG) {
1270 log("notifyPhysicalChannelConfiguration: subId=" + subId + " configs=" + configs);
1271 }
1272
1273 synchronized (mRecords) {
1274 int phoneId = SubscriptionManager.getPhoneId(subId);
1275 if (validatePhoneId(phoneId)) {
1276 mPhysicalChannelConfigs.set(phoneId, configs);
1277 for (Record r : mRecords) {
1278 if (r.matchPhoneStateListenerEvent(
1279 PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION)
1280 && idMatch(r.subId, subId, phoneId)) {
1281 try {
1282 if (DBG_LOC) {
1283 log("notifyPhysicalChannelConfiguration: mPhysicalChannelConfigs="
1284 + configs + " r=" + r);
1285 }
1286 r.callback.onPhysicalChannelConfigurationChanged(configs);
1287 } catch (RemoteException ex) {
1288 mRemoveList.add(r.binder);
1289 }
1290 }
1291 }
1292 }
1293 handleRemoveListLocked();
1294 }
1295 }
1296
xinhe43c50292014-09-18 17:56:48 -07001297 @Override
Wink Saville63f03dd2014-10-23 10:44:45 -07001298 public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001299 if (!checkNotifyPermission("notifyMessageWaitingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001300 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001301 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001302 if (VDBG) {
xinhe43c50292014-09-18 17:56:48 -07001303 log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId
Wink Savillefb40dd42014-06-12 17:02:31 -07001304 + " mwi=" + mwi);
1305 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001306 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001307 if (validatePhoneId(phoneId)) {
1308 mMessageWaiting[phoneId] = mwi;
1309 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001310 if (r.matchPhoneStateListenerEvent(
1311 PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -08001312 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001313 try {
1314 r.callback.onMessageWaitingIndicatorChanged(mwi);
1315 } catch (RemoteException ex) {
1316 mRemoveList.add(r.binder);
1317 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001318 }
1319 }
1320 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001321 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001322 }
1323 }
1324
zxuan35a47022018-01-04 11:24:04 -08001325 public void notifyUserMobileDataStateChangedForPhoneId(int phoneId, int subId, boolean state) {
1326 if (!checkNotifyPermission("notifyUserMobileDataStateChanged()")) {
1327 return;
1328 }
1329 if (VDBG) {
SongFerngWang0b109f5f2019-04-09 17:29:29 +08001330 log("notifyUserMobileDataStateChangedForSubscriberPhoneID: PhoneId=" + phoneId
1331 + " subId=" + subId + " state=" + state);
zxuan35a47022018-01-04 11:24:04 -08001332 }
1333 synchronized (mRecords) {
1334 if (validatePhoneId(phoneId)) {
SongFerngWang0b109f5f2019-04-09 17:29:29 +08001335 mUserMobileDataState[phoneId] = state;
zxuan35a47022018-01-04 11:24:04 -08001336 for (Record r : mRecords) {
1337 if (r.matchPhoneStateListenerEvent(
1338 PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) &&
1339 idMatch(r.subId, subId, phoneId)) {
1340 try {
1341 r.callback.onUserMobileDataStateChanged(state);
1342 } catch (RemoteException ex) {
1343 mRemoveList.add(r.binder);
1344 }
1345 }
1346 }
1347 }
1348 handleRemoveListLocked();
1349 }
1350 }
1351
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001352 public void notifyCallForwardingChanged(boolean cfi) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001353 notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi);
Wink Savillefb40dd42014-06-12 17:02:31 -07001354 }
1355
Wink Saville63f03dd2014-10-23 10:44:45 -07001356 public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001357 if (!checkNotifyPermission("notifyCallForwardingChanged()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001358 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001359 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001360 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001361 log("notifyCallForwardingChangedForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001362 + " cfi=" + cfi);
1363 }
yifan.baie620ce72017-12-22 14:59:57 +08001364 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001365 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001366 if (validatePhoneId(phoneId)) {
1367 mCallForwarding[phoneId] = cfi;
1368 for (Record r : mRecords) {
Wink Savillea374c3d2014-11-11 11:48:04 -08001369 if (r.matchPhoneStateListenerEvent(
1370 PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) &&
xinhe8b79fb62014-11-05 14:55:03 -08001371 idMatch(r.subId, subId, phoneId)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001372 try {
1373 r.callback.onCallForwardingIndicatorChanged(cfi);
1374 } catch (RemoteException ex) {
1375 mRemoveList.add(r.binder);
1376 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001377 }
1378 }
1379 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001380 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001381 }
1382 }
1383
1384 public void notifyDataActivity(int state) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001385 notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state);
Wink Savillefb40dd42014-06-12 17:02:31 -07001386 }
1387
Wink Saville63f03dd2014-10-23 10:44:45 -07001388 public void notifyDataActivityForSubscriber(int subId, int state) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001389 if (!checkNotifyPermission("notifyDataActivity()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001390 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001391 }
yifan.baie620ce72017-12-22 14:59:57 +08001392 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001393 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001394 if (validatePhoneId(phoneId)) {
1395 mDataActivity[phoneId] = state;
1396 for (Record r : mRecords) {
xu.peng9071ced2016-03-22 18:21:28 +08001397 // Notify by correct subId.
1398 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY) &&
1399 idMatch(r.subId, subId, phoneId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001400 try {
1401 r.callback.onDataActivity(state);
1402 } catch (RemoteException ex) {
1403 mRemoveList.add(r.binder);
1404 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001405 }
1406 }
1407 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001408 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001409 }
1410 }
1411
Jack Yu4d1c9452019-01-02 16:51:08 -08001412 public void notifyDataConnection(int state, boolean isDataAllowed, String apn, String apnType,
1413 LinkProperties linkProperties,
1414 NetworkCapabilities networkCapabilities, int networkType,
1415 boolean roaming) {
chen xud5deeb12019-04-29 13:57:42 -07001416 notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX,
1417 SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state,
Jack Yu4d1c9452019-01-02 16:51:08 -08001418 isDataAllowed, apn, apnType, linkProperties,
1419 networkCapabilities, networkType, roaming);
Wink Savillefb40dd42014-06-12 17:02:31 -07001420 }
1421
chen xud5deeb12019-04-29 13:57:42 -07001422 public void notifyDataConnectionForSubscriber(int phoneId, int subId, int state,
1423 boolean isDataAllowed,
Jack Yu4d1c9452019-01-02 16:51:08 -08001424 String apn, String apnType,
Wink Savillefb40dd42014-06-12 17:02:31 -07001425 LinkProperties linkProperties, NetworkCapabilities networkCapabilities,
1426 int networkType, boolean roaming) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001427 if (!checkNotifyPermission("notifyDataConnection()" )) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001428 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001429 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001430 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001431 log("notifyDataConnectionForSubscriber: subId=" + subId
Jack Yubaeec622017-05-01 17:01:11 -07001432 + " state=" + state + " isDataAllowed=" + isDataAllowed
Wink Savillea12a7b32012-09-20 10:09:45 -07001433 + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType
xinheac11ae92014-12-18 10:02:14 -08001434 + " mRecords.size()=" + mRecords.size());
Wink Savillec9acde92011-09-21 11:05:43 -07001435 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001436 synchronized (mRecords) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001437 if (validatePhoneId(phoneId)) {
Jack Yub1bac542018-03-14 16:23:38 -07001438 // We only call the callback when the change is for default APN type.
1439 if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType)
1440 && (mDataConnectionState[phoneId] != state
1441 || mDataConnectionNetworkType[phoneId] != networkType)) {
Jack Yu0c92c232019-04-04 15:10:17 -07001442 String str = "onDataConnectionStateChanged("
1443 + TelephonyManager.dataStateToString(state)
1444 + ", " + TelephonyManager.getNetworkTypeName(networkType)
1445 + ") subId=" + subId + ", phoneId=" + phoneId;
Jack Yud19b6ae2017-04-05 14:12:09 -07001446 log(str);
1447 mLocalLog.log(str);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001448 for (Record r : mRecords) {
1449 if (r.matchPhoneStateListenerEvent(
chen xud5deeb12019-04-29 13:57:42 -07001450 PhoneStateListener.LISTEN_DATA_CONNECTION_STATE)
1451 && idMatch(r.subId, subId, phoneId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001452 try {
Jack Yud19b6ae2017-04-05 14:12:09 -07001453 if (DBG) {
1454 log("Notify data connection state changed on sub: " + subId);
1455 }
Jack Yub1bac542018-03-14 16:23:38 -07001456 r.callback.onDataConnectionStateChanged(state, networkType);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001457 } catch (RemoteException ex) {
1458 mRemoveList.add(r.binder);
1459 }
1460 }
1461 }
1462 handleRemoveListLocked();
Jack Yub1bac542018-03-14 16:23:38 -07001463
1464 mDataConnectionState[phoneId] = state;
1465 mDataConnectionNetworkType[phoneId] = networkType;
Wink Savilled09c4ca2014-11-22 10:08:16 -08001466 }
chen xud5deeb12019-04-29 13:57:42 -07001467 mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
1468 state, networkType,
chen xu16e24cd2018-12-11 18:09:41 -08001469 ApnSetting.getApnTypesBitmaskFromString(apnType), apn,
1470 linkProperties, DataFailCause.NONE);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001471 for (Record r : mRecords) {
1472 if (r.matchPhoneStateListenerEvent(
chen xud5deeb12019-04-29 13:57:42 -07001473 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
1474 && idMatch(r.subId, subId, phoneId)) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001475 try {
Jack Yud19b6ae2017-04-05 14:12:09 -07001476 r.callback.onPreciseDataConnectionStateChanged(
chen xud5deeb12019-04-29 13:57:42 -07001477 mPreciseDataConnectionState[phoneId]);
Wink Savilled09c4ca2014-11-22 10:08:16 -08001478 } catch (RemoteException ex) {
1479 mRemoveList.add(r.binder);
1480 }
Wink Saville2d1ee982014-11-20 20:29:51 +00001481 }
1482 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001483 }
1484 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001485 }
Jack Yu4d1c9452019-01-02 16:51:08 -08001486 broadcastDataConnectionStateChanged(state, isDataAllowed, apn, apnType, linkProperties,
1487 networkCapabilities, roaming, subId);
1488 broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn,
chen xu16e24cd2018-12-11 18:09:41 -08001489 linkProperties, DataFailCause.NONE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001490 }
1491
Jack Yu4d1c9452019-01-02 16:51:08 -08001492 public void notifyDataConnectionFailed(String apnType) {
chen xud5deeb12019-04-29 13:57:42 -07001493 notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX,
1494 SubscriptionManager.DEFAULT_SUBSCRIPTION_ID,
Jack Yu4d1c9452019-01-02 16:51:08 -08001495 apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001496 }
1497
chen xud5deeb12019-04-29 13:57:42 -07001498 public void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType) {
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001499 if (!checkNotifyPermission("notifyDataConnectionFailed()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001500 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001501 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001502 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001503 log("notifyDataConnectionFailedForSubscriber: subId=" + subId
Jack Yu4d1c9452019-01-02 16:51:08 -08001504 + " apnType=" + apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07001505 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001506 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001507 if (validatePhoneId(phoneId)) {
1508 mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
1509 TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN,
1510 ApnSetting.getApnTypesBitmaskFromString(apnType), null, null,
1511 DataFailCause.NONE);
1512 for (Record r : mRecords) {
1513 if (r.matchPhoneStateListenerEvent(
1514 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
1515 && idMatch(r.subId, subId, phoneId)) {
1516 try {
1517 r.callback.onPreciseDataConnectionStateChanged(
1518 mPreciseDataConnectionState[phoneId]);
1519 } catch (RemoteException ex) {
1520 mRemoveList.add(r.binder);
1521 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001522 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001523 }
1524 }
chen xud5deeb12019-04-29 13:57:42 -07001525
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001526 handleRemoveListLocked();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001527 }
Jack Yu4d1c9452019-01-02 16:51:08 -08001528 broadcastDataConnectionFailed(apnType, subId);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001529 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
chen xu81653862019-02-28 10:44:54 -08001530 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, null, null,
chen xu16e24cd2018-12-11 18:09:41 -08001531 DataFailCause.NONE);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001532 }
1533
1534 public void notifyCellLocation(Bundle cellLocation) {
Wink Savilled09c4ca2014-11-22 10:08:16 -08001535 notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation);
Wink Savillefb40dd42014-06-12 17:02:31 -07001536 }
1537
Wink Saville63f03dd2014-10-23 10:44:45 -07001538 public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) {
Wink Savillebc027272014-09-08 14:50:58 -07001539 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001540 + " cellLocation=" + cellLocation);
Jaikumar Ganesh45515652009-04-23 15:20:21 -07001541 if (!checkNotifyPermission("notifyCellLocation()")) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07001542 return;
Wink Savillee9b06d72009-05-18 21:47:50 -07001543 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001544 if (VDBG) {
Wink Savillebc027272014-09-08 14:50:58 -07001545 log("notifyCellLocationForSubscriber: subId=" + subId
Wink Savillefb40dd42014-06-12 17:02:31 -07001546 + " cellLocation=" + cellLocation);
1547 }
yifan.baie620ce72017-12-22 14:59:57 +08001548 int phoneId = SubscriptionManager.getPhoneId(subId);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001549 synchronized (mRecords) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001550 if (validatePhoneId(phoneId)) {
1551 mCellLocation[phoneId] = cellLocation;
1552 for (Record r : mRecords) {
xinhe43c50292014-09-18 17:56:48 -07001553 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) &&
Hall Liu5fb337f2017-11-22 17:38:15 -08001554 idMatch(r.subId, subId, phoneId) &&
Hall Liuee313732018-11-27 14:36:51 -08001555 checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001556 try {
1557 if (DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07001558 log("notifyCellLocation: cellLocation=" + cellLocation
Wink Savillefb40dd42014-06-12 17:02:31 -07001559 + " r=" + r);
1560 }
1561 r.callback.onCellLocationChanged(new Bundle(cellLocation));
1562 } catch (RemoteException ex) {
1563 mRemoveList.add(r.binder);
Wink Savillea12a7b32012-09-20 10:09:45 -07001564 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001565 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001566 }
1567 }
Joe Onorato163d8d92010-10-21 13:21:20 -04001568 handleRemoveListLocked();
Wink Savillee9b06d72009-05-18 21:47:50 -07001569 }
1570 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001571
chen xud5deeb12019-04-29 13:57:42 -07001572 public void notifyOtaspChanged(int subId, int otaspMode) {
Wink Savillefd2d0132010-10-28 14:22:26 -07001573 if (!checkNotifyPermission("notifyOtaspChanged()" )) {
1574 return;
1575 }
chen xud5deeb12019-04-29 13:57:42 -07001576 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savillefd2d0132010-10-28 14:22:26 -07001577 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001578 if (validatePhoneId(phoneId)) {
1579 mOtaspMode[phoneId] = otaspMode;
1580 for (Record r : mRecords) {
1581 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)
1582 && idMatch(r.subId, subId, phoneId)) {
1583 try {
1584 r.callback.onOtaspChanged(otaspMode);
1585 } catch (RemoteException ex) {
1586 mRemoveList.add(r.binder);
1587 }
Wink Savillefd2d0132010-10-28 14:22:26 -07001588 }
1589 }
1590 }
1591 handleRemoveListLocked();
1592 }
1593 }
1594
chen xud5deeb12019-04-29 13:57:42 -07001595 public void notifyPreciseCallState(int phoneId, int subId, int ringingCallState,
1596 int foregroundCallState, int backgroundCallState) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001597 if (!checkNotifyPermission("notifyPreciseCallState()")) {
1598 return;
1599 }
1600 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001601 if (validatePhoneId(phoneId)) {
1602 mRingingCallState[phoneId] = ringingCallState;
1603 mForegroundCallState[phoneId] = foregroundCallState;
1604 mBackgroundCallState[phoneId] = backgroundCallState;
1605 mPreciseCallState[phoneId] = new PreciseCallState(
1606 ringingCallState, foregroundCallState,
1607 backgroundCallState,
1608 DisconnectCause.NOT_VALID,
1609 PreciseDisconnectCause.NOT_VALID);
1610 boolean notifyCallAttributes = true;
1611 if (mCallQuality == null) {
1612 log("notifyPreciseCallState: mCallQuality is null, "
1613 + "skipping call attributes");
1614 notifyCallAttributes = false;
1615 } else {
1616 // If the precise call state is no longer active, reset the call network type
1617 // and call quality.
1618 if (mPreciseCallState[phoneId].getForegroundCallState()
1619 != PreciseCallState.PRECISE_CALL_STATE_ACTIVE) {
1620 mCallNetworkType[phoneId] = TelephonyManager.NETWORK_TYPE_UNKNOWN;
1621 mCallQuality[phoneId] = new CallQuality();
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001622 }
chen xud5deeb12019-04-29 13:57:42 -07001623 mCallAttributes[phoneId] = new CallAttributes(mPreciseCallState[phoneId],
1624 mCallNetworkType[phoneId], mCallQuality[phoneId]);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001625 }
chen xud5deeb12019-04-29 13:57:42 -07001626
1627 for (Record r : mRecords) {
1628 if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)
1629 && idMatch(r.subId, subId, phoneId)) {
1630 try {
1631 r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]);
1632 } catch (RemoteException ex) {
1633 mRemoveList.add(r.binder);
1634 }
1635 }
1636 if (notifyCallAttributes && r.matchPhoneStateListenerEvent(
1637 PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED)
1638 && idMatch(r.subId, subId, phoneId)) {
1639 try {
1640 r.callback.onCallAttributesChanged(mCallAttributes[phoneId]);
1641 } catch (RemoteException ex) {
1642 mRemoveList.add(r.binder);
1643 }
Jordan Liu8218ddd2018-11-28 11:22:39 -08001644 }
1645 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001646 }
1647 handleRemoveListLocked();
1648 }
chen xu6a942d482018-12-12 19:59:30 -08001649 broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState,
1650 backgroundCallState);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001651 }
1652
chen xud5deeb12019-04-29 13:57:42 -07001653 public void notifyDisconnectCause(int phoneId, int subId, int disconnectCause,
1654 int preciseDisconnectCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001655 if (!checkNotifyPermission("notifyDisconnectCause()")) {
1656 return;
1657 }
1658 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001659 if (validatePhoneId(phoneId)) {
1660 mCallDisconnectCause[phoneId] = disconnectCause;
1661 mCallPreciseDisconnectCause[phoneId] = preciseDisconnectCause;
1662 for (Record r : mRecords) {
1663 if (r.matchPhoneStateListenerEvent(PhoneStateListener
1664 .LISTEN_CALL_DISCONNECT_CAUSES) && idMatch(r.subId, subId, phoneId)) {
1665 try {
1666 r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId],
1667 mCallPreciseDisconnectCause[phoneId]);
1668 } catch (RemoteException ex) {
1669 mRemoveList.add(r.binder);
1670 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001671 }
1672 }
1673 }
1674 handleRemoveListLocked();
1675 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001676 }
1677
chen xu6ac5fc12019-01-24 14:14:13 -08001678 public void notifyImsDisconnectCause(int subId, ImsReasonInfo imsReasonInfo) {
1679 if (!checkNotifyPermission("notifyImsCallDisconnectCause()")) {
1680 return;
1681 }
1682 int phoneId = SubscriptionManager.getPhoneId(subId);
1683 synchronized (mRecords) {
1684 if (validatePhoneId(phoneId)) {
1685 mImsReasonInfo.set(phoneId, imsReasonInfo);
1686 for (Record r : mRecords) {
1687 if (r.matchPhoneStateListenerEvent(
1688 PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES)
1689 && idMatch(r.subId, subId, phoneId)) {
1690 try {
1691 if (DBG_LOC) {
1692 log("notifyImsCallDisconnectCause: mImsReasonInfo="
1693 + imsReasonInfo + " r=" + r);
1694 }
1695 r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(phoneId));
1696 } catch (RemoteException ex) {
1697 mRemoveList.add(r.binder);
1698 }
1699 }
1700 }
1701 }
1702 handleRemoveListLocked();
1703 }
1704 }
1705
chen xud5deeb12019-04-29 13:57:42 -07001706 public void notifyPreciseDataConnectionFailed(int phoneId, int subId, String apnType,
chen xu16e24cd2018-12-11 18:09:41 -08001707 String apn, @DataFailCause.FailCause int failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001708 if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) {
1709 return;
1710 }
1711 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001712 if (validatePhoneId(phoneId)) {
1713 mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState(
1714 TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN,
1715 ApnSetting.getApnTypesBitmaskFromString(apnType), apn, null, failCause);
1716 for (Record r : mRecords) {
1717 if (r.matchPhoneStateListenerEvent(
1718 PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)
1719 && idMatch(r.subId, subId, phoneId)) {
1720 try {
1721 r.callback.onPreciseDataConnectionStateChanged(
1722 mPreciseDataConnectionState[phoneId]);
1723 } catch (RemoteException ex) {
1724 mRemoveList.add(r.binder);
1725 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001726 }
1727 }
1728 }
chen xud5deeb12019-04-29 13:57:42 -07001729
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001730 handleRemoveListLocked();
1731 }
1732 broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN,
Jack Yu4d1c9452019-01-02 16:51:08 -08001733 TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, null, failCause);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02001734 }
1735
Brad Ebingerefed9822018-10-26 10:25:57 -07001736 @Override
1737 public void notifySrvccStateChanged(int subId, @TelephonyManager.SrvccState int state) {
1738 if (!checkNotifyPermission("notifySrvccStateChanged()")) {
Wink Savillefb40dd42014-06-12 17:02:31 -07001739 return;
1740 }
Brad Ebingerefed9822018-10-26 10:25:57 -07001741 if (VDBG) {
1742 log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state);
1743 }
1744 int phoneId = SubscriptionManager.getPhoneId(subId);
Wink Savillefb40dd42014-06-12 17:02:31 -07001745 synchronized (mRecords) {
Brad Ebingerefed9822018-10-26 10:25:57 -07001746 if (validatePhoneId(phoneId)) {
chen xu6ac5fc12019-01-24 14:14:13 -08001747 mSrvccState[phoneId] = state;
Brad Ebingerefed9822018-10-26 10:25:57 -07001748 for (Record r : mRecords) {
1749 if (r.matchPhoneStateListenerEvent(
1750 PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) &&
1751 idMatch(r.subId, subId, phoneId)) {
1752 try {
1753 if (DBG_LOC) {
1754 log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r);
1755 }
1756 r.callback.onSrvccStateChanged(state);
1757 } catch (RemoteException ex) {
1758 mRemoveList.add(r.binder);
1759 }
Wink Savillefb40dd42014-06-12 17:02:31 -07001760 }
1761 }
1762 }
1763 handleRemoveListLocked();
1764 }
1765 }
1766
chen xud5deeb12019-04-29 13:57:42 -07001767 public void notifyOemHookRawEventForSubscriber(int phoneId, int subId, byte[] rawData) {
Shuo Qian066e8652018-04-25 21:02:35 +00001768 if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) {
1769 return;
1770 }
1771
1772 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001773 if (validatePhoneId(phoneId)) {
1774 for (Record r : mRecords) {
1775 if (VDBG) {
1776 log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId);
1777 }
1778 if ((r.matchPhoneStateListenerEvent(
1779 PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT))
1780 && idMatch(r.subId, subId, phoneId)) {
1781 try {
1782 r.callback.onOemHookRawEvent(rawData);
1783 } catch (RemoteException ex) {
1784 mRemoveList.add(r.binder);
1785 }
Shuo Qian066e8652018-04-25 21:02:35 +00001786 }
1787 }
1788 }
1789 handleRemoveListLocked();
1790 }
1791 }
1792
Malcolm Chene1623652018-08-08 20:27:45 -07001793 public void notifyPhoneCapabilityChanged(PhoneCapability capability) {
1794 if (!checkNotifyPermission("notifyPhoneCapabilityChanged()")) {
1795 return;
1796 }
1797
1798 if (VDBG) {
1799 log("notifyPhoneCapabilityChanged: capability=" + capability);
1800 }
1801
1802 synchronized (mRecords) {
1803 mPhoneCapability = capability;
1804
1805 for (Record r : mRecords) {
1806 if (r.matchPhoneStateListenerEvent(
1807 PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE)) {
1808 try {
1809 r.callback.onPhoneCapabilityChanged(capability);
1810 } catch (RemoteException ex) {
1811 mRemoveList.add(r.binder);
1812 }
1813 }
1814 }
1815 handleRemoveListLocked();
1816 }
1817 }
1818
Malcolm Chen026451d2019-02-14 19:50:19 -08001819 public void notifyActiveDataSubIdChanged(int activeDataSubId) {
1820 if (!checkNotifyPermission("notifyActiveDataSubIdChanged()")) {
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001821 return;
1822 }
1823
1824 if (VDBG) {
Malcolm Chen026451d2019-02-14 19:50:19 -08001825 log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId);
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001826 }
1827
sqian9e9ed182019-03-20 16:17:09 -07001828 // Create a copy to prevent the IPC call while checking carrier privilege under the lock.
1829 List<Record> copiedRecords;
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001830 synchronized (mRecords) {
sqian9e9ed182019-03-20 16:17:09 -07001831 copiedRecords = new ArrayList<>(mRecords);
1832 }
1833 mActiveDataSubId = activeDataSubId;
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001834
sqian9e9ed182019-03-20 16:17:09 -07001835 // Filter the record that does not listen to this change or does not have the permission.
1836 copiedRecords = copiedRecords.stream().filter(r -> r.matchPhoneStateListenerEvent(
1837 PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)
1838 && TelephonyPermissions.checkReadPhoneStateOnAnyActiveSub(
1839 mContext, r.callerPid, r.callerUid, r.callingPackage,
1840 "notifyActiveDataSubIdChanged")).collect(Collectors.toCollection(ArrayList::new));
1841
1842 synchronized (mRecords) {
1843 for (Record r : copiedRecords) {
1844 if (mRecords.contains(r)) {
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001845 try {
Malcolm Chen026451d2019-02-14 19:50:19 -08001846 r.callback.onActiveDataSubIdChanged(activeDataSubId);
Malcolm Chen8b53afe2018-09-24 20:01:32 -07001847 } catch (RemoteException ex) {
1848 mRemoveList.add(r.binder);
1849 }
1850 }
1851 }
1852 handleRemoveListLocked();
1853 }
1854 }
Malcolm Chene1623652018-08-08 20:27:45 -07001855
chen xud5deeb12019-04-29 13:57:42 -07001856 public void notifyRadioPowerStateChanged(int phoneId, int subId,
1857 @TelephonyManager.RadioPowerState int state) {
Chen Xu7395c632018-10-17 17:53:47 +00001858 if (!checkNotifyPermission("notifyRadioPowerStateChanged()")) {
1859 return;
1860 }
1861
1862 if (VDBG) {
chen xud5deeb12019-04-29 13:57:42 -07001863 log("notifyRadioPowerStateChanged: state= " + state + " subId=" + subId);
Chen Xu7395c632018-10-17 17:53:47 +00001864 }
1865
1866 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001867 if (validatePhoneId(phoneId)) {
1868 mRadioPowerState = state;
Chen Xu7395c632018-10-17 17:53:47 +00001869
chen xud5deeb12019-04-29 13:57:42 -07001870 for (Record r : mRecords) {
1871 if (r.matchPhoneStateListenerEvent(
1872 PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED)
1873 && idMatch(r.subId, subId, phoneId)) {
1874 try {
1875 r.callback.onRadioPowerStateChanged(state);
1876 } catch (RemoteException ex) {
1877 mRemoveList.add(r.binder);
1878 }
Chen Xu7395c632018-10-17 17:53:47 +00001879 }
1880 }
chen xud5deeb12019-04-29 13:57:42 -07001881
Chen Xu7395c632018-10-17 17:53:47 +00001882 }
1883 handleRemoveListLocked();
1884 }
1885 }
1886
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001887 @Override
chen xud5deeb12019-04-29 13:57:42 -07001888 public void notifyEmergencyNumberList(int phoneId, int subId) {
sqian9f93a122018-12-03 22:40:41 -08001889 if (!checkNotifyPermission("notifyEmergencyNumberList()")) {
1890 return;
1891 }
1892
1893 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001894 if (validatePhoneId(phoneId)) {
1895 TelephonyManager tm = (TelephonyManager) mContext.getSystemService(
1896 Context.TELEPHONY_SERVICE);
1897 mEmergencyNumberList = tm.getEmergencyNumberList();
sqian9f93a122018-12-03 22:40:41 -08001898
chen xud5deeb12019-04-29 13:57:42 -07001899 for (Record r : mRecords) {
1900 if (r.matchPhoneStateListenerEvent(
1901 PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST)
1902 && idMatch(r.subId, subId, phoneId)) {
1903 try {
1904 r.callback.onEmergencyNumberListChanged(mEmergencyNumberList);
1905 if (VDBG) {
1906 log("notifyEmergencyNumberList: emergencyNumberList= "
1907 + mEmergencyNumberList);
1908 }
1909 } catch (RemoteException ex) {
1910 mRemoveList.add(r.binder);
sqian9f93a122018-12-03 22:40:41 -08001911 }
sqian9f93a122018-12-03 22:40:41 -08001912 }
1913 }
1914 }
chen xud5deeb12019-04-29 13:57:42 -07001915
sqian9f93a122018-12-03 22:40:41 -08001916 handleRemoveListLocked();
1917 }
sqianbdc5a732018-10-26 13:27:51 -07001918 }
1919
Jordan Liu8218ddd2018-11-28 11:22:39 -08001920 @Override
chen xud5deeb12019-04-29 13:57:42 -07001921 public void notifyCallQualityChanged(CallQuality callQuality, int phoneId, int subId,
Jordan Liu65ed9d92019-02-19 14:42:07 -08001922 int callNetworkType) {
Jordan Liu8218ddd2018-11-28 11:22:39 -08001923 if (!checkNotifyPermission("notifyCallQualityChanged()")) {
1924 return;
1925 }
1926
Jordan Liu8218ddd2018-11-28 11:22:39 -08001927 synchronized (mRecords) {
chen xud5deeb12019-04-29 13:57:42 -07001928 if (validatePhoneId(phoneId)) {
1929 // merge CallQuality with PreciseCallState and network type
1930 mCallQuality[phoneId] = callQuality;
1931 mCallNetworkType[phoneId] = callNetworkType;
1932 mCallAttributes[phoneId] = new CallAttributes(mPreciseCallState[phoneId],
1933 callNetworkType, callQuality);
Jordan Liu8218ddd2018-11-28 11:22:39 -08001934
chen xud5deeb12019-04-29 13:57:42 -07001935 for (Record r : mRecords) {
1936 if (r.matchPhoneStateListenerEvent(
1937 PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED)
1938 && idMatch(r.subId, subId, phoneId)) {
1939 try {
1940 r.callback.onCallAttributesChanged(mCallAttributes[phoneId]);
1941 } catch (RemoteException ex) {
1942 mRemoveList.add(r.binder);
1943 }
Jordan Liu8218ddd2018-11-28 11:22:39 -08001944 }
1945 }
1946 }
chen xud5deeb12019-04-29 13:57:42 -07001947
Jordan Liu8218ddd2018-11-28 11:22:39 -08001948 handleRemoveListLocked();
1949 }
1950 }
1951
sqianbdc5a732018-10-26 13:27:51 -07001952
1953 @Override
Jack Yud19b6ae2017-04-05 14:12:09 -07001954 public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
1955 final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " ");
1956
Jeff Sharkeyfe9a53b2017-03-31 14:08:23 -06001957 if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
Jack Yud19b6ae2017-04-05 14:12:09 -07001958
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001959 synchronized (mRecords) {
Wink Savillee9b06d72009-05-18 21:47:50 -07001960 final int recordCount = mRecords.size();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001961 pw.println("last known state:");
Jack Yud19b6ae2017-04-05 14:12:09 -07001962 pw.increaseIndent();
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301963 for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) {
Jack Yud19b6ae2017-04-05 14:12:09 -07001964 pw.println("Phone Id=" + i);
1965 pw.increaseIndent();
1966 pw.println("mCallState=" + mCallState[i]);
chen xud5deeb12019-04-29 13:57:42 -07001967 pw.println("mRingingCallState=" + mRingingCallState[i]);
1968 pw.println("mForegroundCallState=" + mForegroundCallState[i]);
1969 pw.println("mBackgroundCallState=" + mBackgroundCallState[i]);
1970 pw.println("mPreciseCallState=" + mPreciseCallState[i]);
1971 pw.println("mCallDisconnectCause=" + mCallDisconnectCause[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001972 pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]);
1973 pw.println("mServiceState=" + mServiceState[i]);
1974 pw.println("mVoiceActivationState= " + mVoiceActivationState[i]);
1975 pw.println("mDataActivationState= " + mDataActivationState[i]);
zxuan35a47022018-01-04 11:24:04 -08001976 pw.println("mUserMobileDataState= " + mUserMobileDataState[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001977 pw.println("mSignalStrength=" + mSignalStrength[i]);
1978 pw.println("mMessageWaiting=" + mMessageWaiting[i]);
1979 pw.println("mCallForwarding=" + mCallForwarding[i]);
1980 pw.println("mDataActivity=" + mDataActivity[i]);
1981 pw.println("mDataConnectionState=" + mDataConnectionState[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001982 pw.println("mCellLocation=" + mCellLocation[i]);
1983 pw.println("mCellInfo=" + mCellInfo.get(i));
Tyler Gunnf3f89d02019-03-25 07:26:33 -07001984 pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i));
chen xud5deeb12019-04-29 13:57:42 -07001985 pw.println("mSrvccState=" + mSrvccState[i]);
1986 pw.println("mOtaspMode=" + mOtaspMode[i]);
1987 pw.println("mCallPreciseDisconnectCause=" + mCallPreciseDisconnectCause[i]);
1988 pw.println("mCallQuality=" + mCallQuality[i]);
1989 pw.println("mCallAttributes=" + mCallAttributes[i]);
1990 pw.println("mCallNetworkType=" + mCallNetworkType[i]);
1991 pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState[i]);
Jack Yud19b6ae2017-04-05 14:12:09 -07001992 pw.decreaseIndent();
Sandeep Gutta2f32ac22014-07-16 03:14:03 +05301993 }
Jack Yud19b6ae2017-04-05 14:12:09 -07001994 pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState);
chen xud5deeb12019-04-29 13:57:42 -07001995
Malcolm Chene1623652018-08-08 20:27:45 -07001996 pw.println("mPhoneCapability=" + mPhoneCapability);
Malcolm Chen026451d2019-02-14 19:50:19 -08001997 pw.println("mActiveDataSubId=" + mActiveDataSubId);
Chen Xu7395c632018-10-17 17:53:47 +00001998 pw.println("mRadioPowerState=" + mRadioPowerState);
sqian9f93a122018-12-03 22:40:41 -08001999 pw.println("mEmergencyNumberList=" + mEmergencyNumberList);
chen xuaddc2702019-05-07 16:25:12 -07002000 pw.println("mDefaultPhoneId=" + mDefaultPhoneId);
2001 pw.println("mDefaultSubId=" + mDefaultSubId);
Jack Yud19b6ae2017-04-05 14:12:09 -07002002
2003 pw.decreaseIndent();
2004
2005 pw.println("local logs:");
2006 pw.increaseIndent();
2007 mLocalLog.dump(fd, pw, args);
Jack Yu0c92c232019-04-04 15:10:17 -07002008 pw.println("listen logs:");
2009 mListenLog.dump(fd, pw, args);
Jack Yud19b6ae2017-04-05 14:12:09 -07002010 pw.decreaseIndent();
Wink Savillee9b06d72009-05-18 21:47:50 -07002011 pw.println("registrations: count=" + recordCount);
Jack Yud19b6ae2017-04-05 14:12:09 -07002012 pw.increaseIndent();
Robert Greenwalt02648a42010-05-18 10:52:51 -07002013 for (Record r : mRecords) {
Jack Yud19b6ae2017-04-05 14:12:09 -07002014 pw.println(r);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002015 }
Jack Yud19b6ae2017-04-05 14:12:09 -07002016 pw.decreaseIndent();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002017 }
2018 }
2019
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002020 //
2021 // the legacy intent broadcasting
2022 //
2023
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002024 private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) {
Wink Savillefb40dd42014-06-12 17:02:31 -07002025 long ident = Binder.clearCallingIdentity();
2026 try {
2027 mBatteryStats.notePhoneState(state.getState());
2028 } catch (RemoteException re) {
2029 // Can't do much
2030 } finally {
2031 Binder.restoreCallingIdentity(ident);
2032 }
2033
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002034 Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED);
Christopher Tate42a386b2016-11-07 12:21:21 -08002035 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002036 Bundle data = new Bundle();
2037 state.fillInNotifierBundle(data);
2038 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07002039 // Pass the subscription along with the intent.
2040 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
chen xu379e5312018-09-28 15:53:43 -07002041 intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002042 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002043 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002044 }
2045
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002046 private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId,
2047 int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07002048 long ident = Binder.clearCallingIdentity();
2049 try {
Wink Savillee9b06d72009-05-18 21:47:50 -07002050 mBatteryStats.notePhoneSignalStrength(signalStrength);
Dianne Hackborn627bba72009-03-24 22:32:56 -07002051 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07002052 /* The remote entity disappeared, we can safely ignore the exception. */
Dianne Hackborn627bba72009-03-24 22:32:56 -07002053 } finally {
2054 Binder.restoreCallingIdentity(ident);
2055 }
Wink Savillee9b06d72009-05-18 21:47:50 -07002056
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002057 Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED);
Wink Savillee9b06d72009-05-18 21:47:50 -07002058 Bundle data = new Bundle();
2059 signalStrength.fillInNotifierBundle(data);
2060 intent.putExtras(data);
Wink Savillefb40dd42014-06-12 17:02:31 -07002061 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002062 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002063 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002064 }
2065
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07002066 /**
2067 * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be
2068 * a valid subId, in which case this function fires a subId-specific intent, or it
2069 * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send
2070 * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}).
2071 */
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002072 private void broadcastCallStateChanged(int state, String incomingNumber, int phoneId,
2073 int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002074 long ident = Binder.clearCallingIdentity();
2075 try {
2076 if (state == TelephonyManager.CALL_STATE_IDLE) {
2077 mBatteryStats.notePhoneOff();
Yangster4ccebea2018-10-09 17:09:02 -07002078 StatsLog.write(StatsLog.PHONE_STATE_CHANGED,
2079 StatsLog.PHONE_STATE_CHANGED__STATE__OFF);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002080 } else {
2081 mBatteryStats.notePhoneOn();
Yangster4ccebea2018-10-09 17:09:02 -07002082 StatsLog.write(StatsLog.PHONE_STATE_CHANGED,
2083 StatsLog.PHONE_STATE_CHANGED__STATE__ON);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002084 }
2085 } catch (RemoteException e) {
Wink Savillee9b06d72009-05-18 21:47:50 -07002086 /* The remote entity disappeared, we can safely ignore the exception. */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002087 } finally {
2088 Binder.restoreCallingIdentity(ident);
2089 }
Wink Savillee9b06d72009-05-18 21:47:50 -07002090
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002091 Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07002092 intent.putExtra(PhoneConstants.STATE_KEY,
Nathan Harold5a0618e2016-12-14 10:48:00 -08002093 PhoneConstantConversions.convertCallState(state).toString());
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07002094
2095 // If a valid subId was specified, we should fire off a subId-specific state
2096 // change intent and include the subId.
2097 if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
2098 intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED);
2099 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
chen xu379e5312018-09-28 15:53:43 -07002100 intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07002101 }
Shishir Agrawalf7e59c12016-04-13 09:55:55 -07002102 // If the phoneId is invalid, the broadcast is for overall call state.
2103 if (phoneId != SubscriptionManager.INVALID_PHONE_INDEX) {
2104 intent.putExtra(PhoneConstants.SLOT_KEY, phoneId);
2105 }
Sharvil Nanavati61a3ab02015-04-23 13:57:24 -07002106
Brad Ebinger51de96a2017-04-21 17:05:18 -07002107 // Wakeup apps for the (SUBSCRIPTION_)PHONE_STATE broadcast.
2108 intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
2109
Tyler Gunn1c27bb72018-06-19 09:55:43 -07002110 // Create a version of the intent with the number always populated.
Tyler Gunnf955e562018-04-26 14:43:31 -07002111 Intent intentWithPhoneNumber = new Intent(intent);
Tyler Gunn1c27bb72018-06-19 09:55:43 -07002112 intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber);
2113
Amit Mahajan1cfd4572015-07-09 11:12:19 -07002114 // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those
2115 // that have the runtime one
Tyler Gunnf955e562018-04-26 14:43:31 -07002116 mContext.sendBroadcastAsUser(intentWithPhoneNumber, UserHandle.ALL,
Amit Mahajan1cfd4572015-07-09 11:12:19 -07002117 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002118 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
Svet Ganov16a16892015-04-16 10:32:04 -07002119 android.Manifest.permission.READ_PHONE_STATE,
2120 AppOpsManager.OP_READ_PHONE_STATE);
Tyler Gunnf955e562018-04-26 14:43:31 -07002121 mContext.sendBroadcastAsUserMultiplePermissions(intentWithPhoneNumber, UserHandle.ALL,
2122 new String[] { android.Manifest.permission.READ_PHONE_STATE,
2123 android.Manifest.permission.READ_CALL_LOG});
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002124 }
2125
Jack Yu4d1c9452019-01-02 16:51:08 -08002126 private void broadcastDataConnectionStateChanged(int state, boolean isDataAllowed, String apn,
2127 String apnType, LinkProperties linkProperties,
2128 NetworkCapabilities networkCapabilities,
2129 boolean roaming, int subId) {
Dianne Hackborn627bba72009-03-24 22:32:56 -07002130 // Note: not reporting to the battery stats service here, because the
2131 // status bar takes care of that after taking into account all of the
2132 // required info.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002133 Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED);
Wink Savillea639b312012-07-10 12:37:54 -07002134 intent.putExtra(PhoneConstants.STATE_KEY,
Nathan Harold5a0618e2016-12-14 10:48:00 -08002135 PhoneConstantConversions.convertDataState(state).toString());
Jack Yubaeec622017-05-01 17:01:11 -07002136 if (!isDataAllowed) {
Wink Savillea639b312012-07-10 12:37:54 -07002137 intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002138 }
Robert Greenwalt37e65eb2010-08-30 10:56:47 -07002139 if (linkProperties != null) {
Wink Savillea639b312012-07-10 12:37:54 -07002140 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Irfan Sheriffed5d7d12010-10-01 16:08:28 -07002141 String iface = linkProperties.getInterfaceName();
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07002142 if (iface != null) {
Wink Savillea639b312012-07-10 12:37:54 -07002143 intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface);
Robert Greenwalt47f69fe2010-06-15 15:43:39 -07002144 }
2145 }
Robert Greenwaltf9cb86a2014-04-08 17:34:00 -07002146 if (networkCapabilities != null) {
2147 intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities);
Wink Savillef61101f2010-09-16 16:36:42 -07002148 }
Wink Savillea639b312012-07-10 12:37:54 -07002149 if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true);
Robert Greenwalta6d42482011-09-02 15:19:31 -07002150
Wink Savillea639b312012-07-10 12:37:54 -07002151 intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
2152 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07002153 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002154 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002155 }
2156
Jack Yu4d1c9452019-01-02 16:51:08 -08002157 private void broadcastDataConnectionFailed(String apnType, int subId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002158 Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED);
Wink Savillea639b312012-07-10 12:37:54 -07002159 intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
Wink Savillefb40dd42014-06-12 17:02:31 -07002160 intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId);
Dianne Hackborn5ac72a22012-08-29 18:32:08 -07002161 mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002162 }
Wink Savillee9b06d72009-05-18 21:47:50 -07002163
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002164 private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState,
Jack Yu4d1c9452019-01-02 16:51:08 -08002165 int backgroundCallState) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002166 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED);
2167 intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState);
2168 intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState);
2169 intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002170 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
2171 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
2172 }
2173
2174 private void broadcastPreciseDataConnectionStateChanged(int state, int networkType,
chen xu16e24cd2018-12-11 18:09:41 -08002175 String apnType, String apn, LinkProperties linkProperties,
2176 @DataFailCause.FailCause int failCause) {
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002177 Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED);
2178 intent.putExtra(PhoneConstants.STATE_KEY, state);
2179 intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002180 if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType);
2181 if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn);
Wink Savilled09c4ca2014-11-22 10:08:16 -08002182 if (linkProperties != null) {
Jack Yu4d1c9452019-01-02 16:51:08 -08002183 intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties);
Wink Savilled09c4ca2014-11-22 10:08:16 -08002184 }
chen xu16e24cd2018-12-11 18:09:41 -08002185 intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002186
2187 mContext.sendBroadcastAsUser(intent, UserHandle.ALL,
2188 android.Manifest.permission.READ_PRECISE_PHONE_STATE);
2189 }
2190
Andrew Flynnceaed682015-06-09 12:36:58 +00002191 private void enforceNotifyPermissionOrCarrierPrivilege(String method) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002192 if (checkNotifyPermission()) {
Andrew Flynnceaed682015-06-09 12:36:58 +00002193 return;
Andrew Flynn1f452642015-04-14 22:16:04 -04002194 }
2195
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002196 TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege(
2197 SubscriptionManager.getDefaultSubscriptionId(), method);
Andrew Flynn1f452642015-04-14 22:16:04 -04002198 }
2199
Jaikumar Ganesh45515652009-04-23 15:20:21 -07002200 private boolean checkNotifyPermission(String method) {
Andrew Flynn1f452642015-04-14 22:16:04 -04002201 if (checkNotifyPermission()) {
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07002202 return true;
2203 }
2204 String msg = "Modify Phone State Permission Denial: " + method + " from pid="
Wink Savillee9b06d72009-05-18 21:47:50 -07002205 + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
Wink Savillef4cd25b2014-07-08 19:03:20 -07002206 if (DBG) log(msg);
The Android Open Source Projectba87e3e2009-03-13 13:04:22 -07002207 return false;
2208 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07002209
Andrew Flynn1f452642015-04-14 22:16:04 -04002210 private boolean checkNotifyPermission() {
2211 return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
2212 == PackageManager.PERMISSION_GRANTED;
2213 }
2214
Jeff Davidson29da89f2018-02-28 17:50:16 -08002215 private boolean checkListenerPermission(
2216 int events, int subId, String callingPackage, String message) {
Hall Liuee313732018-11-27 14:36:51 -08002217 LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder =
2218 new LocationAccessPolicy.LocationPermissionQuery.Builder()
2219 .setCallingPackage(callingPackage)
2220 .setMethod(message + " events: " + events)
2221 .setCallingPid(Binder.getCallingPid())
2222 .setCallingUid(Binder.getCallingUid());
2223
2224 boolean shouldCheckLocationPermissions = false;
Hall Liu70bbc162018-03-02 17:44:46 -08002225 if ((events & ENFORCE_COARSE_LOCATION_PERMISSION_MASK) != 0) {
Hall Liuee313732018-11-27 14:36:51 -08002226 locationQueryBuilder.setMinSdkVersionForCoarse(0);
2227 shouldCheckLocationPermissions = true;
2228 }
2229
2230 if ((events & ENFORCE_FINE_LOCATION_PERMISSION_MASK) != 0) {
2231 // Everything that requires fine location started in Q. So far...
2232 locationQueryBuilder.setMinSdkVersionForFine(Build.VERSION_CODES.Q);
2233 shouldCheckLocationPermissions = true;
2234 }
2235
2236 if (shouldCheckLocationPermissions) {
2237 LocationAccessPolicy.LocationPermissionResult result =
2238 LocationAccessPolicy.checkLocationPermission(
2239 mContext, locationQueryBuilder.build());
2240 switch (result) {
2241 case DENIED_HARD:
2242 throw new SecurityException("Unable to listen for events " + events + " due to "
2243 + "insufficient location permissions.");
2244 case DENIED_SOFT:
2245 return false;
Hall Liu70bbc162018-03-02 17:44:46 -08002246 }
John Wang963db55d2012-03-30 16:04:06 -07002247 }
2248
Fyodor Kupolov309b2f632015-06-03 16:29:01 -07002249 if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) {
Jeff Davidson29da89f2018-02-28 17:50:16 -08002250 if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
2251 mContext, subId, callingPackage, message)) {
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002252 return false;
Amit Mahajan1cfd4572015-07-09 11:12:19 -07002253 }
Jaikumar Ganesh45515652009-04-23 15:20:21 -07002254 }
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002255
2256 if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) {
2257 mContext.enforceCallingOrSelfPermission(
2258 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
Antonio Marín Cerezuelac5ac15a2013-05-27 11:36:36 +02002259 }
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002260
Shuo Qian066e8652018-04-25 21:02:35 +00002261 if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) {
2262 mContext.enforceCallingOrSelfPermission(
2263 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2264 }
2265
Brad Ebingerefed9822018-10-26 10:25:57 -07002266 if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) {
2267 mContext.enforceCallingOrSelfPermission(
2268 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2269 }
2270
chen xu6a942d482018-12-12 19:59:30 -08002271 if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) {
2272 mContext.enforceCallingOrSelfPermission(
2273 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
2274 }
2275
Jordan Liu8218ddd2018-11-28 11:22:39 -08002276 if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) {
2277 mContext.enforceCallingOrSelfPermission(
2278 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
2279 }
2280
chen xu52797b62019-01-18 13:16:31 -08002281 if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) {
2282 mContext.enforceCallingOrSelfPermission(
2283 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2284 }
2285
2286 if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) != 0) {
2287 mContext.enforceCallingOrSelfPermission(
2288 android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null);
2289 }
2290
chen xu6ac5fc12019-01-24 14:14:13 -08002291 if ((events & PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) != 0) {
2292 mContext.enforceCallingOrSelfPermission(
2293 android.Manifest.permission.READ_PRECISE_PHONE_STATE, null);
2294 }
2295
Jeff Davidsond7bf38a2018-02-13 18:11:37 -08002296 return true;
Jaikumar Ganesh45515652009-04-23 15:20:21 -07002297 }
Joe Onorato163d8d92010-10-21 13:21:20 -04002298
2299 private void handleRemoveListLocked() {
Wink Savillea374c3d2014-11-11 11:48:04 -08002300 int size = mRemoveList.size();
2301 if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size);
2302 if (size > 0) {
Joe Onorato163d8d92010-10-21 13:21:20 -04002303 for (IBinder b: mRemoveList) {
2304 remove(b);
2305 }
2306 mRemoveList.clear();
2307 }
2308 }
Wink Savillea12a7b32012-09-20 10:09:45 -07002309
2310 private boolean validateEventsAndUserLocked(Record r, int events) {
2311 int foregroundUser;
2312 long callingIdentity = Binder.clearCallingIdentity();
2313 boolean valid = false;
2314 try {
2315 foregroundUser = ActivityManager.getCurrentUser();
Hall Liu5fb337f2017-11-22 17:38:15 -08002316 valid = UserHandle.getUserId(r.callerUid) == foregroundUser
2317 && r.matchPhoneStateListenerEvent(events);
Wink Savillea12a7b32012-09-20 10:09:45 -07002318 if (DBG | DBG_LOC) {
Wink Savillef4cd25b2014-07-08 19:03:20 -07002319 log("validateEventsAndUserLocked: valid=" + valid
Hall Liu5fb337f2017-11-22 17:38:15 -08002320 + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser
Wink Savillea12a7b32012-09-20 10:09:45 -07002321 + " r.events=" + r.events + " events=" + events);
2322 }
2323 } finally {
2324 Binder.restoreCallingIdentity(callingIdentity);
2325 }
2326 return valid;
2327 }
Wink Savillefb40dd42014-06-12 17:02:31 -07002328
2329 private boolean validatePhoneId(int phoneId) {
2330 boolean valid = (phoneId >= 0) && (phoneId < mNumPhones);
Wink Savillef4cd25b2014-07-08 19:03:20 -07002331 if (VDBG) log("validatePhoneId: " + valid);
Wink Savillefb40dd42014-06-12 17:02:31 -07002332 return valid;
2333 }
Wink Savillef4cd25b2014-07-08 19:03:20 -07002334
2335 private static void log(String s) {
2336 Rlog.d(TAG, s);
2337 }
Wink Saville47d8d1b2014-07-10 13:01:52 -07002338
chen xu627d1b22019-04-11 02:16:19 -07002339 private static void loge(String s) {
2340 Rlog.e(TAG, s);
2341 }
2342
xinhe8b79fb62014-11-05 14:55:03 -08002343 boolean idMatch(int rSubId, int subId, int phoneId) {
xinheac11ae92014-12-18 10:02:14 -08002344
2345 if(subId < 0) {
2346 // Invalid case, we need compare phoneId with default one.
2347 return (mDefaultPhoneId == phoneId);
2348 }
Wink Savilled09c4ca2014-11-22 10:08:16 -08002349 if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) {
xinhee9f16402014-09-25 16:39:28 -07002350 return (subId == mDefaultSubId);
2351 } else {
2352 return (rSubId == subId);
2353 }
2354 }
2355
Hall Liuee313732018-11-27 14:36:51 -08002356 private boolean checkFineLocationAccess(Record r, int minSdk) {
2357 LocationAccessPolicy.LocationPermissionQuery query =
2358 new LocationAccessPolicy.LocationPermissionQuery.Builder()
2359 .setCallingPackage(r.callingPackage)
2360 .setCallingPid(r.callerPid)
2361 .setCallingUid(r.callerUid)
2362 .setMethod("TelephonyRegistry push")
Hall Liu879024a2019-04-17 13:33:43 -07002363 .setLogAsInfo(true) // we don't need to log an error every time we push
Hall Liuee313732018-11-27 14:36:51 -08002364 .setMinSdkVersionForFine(minSdk)
2365 .build();
2366
2367 return Binder.withCleanCallingIdentity(() -> {
2368 LocationAccessPolicy.LocationPermissionResult locationResult =
2369 LocationAccessPolicy.checkLocationPermission(mContext, query);
2370 return locationResult == LocationAccessPolicy.LocationPermissionResult.ALLOWED;
2371 });
2372 }
2373
2374 private boolean checkCoarseLocationAccess(Record r, int minSdk) {
2375 LocationAccessPolicy.LocationPermissionQuery query =
2376 new LocationAccessPolicy.LocationPermissionQuery.Builder()
2377 .setCallingPackage(r.callingPackage)
2378 .setCallingPid(r.callerPid)
2379 .setCallingUid(r.callerUid)
2380 .setMethod("TelephonyRegistry push")
Hall Liu879024a2019-04-17 13:33:43 -07002381 .setLogAsInfo(true) // we don't need to log an error every time we push
Hall Liuee313732018-11-27 14:36:51 -08002382 .setMinSdkVersionForCoarse(minSdk)
2383 .build();
2384
2385 return Binder.withCleanCallingIdentity(() -> {
2386 LocationAccessPolicy.LocationPermissionResult locationResult =
2387 LocationAccessPolicy.checkLocationPermission(mContext, query);
2388 return locationResult == LocationAccessPolicy.LocationPermissionResult.ALLOWED;
2389 });
Hall Liu5fb337f2017-11-22 17:38:15 -08002390 }
2391
xinhee9f16402014-09-25 16:39:28 -07002392 private void checkPossibleMissNotify(Record r, int phoneId) {
2393 int events = r.events;
2394
2395 if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) {
2396 try {
2397 if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" +
2398 mServiceState[phoneId]);
2399 r.callback.onServiceStateChanged(
2400 new ServiceState(mServiceState[phoneId]));
2401 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002402 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002403 }
2404 }
2405
2406 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) {
2407 try {
2408 SignalStrength signalStrength = mSignalStrength[phoneId];
2409 if (DBG) {
2410 log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength);
2411 }
2412 r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength));
2413 } catch (RemoteException ex) {
2414 mRemoveList.add(r.binder);
2415 }
2416 }
2417
2418 if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) {
2419 try {
2420 int gsmSignalStrength = mSignalStrength[phoneId]
2421 .getGsmSignalStrength();
2422 if (DBG) {
2423 log("checkPossibleMissNotify: onSignalStrengthChanged SS=" +
2424 gsmSignalStrength);
2425 }
2426 r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1
2427 : gsmSignalStrength));
2428 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002429 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002430 }
2431 }
2432
2433 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) {
2434 try {
2435 if (DBG_LOC) {
2436 log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = "
2437 + mCellInfo.get(phoneId));
2438 }
Hall Liuee313732018-11-27 14:36:51 -08002439 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Hall Liu5fb337f2017-11-22 17:38:15 -08002440 r.callback.onCellInfoChanged(mCellInfo.get(phoneId));
2441 }
xinhee9f16402014-09-25 16:39:28 -07002442 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002443 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002444 }
2445 }
2446
zxuan35a47022018-01-04 11:24:04 -08002447 if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) {
2448 try {
2449 if (VDBG) {
2450 log("checkPossibleMissNotify: onUserMobileDataStateChanged phoneId="
2451 + phoneId + " umds=" + mUserMobileDataState[phoneId]);
2452 }
2453 r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]);
2454 } catch (RemoteException ex) {
2455 mRemoveList.add(r.binder);
2456 }
2457 }
2458
xinhee9f16402014-09-25 16:39:28 -07002459 if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) {
2460 try {
2461 if (VDBG) {
2462 log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId="
2463 + phoneId + " mwi=" + mMessageWaiting[phoneId]);
2464 }
2465 r.callback.onMessageWaitingIndicatorChanged(
2466 mMessageWaiting[phoneId]);
2467 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002468 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002469 }
2470 }
2471
2472 if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) {
2473 try {
2474 if (VDBG) {
2475 log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId="
2476 + phoneId + " cfi=" + mCallForwarding[phoneId]);
2477 }
2478 r.callback.onCallForwardingIndicatorChanged(
2479 mCallForwarding[phoneId]);
2480 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002481 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002482 }
2483 }
2484
2485 if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) {
2486 try {
2487 if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = "
2488 + mCellLocation[phoneId]);
Hall Liuee313732018-11-27 14:36:51 -08002489 if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) {
Hall Liu5fb337f2017-11-22 17:38:15 -08002490 r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId]));
2491 }
xinhee9f16402014-09-25 16:39:28 -07002492 } catch (RemoteException ex) {
2493 mRemoveList.add(r.binder);
2494 }
2495 }
2496
2497 if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) {
2498 try {
2499 if (DBG) {
2500 log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState"
2501 + "=" + mDataConnectionState[phoneId]
2502 + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId]
2503 + ")");
2504 }
2505 r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId],
2506 mDataConnectionNetworkType[phoneId]);
2507 } catch (RemoteException ex) {
Etan Cohena33cf072014-09-30 10:35:24 -07002508 mRemoveList.add(r.binder);
xinhee9f16402014-09-25 16:39:28 -07002509 }
2510 }
2511 }
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08002512}