The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server; |
| 18 | |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 19 | import static android.telephony.TelephonyManager.ACTION_MULTI_SIM_CONFIG_CHANGED; |
| 20 | |
| 21 | import static java.util.Arrays.copyOf; |
| 22 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 23 | import android.app.ActivityManager; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 24 | import android.app.AppOpsManager; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 25 | import android.content.BroadcastReceiver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 26 | import android.content.Context; |
| 27 | import android.content.Intent; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 28 | import android.content.IntentFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | import android.content.pm.PackageManager; |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 30 | import android.net.LinkProperties; |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 31 | import android.net.NetworkCapabilities; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.Binder; |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 33 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.os.Bundle; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 35 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 36 | import android.os.IBinder; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 37 | import android.os.Message; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | import android.os.RemoteException; |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 39 | import android.os.UserHandle; |
zoey chen | b1f74e7 | 2019-12-04 16:33:59 +0800 | [diff] [blame] | 40 | import android.telephony.Annotation; |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 41 | import android.telephony.Annotation.DataFailureCause; |
| 42 | import android.telephony.Annotation.RadioPowerState; |
| 43 | import android.telephony.Annotation.SrvccState; |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 44 | import android.telephony.CallAttributes; |
| 45 | import android.telephony.CallQuality; |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 46 | import android.telephony.CellInfo; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 47 | import android.telephony.CellLocation; |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 48 | import android.telephony.DataFailCause; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 49 | import android.telephony.DisconnectCause; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 50 | import android.telephony.LocationAccessPolicy; |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 51 | import android.telephony.PhoneCapability; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 52 | import android.telephony.PhoneStateListener; |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 53 | import android.telephony.PhysicalChannelConfig; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 54 | import android.telephony.PreciseCallState; |
| 55 | import android.telephony.PreciseDataConnectionState; |
| 56 | import android.telephony.PreciseDisconnectCause; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 57 | import android.telephony.Rlog; |
| 58 | import android.telephony.ServiceState; |
| 59 | import android.telephony.SignalStrength; |
| 60 | import android.telephony.SubscriptionManager; |
| 61 | import android.telephony.TelephonyManager; |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 62 | import android.telephony.data.ApnSetting; |
sqian | bdc5a73 | 2018-10-26 13:27:51 -0700 | [diff] [blame] | 63 | import android.telephony.emergency.EmergencyNumber; |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 64 | import android.telephony.ims.ImsReasonInfo; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 65 | import android.util.LocalLog; |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 66 | import android.util.StatsLog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | |
Malcolm Chen | 3ceeedd | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 68 | import com.android.internal.annotations.VisibleForTesting; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 69 | import com.android.internal.app.IBatteryStats; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 70 | import com.android.internal.telephony.IOnSubscriptionsChangedListener; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 71 | import com.android.internal.telephony.IPhoneStateListener; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 72 | import com.android.internal.telephony.ITelephonyRegistry; |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 73 | import com.android.internal.telephony.PhoneConstantConversions; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 74 | import com.android.internal.telephony.PhoneConstants; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | import com.android.internal.telephony.TelephonyIntents; |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 76 | import com.android.internal.telephony.TelephonyPermissions; |
chen xu | badf2b0 | 2019-04-26 17:45:26 -0700 | [diff] [blame] | 77 | import com.android.internal.util.ArrayUtils; |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 78 | import com.android.internal.util.DumpUtils; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 79 | import com.android.internal.util.IndentingPrintWriter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | import com.android.server.am.BatteryStatsService; |
| 81 | |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 82 | import java.io.FileDescriptor; |
| 83 | import java.io.PrintWriter; |
| 84 | import java.util.ArrayList; |
chen xu | 5b98d40 | 2019-03-22 16:56:34 -0700 | [diff] [blame] | 85 | import java.util.Arrays; |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 86 | import java.util.HashMap; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 87 | import java.util.List; |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 88 | import java.util.Map; |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 89 | import java.util.NoSuchElementException; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 90 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 92 | * Since phone process can be restarted, this class provides a centralized place |
| 93 | * that applications can register and be called back from. |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 94 | * |
| 95 | * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026 |
| 96 | * and 15973975 by saving the phoneId of the registrant and then using the |
| 97 | * phoneId when deciding to to make a callback. This is necessary because |
| 98 | * a subId changes from to a dummy value when a SIM is removed and thus won't |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 99 | * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 100 | * the dummy value conversion we properly do the callbacks. |
| 101 | * |
| 102 | * Eventually we may want to remove the notion of dummy value but for now this |
| 103 | * looks like the best approach. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | */ |
Malcolm Chen | 3ceeedd | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 105 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 106 | public class TelephonyRegistry extends ITelephonyRegistry.Stub { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | private static final String TAG = "TelephonyRegistry"; |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 108 | private static final boolean DBG = false; // STOPSHIP if true |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 109 | private static final boolean DBG_LOC = false; // STOPSHIP if true |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 110 | private static final boolean VDBG = false; // STOPSHIP if true |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 111 | |
| 112 | private static class Record { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 113 | Context context; |
| 114 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 115 | String callingPackage; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 116 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 117 | IBinder binder; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 118 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 119 | TelephonyRegistryDeathRecipient deathRecipient; |
| 120 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 121 | IPhoneStateListener callback; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 122 | IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback; |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 123 | IOnSubscriptionsChangedListener onOpportunisticSubscriptionsChangedListenerCallback; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 124 | |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 125 | int callerUid; |
| 126 | int callerPid; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 127 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 128 | int events; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 129 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 130 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 131 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 132 | int phoneId = SubscriptionManager.INVALID_PHONE_INDEX; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 133 | |
| 134 | boolean matchPhoneStateListenerEvent(int events) { |
| 135 | return (callback != null) && ((events & this.events) != 0); |
| 136 | } |
| 137 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 138 | boolean matchOnSubscriptionsChangedListener() { |
| 139 | return (onSubscriptionsChangedListenerCallback != null); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 140 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 141 | |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 142 | boolean matchOnOpportunisticSubscriptionsChangedListener() { |
| 143 | return (onOpportunisticSubscriptionsChangedListenerCallback != null); |
| 144 | } |
| 145 | |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 146 | boolean canReadCallLog() { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 147 | try { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 148 | return TelephonyPermissions.checkReadCallLog( |
| 149 | context, subId, callerPid, callerUid, callingPackage); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 150 | } catch (SecurityException e) { |
| 151 | return false; |
| 152 | } |
| 153 | } |
| 154 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 155 | @Override |
| 156 | public String toString() { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 157 | return "{callingPackage=" + callingPackage + " binder=" + binder |
| 158 | + " callback=" + callback |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 159 | + " onSubscriptionsChangedListenererCallback=" |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 160 | + onSubscriptionsChangedListenerCallback |
| 161 | + " onOpportunisticSubscriptionsChangedListenererCallback=" |
| 162 | + onOpportunisticSubscriptionsChangedListenerCallback |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 163 | + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 164 | + " events=" + Integer.toHexString(events) + "}"; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 165 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | private final Context mContext; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 169 | |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 170 | // access should be inside synchronized (mRecords) for these two fields |
| 171 | private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>(); |
| 172 | private final ArrayList<Record> mRecords = new ArrayList<Record>(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 173 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | private final IBatteryStats mBatteryStats; |
| 175 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 176 | private final AppOpsManager mAppOps; |
| 177 | |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 178 | private boolean mHasNotifySubscriptionInfoChangedOccurred = false; |
| 179 | |
| 180 | private boolean mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = false; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 181 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 182 | private int mNumPhones; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 183 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 184 | private int[] mCallState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 185 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 186 | private String[] mCallIncomingNumber; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 187 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 188 | private ServiceState[] mServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 189 | |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 190 | private int[] mVoiceActivationState; |
| 191 | |
| 192 | private int[] mDataActivationState; |
| 193 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 194 | private boolean[] mUserMobileDataState; |
| 195 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 196 | private SignalStrength[] mSignalStrength; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 197 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 198 | private boolean[] mMessageWaiting; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 199 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 200 | private boolean[] mCallForwarding; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 201 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 202 | private int[] mDataActivity; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 203 | |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 204 | // Connection state of default APN type data (i.e. internet) of phones |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 205 | private int[] mDataConnectionState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 206 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 207 | private Bundle[] mCellLocation; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 208 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 209 | private int[] mDataConnectionNetworkType; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 210 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 211 | private int[] mOtaspMode; |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 212 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 213 | private ArrayList<List<CellInfo>> mCellInfo = null; |
| 214 | |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 215 | private ArrayList<List<PhysicalChannelConfig>> mPhysicalChannelConfigs; |
| 216 | |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 217 | private Map<Integer, List<EmergencyNumber>> mEmergencyNumberList; |
| 218 | |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 219 | private EmergencyNumber[] mOutgoingSmsEmergencyNumber; |
| 220 | |
| 221 | private EmergencyNumber[] mOutgoingCallEmergencyNumber; |
| 222 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 223 | private CallQuality[] mCallQuality; |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 224 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 225 | private CallAttributes[] mCallAttributes; |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 226 | |
Jordan Liu | 65ed9d9 | 2019-02-19 14:42:07 -0800 | [diff] [blame] | 227 | // network type of the call associated with the mCallAttributes and mCallQuality |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 228 | private int[] mCallNetworkType; |
Jordan Liu | 65ed9d9 | 2019-02-19 14:42:07 -0800 | [diff] [blame] | 229 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 230 | private int[] mSrvccState; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 231 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 232 | private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 233 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 234 | private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 235 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 236 | private int[] mRingingCallState; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 237 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 238 | private int[] mForegroundCallState; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 239 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 240 | private int[] mBackgroundCallState; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 241 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 242 | private PreciseCallState[] mPreciseCallState; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 243 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 244 | private int[] mCallDisconnectCause; |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 245 | |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 246 | private List<ImsReasonInfo> mImsReasonInfo = null; |
| 247 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 248 | private int[] mCallPreciseDisconnectCause; |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 249 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 250 | private boolean mCarrierNetworkChangeState = false; |
| 251 | |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 252 | private PhoneCapability mPhoneCapability = null; |
| 253 | |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 254 | private int mActiveDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 255 | |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 256 | @RadioPowerState |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 257 | private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE; |
| 258 | |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 259 | private final LocalLog mLocalLog = new LocalLog(100); |
| 260 | |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 261 | private final LocalLog mListenLog = new LocalLog(100); |
| 262 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 263 | private PreciseDataConnectionState[] mPreciseDataConnectionState; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 264 | |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 265 | // Nothing here yet, but putting it here in case we want to add more in the future. |
| 266 | static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK = 0; |
| 267 | |
| 268 | static final int ENFORCE_FINE_LOCATION_PERMISSION_MASK = |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 269 | PhoneStateListener.LISTEN_CELL_LOCATION |
| 270 | | PhoneStateListener.LISTEN_CELL_INFO; |
| 271 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 272 | static final int ENFORCE_PHONE_STATE_PERMISSION_MASK = |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 273 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR |
| 274 | | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR |
sqian | 9e9ed18 | 2019-03-20 16:17:09 -0700 | [diff] [blame] | 275 | | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST; |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 276 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 277 | static final int PRECISE_PHONE_STATE_PERMISSION_MASK = |
| 278 | PhoneStateListener.LISTEN_PRECISE_CALL_STATE | |
| 279 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; |
| 280 | |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 281 | static final int READ_ACTIVE_EMERGENCY_SESSION_PERMISSION_MASK = |
Shuo Qian | d966376 | 2019-10-04 13:20:45 -0700 | [diff] [blame] | 282 | PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_CALL |
| 283 | | PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_SMS; |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 284 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 285 | private static final int MSG_USER_SWITCHED = 1; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 286 | private static final int MSG_UPDATE_DEFAULT_SUB = 2; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 287 | |
| 288 | private final Handler mHandler = new Handler() { |
| 289 | @Override |
| 290 | public void handleMessage(Message msg) { |
| 291 | switch (msg.what) { |
| 292 | case MSG_USER_SWITCHED: { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 293 | if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1); |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 294 | int numPhones = getTelephonyManager().getPhoneCount(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 295 | for (int sub = 0; sub < numPhones; sub++) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 296 | TelephonyRegistry.this.notifyCellLocationForSubscriber(sub, |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 297 | mCellLocation[sub]); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 298 | } |
| 299 | break; |
| 300 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 301 | case MSG_UPDATE_DEFAULT_SUB: { |
| 302 | int newDefaultPhoneId = msg.arg1; |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 303 | int newDefaultSubId = msg.arg2; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 304 | if (VDBG) { |
| 305 | log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 306 | + " current mDefaultPhoneId=" + mDefaultPhoneId |
| 307 | + " newDefaultSubId=" + newDefaultSubId |
| 308 | + " newDefaultPhoneId=" + newDefaultPhoneId); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | //Due to possible risk condition,(notify call back using the new |
| 312 | //defaultSubId comes before new defaultSubId update) we need to recall all |
| 313 | //possible missed notify callback |
| 314 | synchronized (mRecords) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 315 | for (Record r : mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 316 | if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 317 | checkPossibleMissNotify(r, newDefaultPhoneId); |
| 318 | } |
| 319 | } |
| 320 | handleRemoveListLocked(); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 321 | } |
| 322 | mDefaultSubId = newDefaultSubId; |
| 323 | mDefaultPhoneId = newDefaultPhoneId; |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 324 | mLocalLog.log("Default subscription updated: mDefaultPhoneId=" |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 325 | + mDefaultPhoneId + ", mDefaultSubId=" + mDefaultSubId); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 326 | } |
| 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 331 | private class TelephonyRegistryDeathRecipient implements IBinder.DeathRecipient { |
| 332 | |
| 333 | private final IBinder binder; |
| 334 | |
| 335 | TelephonyRegistryDeathRecipient(IBinder binder) { |
| 336 | this.binder = binder; |
| 337 | } |
| 338 | |
| 339 | @Override |
| 340 | public void binderDied() { |
| 341 | if (DBG) log("binderDied " + binder); |
| 342 | remove(binder); |
| 343 | } |
| 344 | } |
| 345 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 346 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 347 | @Override |
| 348 | public void onReceive(Context context, Intent intent) { |
| 349 | String action = intent.getAction(); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 350 | if (VDBG) log("mBroadcastReceiver: action=" + action); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 351 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 352 | int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 353 | if (DBG) log("onReceive: userHandle=" + userHandle); |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 354 | mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0)); |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 355 | } else if (action.equals(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) { |
| 356 | int newDefaultSubId = intent.getIntExtra( |
| 357 | SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, |
| 358 | SubscriptionManager.getDefaultSubscriptionId()); |
| 359 | int newDefaultPhoneId = intent.getIntExtra( |
| 360 | PhoneConstants.PHONE_KEY, |
| 361 | SubscriptionManager.getPhoneId(newDefaultSubId)); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 362 | if (DBG) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 363 | log("onReceive:current mDefaultSubId=" + mDefaultSubId |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 364 | + " current mDefaultPhoneId=" + mDefaultPhoneId |
| 365 | + " newDefaultSubId=" + newDefaultSubId |
| 366 | + " newDefaultPhoneId=" + newDefaultPhoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 367 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 368 | |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 369 | if (validatePhoneId(newDefaultPhoneId) |
| 370 | && (newDefaultSubId != mDefaultSubId |
| 371 | || newDefaultPhoneId != mDefaultPhoneId)) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 372 | mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB, |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 373 | newDefaultPhoneId, newDefaultSubId)); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 374 | } |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 375 | } else if (action.equals(ACTION_MULTI_SIM_CONFIG_CHANGED)) { |
| 376 | onMultiSimConfigChanged(); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 377 | } |
| 378 | } |
| 379 | }; |
| 380 | |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 381 | private TelephonyManager getTelephonyManager() { |
| 382 | return (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); |
| 383 | } |
| 384 | |
| 385 | private void onMultiSimConfigChanged() { |
| 386 | int oldNumPhones = mNumPhones; |
| 387 | mNumPhones = getTelephonyManager().getActiveModemCount(); |
| 388 | if (oldNumPhones == mNumPhones) return; |
| 389 | |
| 390 | if (DBG) { |
| 391 | log("TelephonyRegistry: activeModemCount changed from " + oldNumPhones |
| 392 | + " to " + mNumPhones); |
| 393 | } |
| 394 | mCallState = copyOf(mCallState, mNumPhones); |
| 395 | mDataActivity = copyOf(mCallState, mNumPhones); |
| 396 | mDataConnectionState = copyOf(mCallState, mNumPhones); |
| 397 | mDataConnectionNetworkType = copyOf(mCallState, mNumPhones); |
| 398 | mCallIncomingNumber = copyOf(mCallIncomingNumber, mNumPhones); |
| 399 | mServiceState = copyOf(mServiceState, mNumPhones); |
| 400 | mVoiceActivationState = copyOf(mVoiceActivationState, mNumPhones); |
| 401 | mDataActivationState = copyOf(mDataActivationState, mNumPhones); |
| 402 | mUserMobileDataState = copyOf(mUserMobileDataState, mNumPhones); |
| 403 | mSignalStrength = copyOf(mSignalStrength, mNumPhones); |
| 404 | mMessageWaiting = copyOf(mMessageWaiting, mNumPhones); |
| 405 | mCallForwarding = copyOf(mCallForwarding, mNumPhones); |
| 406 | mCellLocation = copyOf(mCellLocation, mNumPhones); |
| 407 | mSrvccState = copyOf(mSrvccState, mNumPhones); |
| 408 | mOtaspMode = copyOf(mOtaspMode, mNumPhones); |
| 409 | mPreciseCallState = copyOf(mPreciseCallState, mNumPhones); |
| 410 | mForegroundCallState = copyOf(mForegroundCallState, mNumPhones); |
| 411 | mBackgroundCallState = copyOf(mBackgroundCallState, mNumPhones); |
| 412 | mRingingCallState = copyOf(mRingingCallState, mNumPhones); |
| 413 | mCallDisconnectCause = copyOf(mCallDisconnectCause, mNumPhones); |
| 414 | mCallPreciseDisconnectCause = copyOf(mCallPreciseDisconnectCause, mNumPhones); |
| 415 | mCallQuality = copyOf(mCallQuality, mNumPhones); |
| 416 | mCallNetworkType = copyOf(mCallNetworkType, mNumPhones); |
| 417 | mCallAttributes = copyOf(mCallAttributes, mNumPhones); |
| 418 | mPreciseDataConnectionState = copyOf(mPreciseDataConnectionState, mNumPhones); |
| 419 | mOutgoingCallEmergencyNumber = copyOf(mOutgoingCallEmergencyNumber, mNumPhones); |
| 420 | mOutgoingSmsEmergencyNumber = copyOf(mOutgoingSmsEmergencyNumber, mNumPhones); |
| 421 | |
| 422 | // ds -> ss switch. |
| 423 | if (mNumPhones < oldNumPhones) { |
| 424 | cutListToSize(mCellInfo, mNumPhones); |
| 425 | cutListToSize(mImsReasonInfo, mNumPhones); |
| 426 | cutListToSize(mPhysicalChannelConfigs, mNumPhones); |
| 427 | return; |
| 428 | } |
| 429 | |
| 430 | // mNumPhones > oldNumPhones: ss -> ds switch |
| 431 | for (int i = oldNumPhones; i < mNumPhones; i++) { |
| 432 | mCallState[i] = TelephonyManager.CALL_STATE_IDLE; |
| 433 | mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; |
| 434 | mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN; |
| 435 | mVoiceActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 436 | mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 437 | mCallIncomingNumber[i] = ""; |
| 438 | mServiceState[i] = new ServiceState(); |
| 439 | mSignalStrength[i] = new SignalStrength(); |
| 440 | mUserMobileDataState[i] = false; |
| 441 | mMessageWaiting[i] = false; |
| 442 | mCallForwarding[i] = false; |
| 443 | mCellLocation[i] = new Bundle(); |
| 444 | mCellInfo.add(i, null); |
| 445 | mImsReasonInfo.add(i, null); |
| 446 | mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE; |
| 447 | mPhysicalChannelConfigs.add(i, new ArrayList<>()); |
| 448 | mOtaspMode[i] = TelephonyManager.OTASP_UNKNOWN; |
| 449 | mCallDisconnectCause[i] = DisconnectCause.NOT_VALID; |
| 450 | mCallPreciseDisconnectCause[i] = PreciseDisconnectCause.NOT_VALID; |
| 451 | mCallQuality[i] = new CallQuality(); |
| 452 | mCallAttributes[i] = new CallAttributes(new PreciseCallState(), |
| 453 | TelephonyManager.NETWORK_TYPE_UNKNOWN, new CallQuality()); |
| 454 | mCallNetworkType[i] = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 455 | mPreciseCallState[i] = new PreciseCallState(); |
| 456 | mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 457 | mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 458 | mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 459 | mPreciseDataConnectionState[i] = new PreciseDataConnectionState(); |
| 460 | } |
| 461 | |
| 462 | // Note that location can be null for non-phone builds like |
| 463 | // like the generic one. |
| 464 | CellLocation location = CellLocation.getEmpty(); |
| 465 | if (location != null) { |
| 466 | for (int i = oldNumPhones; i < mNumPhones; i++) { |
| 467 | location.fillInNotifierBundle(mCellLocation[i]); |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | |
| 472 | private void cutListToSize(List list, int size) { |
| 473 | if (list == null) return; |
| 474 | |
| 475 | while (list.size() > size) { |
| 476 | list.remove(list.size() - 1); |
| 477 | } |
| 478 | } |
| 479 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 480 | // we keep a copy of all of the state so we can send it out when folks |
| 481 | // register for it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | // |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 483 | // In these calls we call with the lock held. This is safe becasuse remote |
| 484 | // calls go through a oneway interface and local calls going through a |
| 485 | // handler before they get to app code. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 486 | |
Malcolm Chen | 3ceeedd | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 487 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 488 | public TelephonyRegistry(Context context) { |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 489 | CellLocation location = CellLocation.getEmpty(); |
| 490 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 491 | mContext = context; |
| 492 | mBatteryStats = BatteryStatsService.getService(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 493 | |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 494 | int numPhones = getTelephonyManager().getActiveModemCount(); |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 495 | if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 496 | mNumPhones = numPhones; |
| 497 | mCallState = new int[numPhones]; |
| 498 | mDataActivity = new int[numPhones]; |
| 499 | mDataConnectionState = new int[numPhones]; |
| 500 | mDataConnectionNetworkType = new int[numPhones]; |
| 501 | mCallIncomingNumber = new String[numPhones]; |
| 502 | mServiceState = new ServiceState[numPhones]; |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 503 | mVoiceActivationState = new int[numPhones]; |
| 504 | mDataActivationState = new int[numPhones]; |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 505 | mUserMobileDataState = new boolean[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 506 | mSignalStrength = new SignalStrength[numPhones]; |
| 507 | mMessageWaiting = new boolean[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 508 | mCallForwarding = new boolean[numPhones]; |
| 509 | mCellLocation = new Bundle[numPhones]; |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 510 | mSrvccState = new int[numPhones]; |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 511 | mOtaspMode = new int[numPhones]; |
| 512 | mPreciseCallState = new PreciseCallState[numPhones]; |
| 513 | mForegroundCallState = new int[numPhones]; |
| 514 | mBackgroundCallState = new int[numPhones]; |
| 515 | mRingingCallState = new int[numPhones]; |
| 516 | mCallDisconnectCause = new int[numPhones]; |
| 517 | mCallPreciseDisconnectCause = new int[numPhones]; |
| 518 | mCallQuality = new CallQuality[numPhones]; |
| 519 | mCallNetworkType = new int[numPhones]; |
| 520 | mCallAttributes = new CallAttributes[numPhones]; |
| 521 | mPreciseDataConnectionState = new PreciseDataConnectionState[numPhones]; |
| 522 | mCellInfo = new ArrayList<>(); |
| 523 | mImsReasonInfo = new ArrayList<>(); |
| 524 | mPhysicalChannelConfigs = new ArrayList<>(); |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 525 | mEmergencyNumberList = new HashMap<>(); |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 526 | mOutgoingCallEmergencyNumber = new EmergencyNumber[numPhones]; |
| 527 | mOutgoingSmsEmergencyNumber = new EmergencyNumber[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 528 | for (int i = 0; i < numPhones; i++) { |
| 529 | mCallState[i] = TelephonyManager.CALL_STATE_IDLE; |
| 530 | mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; |
| 531 | mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN; |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 532 | mVoiceActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 533 | mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 534 | mCallIncomingNumber[i] = ""; |
| 535 | mServiceState[i] = new ServiceState(); |
| 536 | mSignalStrength[i] = new SignalStrength(); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 537 | mUserMobileDataState[i] = false; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 538 | mMessageWaiting[i] = false; |
| 539 | mCallForwarding[i] = false; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 540 | mCellLocation[i] = new Bundle(); |
| 541 | mCellInfo.add(i, null); |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 542 | mImsReasonInfo.add(i, null); |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 543 | mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE; |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 544 | mPhysicalChannelConfigs.add(i, new ArrayList<>()); |
| 545 | mOtaspMode[i] = TelephonyManager.OTASP_UNKNOWN; |
| 546 | mCallDisconnectCause[i] = DisconnectCause.NOT_VALID; |
| 547 | mCallPreciseDisconnectCause[i] = PreciseDisconnectCause.NOT_VALID; |
| 548 | mCallQuality[i] = new CallQuality(); |
| 549 | mCallAttributes[i] = new CallAttributes(new PreciseCallState(), |
| 550 | TelephonyManager.NETWORK_TYPE_UNKNOWN, new CallQuality()); |
| 551 | mCallNetworkType[i] = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 552 | mPreciseCallState[i] = new PreciseCallState(); |
| 553 | mRingingCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 554 | mForegroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 555 | mBackgroundCallState[i] = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 556 | mPreciseDataConnectionState[i] = new PreciseDataConnectionState(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 557 | } |
| 558 | |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 559 | // Note that location can be null for non-phone builds like |
| 560 | // like the generic one. |
| 561 | if (location != null) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 562 | for (int i = 0; i < numPhones; i++) { |
| 563 | location.fillInNotifierBundle(mCellLocation[i]); |
| 564 | } |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 565 | } |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 566 | |
| 567 | mAppOps = mContext.getSystemService(AppOpsManager.class); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | } |
| 569 | |
Svetoslav Ganov | a002715 | 2013-06-25 14:59:53 -0700 | [diff] [blame] | 570 | public void systemRunning() { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 571 | // Watch for interesting updates |
| 572 | final IntentFilter filter = new IntentFilter(); |
| 573 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
| 574 | filter.addAction(Intent.ACTION_USER_REMOVED); |
Taesu Lee | c955cd9 | 2019-09-23 08:06:31 +0900 | [diff] [blame] | 575 | filter.addAction(SubscriptionManager.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 576 | filter.addAction(ACTION_MULTI_SIM_CONFIG_CHANGED); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 577 | log("systemRunning register for intents"); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 578 | mContext.registerReceiver(mBroadcastReceiver, filter); |
| 579 | } |
| 580 | |
| 581 | @Override |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 582 | public void addOnSubscriptionsChangedListener(String callingPackage, |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 583 | IOnSubscriptionsChangedListener callback) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 584 | int callerUserId = UserHandle.getCallingUserId(); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 585 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 586 | if (VDBG) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 587 | log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId() |
| 588 | + " callerUserId=" + callerUserId + " callback=" + callback |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 589 | + " callback.asBinder=" + callback.asBinder()); |
| 590 | } |
| 591 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 592 | synchronized (mRecords) { |
| 593 | // register |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 594 | IBinder b = callback.asBinder(); |
| 595 | Record r = add(b); |
| 596 | |
| 597 | if (r == null) { |
| 598 | return; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 599 | } |
| 600 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 601 | r.context = mContext; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 602 | r.onSubscriptionsChangedListenerCallback = callback; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 603 | r.callingPackage = callingPackage; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 604 | r.callerUid = Binder.getCallingUid(); |
| 605 | r.callerPid = Binder.getCallingPid(); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 606 | r.events = 0; |
| 607 | if (DBG) { |
| 608 | log("listen oscl: Register r=" + r); |
| 609 | } |
| 610 | // Always notify when registration occurs if there has been a notification. |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 611 | if (mHasNotifySubscriptionInfoChangedOccurred) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 612 | try { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 613 | if (VDBG) log("listen oscl: send to r=" + r); |
| 614 | r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 615 | if (VDBG) log("listen oscl: sent to r=" + r); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 616 | } catch (RemoteException e) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 617 | if (VDBG) log("listen oscl: remote exception sending to r=" + r + " e=" + e); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 618 | remove(r.binder); |
| 619 | } |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 620 | } else { |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 621 | log("listen oscl: mHasNotifySubscriptionInfoChangedOccurred==false no callback"); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 622 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 623 | } |
| 624 | } |
| 625 | |
| 626 | @Override |
Wink Saville | 071743f | 2015-01-12 17:11:04 -0800 | [diff] [blame] | 627 | public void removeOnSubscriptionsChangedListener(String pkgForDebug, |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 628 | IOnSubscriptionsChangedListener callback) { |
| 629 | if (DBG) log("listen oscl: Unregister"); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 630 | remove(callback.asBinder()); |
| 631 | } |
| 632 | |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 633 | |
| 634 | @Override |
| 635 | public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage, |
| 636 | IOnSubscriptionsChangedListener callback) { |
| 637 | int callerUserId = UserHandle.getCallingUserId(); |
| 638 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 639 | if (VDBG) { |
| 640 | log("listen ooscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId() |
| 641 | + " callerUserId=" + callerUserId + " callback=" + callback |
| 642 | + " callback.asBinder=" + callback.asBinder()); |
| 643 | } |
| 644 | |
| 645 | synchronized (mRecords) { |
| 646 | // register |
| 647 | IBinder b = callback.asBinder(); |
| 648 | Record r = add(b); |
| 649 | |
| 650 | if (r == null) { |
| 651 | return; |
| 652 | } |
| 653 | |
| 654 | r.context = mContext; |
| 655 | r.onOpportunisticSubscriptionsChangedListenerCallback = callback; |
| 656 | r.callingPackage = callingPackage; |
| 657 | r.callerUid = Binder.getCallingUid(); |
| 658 | r.callerPid = Binder.getCallingPid(); |
| 659 | r.events = 0; |
| 660 | if (DBG) { |
| 661 | log("listen ooscl: Register r=" + r); |
| 662 | } |
| 663 | // Always notify when registration occurs if there has been a notification. |
| 664 | if (mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) { |
| 665 | try { |
| 666 | if (VDBG) log("listen ooscl: send to r=" + r); |
| 667 | r.onOpportunisticSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 668 | if (VDBG) log("listen ooscl: sent to r=" + r); |
| 669 | } catch (RemoteException e) { |
| 670 | if (VDBG) log("listen ooscl: remote exception sending to r=" + r + " e=" + e); |
| 671 | remove(r.binder); |
| 672 | } |
| 673 | } else { |
| 674 | log("listen ooscl: hasNotifyOpptSubInfoChangedOccurred==false no callback"); |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 679 | @Override |
| 680 | public void notifySubscriptionInfoChanged() { |
| 681 | if (VDBG) log("notifySubscriptionInfoChanged:"); |
| 682 | synchronized (mRecords) { |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 683 | if (!mHasNotifySubscriptionInfoChangedOccurred) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 684 | log("notifySubscriptionInfoChanged: first invocation mRecords.size=" |
| 685 | + mRecords.size()); |
| 686 | } |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 687 | mHasNotifySubscriptionInfoChangedOccurred = true; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 688 | mRemoveList.clear(); |
| 689 | for (Record r : mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 690 | if (r.matchOnSubscriptionsChangedListener()) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 691 | try { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 692 | if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r); |
| 693 | r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 694 | if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 695 | } catch (RemoteException ex) { |
| 696 | if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r); |
| 697 | mRemoveList.add(r.binder); |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | handleRemoveListLocked(); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | @Override |
Malcolm Chen | 13f31af | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 706 | public void notifyOpportunisticSubscriptionInfoChanged() { |
| 707 | if (VDBG) log("notifyOpptSubscriptionInfoChanged:"); |
| 708 | synchronized (mRecords) { |
| 709 | if (!mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) { |
| 710 | log("notifyOpptSubscriptionInfoChanged: first invocation mRecords.size=" |
| 711 | + mRecords.size()); |
| 712 | } |
| 713 | mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = true; |
| 714 | mRemoveList.clear(); |
| 715 | for (Record r : mRecords) { |
| 716 | if (r.matchOnOpportunisticSubscriptionsChangedListener()) { |
| 717 | try { |
| 718 | if (VDBG) log("notifyOpptSubChanged: call oosc to r=" + r); |
| 719 | r.onOpportunisticSubscriptionsChangedListenerCallback |
| 720 | .onSubscriptionsChanged(); |
| 721 | if (VDBG) log("notifyOpptSubChanged: done oosc to r=" + r); |
| 722 | } catch (RemoteException ex) { |
| 723 | if (VDBG) log("notifyOpptSubChanged: RemoteException r=" + r); |
| 724 | mRemoveList.add(r.binder); |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | handleRemoveListLocked(); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 733 | public void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 734 | boolean notifyNow) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 735 | listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback, |
| 736 | events, notifyNow); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 740 | public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 741 | int events, boolean notifyNow) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 742 | listen(pkgForDebug, callback, events, notifyNow, subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 743 | } |
| 744 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 745 | private void listen(String callingPackage, IPhoneStateListener callback, int events, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 746 | boolean notifyNow, int subId) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 747 | int callerUserId = UserHandle.getCallingUserId(); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 748 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 749 | String str = "listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events) |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 750 | + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId=" |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 751 | + UserHandle.myUserId() + " callerUserId=" + callerUserId; |
| 752 | mListenLog.log(str); |
| 753 | if (VDBG) { |
| 754 | log(str); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 755 | } |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 756 | |
| 757 | if (events != PhoneStateListener.LISTEN_NONE) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 758 | // Checks permission and throws SecurityException for disallowed operations. For pre-M |
| 759 | // apps whose runtime permission has been revoked, we return immediately to skip sending |
| 760 | // events to the app without crashing it. |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 761 | if (!checkListenerPermission(events, subId, callingPackage, "listen")) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 762 | return; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 763 | } |
| 764 | |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 765 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 766 | synchronized (mRecords) { |
| 767 | // register |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 768 | IBinder b = callback.asBinder(); |
| 769 | Record r = add(b); |
| 770 | |
| 771 | if (r == null) { |
| 772 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 773 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 774 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 775 | r.context = mContext; |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 776 | r.callback = callback; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 777 | r.callingPackage = callingPackage; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 778 | r.callerUid = Binder.getCallingUid(); |
| 779 | r.callerPid = Binder.getCallingPid(); |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 780 | // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, |
| 781 | // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID |
Wink Saville | a54bf65 | 2014-12-11 13:37:50 -0800 | [diff] [blame] | 782 | if (!SubscriptionManager.isValidSubscriptionId(subId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 783 | r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 784 | } else {//APP specify subID |
| 785 | r.subId = subId; |
| 786 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 787 | r.phoneId = phoneId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 788 | r.events = events; |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 789 | if (DBG) { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 790 | log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 791 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 792 | if (notifyNow && validatePhoneId(phoneId)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 793 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 794 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 795 | if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]); |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 796 | ServiceState rawSs = new ServiceState(mServiceState[phoneId]); |
| 797 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
| 798 | r.callback.onServiceStateChanged(rawSs); |
| 799 | } else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) { |
| 800 | r.callback.onServiceStateChanged(rawSs.sanitizeLocationInfo(false)); |
| 801 | } else { |
| 802 | r.callback.onServiceStateChanged(rawSs.sanitizeLocationInfo(true)); |
| 803 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 804 | } catch (RemoteException ex) { |
| 805 | remove(r.binder); |
| 806 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 807 | } |
| 808 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 809 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 810 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 811 | .getGsmSignalStrength(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 812 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 813 | : gsmSignalStrength)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 814 | } catch (RemoteException ex) { |
| 815 | remove(r.binder); |
| 816 | } |
| 817 | } |
| 818 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 819 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 820 | r.callback.onMessageWaitingIndicatorChanged( |
| 821 | mMessageWaiting[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 822 | } catch (RemoteException ex) { |
| 823 | remove(r.binder); |
| 824 | } |
| 825 | } |
| 826 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 827 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 828 | r.callback.onCallForwardingIndicatorChanged( |
| 829 | mCallForwarding[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 830 | } catch (RemoteException ex) { |
| 831 | remove(r.binder); |
| 832 | } |
| 833 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 834 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 835 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 836 | if (DBG_LOC) log("listen: mCellLocation = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 837 | + mCellLocation[phoneId]); |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 838 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 839 | r.callback.onCellLocationChanged( |
| 840 | new Bundle(mCellLocation[phoneId])); |
| 841 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 842 | } catch (RemoteException ex) { |
| 843 | remove(r.binder); |
| 844 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 845 | } |
| 846 | if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 847 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 848 | r.callback.onCallStateChanged(mCallState[phoneId], |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 849 | getCallIncomingNumber(r, phoneId)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | } catch (RemoteException ex) { |
| 851 | remove(r.binder); |
| 852 | } |
| 853 | } |
| 854 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 855 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 856 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 857 | mDataConnectionNetworkType[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 858 | } catch (RemoteException ex) { |
| 859 | remove(r.binder); |
| 860 | } |
| 861 | } |
| 862 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 863 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 864 | r.callback.onDataActivity(mDataActivity[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 865 | } catch (RemoteException ex) { |
| 866 | remove(r.binder); |
| 867 | } |
| 868 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 869 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 870 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 871 | r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 872 | } catch (RemoteException ex) { |
| 873 | remove(r.binder); |
| 874 | } |
| 875 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 876 | if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 877 | try { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 878 | r.callback.onOtaspChanged(mOtaspMode[phoneId]); |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 879 | } catch (RemoteException ex) { |
| 880 | remove(r.binder); |
| 881 | } |
| 882 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 883 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 884 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 885 | if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 886 | + mCellInfo.get(phoneId)); |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 887 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 888 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
| 889 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 890 | } catch (RemoteException ex) { |
| 891 | remove(r.binder); |
| 892 | } |
| 893 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 894 | if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 895 | try { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 896 | r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 897 | } catch (RemoteException ex) { |
| 898 | remove(r.binder); |
| 899 | } |
| 900 | } |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 901 | if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { |
| 902 | try { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 903 | r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId], |
| 904 | mCallPreciseDisconnectCause[phoneId]); |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 905 | } catch (RemoteException ex) { |
| 906 | remove(r.binder); |
| 907 | } |
| 908 | } |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 909 | if ((events & PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) != 0) { |
| 910 | try { |
| 911 | r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(phoneId)); |
| 912 | } catch (RemoteException ex) { |
| 913 | remove(r.binder); |
| 914 | } |
| 915 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 916 | if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 917 | try { |
| 918 | r.callback.onPreciseDataConnectionStateChanged( |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 919 | mPreciseDataConnectionState[phoneId]); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 920 | } catch (RemoteException ex) { |
| 921 | remove(r.binder); |
| 922 | } |
| 923 | } |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 924 | if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) { |
| 925 | try { |
| 926 | r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState); |
| 927 | } catch (RemoteException ex) { |
| 928 | remove(r.binder); |
| 929 | } |
| 930 | } |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 931 | if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) !=0) { |
| 932 | try { |
| 933 | r.callback.onVoiceActivationStateChanged(mVoiceActivationState[phoneId]); |
| 934 | } catch (RemoteException ex) { |
| 935 | remove(r.binder); |
| 936 | } |
| 937 | } |
| 938 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) !=0) { |
| 939 | try { |
| 940 | r.callback.onDataActivationStateChanged(mDataActivationState[phoneId]); |
| 941 | } catch (RemoteException ex) { |
| 942 | remove(r.binder); |
| 943 | } |
| 944 | } |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 945 | if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) { |
| 946 | try { |
| 947 | r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]); |
| 948 | } catch (RemoteException ex) { |
| 949 | remove(r.binder); |
| 950 | } |
| 951 | } |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 952 | if ((events & PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) != 0) { |
| 953 | try { |
| 954 | r.callback.onPhysicalChannelConfigurationChanged( |
| 955 | mPhysicalChannelConfigs.get(phoneId)); |
| 956 | } catch (RemoteException ex) { |
| 957 | remove(r.binder); |
| 958 | } |
| 959 | } |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 960 | if ((events & PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) != 0) { |
| 961 | try { |
| 962 | r.callback.onEmergencyNumberListChanged(mEmergencyNumberList); |
| 963 | } catch (RemoteException ex) { |
| 964 | remove(r.binder); |
| 965 | } |
| 966 | } |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 967 | if ((events & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) { |
| 968 | try { |
| 969 | r.callback.onPhoneCapabilityChanged(mPhoneCapability); |
| 970 | } catch (RemoteException ex) { |
| 971 | remove(r.binder); |
| 972 | } |
| 973 | } |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 974 | if ((events & PhoneStateListener |
Malcolm Chen | 118b02f | 2019-09-04 16:10:34 -0700 | [diff] [blame] | 975 | .LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE) != 0) { |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 976 | try { |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 977 | r.callback.onActiveDataSubIdChanged(mActiveDataSubId); |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 978 | } catch (RemoteException ex) { |
| 979 | remove(r.binder); |
| 980 | } |
| 981 | } |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 982 | if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) { |
| 983 | try { |
| 984 | r.callback.onRadioPowerStateChanged(mRadioPowerState); |
| 985 | } catch (RemoteException ex) { |
| 986 | remove(r.binder); |
| 987 | } |
| 988 | } |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 989 | if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) { |
| 990 | try { |
| 991 | r.callback.onSrvccStateChanged(mSrvccState[phoneId]); |
| 992 | } catch (RemoteException ex) { |
| 993 | remove(r.binder); |
| 994 | } |
| 995 | } |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 996 | if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) { |
| 997 | try { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 998 | r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 999 | } catch (RemoteException ex) { |
| 1000 | remove(r.binder); |
| 1001 | } |
| 1002 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1003 | } |
| 1004 | } |
| 1005 | } else { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 1006 | if(DBG) log("listen: Unregister"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1007 | remove(callback.asBinder()); |
| 1008 | } |
| 1009 | } |
| 1010 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 1011 | private String getCallIncomingNumber(Record record, int phoneId) { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1012 | // Only reveal the incoming number if the record has read call log permission. |
| 1013 | return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : ""; |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 1014 | } |
| 1015 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 1016 | private Record add(IBinder binder) { |
| 1017 | Record r; |
| 1018 | |
| 1019 | synchronized (mRecords) { |
| 1020 | final int N = mRecords.size(); |
| 1021 | for (int i = 0; i < N; i++) { |
| 1022 | r = mRecords.get(i); |
| 1023 | if (binder == r.binder) { |
| 1024 | // Already existed. |
| 1025 | return r; |
| 1026 | } |
| 1027 | } |
| 1028 | r = new Record(); |
| 1029 | r.binder = binder; |
| 1030 | r.deathRecipient = new TelephonyRegistryDeathRecipient(binder); |
| 1031 | |
| 1032 | try { |
| 1033 | binder.linkToDeath(r.deathRecipient, 0); |
| 1034 | } catch (RemoteException e) { |
| 1035 | if (VDBG) log("LinkToDeath remote exception sending to r=" + r + " e=" + e); |
| 1036 | // Binder already died. Return null. |
| 1037 | return null; |
| 1038 | } |
| 1039 | |
| 1040 | mRecords.add(r); |
| 1041 | if (DBG) log("add new record"); |
| 1042 | } |
| 1043 | |
| 1044 | return r; |
| 1045 | } |
| 1046 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1047 | private void remove(IBinder binder) { |
| 1048 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1049 | final int recordCount = mRecords.size(); |
| 1050 | for (int i = 0; i < recordCount; i++) { |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 1051 | Record r = mRecords.get(i); |
| 1052 | if (r.binder == binder) { |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 1053 | if (DBG) { |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 1054 | log("remove: binder=" + binder + " r.callingPackage " + r.callingPackage |
| 1055 | + " r.callback " + r.callback); |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 1056 | } |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 1057 | |
| 1058 | if (r.deathRecipient != null) { |
| 1059 | try { |
| 1060 | binder.unlinkToDeath(r.deathRecipient, 0); |
| 1061 | } catch (NoSuchElementException e) { |
| 1062 | if (VDBG) log("UnlinkToDeath NoSuchElementException sending to r=" |
| 1063 | + r + " e=" + e); |
| 1064 | } |
| 1065 | } |
| 1066 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1067 | mRecords.remove(i); |
| 1068 | return; |
| 1069 | } |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1074 | public void notifyCallStateForAllSubs(int state, String phoneNumber) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1075 | if (!checkNotifyPermission("notifyCallState()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1076 | return; |
| 1077 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1078 | |
| 1079 | if (VDBG) { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1080 | log("notifyCallStateForAllSubs: state=" + state + " phoneNumber=" + phoneNumber); |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1081 | } |
| 1082 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1083 | synchronized (mRecords) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 1084 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1085 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1086 | (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1087 | try { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1088 | // Ensure the listener has read call log permission; if they do not return |
| 1089 | // an empty phone number. |
| 1090 | String phoneNumberOrEmpty = r.canReadCallLog() ? phoneNumber : ""; |
| 1091 | r.callback.onCallStateChanged(state, phoneNumberOrEmpty); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1092 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1093 | mRemoveList.add(r.binder); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1094 | } |
| 1095 | } |
| 1096 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1097 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1098 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1099 | |
| 1100 | // Called only by Telecomm to communicate call state across different phone accounts. So |
| 1101 | // there is no need to add a valid subId or slotId. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1102 | broadcastCallStateChanged(state, phoneNumber, |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1103 | SubscriptionManager.INVALID_PHONE_INDEX, |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 1104 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1105 | } |
| 1106 | |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1107 | public void notifyCallState(int phoneId, int subId, int state, String incomingNumber) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1108 | if (!checkNotifyPermission("notifyCallState()")) { |
| 1109 | return; |
| 1110 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1111 | if (VDBG) { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1112 | log("notifyCallState: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1113 | + " state=" + state + " incomingNumber=" + incomingNumber); |
| 1114 | } |
| 1115 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1116 | if (validatePhoneId(phoneId)) { |
| 1117 | mCallState[phoneId] = state; |
| 1118 | mCallIncomingNumber[phoneId] = incomingNumber; |
| 1119 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1120 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1121 | (r.subId == subId) && |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1122 | (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1123 | try { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 1124 | String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId); |
| 1125 | r.callback.onCallStateChanged(state, incomingNumberOrEmpty); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1126 | } catch (RemoteException ex) { |
| 1127 | mRemoveList.add(r.binder); |
| 1128 | } |
| 1129 | } |
| 1130 | } |
| 1131 | } |
| 1132 | handleRemoveListLocked(); |
| 1133 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1134 | broadcastCallStateChanged(state, incomingNumber, phoneId, subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1135 | } |
| 1136 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1137 | public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1138 | if (!checkNotifyPermission("notifyServiceState()")){ |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1139 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1140 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1141 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1142 | synchronized (mRecords) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1143 | String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId |
| 1144 | + " state=" + state; |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1145 | if (VDBG) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1146 | log(str); |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1147 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1148 | mLocalLog.log(str); |
Jordan Liu | d2d614a | 2019-06-24 11:27:34 -0700 | [diff] [blame] | 1149 | // for service state updates, don't notify clients when subId is invalid. This prevents |
| 1150 | // us from sending incorrect notifications like b/133140128 |
| 1151 | // In the future, we can remove this logic for every notification here and add a |
| 1152 | // callback so listeners know when their PhoneStateListener's subId becomes invalid, but |
| 1153 | // for now we use the simplest fix. |
| 1154 | if (validatePhoneId(phoneId) && SubscriptionManager.isValidSubscriptionId(subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1155 | mServiceState[phoneId] = state; |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1156 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1157 | for (Record r : mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1158 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1159 | log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1160 | + " phoneId=" + phoneId + " state=" + state); |
| 1161 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1162 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1163 | idMatch(r.subId, subId, phoneId)) { |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 1164 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1165 | try { |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 1166 | ServiceState stateToSend; |
| 1167 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
| 1168 | stateToSend = new ServiceState(state); |
| 1169 | } else if (checkCoarseLocationAccess(r, Build.VERSION_CODES.Q)) { |
| 1170 | stateToSend = state.sanitizeLocationInfo(false); |
| 1171 | } else { |
| 1172 | stateToSend = state.sanitizeLocationInfo(true); |
| 1173 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1174 | if (DBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1175 | log("notifyServiceStateForSubscriber: callback.onSSC r=" + r |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1176 | + " subId=" + subId + " phoneId=" + phoneId |
| 1177 | + " state=" + state); |
| 1178 | } |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 1179 | r.callback.onServiceStateChanged(stateToSend); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1180 | } catch (RemoteException ex) { |
| 1181 | mRemoveList.add(r.binder); |
| 1182 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1183 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1184 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1185 | } else { |
Jordan Liu | d2d614a | 2019-06-24 11:27:34 -0700 | [diff] [blame] | 1186 | log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId |
| 1187 | + " or subId=" + subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1188 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1189 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1190 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1191 | broadcastServiceStateChanged(state, phoneId, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1192 | } |
| 1193 | |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1194 | public void notifySimActivationStateChangedForPhoneId(int phoneId, int subId, |
| 1195 | int activationType, int activationState) { |
| 1196 | if (!checkNotifyPermission("notifySimActivationState()")){ |
| 1197 | return; |
| 1198 | } |
| 1199 | if (VDBG) { |
| 1200 | log("notifySimActivationStateForPhoneId: subId=" + subId + " phoneId=" + phoneId |
| 1201 | + "type=" + activationType + " state=" + activationState); |
| 1202 | } |
| 1203 | synchronized (mRecords) { |
| 1204 | if (validatePhoneId(phoneId)) { |
| 1205 | switch (activationType) { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1206 | case TelephonyManager.SIM_ACTIVATION_TYPE_VOICE: |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1207 | mVoiceActivationState[phoneId] = activationState; |
| 1208 | break; |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1209 | case TelephonyManager.SIM_ACTIVATION_TYPE_DATA: |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1210 | mDataActivationState[phoneId] = activationState; |
| 1211 | break; |
| 1212 | default: |
| 1213 | return; |
| 1214 | } |
| 1215 | for (Record r : mRecords) { |
| 1216 | if (VDBG) { |
| 1217 | log("notifySimActivationStateForPhoneId: r=" + r + " subId=" + subId |
| 1218 | + " phoneId=" + phoneId + "type=" + activationType |
| 1219 | + " state=" + activationState); |
| 1220 | } |
| 1221 | try { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1222 | if ((activationType == TelephonyManager.SIM_ACTIVATION_TYPE_VOICE) && |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1223 | r.matchPhoneStateListenerEvent( |
| 1224 | PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) && |
| 1225 | idMatch(r.subId, subId, phoneId)) { |
| 1226 | if (DBG) { |
| 1227 | log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r |
| 1228 | + " subId=" + subId + " phoneId=" + phoneId |
| 1229 | + " state=" + activationState); |
| 1230 | } |
| 1231 | r.callback.onVoiceActivationStateChanged(activationState); |
| 1232 | } |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1233 | if ((activationType == TelephonyManager.SIM_ACTIVATION_TYPE_DATA) && |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1234 | r.matchPhoneStateListenerEvent( |
| 1235 | PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) && |
| 1236 | idMatch(r.subId, subId, phoneId)) { |
| 1237 | if (DBG) { |
| 1238 | log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r |
| 1239 | + " subId=" + subId + " phoneId=" + phoneId |
| 1240 | + " state=" + activationState); |
| 1241 | } |
| 1242 | r.callback.onDataActivationStateChanged(activationState); |
| 1243 | } |
| 1244 | } catch (RemoteException ex) { |
| 1245 | mRemoveList.add(r.binder); |
| 1246 | } |
| 1247 | } |
| 1248 | } else { |
| 1249 | log("notifySimActivationStateForPhoneId: INVALID phoneId=" + phoneId); |
| 1250 | } |
| 1251 | handleRemoveListLocked(); |
| 1252 | } |
| 1253 | } |
| 1254 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1255 | public void notifySignalStrengthForPhoneId(int phoneId, int subId, |
| 1256 | SignalStrength signalStrength) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1257 | if (!checkNotifyPermission("notifySignalStrength()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1258 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1259 | } |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1260 | if (VDBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1261 | log("notifySignalStrengthForPhoneId: subId=" + subId |
| 1262 | +" phoneId=" + phoneId + " signalStrength=" + signalStrength); |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1263 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1264 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1265 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1266 | if (validatePhoneId(phoneId)) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1267 | if (VDBG) log("notifySignalStrengthForPhoneId: valid phoneId=" + phoneId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1268 | mSignalStrength[phoneId] = signalStrength; |
| 1269 | for (Record r : mRecords) { |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1270 | if (VDBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1271 | log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1272 | + " phoneId=" + phoneId + " ss=" + signalStrength); |
| 1273 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1274 | if (r.matchPhoneStateListenerEvent( |
| 1275 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1276 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1277 | try { |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1278 | if (DBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1279 | log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1280 | + " subId=" + subId + " phoneId=" + phoneId |
| 1281 | + " ss=" + signalStrength); |
| 1282 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1283 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 1284 | } catch (RemoteException ex) { |
| 1285 | mRemoveList.add(r.binder); |
| 1286 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1287 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1288 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1289 | idMatch(r.subId, subId, phoneId)){ |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1290 | try { |
| 1291 | int gsmSignalStrength = signalStrength.getGsmSignalStrength(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1292 | int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength); |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1293 | if (DBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1294 | log("notifySignalStrengthForPhoneId: callback.onSS r=" + r |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1295 | + " subId=" + subId + " phoneId=" + phoneId |
| 1296 | + " gsmSS=" + gsmSignalStrength + " ss=" + ss); |
| 1297 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1298 | r.callback.onSignalStrengthChanged(ss); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1299 | } catch (RemoteException ex) { |
| 1300 | mRemoveList.add(r.binder); |
| 1301 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1302 | } |
| 1303 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1304 | } else { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1305 | log("notifySignalStrengthForPhoneId: invalid phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1306 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1307 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1308 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1309 | broadcastSignalStrengthChanged(signalStrength, phoneId, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1310 | } |
| 1311 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1312 | @Override |
| 1313 | public void notifyCarrierNetworkChange(boolean active) { |
chen xu | badf2b0 | 2019-04-26 17:45:26 -0700 | [diff] [blame] | 1314 | // only CarrierService with carrier privilege rule should have the permission |
| 1315 | int[] subIds = Arrays.stream(SubscriptionManager.from(mContext) |
Malcolm Chen | 1eb939c | 2019-09-25 14:02:14 -0700 | [diff] [blame] | 1316 | .getActiveSubscriptionIdList(false)) |
chen xu | badf2b0 | 2019-04-26 17:45:26 -0700 | [diff] [blame] | 1317 | .filter(i -> TelephonyPermissions.checkCarrierPrivilegeForSubId(i)).toArray(); |
| 1318 | if (ArrayUtils.isEmpty(subIds)) { |
chen xu | 627d1b2 | 2019-04-11 02:16:19 -0700 | [diff] [blame] | 1319 | loge("notifyCarrierNetworkChange without carrier privilege"); |
chen xu | badf2b0 | 2019-04-26 17:45:26 -0700 | [diff] [blame] | 1320 | // the active subId does not have carrier privilege. |
chen xu | 627d1b2 | 2019-04-11 02:16:19 -0700 | [diff] [blame] | 1321 | throw new SecurityException("notifyCarrierNetworkChange without carrier privilege"); |
chen xu | 5b98d40 | 2019-03-22 16:56:34 -0700 | [diff] [blame] | 1322 | } |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1323 | |
| 1324 | synchronized (mRecords) { |
| 1325 | mCarrierNetworkChangeState = active; |
chen xu | badf2b0 | 2019-04-26 17:45:26 -0700 | [diff] [blame] | 1326 | for (int subId : subIds) { |
| 1327 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 1328 | |
| 1329 | if (VDBG) { |
| 1330 | log("notifyCarrierNetworkChange: active=" + active + "subId: " + subId); |
| 1331 | } |
| 1332 | for (Record r : mRecords) { |
| 1333 | if (r.matchPhoneStateListenerEvent( |
| 1334 | PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) && |
| 1335 | idMatch(r.subId, subId, phoneId)) { |
| 1336 | try { |
| 1337 | r.callback.onCarrierNetworkChange(active); |
| 1338 | } catch (RemoteException ex) { |
| 1339 | mRemoveList.add(r.binder); |
| 1340 | } |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1341 | } |
| 1342 | } |
| 1343 | } |
| 1344 | handleRemoveListLocked(); |
| 1345 | } |
| 1346 | } |
| 1347 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 1348 | public void notifyCellInfo(List<CellInfo> cellInfo) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1349 | notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1350 | } |
| 1351 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1352 | public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1353 | if (!checkNotifyPermission("notifyCellInfoForSubscriber()")) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1354 | return; |
| 1355 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1356 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1357 | log("notifyCellInfoForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1358 | + " cellInfo=" + cellInfo); |
| 1359 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1360 | int phoneId = SubscriptionManager.getPhoneId(subId); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1361 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1362 | if (validatePhoneId(phoneId)) { |
| 1363 | mCellInfo.set(phoneId, cellInfo); |
| 1364 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1365 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) && |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 1366 | idMatch(r.subId, subId, phoneId) && |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 1367 | checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1368 | try { |
| 1369 | if (DBG_LOC) { |
Chen Xu | 1f1c25e | 2019-09-15 18:28:21 -0700 | [diff] [blame] | 1370 | log("notifyCellInfoForSubscriber: mCellInfo=" + cellInfo |
| 1371 | + " r=" + r); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1372 | } |
| 1373 | r.callback.onCellInfoChanged(cellInfo); |
| 1374 | } catch (RemoteException ex) { |
| 1375 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1376 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1377 | } |
| 1378 | } |
| 1379 | } |
| 1380 | handleRemoveListLocked(); |
| 1381 | } |
| 1382 | } |
| 1383 | |
andychou | ce65922 | 2019-06-19 20:54:32 +0800 | [diff] [blame] | 1384 | /** |
| 1385 | * Notify physical channel configuration according to subscripton ID and phone ID |
| 1386 | */ |
| 1387 | public void notifyPhysicalChannelConfigurationForSubscriber(int phoneId, int subId, |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 1388 | List<PhysicalChannelConfig> configs) { |
| 1389 | if (!checkNotifyPermission("notifyPhysicalChannelConfiguration()")) { |
| 1390 | return; |
| 1391 | } |
| 1392 | |
| 1393 | if (VDBG) { |
andychou | ce65922 | 2019-06-19 20:54:32 +0800 | [diff] [blame] | 1394 | log("notifyPhysicalChannelConfiguration: subId=" + subId + " phoneId=" + phoneId |
| 1395 | + " configs=" + configs); |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | synchronized (mRecords) { |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 1399 | if (validatePhoneId(phoneId)) { |
| 1400 | mPhysicalChannelConfigs.set(phoneId, configs); |
| 1401 | for (Record r : mRecords) { |
| 1402 | if (r.matchPhoneStateListenerEvent( |
| 1403 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) |
| 1404 | && idMatch(r.subId, subId, phoneId)) { |
| 1405 | try { |
| 1406 | if (DBG_LOC) { |
| 1407 | log("notifyPhysicalChannelConfiguration: mPhysicalChannelConfigs=" |
| 1408 | + configs + " r=" + r); |
| 1409 | } |
| 1410 | r.callback.onPhysicalChannelConfigurationChanged(configs); |
| 1411 | } catch (RemoteException ex) { |
| 1412 | mRemoveList.add(r.binder); |
| 1413 | } |
| 1414 | } |
| 1415 | } |
| 1416 | } |
| 1417 | handleRemoveListLocked(); |
| 1418 | } |
| 1419 | } |
| 1420 | |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1421 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1422 | public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1423 | if (!checkNotifyPermission("notifyMessageWaitingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1424 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1425 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1426 | if (VDBG) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1427 | log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1428 | + " mwi=" + mwi); |
| 1429 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1430 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1431 | if (validatePhoneId(phoneId)) { |
| 1432 | mMessageWaiting[phoneId] = mwi; |
| 1433 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1434 | if (r.matchPhoneStateListenerEvent( |
| 1435 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1436 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1437 | try { |
| 1438 | r.callback.onMessageWaitingIndicatorChanged(mwi); |
| 1439 | } catch (RemoteException ex) { |
| 1440 | mRemoveList.add(r.binder); |
| 1441 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1442 | } |
| 1443 | } |
| 1444 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1445 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1446 | } |
| 1447 | } |
| 1448 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1449 | public void notifyUserMobileDataStateChangedForPhoneId(int phoneId, int subId, boolean state) { |
| 1450 | if (!checkNotifyPermission("notifyUserMobileDataStateChanged()")) { |
| 1451 | return; |
| 1452 | } |
| 1453 | if (VDBG) { |
SongFerngWang | 0b109f5f | 2019-04-09 17:29:29 +0800 | [diff] [blame] | 1454 | log("notifyUserMobileDataStateChangedForSubscriberPhoneID: PhoneId=" + phoneId |
| 1455 | + " subId=" + subId + " state=" + state); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1456 | } |
| 1457 | synchronized (mRecords) { |
| 1458 | if (validatePhoneId(phoneId)) { |
SongFerngWang | 0b109f5f | 2019-04-09 17:29:29 +0800 | [diff] [blame] | 1459 | mUserMobileDataState[phoneId] = state; |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1460 | for (Record r : mRecords) { |
| 1461 | if (r.matchPhoneStateListenerEvent( |
| 1462 | PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) && |
| 1463 | idMatch(r.subId, subId, phoneId)) { |
| 1464 | try { |
| 1465 | r.callback.onUserMobileDataStateChanged(state); |
| 1466 | } catch (RemoteException ex) { |
| 1467 | mRemoveList.add(r.binder); |
| 1468 | } |
| 1469 | } |
| 1470 | } |
| 1471 | } |
| 1472 | handleRemoveListLocked(); |
| 1473 | } |
| 1474 | } |
| 1475 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1476 | public void notifyCallForwardingChanged(boolean cfi) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1477 | notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1478 | } |
| 1479 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1480 | public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1481 | if (!checkNotifyPermission("notifyCallForwardingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1482 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1483 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1484 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1485 | log("notifyCallForwardingChangedForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1486 | + " cfi=" + cfi); |
| 1487 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1488 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1489 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1490 | if (validatePhoneId(phoneId)) { |
| 1491 | mCallForwarding[phoneId] = cfi; |
| 1492 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1493 | if (r.matchPhoneStateListenerEvent( |
| 1494 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1495 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1496 | try { |
| 1497 | r.callback.onCallForwardingIndicatorChanged(cfi); |
| 1498 | } catch (RemoteException ex) { |
| 1499 | mRemoveList.add(r.binder); |
| 1500 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1501 | } |
| 1502 | } |
| 1503 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1504 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1505 | } |
| 1506 | } |
| 1507 | |
| 1508 | public void notifyDataActivity(int state) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1509 | notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1510 | } |
| 1511 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1512 | public void notifyDataActivityForSubscriber(int subId, int state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1513 | if (!checkNotifyPermission("notifyDataActivity()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1514 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1515 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1516 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1517 | synchronized (mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1518 | if (validatePhoneId(phoneId)) { |
| 1519 | mDataActivity[phoneId] = state; |
| 1520 | for (Record r : mRecords) { |
xu.peng | 9071ced | 2016-03-22 18:21:28 +0800 | [diff] [blame] | 1521 | // Notify by correct subId. |
| 1522 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY) && |
| 1523 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1524 | try { |
| 1525 | r.callback.onDataActivity(state); |
| 1526 | } catch (RemoteException ex) { |
| 1527 | mRemoveList.add(r.binder); |
| 1528 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1529 | } |
| 1530 | } |
| 1531 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1532 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1533 | } |
| 1534 | } |
| 1535 | |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1536 | public void notifyDataConnection(int state, boolean isDataAllowed, String apn, String apnType, |
| 1537 | LinkProperties linkProperties, |
| 1538 | NetworkCapabilities networkCapabilities, int networkType, |
| 1539 | boolean roaming) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1540 | notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX, |
| 1541 | SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state, |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1542 | isDataAllowed, apn, apnType, linkProperties, |
| 1543 | networkCapabilities, networkType, roaming); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1544 | } |
| 1545 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1546 | public void notifyDataConnectionForSubscriber(int phoneId, int subId, int state, |
| 1547 | boolean isDataAllowed, |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1548 | String apn, String apnType, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1549 | LinkProperties linkProperties, NetworkCapabilities networkCapabilities, |
| 1550 | int networkType, boolean roaming) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1551 | if (!checkNotifyPermission("notifyDataConnection()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1552 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1553 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1554 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1555 | log("notifyDataConnectionForSubscriber: subId=" + subId |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1556 | + " state=" + state + " isDataAllowed=" + isDataAllowed |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1557 | + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 1558 | + " mRecords.size()=" + mRecords.size()); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 1559 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1560 | synchronized (mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1561 | if (validatePhoneId(phoneId)) { |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1562 | // We only call the callback when the change is for default APN type. |
| 1563 | if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType) |
| 1564 | && (mDataConnectionState[phoneId] != state |
| 1565 | || mDataConnectionNetworkType[phoneId] != networkType)) { |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 1566 | String str = "onDataConnectionStateChanged(" |
zoey chen | b1f74e7 | 2019-12-04 16:33:59 +0800 | [diff] [blame] | 1567 | + dataStateToString(state) |
| 1568 | + ", " + getNetworkTypeName(networkType) |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 1569 | + ") subId=" + subId + ", phoneId=" + phoneId; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1570 | log(str); |
| 1571 | mLocalLog.log(str); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1572 | for (Record r : mRecords) { |
| 1573 | if (r.matchPhoneStateListenerEvent( |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1574 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) |
| 1575 | && idMatch(r.subId, subId, phoneId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1576 | try { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1577 | if (DBG) { |
| 1578 | log("Notify data connection state changed on sub: " + subId); |
| 1579 | } |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1580 | r.callback.onDataConnectionStateChanged(state, networkType); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1581 | } catch (RemoteException ex) { |
| 1582 | mRemoveList.add(r.binder); |
| 1583 | } |
| 1584 | } |
| 1585 | } |
| 1586 | handleRemoveListLocked(); |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1587 | |
| 1588 | mDataConnectionState[phoneId] = state; |
| 1589 | mDataConnectionNetworkType[phoneId] = networkType; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1590 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1591 | mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState( |
| 1592 | state, networkType, |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 1593 | ApnSetting.getApnTypesBitmaskFromString(apnType), apn, |
| 1594 | linkProperties, DataFailCause.NONE); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1595 | for (Record r : mRecords) { |
| 1596 | if (r.matchPhoneStateListenerEvent( |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1597 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) |
| 1598 | && idMatch(r.subId, subId, phoneId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1599 | try { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1600 | r.callback.onPreciseDataConnectionStateChanged( |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1601 | mPreciseDataConnectionState[phoneId]); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1602 | } catch (RemoteException ex) { |
| 1603 | mRemoveList.add(r.binder); |
| 1604 | } |
Wink Saville | 2d1ee98 | 2014-11-20 20:29:51 +0000 | [diff] [blame] | 1605 | } |
| 1606 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1607 | } |
| 1608 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1609 | } |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1610 | broadcastDataConnectionStateChanged(state, isDataAllowed, apn, apnType, linkProperties, |
| 1611 | networkCapabilities, roaming, subId); |
| 1612 | broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 1613 | linkProperties, DataFailCause.NONE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1614 | } |
| 1615 | |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1616 | public void notifyDataConnectionFailed(String apnType) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1617 | notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_PHONE_INDEX, |
| 1618 | SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1619 | apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1620 | } |
| 1621 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1622 | public void notifyDataConnectionFailedForSubscriber(int phoneId, int subId, String apnType) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1623 | if (!checkNotifyPermission("notifyDataConnectionFailed()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1624 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1625 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1626 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1627 | log("notifyDataConnectionFailedForSubscriber: subId=" + subId |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1628 | + " apnType=" + apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1629 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1630 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1631 | if (validatePhoneId(phoneId)) { |
| 1632 | mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState( |
| 1633 | TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1634 | ApnSetting.getApnTypesBitmaskFromString(apnType), null, null, |
| 1635 | DataFailCause.NONE); |
| 1636 | for (Record r : mRecords) { |
| 1637 | if (r.matchPhoneStateListenerEvent( |
| 1638 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) |
| 1639 | && idMatch(r.subId, subId, phoneId)) { |
| 1640 | try { |
| 1641 | r.callback.onPreciseDataConnectionStateChanged( |
| 1642 | mPreciseDataConnectionState[phoneId]); |
| 1643 | } catch (RemoteException ex) { |
| 1644 | mRemoveList.add(r.binder); |
| 1645 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1646 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1647 | } |
| 1648 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1649 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1650 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1651 | } |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1652 | broadcastDataConnectionFailed(apnType, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1653 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
chen xu | 8165386 | 2019-02-28 10:44:54 -0800 | [diff] [blame] | 1654 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, null, null, |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 1655 | DataFailCause.NONE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1656 | } |
| 1657 | |
| 1658 | public void notifyCellLocation(Bundle cellLocation) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1659 | notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1662 | public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1663 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1664 | + " cellLocation=" + cellLocation); |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1665 | if (!checkNotifyPermission("notifyCellLocation()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1666 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1667 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1668 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1669 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1670 | + " cellLocation=" + cellLocation); |
| 1671 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1672 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1673 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1674 | if (validatePhoneId(phoneId)) { |
| 1675 | mCellLocation[phoneId] = cellLocation; |
| 1676 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1677 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) && |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 1678 | idMatch(r.subId, subId, phoneId) && |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 1679 | checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1680 | try { |
| 1681 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1682 | log("notifyCellLocation: cellLocation=" + cellLocation |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1683 | + " r=" + r); |
| 1684 | } |
| 1685 | r.callback.onCellLocationChanged(new Bundle(cellLocation)); |
| 1686 | } catch (RemoteException ex) { |
| 1687 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1688 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1689 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1690 | } |
| 1691 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1692 | handleRemoveListLocked(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1693 | } |
| 1694 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1695 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1696 | public void notifyOtaspChanged(int subId, int otaspMode) { |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1697 | if (!checkNotifyPermission("notifyOtaspChanged()" )) { |
| 1698 | return; |
| 1699 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1700 | int phoneId = SubscriptionManager.getPhoneId(subId); |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1701 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1702 | if (validatePhoneId(phoneId)) { |
| 1703 | mOtaspMode[phoneId] = otaspMode; |
| 1704 | for (Record r : mRecords) { |
| 1705 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED) |
| 1706 | && idMatch(r.subId, subId, phoneId)) { |
| 1707 | try { |
| 1708 | r.callback.onOtaspChanged(otaspMode); |
| 1709 | } catch (RemoteException ex) { |
| 1710 | mRemoveList.add(r.binder); |
| 1711 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1712 | } |
| 1713 | } |
| 1714 | } |
| 1715 | handleRemoveListLocked(); |
| 1716 | } |
| 1717 | } |
| 1718 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1719 | public void notifyPreciseCallState(int phoneId, int subId, int ringingCallState, |
| 1720 | int foregroundCallState, int backgroundCallState) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1721 | if (!checkNotifyPermission("notifyPreciseCallState()")) { |
| 1722 | return; |
| 1723 | } |
| 1724 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1725 | if (validatePhoneId(phoneId)) { |
| 1726 | mRingingCallState[phoneId] = ringingCallState; |
| 1727 | mForegroundCallState[phoneId] = foregroundCallState; |
| 1728 | mBackgroundCallState[phoneId] = backgroundCallState; |
| 1729 | mPreciseCallState[phoneId] = new PreciseCallState( |
| 1730 | ringingCallState, foregroundCallState, |
| 1731 | backgroundCallState, |
| 1732 | DisconnectCause.NOT_VALID, |
| 1733 | PreciseDisconnectCause.NOT_VALID); |
| 1734 | boolean notifyCallAttributes = true; |
| 1735 | if (mCallQuality == null) { |
| 1736 | log("notifyPreciseCallState: mCallQuality is null, " |
| 1737 | + "skipping call attributes"); |
| 1738 | notifyCallAttributes = false; |
| 1739 | } else { |
| 1740 | // If the precise call state is no longer active, reset the call network type |
| 1741 | // and call quality. |
| 1742 | if (mPreciseCallState[phoneId].getForegroundCallState() |
| 1743 | != PreciseCallState.PRECISE_CALL_STATE_ACTIVE) { |
| 1744 | mCallNetworkType[phoneId] = TelephonyManager.NETWORK_TYPE_UNKNOWN; |
| 1745 | mCallQuality[phoneId] = new CallQuality(); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1746 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1747 | mCallAttributes[phoneId] = new CallAttributes(mPreciseCallState[phoneId], |
| 1748 | mCallNetworkType[phoneId], mCallQuality[phoneId]); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1749 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1750 | |
| 1751 | for (Record r : mRecords) { |
| 1752 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE) |
| 1753 | && idMatch(r.subId, subId, phoneId)) { |
| 1754 | try { |
| 1755 | r.callback.onPreciseCallStateChanged(mPreciseCallState[phoneId]); |
| 1756 | } catch (RemoteException ex) { |
| 1757 | mRemoveList.add(r.binder); |
| 1758 | } |
| 1759 | } |
| 1760 | if (notifyCallAttributes && r.matchPhoneStateListenerEvent( |
| 1761 | PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) |
| 1762 | && idMatch(r.subId, subId, phoneId)) { |
| 1763 | try { |
| 1764 | r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); |
| 1765 | } catch (RemoteException ex) { |
| 1766 | mRemoveList.add(r.binder); |
| 1767 | } |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 1768 | } |
| 1769 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1770 | } |
| 1771 | handleRemoveListLocked(); |
| 1772 | } |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 1773 | broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, |
| 1774 | backgroundCallState); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1775 | } |
| 1776 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1777 | public void notifyDisconnectCause(int phoneId, int subId, int disconnectCause, |
| 1778 | int preciseDisconnectCause) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1779 | if (!checkNotifyPermission("notifyDisconnectCause()")) { |
| 1780 | return; |
| 1781 | } |
| 1782 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1783 | if (validatePhoneId(phoneId)) { |
| 1784 | mCallDisconnectCause[phoneId] = disconnectCause; |
| 1785 | mCallPreciseDisconnectCause[phoneId] = preciseDisconnectCause; |
| 1786 | for (Record r : mRecords) { |
| 1787 | if (r.matchPhoneStateListenerEvent(PhoneStateListener |
| 1788 | .LISTEN_CALL_DISCONNECT_CAUSES) && idMatch(r.subId, subId, phoneId)) { |
| 1789 | try { |
| 1790 | r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause[phoneId], |
| 1791 | mCallPreciseDisconnectCause[phoneId]); |
| 1792 | } catch (RemoteException ex) { |
| 1793 | mRemoveList.add(r.binder); |
| 1794 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1795 | } |
| 1796 | } |
| 1797 | } |
| 1798 | handleRemoveListLocked(); |
| 1799 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1800 | } |
| 1801 | |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 1802 | public void notifyImsDisconnectCause(int subId, ImsReasonInfo imsReasonInfo) { |
| 1803 | if (!checkNotifyPermission("notifyImsCallDisconnectCause()")) { |
| 1804 | return; |
| 1805 | } |
| 1806 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 1807 | synchronized (mRecords) { |
| 1808 | if (validatePhoneId(phoneId)) { |
| 1809 | mImsReasonInfo.set(phoneId, imsReasonInfo); |
| 1810 | for (Record r : mRecords) { |
| 1811 | if (r.matchPhoneStateListenerEvent( |
| 1812 | PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) |
| 1813 | && idMatch(r.subId, subId, phoneId)) { |
| 1814 | try { |
| 1815 | if (DBG_LOC) { |
| 1816 | log("notifyImsCallDisconnectCause: mImsReasonInfo=" |
| 1817 | + imsReasonInfo + " r=" + r); |
| 1818 | } |
| 1819 | r.callback.onImsCallDisconnectCauseChanged(mImsReasonInfo.get(phoneId)); |
| 1820 | } catch (RemoteException ex) { |
| 1821 | mRemoveList.add(r.binder); |
| 1822 | } |
| 1823 | } |
| 1824 | } |
| 1825 | } |
| 1826 | handleRemoveListLocked(); |
| 1827 | } |
| 1828 | } |
| 1829 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1830 | public void notifyPreciseDataConnectionFailed(int phoneId, int subId, String apnType, |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1831 | String apn, @DataFailureCause int failCause) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1832 | if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) { |
| 1833 | return; |
| 1834 | } |
| 1835 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1836 | if (validatePhoneId(phoneId)) { |
| 1837 | mPreciseDataConnectionState[phoneId] = new PreciseDataConnectionState( |
| 1838 | TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1839 | ApnSetting.getApnTypesBitmaskFromString(apnType), apn, null, failCause); |
| 1840 | for (Record r : mRecords) { |
| 1841 | if (r.matchPhoneStateListenerEvent( |
| 1842 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) |
| 1843 | && idMatch(r.subId, subId, phoneId)) { |
| 1844 | try { |
| 1845 | r.callback.onPreciseDataConnectionStateChanged( |
| 1846 | mPreciseDataConnectionState[phoneId]); |
| 1847 | } catch (RemoteException ex) { |
| 1848 | mRemoveList.add(r.binder); |
| 1849 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1850 | } |
| 1851 | } |
| 1852 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1853 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1854 | handleRemoveListLocked(); |
| 1855 | } |
| 1856 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 1857 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, null, failCause); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1858 | } |
| 1859 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1860 | @Override |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1861 | public void notifySrvccStateChanged(int subId, @SrvccState int state) { |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1862 | if (!checkNotifyPermission("notifySrvccStateChanged()")) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1863 | return; |
| 1864 | } |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1865 | if (VDBG) { |
| 1866 | log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state); |
| 1867 | } |
| 1868 | int phoneId = SubscriptionManager.getPhoneId(subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1869 | synchronized (mRecords) { |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1870 | if (validatePhoneId(phoneId)) { |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 1871 | mSrvccState[phoneId] = state; |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1872 | for (Record r : mRecords) { |
| 1873 | if (r.matchPhoneStateListenerEvent( |
| 1874 | PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) && |
| 1875 | idMatch(r.subId, subId, phoneId)) { |
| 1876 | try { |
| 1877 | if (DBG_LOC) { |
| 1878 | log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r); |
| 1879 | } |
| 1880 | r.callback.onSrvccStateChanged(state); |
| 1881 | } catch (RemoteException ex) { |
| 1882 | mRemoveList.add(r.binder); |
| 1883 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1884 | } |
| 1885 | } |
| 1886 | } |
| 1887 | handleRemoveListLocked(); |
| 1888 | } |
| 1889 | } |
| 1890 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1891 | public void notifyOemHookRawEventForSubscriber(int phoneId, int subId, byte[] rawData) { |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1892 | if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) { |
| 1893 | return; |
| 1894 | } |
| 1895 | |
| 1896 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1897 | if (validatePhoneId(phoneId)) { |
| 1898 | for (Record r : mRecords) { |
| 1899 | if (VDBG) { |
| 1900 | log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); |
| 1901 | } |
| 1902 | if ((r.matchPhoneStateListenerEvent( |
| 1903 | PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) |
| 1904 | && idMatch(r.subId, subId, phoneId)) { |
| 1905 | try { |
| 1906 | r.callback.onOemHookRawEvent(rawData); |
| 1907 | } catch (RemoteException ex) { |
| 1908 | mRemoveList.add(r.binder); |
| 1909 | } |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1910 | } |
| 1911 | } |
| 1912 | } |
| 1913 | handleRemoveListLocked(); |
| 1914 | } |
| 1915 | } |
| 1916 | |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1917 | public void notifyPhoneCapabilityChanged(PhoneCapability capability) { |
| 1918 | if (!checkNotifyPermission("notifyPhoneCapabilityChanged()")) { |
| 1919 | return; |
| 1920 | } |
| 1921 | |
| 1922 | if (VDBG) { |
| 1923 | log("notifyPhoneCapabilityChanged: capability=" + capability); |
| 1924 | } |
| 1925 | |
| 1926 | synchronized (mRecords) { |
| 1927 | mPhoneCapability = capability; |
| 1928 | |
| 1929 | for (Record r : mRecords) { |
| 1930 | if (r.matchPhoneStateListenerEvent( |
| 1931 | PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE)) { |
| 1932 | try { |
| 1933 | r.callback.onPhoneCapabilityChanged(capability); |
| 1934 | } catch (RemoteException ex) { |
| 1935 | mRemoveList.add(r.binder); |
| 1936 | } |
| 1937 | } |
| 1938 | } |
| 1939 | handleRemoveListLocked(); |
| 1940 | } |
| 1941 | } |
| 1942 | |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 1943 | public void notifyActiveDataSubIdChanged(int activeDataSubId) { |
| 1944 | if (!checkNotifyPermission("notifyActiveDataSubIdChanged()")) { |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1945 | return; |
| 1946 | } |
| 1947 | |
| 1948 | if (VDBG) { |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 1949 | log("notifyActiveDataSubIdChanged: activeDataSubId=" + activeDataSubId); |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1950 | } |
| 1951 | |
sqian | 9e9ed18 | 2019-03-20 16:17:09 -0700 | [diff] [blame] | 1952 | mActiveDataSubId = activeDataSubId; |
sqian | 9e9ed18 | 2019-03-20 16:17:09 -0700 | [diff] [blame] | 1953 | synchronized (mRecords) { |
Malcolm Chen | 118b02f | 2019-09-04 16:10:34 -0700 | [diff] [blame] | 1954 | for (Record r : mRecords) { |
| 1955 | if (r.matchPhoneStateListenerEvent( |
| 1956 | PhoneStateListener.LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE)) { |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1957 | try { |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 1958 | r.callback.onActiveDataSubIdChanged(activeDataSubId); |
Malcolm Chen | 8b53afe | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1959 | } catch (RemoteException ex) { |
| 1960 | mRemoveList.add(r.binder); |
| 1961 | } |
| 1962 | } |
| 1963 | } |
| 1964 | handleRemoveListLocked(); |
| 1965 | } |
| 1966 | } |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1967 | |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1968 | public void notifyRadioPowerStateChanged(int phoneId, int subId, @RadioPowerState int state) { |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 1969 | if (!checkNotifyPermission("notifyRadioPowerStateChanged()")) { |
| 1970 | return; |
| 1971 | } |
| 1972 | |
| 1973 | if (VDBG) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1974 | log("notifyRadioPowerStateChanged: state= " + state + " subId=" + subId); |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 1975 | } |
| 1976 | |
| 1977 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1978 | if (validatePhoneId(phoneId)) { |
| 1979 | mRadioPowerState = state; |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 1980 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1981 | for (Record r : mRecords) { |
| 1982 | if (r.matchPhoneStateListenerEvent( |
| 1983 | PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) |
| 1984 | && idMatch(r.subId, subId, phoneId)) { |
| 1985 | try { |
| 1986 | r.callback.onRadioPowerStateChanged(state); |
| 1987 | } catch (RemoteException ex) { |
| 1988 | mRemoveList.add(r.binder); |
| 1989 | } |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 1990 | } |
| 1991 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1992 | |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 1993 | } |
| 1994 | handleRemoveListLocked(); |
| 1995 | } |
| 1996 | } |
| 1997 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1998 | @Override |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1999 | public void notifyEmergencyNumberList(int phoneId, int subId) { |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2000 | if (!checkNotifyPermission("notifyEmergencyNumberList()")) { |
| 2001 | return; |
| 2002 | } |
| 2003 | |
| 2004 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2005 | if (validatePhoneId(phoneId)) { |
| 2006 | TelephonyManager tm = (TelephonyManager) mContext.getSystemService( |
| 2007 | Context.TELEPHONY_SERVICE); |
| 2008 | mEmergencyNumberList = tm.getEmergencyNumberList(); |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2009 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2010 | for (Record r : mRecords) { |
| 2011 | if (r.matchPhoneStateListenerEvent( |
| 2012 | PhoneStateListener.LISTEN_EMERGENCY_NUMBER_LIST) |
| 2013 | && idMatch(r.subId, subId, phoneId)) { |
| 2014 | try { |
| 2015 | r.callback.onEmergencyNumberListChanged(mEmergencyNumberList); |
| 2016 | if (VDBG) { |
| 2017 | log("notifyEmergencyNumberList: emergencyNumberList= " |
| 2018 | + mEmergencyNumberList); |
| 2019 | } |
| 2020 | } catch (RemoteException ex) { |
| 2021 | mRemoveList.add(r.binder); |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2022 | } |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2023 | } |
| 2024 | } |
| 2025 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2026 | |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2027 | handleRemoveListLocked(); |
| 2028 | } |
sqian | bdc5a73 | 2018-10-26 13:27:51 -0700 | [diff] [blame] | 2029 | } |
| 2030 | |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2031 | @Override |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 2032 | public void notifyOutgoingEmergencyCall(int phoneId, int subId, |
| 2033 | EmergencyNumber emergencyNumber) { |
| 2034 | if (!checkNotifyPermission("notifyOutgoingEmergencyCall()")) { |
| 2035 | return; |
| 2036 | } |
| 2037 | synchronized (mRecords) { |
| 2038 | if (validatePhoneId(phoneId)) { |
| 2039 | mOutgoingCallEmergencyNumber[phoneId] = emergencyNumber; |
| 2040 | for (Record r : mRecords) { |
| 2041 | if (r.matchPhoneStateListenerEvent( |
Shuo Qian | d966376 | 2019-10-04 13:20:45 -0700 | [diff] [blame] | 2042 | PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_CALL) |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 2043 | && idMatch(r.subId, subId, phoneId)) { |
| 2044 | try { |
| 2045 | r.callback.onOutgoingEmergencyCall(emergencyNumber); |
| 2046 | } catch (RemoteException ex) { |
| 2047 | mRemoveList.add(r.binder); |
| 2048 | } |
| 2049 | } |
| 2050 | } |
| 2051 | } |
| 2052 | handleRemoveListLocked(); |
| 2053 | } |
| 2054 | } |
| 2055 | |
| 2056 | @Override |
| 2057 | public void notifyOutgoingEmergencySms(int phoneId, int subId, |
| 2058 | EmergencyNumber emergencyNumber) { |
| 2059 | if (!checkNotifyPermission("notifyOutgoingEmergencySms()")) { |
| 2060 | return; |
| 2061 | } |
| 2062 | synchronized (mRecords) { |
| 2063 | if (validatePhoneId(phoneId)) { |
| 2064 | mOutgoingSmsEmergencyNumber[phoneId] = emergencyNumber; |
| 2065 | for (Record r : mRecords) { |
| 2066 | if (r.matchPhoneStateListenerEvent( |
Shuo Qian | d966376 | 2019-10-04 13:20:45 -0700 | [diff] [blame] | 2067 | PhoneStateListener.LISTEN_OUTGOING_EMERGENCY_SMS) |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 2068 | && idMatch(r.subId, subId, phoneId)) { |
| 2069 | try { |
| 2070 | r.callback.onOutgoingEmergencySms(emergencyNumber); |
| 2071 | } catch (RemoteException ex) { |
| 2072 | mRemoveList.add(r.binder); |
| 2073 | } |
| 2074 | } |
| 2075 | } |
| 2076 | } |
| 2077 | handleRemoveListLocked(); |
| 2078 | } |
| 2079 | } |
| 2080 | |
| 2081 | @Override |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2082 | public void notifyCallQualityChanged(CallQuality callQuality, int phoneId, int subId, |
Jordan Liu | 65ed9d9 | 2019-02-19 14:42:07 -0800 | [diff] [blame] | 2083 | int callNetworkType) { |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2084 | if (!checkNotifyPermission("notifyCallQualityChanged()")) { |
| 2085 | return; |
| 2086 | } |
| 2087 | |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2088 | synchronized (mRecords) { |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2089 | if (validatePhoneId(phoneId)) { |
| 2090 | // merge CallQuality with PreciseCallState and network type |
| 2091 | mCallQuality[phoneId] = callQuality; |
| 2092 | mCallNetworkType[phoneId] = callNetworkType; |
| 2093 | mCallAttributes[phoneId] = new CallAttributes(mPreciseCallState[phoneId], |
| 2094 | callNetworkType, callQuality); |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2095 | |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2096 | for (Record r : mRecords) { |
| 2097 | if (r.matchPhoneStateListenerEvent( |
| 2098 | PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) |
| 2099 | && idMatch(r.subId, subId, phoneId)) { |
| 2100 | try { |
| 2101 | r.callback.onCallAttributesChanged(mCallAttributes[phoneId]); |
| 2102 | } catch (RemoteException ex) { |
| 2103 | mRemoveList.add(r.binder); |
| 2104 | } |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2105 | } |
| 2106 | } |
| 2107 | } |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2108 | |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2109 | handleRemoveListLocked(); |
| 2110 | } |
| 2111 | } |
| 2112 | |
sqian | bdc5a73 | 2018-10-26 13:27:51 -0700 | [diff] [blame] | 2113 | |
| 2114 | @Override |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2115 | public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |
| 2116 | final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); |
| 2117 | |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 2118 | if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2119 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2120 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2121 | final int recordCount = mRecords.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2122 | pw.println("last known state:"); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2123 | pw.increaseIndent(); |
Malcolm Chen | a37405b | 2019-11-06 15:03:23 -0800 | [diff] [blame] | 2124 | for (int i = 0; i < getTelephonyManager().getPhoneCount(); i++) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2125 | pw.println("Phone Id=" + i); |
| 2126 | pw.increaseIndent(); |
| 2127 | pw.println("mCallState=" + mCallState[i]); |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2128 | pw.println("mRingingCallState=" + mRingingCallState[i]); |
| 2129 | pw.println("mForegroundCallState=" + mForegroundCallState[i]); |
| 2130 | pw.println("mBackgroundCallState=" + mBackgroundCallState[i]); |
| 2131 | pw.println("mPreciseCallState=" + mPreciseCallState[i]); |
| 2132 | pw.println("mCallDisconnectCause=" + mCallDisconnectCause[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2133 | pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]); |
| 2134 | pw.println("mServiceState=" + mServiceState[i]); |
| 2135 | pw.println("mVoiceActivationState= " + mVoiceActivationState[i]); |
| 2136 | pw.println("mDataActivationState= " + mDataActivationState[i]); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 2137 | pw.println("mUserMobileDataState= " + mUserMobileDataState[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2138 | pw.println("mSignalStrength=" + mSignalStrength[i]); |
| 2139 | pw.println("mMessageWaiting=" + mMessageWaiting[i]); |
| 2140 | pw.println("mCallForwarding=" + mCallForwarding[i]); |
| 2141 | pw.println("mDataActivity=" + mDataActivity[i]); |
| 2142 | pw.println("mDataConnectionState=" + mDataConnectionState[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2143 | pw.println("mCellLocation=" + mCellLocation[i]); |
| 2144 | pw.println("mCellInfo=" + mCellInfo.get(i)); |
Tyler Gunn | f3f89d0 | 2019-03-25 07:26:33 -0700 | [diff] [blame] | 2145 | pw.println("mImsCallDisconnectCause=" + mImsReasonInfo.get(i)); |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2146 | pw.println("mSrvccState=" + mSrvccState[i]); |
| 2147 | pw.println("mOtaspMode=" + mOtaspMode[i]); |
| 2148 | pw.println("mCallPreciseDisconnectCause=" + mCallPreciseDisconnectCause[i]); |
| 2149 | pw.println("mCallQuality=" + mCallQuality[i]); |
| 2150 | pw.println("mCallAttributes=" + mCallAttributes[i]); |
| 2151 | pw.println("mCallNetworkType=" + mCallNetworkType[i]); |
| 2152 | pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState[i]); |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 2153 | pw.println("mOutgoingCallEmergencyNumber=" + mOutgoingCallEmergencyNumber[i]); |
| 2154 | pw.println("mOutgoingSmsEmergencyNumber=" + mOutgoingSmsEmergencyNumber[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2155 | pw.decreaseIndent(); |
Sandeep Gutta | 2f32ac2 | 2014-07-16 03:14:03 +0530 | [diff] [blame] | 2156 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2157 | pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState); |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 2158 | |
Malcolm Chen | e162365 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 2159 | pw.println("mPhoneCapability=" + mPhoneCapability); |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 2160 | pw.println("mActiveDataSubId=" + mActiveDataSubId); |
Chen Xu | 7395c63 | 2018-10-17 17:53:47 +0000 | [diff] [blame] | 2161 | pw.println("mRadioPowerState=" + mRadioPowerState); |
sqian | 9f93a12 | 2018-12-03 22:40:41 -0800 | [diff] [blame] | 2162 | pw.println("mEmergencyNumberList=" + mEmergencyNumberList); |
chen xu | addc270 | 2019-05-07 16:25:12 -0700 | [diff] [blame] | 2163 | pw.println("mDefaultPhoneId=" + mDefaultPhoneId); |
| 2164 | pw.println("mDefaultSubId=" + mDefaultSubId); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2165 | |
| 2166 | pw.decreaseIndent(); |
| 2167 | |
| 2168 | pw.println("local logs:"); |
| 2169 | pw.increaseIndent(); |
| 2170 | mLocalLog.dump(fd, pw, args); |
Jack Yu | 0c92c23 | 2019-04-04 15:10:17 -0700 | [diff] [blame] | 2171 | pw.println("listen logs:"); |
| 2172 | mListenLog.dump(fd, pw, args); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2173 | pw.decreaseIndent(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2174 | pw.println("registrations: count=" + recordCount); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2175 | pw.increaseIndent(); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 2176 | for (Record r : mRecords) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2177 | pw.println(r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2178 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 2179 | pw.decreaseIndent(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2180 | } |
| 2181 | } |
| 2182 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2183 | // |
| 2184 | // the legacy intent broadcasting |
| 2185 | // |
| 2186 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2187 | private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2188 | long ident = Binder.clearCallingIdentity(); |
| 2189 | try { |
| 2190 | mBatteryStats.notePhoneState(state.getState()); |
| 2191 | } catch (RemoteException re) { |
| 2192 | // Can't do much |
| 2193 | } finally { |
| 2194 | Binder.restoreCallingIdentity(ident); |
| 2195 | } |
| 2196 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2197 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 2198 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2199 | Bundle data = new Bundle(); |
| 2200 | state.fillInNotifierBundle(data); |
| 2201 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2202 | // Pass the subscription along with the intent. |
| 2203 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
chen xu | 379e531 | 2018-09-28 15:53:43 -0700 | [diff] [blame] | 2204 | intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2205 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2206 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2207 | } |
| 2208 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2209 | private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId, |
| 2210 | int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 2211 | long ident = Binder.clearCallingIdentity(); |
| 2212 | try { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2213 | mBatteryStats.notePhoneSignalStrength(signalStrength); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 2214 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2215 | /* The remote entity disappeared, we can safely ignore the exception. */ |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 2216 | } finally { |
| 2217 | Binder.restoreCallingIdentity(ident); |
| 2218 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2219 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2220 | Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2221 | Bundle data = new Bundle(); |
| 2222 | signalStrength.fillInNotifierBundle(data); |
| 2223 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2224 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2225 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2226 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2227 | } |
| 2228 | |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 2229 | /** |
| 2230 | * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be |
| 2231 | * a valid subId, in which case this function fires a subId-specific intent, or it |
| 2232 | * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send |
| 2233 | * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}). |
| 2234 | */ |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2235 | private void broadcastCallStateChanged(int state, String incomingNumber, int phoneId, |
| 2236 | int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2237 | long ident = Binder.clearCallingIdentity(); |
| 2238 | try { |
| 2239 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
| 2240 | mBatteryStats.notePhoneOff(); |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 2241 | StatsLog.write(StatsLog.PHONE_STATE_CHANGED, |
| 2242 | StatsLog.PHONE_STATE_CHANGED__STATE__OFF); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2243 | } else { |
| 2244 | mBatteryStats.notePhoneOn(); |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 2245 | StatsLog.write(StatsLog.PHONE_STATE_CHANGED, |
| 2246 | StatsLog.PHONE_STATE_CHANGED__STATE__ON); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2247 | } |
| 2248 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2249 | /* The remote entity disappeared, we can safely ignore the exception. */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2250 | } finally { |
| 2251 | Binder.restoreCallingIdentity(ident); |
| 2252 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2253 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2254 | Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2255 | intent.putExtra(PhoneConstants.STATE_KEY, |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 2256 | PhoneConstantConversions.convertCallState(state).toString()); |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 2257 | |
| 2258 | // If a valid subId was specified, we should fire off a subId-specific state |
| 2259 | // change intent and include the subId. |
| 2260 | if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { |
| 2261 | intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED); |
| 2262 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
chen xu | 379e531 | 2018-09-28 15:53:43 -0700 | [diff] [blame] | 2263 | intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 2264 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 2265 | // If the phoneId is invalid, the broadcast is for overall call state. |
| 2266 | if (phoneId != SubscriptionManager.INVALID_PHONE_INDEX) { |
| 2267 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
| 2268 | } |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 2269 | |
Brad Ebinger | 51de96a | 2017-04-21 17:05:18 -0700 | [diff] [blame] | 2270 | // Wakeup apps for the (SUBSCRIPTION_)PHONE_STATE broadcast. |
| 2271 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
| 2272 | |
Tyler Gunn | 1c27bb7 | 2018-06-19 09:55:43 -0700 | [diff] [blame] | 2273 | // Create a version of the intent with the number always populated. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2274 | Intent intentWithPhoneNumber = new Intent(intent); |
Tyler Gunn | 1c27bb7 | 2018-06-19 09:55:43 -0700 | [diff] [blame] | 2275 | intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); |
| 2276 | |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 2277 | // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those |
| 2278 | // that have the runtime one |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2279 | mContext.sendBroadcastAsUser(intentWithPhoneNumber, UserHandle.ALL, |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 2280 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2281 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 2282 | android.Manifest.permission.READ_PHONE_STATE, |
| 2283 | AppOpsManager.OP_READ_PHONE_STATE); |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 2284 | mContext.sendBroadcastAsUserMultiplePermissions(intentWithPhoneNumber, UserHandle.ALL, |
| 2285 | new String[] { android.Manifest.permission.READ_PHONE_STATE, |
| 2286 | android.Manifest.permission.READ_CALL_LOG}); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2287 | } |
| 2288 | |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 2289 | private void broadcastDataConnectionStateChanged(int state, boolean isDataAllowed, String apn, |
| 2290 | String apnType, LinkProperties linkProperties, |
| 2291 | NetworkCapabilities networkCapabilities, |
| 2292 | boolean roaming, int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 2293 | // Note: not reporting to the battery stats service here, because the |
| 2294 | // status bar takes care of that after taking into account all of the |
| 2295 | // required info. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2296 | Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2297 | intent.putExtra(PhoneConstants.STATE_KEY, |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 2298 | PhoneConstantConversions.convertDataState(state).toString()); |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 2299 | if (!isDataAllowed) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2300 | intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2301 | } |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 2302 | if (linkProperties != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2303 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
Irfan Sheriff | ed5d7d1 | 2010-10-01 16:08:28 -0700 | [diff] [blame] | 2304 | String iface = linkProperties.getInterfaceName(); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 2305 | if (iface != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2306 | intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 2307 | } |
| 2308 | } |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 2309 | if (networkCapabilities != null) { |
| 2310 | intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities); |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 2311 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2312 | if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true); |
Robert Greenwalt | a6d4248 | 2011-09-02 15:19:31 -0700 | [diff] [blame] | 2313 | |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2314 | intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 2315 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2316 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2317 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2318 | } |
| 2319 | |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 2320 | private void broadcastDataConnectionFailed(String apnType, int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2321 | Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 2322 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2323 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 2324 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2325 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2326 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2327 | private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState, |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 2328 | int backgroundCallState) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2329 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED); |
| 2330 | intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState); |
| 2331 | intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState); |
| 2332 | intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2333 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 2334 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 2335 | } |
| 2336 | |
| 2337 | private void broadcastPreciseDataConnectionStateChanged(int state, int networkType, |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 2338 | String apnType, String apn, LinkProperties linkProperties, |
Chen Xu | 7631ff7 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 2339 | @DataFailureCause int failCause) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2340 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 2341 | intent.putExtra(PhoneConstants.STATE_KEY, state); |
| 2342 | intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2343 | if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
| 2344 | if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2345 | if (linkProperties != null) { |
Jack Yu | 4d1c945 | 2019-01-02 16:51:08 -0800 | [diff] [blame] | 2346 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2347 | } |
chen xu | 16e24cd | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 2348 | intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2349 | |
| 2350 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 2351 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 2352 | } |
| 2353 | |
Andrew Flynn | ceaed68 | 2015-06-09 12:36:58 +0000 | [diff] [blame] | 2354 | private void enforceNotifyPermissionOrCarrierPrivilege(String method) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 2355 | if (checkNotifyPermission()) { |
Andrew Flynn | ceaed68 | 2015-06-09 12:36:58 +0000 | [diff] [blame] | 2356 | return; |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 2357 | } |
| 2358 | |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 2359 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( |
| 2360 | SubscriptionManager.getDefaultSubscriptionId(), method); |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 2361 | } |
| 2362 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 2363 | private boolean checkNotifyPermission(String method) { |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 2364 | if (checkNotifyPermission()) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 2365 | return true; |
| 2366 | } |
| 2367 | String msg = "Modify Phone State Permission Denial: " + method + " from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 2368 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2369 | if (DBG) log(msg); |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 2370 | return false; |
| 2371 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 2372 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 2373 | private boolean checkNotifyPermission() { |
| 2374 | return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 2375 | == PackageManager.PERMISSION_GRANTED; |
| 2376 | } |
| 2377 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 2378 | private boolean checkListenerPermission( |
| 2379 | int events, int subId, String callingPackage, String message) { |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2380 | LocationAccessPolicy.LocationPermissionQuery.Builder locationQueryBuilder = |
| 2381 | new LocationAccessPolicy.LocationPermissionQuery.Builder() |
| 2382 | .setCallingPackage(callingPackage) |
| 2383 | .setMethod(message + " events: " + events) |
| 2384 | .setCallingPid(Binder.getCallingPid()) |
| 2385 | .setCallingUid(Binder.getCallingUid()); |
| 2386 | |
| 2387 | boolean shouldCheckLocationPermissions = false; |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 2388 | if ((events & ENFORCE_COARSE_LOCATION_PERMISSION_MASK) != 0) { |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2389 | locationQueryBuilder.setMinSdkVersionForCoarse(0); |
| 2390 | shouldCheckLocationPermissions = true; |
| 2391 | } |
| 2392 | |
| 2393 | if ((events & ENFORCE_FINE_LOCATION_PERMISSION_MASK) != 0) { |
| 2394 | // Everything that requires fine location started in Q. So far... |
| 2395 | locationQueryBuilder.setMinSdkVersionForFine(Build.VERSION_CODES.Q); |
| 2396 | shouldCheckLocationPermissions = true; |
| 2397 | } |
| 2398 | |
| 2399 | if (shouldCheckLocationPermissions) { |
| 2400 | LocationAccessPolicy.LocationPermissionResult result = |
| 2401 | LocationAccessPolicy.checkLocationPermission( |
| 2402 | mContext, locationQueryBuilder.build()); |
| 2403 | switch (result) { |
| 2404 | case DENIED_HARD: |
| 2405 | throw new SecurityException("Unable to listen for events " + events + " due to " |
| 2406 | + "insufficient location permissions."); |
| 2407 | case DENIED_SOFT: |
| 2408 | return false; |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 2409 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 2410 | } |
| 2411 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 2412 | if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 2413 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 2414 | mContext, subId, callingPackage, message)) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 2415 | return false; |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 2416 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 2417 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2418 | |
| 2419 | if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) { |
| 2420 | mContext.enforceCallingOrSelfPermission( |
| 2421 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 2422 | } |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 2423 | |
Shuo Qian | b61230c | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 2424 | if ((events & READ_ACTIVE_EMERGENCY_SESSION_PERMISSION_MASK) != 0) { |
| 2425 | mContext.enforceCallingOrSelfPermission( |
| 2426 | android.Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION, null); |
| 2427 | } |
| 2428 | |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 2429 | if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) { |
| 2430 | mContext.enforceCallingOrSelfPermission( |
| 2431 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 2432 | } |
| 2433 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 2434 | if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) { |
| 2435 | mContext.enforceCallingOrSelfPermission( |
| 2436 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 2437 | } |
| 2438 | |
chen xu | 6a942d48 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 2439 | if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { |
| 2440 | mContext.enforceCallingOrSelfPermission( |
| 2441 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 2442 | } |
| 2443 | |
Jordan Liu | 8218ddd | 2018-11-28 11:22:39 -0800 | [diff] [blame] | 2444 | if ((events & PhoneStateListener.LISTEN_CALL_ATTRIBUTES_CHANGED) != 0) { |
| 2445 | mContext.enforceCallingOrSelfPermission( |
| 2446 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 2447 | } |
| 2448 | |
chen xu | 52797b6 | 2019-01-18 13:16:31 -0800 | [diff] [blame] | 2449 | if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) { |
| 2450 | mContext.enforceCallingOrSelfPermission( |
| 2451 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 2452 | } |
| 2453 | |
| 2454 | if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) != 0) { |
| 2455 | mContext.enforceCallingOrSelfPermission( |
| 2456 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 2457 | } |
| 2458 | |
chen xu | 6ac5fc1 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 2459 | if ((events & PhoneStateListener.LISTEN_IMS_CALL_DISCONNECT_CAUSES) != 0) { |
| 2460 | mContext.enforceCallingOrSelfPermission( |
| 2461 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 2462 | } |
| 2463 | |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 2464 | return true; |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 2465 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 2466 | |
| 2467 | private void handleRemoveListLocked() { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 2468 | int size = mRemoveList.size(); |
| 2469 | if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size); |
| 2470 | if (size > 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 2471 | for (IBinder b: mRemoveList) { |
| 2472 | remove(b); |
| 2473 | } |
| 2474 | mRemoveList.clear(); |
| 2475 | } |
| 2476 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 2477 | |
| 2478 | private boolean validateEventsAndUserLocked(Record r, int events) { |
| 2479 | int foregroundUser; |
| 2480 | long callingIdentity = Binder.clearCallingIdentity(); |
| 2481 | boolean valid = false; |
| 2482 | try { |
| 2483 | foregroundUser = ActivityManager.getCurrentUser(); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2484 | valid = UserHandle.getUserId(r.callerUid) == foregroundUser |
| 2485 | && r.matchPhoneStateListenerEvent(events); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 2486 | if (DBG | DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2487 | log("validateEventsAndUserLocked: valid=" + valid |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2488 | + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 2489 | + " r.events=" + r.events + " events=" + events); |
| 2490 | } |
| 2491 | } finally { |
| 2492 | Binder.restoreCallingIdentity(callingIdentity); |
| 2493 | } |
| 2494 | return valid; |
| 2495 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2496 | |
| 2497 | private boolean validatePhoneId(int phoneId) { |
| 2498 | boolean valid = (phoneId >= 0) && (phoneId < mNumPhones); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2499 | if (VDBG) log("validatePhoneId: " + valid); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2500 | return valid; |
| 2501 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2502 | |
| 2503 | private static void log(String s) { |
| 2504 | Rlog.d(TAG, s); |
| 2505 | } |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 2506 | |
chen xu | 627d1b2 | 2019-04-11 02:16:19 -0700 | [diff] [blame] | 2507 | private static void loge(String s) { |
| 2508 | Rlog.e(TAG, s); |
| 2509 | } |
| 2510 | |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 2511 | boolean idMatch(int rSubId, int subId, int phoneId) { |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 2512 | |
| 2513 | if(subId < 0) { |
| 2514 | // Invalid case, we need compare phoneId with default one. |
| 2515 | return (mDefaultPhoneId == phoneId); |
| 2516 | } |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2517 | if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2518 | return (subId == mDefaultSubId); |
| 2519 | } else { |
| 2520 | return (rSubId == subId); |
| 2521 | } |
| 2522 | } |
| 2523 | |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2524 | private boolean checkFineLocationAccess(Record r, int minSdk) { |
| 2525 | LocationAccessPolicy.LocationPermissionQuery query = |
| 2526 | new LocationAccessPolicy.LocationPermissionQuery.Builder() |
| 2527 | .setCallingPackage(r.callingPackage) |
| 2528 | .setCallingPid(r.callerPid) |
| 2529 | .setCallingUid(r.callerUid) |
| 2530 | .setMethod("TelephonyRegistry push") |
Hall Liu | 879024a | 2019-04-17 13:33:43 -0700 | [diff] [blame] | 2531 | .setLogAsInfo(true) // we don't need to log an error every time we push |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2532 | .setMinSdkVersionForFine(minSdk) |
| 2533 | .build(); |
| 2534 | |
| 2535 | return Binder.withCleanCallingIdentity(() -> { |
| 2536 | LocationAccessPolicy.LocationPermissionResult locationResult = |
| 2537 | LocationAccessPolicy.checkLocationPermission(mContext, query); |
| 2538 | return locationResult == LocationAccessPolicy.LocationPermissionResult.ALLOWED; |
| 2539 | }); |
| 2540 | } |
| 2541 | |
| 2542 | private boolean checkCoarseLocationAccess(Record r, int minSdk) { |
| 2543 | LocationAccessPolicy.LocationPermissionQuery query = |
| 2544 | new LocationAccessPolicy.LocationPermissionQuery.Builder() |
| 2545 | .setCallingPackage(r.callingPackage) |
| 2546 | .setCallingPid(r.callerPid) |
| 2547 | .setCallingUid(r.callerUid) |
| 2548 | .setMethod("TelephonyRegistry push") |
Hall Liu | 879024a | 2019-04-17 13:33:43 -0700 | [diff] [blame] | 2549 | .setLogAsInfo(true) // we don't need to log an error every time we push |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2550 | .setMinSdkVersionForCoarse(minSdk) |
| 2551 | .build(); |
| 2552 | |
| 2553 | return Binder.withCleanCallingIdentity(() -> { |
| 2554 | LocationAccessPolicy.LocationPermissionResult locationResult = |
| 2555 | LocationAccessPolicy.checkLocationPermission(mContext, query); |
| 2556 | return locationResult == LocationAccessPolicy.LocationPermissionResult.ALLOWED; |
| 2557 | }); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2558 | } |
| 2559 | |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2560 | private void checkPossibleMissNotify(Record r, int phoneId) { |
| 2561 | int events = r.events; |
| 2562 | |
| 2563 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 2564 | try { |
| 2565 | if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" + |
| 2566 | mServiceState[phoneId]); |
| 2567 | r.callback.onServiceStateChanged( |
| 2568 | new ServiceState(mServiceState[phoneId])); |
| 2569 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2570 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2571 | } |
| 2572 | } |
| 2573 | |
| 2574 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 2575 | try { |
| 2576 | SignalStrength signalStrength = mSignalStrength[phoneId]; |
| 2577 | if (DBG) { |
| 2578 | log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength); |
| 2579 | } |
| 2580 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 2581 | } catch (RemoteException ex) { |
| 2582 | mRemoveList.add(r.binder); |
| 2583 | } |
| 2584 | } |
| 2585 | |
| 2586 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 2587 | try { |
| 2588 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 2589 | .getGsmSignalStrength(); |
| 2590 | if (DBG) { |
| 2591 | log("checkPossibleMissNotify: onSignalStrengthChanged SS=" + |
| 2592 | gsmSignalStrength); |
| 2593 | } |
| 2594 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 2595 | : gsmSignalStrength)); |
| 2596 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2597 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2598 | } |
| 2599 | } |
| 2600 | |
| 2601 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
| 2602 | try { |
| 2603 | if (DBG_LOC) { |
| 2604 | log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = " |
| 2605 | + mCellInfo.get(phoneId)); |
| 2606 | } |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2607 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2608 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
| 2609 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2610 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2611 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2612 | } |
| 2613 | } |
| 2614 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 2615 | if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) { |
| 2616 | try { |
| 2617 | if (VDBG) { |
| 2618 | log("checkPossibleMissNotify: onUserMobileDataStateChanged phoneId=" |
| 2619 | + phoneId + " umds=" + mUserMobileDataState[phoneId]); |
| 2620 | } |
| 2621 | r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]); |
| 2622 | } catch (RemoteException ex) { |
| 2623 | mRemoveList.add(r.binder); |
| 2624 | } |
| 2625 | } |
| 2626 | |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2627 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 2628 | try { |
| 2629 | if (VDBG) { |
| 2630 | log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId=" |
| 2631 | + phoneId + " mwi=" + mMessageWaiting[phoneId]); |
| 2632 | } |
| 2633 | r.callback.onMessageWaitingIndicatorChanged( |
| 2634 | mMessageWaiting[phoneId]); |
| 2635 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2636 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2637 | } |
| 2638 | } |
| 2639 | |
| 2640 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 2641 | try { |
| 2642 | if (VDBG) { |
| 2643 | log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId=" |
| 2644 | + phoneId + " cfi=" + mCallForwarding[phoneId]); |
| 2645 | } |
| 2646 | r.callback.onCallForwardingIndicatorChanged( |
| 2647 | mCallForwarding[phoneId]); |
| 2648 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2649 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2650 | } |
| 2651 | } |
| 2652 | |
| 2653 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
| 2654 | try { |
| 2655 | if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = " |
| 2656 | + mCellLocation[phoneId]); |
Hall Liu | ee31373 | 2018-11-27 14:36:51 -0800 | [diff] [blame] | 2657 | if (checkFineLocationAccess(r, Build.VERSION_CODES.Q)) { |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2658 | r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId])); |
| 2659 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2660 | } catch (RemoteException ex) { |
| 2661 | mRemoveList.add(r.binder); |
| 2662 | } |
| 2663 | } |
| 2664 | |
| 2665 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 2666 | try { |
| 2667 | if (DBG) { |
| 2668 | log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState" |
| 2669 | + "=" + mDataConnectionState[phoneId] |
| 2670 | + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId] |
| 2671 | + ")"); |
| 2672 | } |
| 2673 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 2674 | mDataConnectionNetworkType[phoneId]); |
| 2675 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2676 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2677 | } |
| 2678 | } |
| 2679 | } |
zoey chen | b1f74e7 | 2019-12-04 16:33:59 +0800 | [diff] [blame] | 2680 | |
| 2681 | /** |
| 2682 | * Convert data state to string |
| 2683 | * |
| 2684 | * @return The data state in string format. |
| 2685 | */ |
| 2686 | private String dataStateToString(@TelephonyManager.DataState int state) { |
| 2687 | switch (state) { |
| 2688 | case TelephonyManager.DATA_DISCONNECTED: return "DISCONNECTED"; |
| 2689 | case TelephonyManager.DATA_CONNECTING: return "CONNECTING"; |
| 2690 | case TelephonyManager.DATA_CONNECTED: return "CONNECTED"; |
| 2691 | case TelephonyManager.DATA_SUSPENDED: return "SUSPENDED"; |
| 2692 | } |
| 2693 | return "UNKNOWN(" + state + ")"; |
| 2694 | } |
| 2695 | |
| 2696 | /** |
| 2697 | * Returns a string representation of the radio technology (network type) |
| 2698 | * currently in use on the device. |
| 2699 | * @param subId for which network type is returned |
| 2700 | * @return the name of the radio technology |
| 2701 | * |
| 2702 | */ |
| 2703 | private String getNetworkTypeName(@Annotation.NetworkType int type) { |
| 2704 | switch (type) { |
| 2705 | case TelephonyManager.NETWORK_TYPE_GPRS: |
| 2706 | return "GPRS"; |
| 2707 | case TelephonyManager.NETWORK_TYPE_EDGE: |
| 2708 | return "EDGE"; |
| 2709 | case TelephonyManager.NETWORK_TYPE_UMTS: |
| 2710 | return "UMTS"; |
| 2711 | case TelephonyManager.NETWORK_TYPE_HSDPA: |
| 2712 | return "HSDPA"; |
| 2713 | case TelephonyManager.NETWORK_TYPE_HSUPA: |
| 2714 | return "HSUPA"; |
| 2715 | case TelephonyManager.NETWORK_TYPE_HSPA: |
| 2716 | return "HSPA"; |
| 2717 | case TelephonyManager.NETWORK_TYPE_CDMA: |
| 2718 | return "CDMA"; |
| 2719 | case TelephonyManager.NETWORK_TYPE_EVDO_0: |
| 2720 | return "CDMA - EvDo rev. 0"; |
| 2721 | case TelephonyManager.NETWORK_TYPE_EVDO_A: |
| 2722 | return "CDMA - EvDo rev. A"; |
| 2723 | case TelephonyManager.NETWORK_TYPE_EVDO_B: |
| 2724 | return "CDMA - EvDo rev. B"; |
| 2725 | case TelephonyManager.NETWORK_TYPE_1xRTT: |
| 2726 | return "CDMA - 1xRTT"; |
| 2727 | case TelephonyManager.NETWORK_TYPE_LTE: |
| 2728 | return "LTE"; |
| 2729 | case TelephonyManager.NETWORK_TYPE_EHRPD: |
| 2730 | return "CDMA - eHRPD"; |
| 2731 | case TelephonyManager.NETWORK_TYPE_IDEN: |
| 2732 | return "iDEN"; |
| 2733 | case TelephonyManager.NETWORK_TYPE_HSPAP: |
| 2734 | return "HSPA+"; |
| 2735 | case TelephonyManager.NETWORK_TYPE_GSM: |
| 2736 | return "GSM"; |
| 2737 | case TelephonyManager.NETWORK_TYPE_TD_SCDMA: |
| 2738 | return "TD_SCDMA"; |
| 2739 | case TelephonyManager.NETWORK_TYPE_IWLAN: |
| 2740 | return "IWLAN"; |
| 2741 | case TelephonyManager.NETWORK_TYPE_LTE_CA: |
| 2742 | return "LTE_CA"; |
| 2743 | case TelephonyManager.NETWORK_TYPE_NR: |
| 2744 | return "NR"; |
| 2745 | default: |
| 2746 | return "UNKNOWN"; |
| 2747 | } |
| 2748 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2749 | } |