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 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 19 | import android.app.ActivityManager; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 20 | import android.app.AppOpsManager; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 21 | import android.content.BroadcastReceiver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.Intent; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 24 | import android.content.IntentFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 26 | import android.net.LinkProperties; |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 27 | import android.net.NetworkCapabilities; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.os.Binder; |
| 29 | import android.os.Bundle; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 30 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.os.IBinder; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 32 | import android.os.Message; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | import android.os.RemoteException; |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 34 | import android.os.UserHandle; |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 35 | import android.telephony.CellInfo; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 36 | import android.telephony.CellLocation; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 37 | import android.telephony.DisconnectCause; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 38 | import android.telephony.LocationAccessPolicy; |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 39 | import android.telephony.PhoneCapability; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 40 | import android.telephony.PhoneStateListener; |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 41 | import android.telephony.PhysicalChannelConfig; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 42 | import android.telephony.PreciseCallState; |
| 43 | import android.telephony.PreciseDataConnectionState; |
| 44 | import android.telephony.PreciseDisconnectCause; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 45 | import android.telephony.Rlog; |
| 46 | import android.telephony.ServiceState; |
| 47 | import android.telephony.SignalStrength; |
| 48 | import android.telephony.SubscriptionManager; |
| 49 | import android.telephony.TelephonyManager; |
sqian | bf165bc | 2018-12-07 17:09:39 -0800 | [diff] [blame] | 50 | import android.telephony.emergency.EmergencyNumber; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 51 | import android.util.LocalLog; |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 52 | import android.util.StatsLog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
Malcolm Chen | 800a7d6 | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 54 | import com.android.internal.annotations.VisibleForTesting; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import com.android.internal.app.IBatteryStats; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 56 | import com.android.internal.telephony.IOnSubscriptionsChangedListener; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | import com.android.internal.telephony.IPhoneStateListener; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 58 | import com.android.internal.telephony.ITelephonyRegistry; |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 59 | import com.android.internal.telephony.PhoneConstantConversions; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 60 | import com.android.internal.telephony.PhoneConstants; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | import com.android.internal.telephony.TelephonyIntents; |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 62 | import com.android.internal.telephony.TelephonyPermissions; |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 63 | import com.android.internal.util.DumpUtils; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 64 | import com.android.internal.util.IndentingPrintWriter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | import com.android.server.am.BatteryStatsService; |
| 66 | |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 67 | import java.io.FileDescriptor; |
| 68 | import java.io.PrintWriter; |
| 69 | import java.util.ArrayList; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 70 | import java.util.List; |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 71 | import java.util.NoSuchElementException; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 72 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 74 | * Since phone process can be restarted, this class provides a centralized place |
| 75 | * that applications can register and be called back from. |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 76 | * |
| 77 | * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026 |
| 78 | * and 15973975 by saving the phoneId of the registrant and then using the |
| 79 | * phoneId when deciding to to make a callback. This is necessary because |
| 80 | * 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] | 81 | * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 82 | * the dummy value conversion we properly do the callbacks. |
| 83 | * |
| 84 | * Eventually we may want to remove the notion of dummy value but for now this |
| 85 | * looks like the best approach. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | */ |
Malcolm Chen | 800a7d6 | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 87 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 88 | public class TelephonyRegistry extends ITelephonyRegistry.Stub { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | private static final String TAG = "TelephonyRegistry"; |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 90 | private static final boolean DBG = false; // STOPSHIP if true |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 91 | private static final boolean DBG_LOC = false; // STOPSHIP if true |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 92 | private static final boolean VDBG = false; // STOPSHIP if true |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | |
| 94 | private static class Record { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 95 | Context context; |
| 96 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 97 | String callingPackage; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 98 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | IBinder binder; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 100 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 101 | TelephonyRegistryDeathRecipient deathRecipient; |
| 102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | IPhoneStateListener callback; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 104 | IOnSubscriptionsChangedListener onSubscriptionsChangedListenerCallback; |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 105 | IOnSubscriptionsChangedListener onOpportunisticSubscriptionsChangedListenerCallback; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 106 | |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 107 | int callerUid; |
| 108 | int callerPid; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 109 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | int events; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 111 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 112 | int subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 113 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 114 | int phoneId = SubscriptionManager.INVALID_PHONE_INDEX; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 115 | |
| 116 | boolean matchPhoneStateListenerEvent(int events) { |
| 117 | return (callback != null) && ((events & this.events) != 0); |
| 118 | } |
| 119 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 120 | boolean matchOnSubscriptionsChangedListener() { |
| 121 | return (onSubscriptionsChangedListenerCallback != null); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 122 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 123 | |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 124 | boolean matchOnOpportunisticSubscriptionsChangedListener() { |
| 125 | return (onOpportunisticSubscriptionsChangedListenerCallback != null); |
| 126 | } |
| 127 | |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 128 | boolean canReadCallLog() { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 129 | try { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 130 | return TelephonyPermissions.checkReadCallLog( |
| 131 | context, subId, callerPid, callerUid, callingPackage); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 132 | } catch (SecurityException e) { |
| 133 | return false; |
| 134 | } |
| 135 | } |
| 136 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 137 | @Override |
| 138 | public String toString() { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 139 | return "{callingPackage=" + callingPackage + " binder=" + binder |
| 140 | + " callback=" + callback |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 141 | + " onSubscriptionsChangedListenererCallback=" |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 142 | + onSubscriptionsChangedListenerCallback |
| 143 | + " onOpportunisticSubscriptionsChangedListenererCallback=" |
| 144 | + onOpportunisticSubscriptionsChangedListenerCallback |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 145 | + " callerUid=" + callerUid + " subId=" + subId + " phoneId=" + phoneId |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 146 | + " events=" + Integer.toHexString(events) + "}"; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 147 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | private final Context mContext; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 151 | |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 152 | // access should be inside synchronized (mRecords) for these two fields |
| 153 | private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>(); |
| 154 | private final ArrayList<Record> mRecords = new ArrayList<Record>(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 155 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | private final IBatteryStats mBatteryStats; |
| 157 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 158 | private final AppOpsManager mAppOps; |
| 159 | |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 160 | private boolean mHasNotifySubscriptionInfoChangedOccurred = false; |
| 161 | |
| 162 | private boolean mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = false; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 163 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 164 | private int mNumPhones; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 165 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 166 | private int[] mCallState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 167 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 168 | private String[] mCallIncomingNumber; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 169 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 170 | private ServiceState[] mServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 171 | |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 172 | private int[] mVoiceActivationState; |
| 173 | |
| 174 | private int[] mDataActivationState; |
| 175 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 176 | private boolean[] mUserMobileDataState; |
| 177 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 178 | private SignalStrength[] mSignalStrength; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 179 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 180 | private boolean[] mMessageWaiting; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 181 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 182 | private boolean[] mCallForwarding; |
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[] mDataActivity; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 185 | |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 186 | // Connection state of default APN type data (i.e. internet) of phones |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 187 | private int[] mDataConnectionState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 188 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 189 | private Bundle[] mCellLocation; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 190 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 191 | private int[] mDataConnectionNetworkType; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 192 | |
Nathan Harold | 016e9c6 | 2016-12-14 11:24:48 -0800 | [diff] [blame] | 193 | private int mOtaspMode = TelephonyManager.OTASP_UNKNOWN; |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 194 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 195 | private ArrayList<List<CellInfo>> mCellInfo = null; |
| 196 | |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 197 | private ArrayList<List<PhysicalChannelConfig>> mPhysicalChannelConfigs; |
| 198 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 199 | private int[] mSrvccState; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 200 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 201 | private int mDefaultSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 202 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 203 | private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_INDEX; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 204 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 205 | private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 206 | |
| 207 | private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 208 | |
| 209 | private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 210 | |
| 211 | private PreciseCallState mPreciseCallState = new PreciseCallState(); |
| 212 | |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 213 | private int mCallDisconnectCause = DisconnectCause.NOT_VALID; |
| 214 | |
| 215 | private int mCallPreciseDisconnectCause = PreciseDisconnectCause.NOT_VALID; |
| 216 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 217 | private boolean mCarrierNetworkChangeState = false; |
| 218 | |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 219 | private PhoneCapability mPhoneCapability = null; |
| 220 | |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 221 | @TelephonyManager.RadioPowerState |
| 222 | private int mRadioPowerState = TelephonyManager.RADIO_POWER_UNAVAILABLE; |
| 223 | |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 224 | private int mPreferredDataSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; |
| 225 | |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 226 | private final LocalLog mLocalLog = new LocalLog(100); |
| 227 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 228 | private PreciseDataConnectionState mPreciseDataConnectionState = |
| 229 | new PreciseDataConnectionState(); |
| 230 | |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 231 | static final int ENFORCE_COARSE_LOCATION_PERMISSION_MASK = |
| 232 | PhoneStateListener.LISTEN_CELL_LOCATION |
| 233 | | PhoneStateListener.LISTEN_CELL_INFO; |
| 234 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 235 | static final int ENFORCE_PHONE_STATE_PERMISSION_MASK = |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 236 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 237 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR; |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 238 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 239 | static final int PRECISE_PHONE_STATE_PERMISSION_MASK = |
| 240 | PhoneStateListener.LISTEN_PRECISE_CALL_STATE | |
| 241 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; |
| 242 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 243 | private static final int MSG_USER_SWITCHED = 1; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 244 | private static final int MSG_UPDATE_DEFAULT_SUB = 2; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 245 | |
| 246 | private final Handler mHandler = new Handler() { |
| 247 | @Override |
| 248 | public void handleMessage(Message msg) { |
| 249 | switch (msg.what) { |
| 250 | case MSG_USER_SWITCHED: { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 251 | if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 252 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
| 253 | for (int sub = 0; sub < numPhones; sub++) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 254 | TelephonyRegistry.this.notifyCellLocationForSubscriber(sub, |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 255 | mCellLocation[sub]); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 256 | } |
| 257 | break; |
| 258 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 259 | case MSG_UPDATE_DEFAULT_SUB: { |
| 260 | int newDefaultPhoneId = msg.arg1; |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 261 | int newDefaultSubId = (Integer)(msg.obj); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 262 | if (VDBG) { |
| 263 | log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId |
| 264 | + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= " |
| 265 | + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId); |
| 266 | } |
| 267 | |
| 268 | //Due to possible risk condition,(notify call back using the new |
| 269 | //defaultSubId comes before new defaultSubId update) we need to recall all |
| 270 | //possible missed notify callback |
| 271 | synchronized (mRecords) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 272 | for (Record r : mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 273 | if(r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 274 | checkPossibleMissNotify(r, newDefaultPhoneId); |
| 275 | } |
| 276 | } |
| 277 | handleRemoveListLocked(); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 278 | } |
| 279 | mDefaultSubId = newDefaultSubId; |
| 280 | mDefaultPhoneId = newDefaultPhoneId; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 281 | } |
| 282 | } |
| 283 | } |
| 284 | }; |
| 285 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 286 | private class TelephonyRegistryDeathRecipient implements IBinder.DeathRecipient { |
| 287 | |
| 288 | private final IBinder binder; |
| 289 | |
| 290 | TelephonyRegistryDeathRecipient(IBinder binder) { |
| 291 | this.binder = binder; |
| 292 | } |
| 293 | |
| 294 | @Override |
| 295 | public void binderDied() { |
| 296 | if (DBG) log("binderDied " + binder); |
| 297 | remove(binder); |
| 298 | } |
| 299 | } |
| 300 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 301 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 302 | @Override |
| 303 | public void onReceive(Context context, Intent intent) { |
| 304 | String action = intent.getAction(); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 305 | if (VDBG) log("mBroadcastReceiver: action=" + action); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 306 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 307 | int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 308 | if (DBG) log("onReceive: userHandle=" + userHandle); |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 309 | mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0)); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 310 | } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) { |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 311 | Integer newDefaultSubIdObj = new Integer(intent.getIntExtra( |
Shishir Agrawal | 7ea3e8b | 2016-01-25 13:03:07 -0800 | [diff] [blame] | 312 | PhoneConstants.SUBSCRIPTION_KEY, |
| 313 | SubscriptionManager.getDefaultSubscriptionId())); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 314 | int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY, |
| 315 | SubscriptionManager.getPhoneId(mDefaultSubId)); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 316 | if (DBG) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 317 | log("onReceive:current mDefaultSubId=" + mDefaultSubId |
| 318 | + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= " |
| 319 | + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 320 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 321 | |
Junda Liu | 985f52c | 2015-02-23 16:06:51 -0800 | [diff] [blame] | 322 | if(validatePhoneId(newDefaultPhoneId) && (!newDefaultSubIdObj.equals(mDefaultSubId) |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 323 | || (newDefaultPhoneId != mDefaultPhoneId))) { |
| 324 | mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB, |
| 325 | newDefaultPhoneId, 0, newDefaultSubIdObj)); |
| 326 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | }; |
| 330 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 331 | // we keep a copy of all of the state so we can send it out when folks |
| 332 | // register for it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 333 | // |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 334 | // In these calls we call with the lock held. This is safe becasuse remote |
| 335 | // calls go through a oneway interface and local calls going through a |
| 336 | // handler before they get to app code. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 337 | |
Malcolm Chen | 800a7d6 | 2018-08-27 20:38:29 -0700 | [diff] [blame] | 338 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 339 | public TelephonyRegistry(Context context) { |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 340 | CellLocation location = CellLocation.getEmpty(); |
| 341 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 342 | mContext = context; |
| 343 | mBatteryStats = BatteryStatsService.getService(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 344 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 345 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 346 | if (DBG) log("TelephonyRegistry: ctor numPhones=" + numPhones); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 347 | mNumPhones = numPhones; |
| 348 | mCallState = new int[numPhones]; |
| 349 | mDataActivity = new int[numPhones]; |
| 350 | mDataConnectionState = new int[numPhones]; |
| 351 | mDataConnectionNetworkType = new int[numPhones]; |
| 352 | mCallIncomingNumber = new String[numPhones]; |
| 353 | mServiceState = new ServiceState[numPhones]; |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 354 | mVoiceActivationState = new int[numPhones]; |
| 355 | mDataActivationState = new int[numPhones]; |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 356 | mUserMobileDataState = new boolean[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 357 | mSignalStrength = new SignalStrength[numPhones]; |
| 358 | mMessageWaiting = new boolean[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 359 | mCallForwarding = new boolean[numPhones]; |
| 360 | mCellLocation = new Bundle[numPhones]; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 361 | mCellInfo = new ArrayList<List<CellInfo>>(); |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 362 | mSrvccState = new int[numPhones]; |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 363 | mPhysicalChannelConfigs = new ArrayList<List<PhysicalChannelConfig>>(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 364 | for (int i = 0; i < numPhones; i++) { |
| 365 | mCallState[i] = TelephonyManager.CALL_STATE_IDLE; |
| 366 | mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; |
| 367 | mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN; |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 368 | mVoiceActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
| 369 | mDataActivationState[i] = TelephonyManager.SIM_ACTIVATION_STATE_UNKNOWN; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 370 | mCallIncomingNumber[i] = ""; |
| 371 | mServiceState[i] = new ServiceState(); |
| 372 | mSignalStrength[i] = new SignalStrength(); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 373 | mUserMobileDataState[i] = false; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 374 | mMessageWaiting[i] = false; |
| 375 | mCallForwarding[i] = false; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 376 | mCellLocation[i] = new Bundle(); |
| 377 | mCellInfo.add(i, null); |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 378 | mSrvccState[i] = TelephonyManager.SRVCC_STATE_HANDOVER_NONE; |
Nathan Harold | c9bad6e | 2018-04-25 12:53:04 -0700 | [diff] [blame] | 379 | mPhysicalChannelConfigs.add(i, new ArrayList<PhysicalChannelConfig>()); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 380 | } |
| 381 | |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 382 | // Note that location can be null for non-phone builds like |
| 383 | // like the generic one. |
| 384 | if (location != null) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 385 | for (int i = 0; i < numPhones; i++) { |
| 386 | location.fillInNotifierBundle(mCellLocation[i]); |
| 387 | } |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 388 | } |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 389 | |
| 390 | mAppOps = mContext.getSystemService(AppOpsManager.class); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | } |
| 392 | |
Svetoslav Ganov | a002715 | 2013-06-25 14:59:53 -0700 | [diff] [blame] | 393 | public void systemRunning() { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 394 | // Watch for interesting updates |
| 395 | final IntentFilter filter = new IntentFilter(); |
| 396 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
| 397 | filter.addAction(Intent.ACTION_USER_REMOVED); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 398 | filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 399 | log("systemRunning register for intents"); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 400 | mContext.registerReceiver(mBroadcastReceiver, filter); |
| 401 | } |
| 402 | |
| 403 | @Override |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 404 | public void addOnSubscriptionsChangedListener(String callingPackage, |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 405 | IOnSubscriptionsChangedListener callback) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 406 | int callerUserId = UserHandle.getCallingUserId(); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 407 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 408 | if (VDBG) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 409 | log("listen oscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId() |
| 410 | + " callerUserId=" + callerUserId + " callback=" + callback |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 411 | + " callback.asBinder=" + callback.asBinder()); |
| 412 | } |
| 413 | |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 414 | synchronized (mRecords) { |
| 415 | // register |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 416 | IBinder b = callback.asBinder(); |
| 417 | Record r = add(b); |
| 418 | |
| 419 | if (r == null) { |
| 420 | return; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 423 | r.context = mContext; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 424 | r.onSubscriptionsChangedListenerCallback = callback; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 425 | r.callingPackage = callingPackage; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 426 | r.callerUid = Binder.getCallingUid(); |
| 427 | r.callerPid = Binder.getCallingPid(); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 428 | r.events = 0; |
| 429 | if (DBG) { |
| 430 | log("listen oscl: Register r=" + r); |
| 431 | } |
| 432 | // Always notify when registration occurs if there has been a notification. |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 433 | if (mHasNotifySubscriptionInfoChangedOccurred) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 434 | try { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 435 | if (VDBG) log("listen oscl: send to r=" + r); |
| 436 | r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 437 | if (VDBG) log("listen oscl: sent to r=" + r); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 438 | } catch (RemoteException e) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 439 | 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] | 440 | remove(r.binder); |
| 441 | } |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 442 | } else { |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 443 | log("listen oscl: mHasNotifySubscriptionInfoChangedOccurred==false no callback"); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 444 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 445 | } |
| 446 | } |
| 447 | |
| 448 | @Override |
Wink Saville | 071743f | 2015-01-12 17:11:04 -0800 | [diff] [blame] | 449 | public void removeOnSubscriptionsChangedListener(String pkgForDebug, |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 450 | IOnSubscriptionsChangedListener callback) { |
| 451 | if (DBG) log("listen oscl: Unregister"); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 452 | remove(callback.asBinder()); |
| 453 | } |
| 454 | |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 455 | |
| 456 | @Override |
| 457 | public void addOnOpportunisticSubscriptionsChangedListener(String callingPackage, |
| 458 | IOnSubscriptionsChangedListener callback) { |
| 459 | int callerUserId = UserHandle.getCallingUserId(); |
| 460 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
| 461 | if (VDBG) { |
| 462 | log("listen ooscl: E pkg=" + callingPackage + " myUserId=" + UserHandle.myUserId() |
| 463 | + " callerUserId=" + callerUserId + " callback=" + callback |
| 464 | + " callback.asBinder=" + callback.asBinder()); |
| 465 | } |
| 466 | |
| 467 | synchronized (mRecords) { |
| 468 | // register |
| 469 | IBinder b = callback.asBinder(); |
| 470 | Record r = add(b); |
| 471 | |
| 472 | if (r == null) { |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | r.context = mContext; |
| 477 | r.onOpportunisticSubscriptionsChangedListenerCallback = callback; |
| 478 | r.callingPackage = callingPackage; |
| 479 | r.callerUid = Binder.getCallingUid(); |
| 480 | r.callerPid = Binder.getCallingPid(); |
| 481 | r.events = 0; |
| 482 | if (DBG) { |
| 483 | log("listen ooscl: Register r=" + r); |
| 484 | } |
| 485 | // Always notify when registration occurs if there has been a notification. |
| 486 | if (mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) { |
| 487 | try { |
| 488 | if (VDBG) log("listen ooscl: send to r=" + r); |
| 489 | r.onOpportunisticSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 490 | if (VDBG) log("listen ooscl: sent to r=" + r); |
| 491 | } catch (RemoteException e) { |
| 492 | if (VDBG) log("listen ooscl: remote exception sending to r=" + r + " e=" + e); |
| 493 | remove(r.binder); |
| 494 | } |
| 495 | } else { |
| 496 | log("listen ooscl: hasNotifyOpptSubInfoChangedOccurred==false no callback"); |
| 497 | } |
| 498 | } |
| 499 | } |
| 500 | |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 501 | @Override |
| 502 | public void notifySubscriptionInfoChanged() { |
| 503 | if (VDBG) log("notifySubscriptionInfoChanged:"); |
| 504 | synchronized (mRecords) { |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 505 | if (!mHasNotifySubscriptionInfoChangedOccurred) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 506 | log("notifySubscriptionInfoChanged: first invocation mRecords.size=" |
| 507 | + mRecords.size()); |
| 508 | } |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 509 | mHasNotifySubscriptionInfoChangedOccurred = true; |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 510 | mRemoveList.clear(); |
| 511 | for (Record r : mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 512 | if (r.matchOnSubscriptionsChangedListener()) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 513 | try { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 514 | if (VDBG) log("notifySubscriptionInfoChanged: call osc to r=" + r); |
| 515 | r.onSubscriptionsChangedListenerCallback.onSubscriptionsChanged(); |
| 516 | if (VDBG) log("notifySubscriptionInfoChanged: done osc to r=" + r); |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 517 | } catch (RemoteException ex) { |
| 518 | if (VDBG) log("notifySubscriptionInfoChanged: RemoteException r=" + r); |
| 519 | mRemoveList.add(r.binder); |
| 520 | } |
| 521 | } |
| 522 | } |
| 523 | handleRemoveListLocked(); |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | @Override |
Malcolm Chen | 27829e2 | 2018-09-04 22:12:31 -0700 | [diff] [blame] | 528 | public void notifyOpportunisticSubscriptionInfoChanged() { |
| 529 | if (VDBG) log("notifyOpptSubscriptionInfoChanged:"); |
| 530 | synchronized (mRecords) { |
| 531 | if (!mHasNotifyOpportunisticSubscriptionInfoChangedOccurred) { |
| 532 | log("notifyOpptSubscriptionInfoChanged: first invocation mRecords.size=" |
| 533 | + mRecords.size()); |
| 534 | } |
| 535 | mHasNotifyOpportunisticSubscriptionInfoChangedOccurred = true; |
| 536 | mRemoveList.clear(); |
| 537 | for (Record r : mRecords) { |
| 538 | if (r.matchOnOpportunisticSubscriptionsChangedListener()) { |
| 539 | try { |
| 540 | if (VDBG) log("notifyOpptSubChanged: call oosc to r=" + r); |
| 541 | r.onOpportunisticSubscriptionsChangedListenerCallback |
| 542 | .onSubscriptionsChanged(); |
| 543 | if (VDBG) log("notifyOpptSubChanged: done oosc to r=" + r); |
| 544 | } catch (RemoteException ex) { |
| 545 | if (VDBG) log("notifyOpptSubChanged: RemoteException r=" + r); |
| 546 | mRemoveList.add(r.binder); |
| 547 | } |
| 548 | } |
| 549 | } |
| 550 | handleRemoveListLocked(); |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 555 | public void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 556 | boolean notifyNow) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 557 | listenForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, pkgForDebug, callback, |
| 558 | events, notifyNow); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 562 | public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 563 | int events, boolean notifyNow) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 564 | listen(pkgForDebug, callback, events, notifyNow, subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 565 | } |
| 566 | |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 567 | private void listen(String callingPackage, IPhoneStateListener callback, int events, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 568 | boolean notifyNow, int subId) { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 569 | int callerUserId = UserHandle.getCallingUserId(); |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 570 | mAppOps.checkPackage(Binder.getCallingUid(), callingPackage); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 571 | if (VDBG) { |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 572 | log("listen: E pkg=" + callingPackage + " events=0x" + Integer.toHexString(events) |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 573 | + " notifyNow=" + notifyNow + " subId=" + subId + " myUserId=" |
| 574 | + UserHandle.myUserId() + " callerUserId=" + callerUserId); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 575 | } |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 576 | |
| 577 | if (events != PhoneStateListener.LISTEN_NONE) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 578 | // Checks permission and throws SecurityException for disallowed operations. For pre-M |
| 579 | // apps whose runtime permission has been revoked, we return immediately to skip sending |
| 580 | // events to the app without crashing it. |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 581 | if (!checkListenerPermission(events, subId, callingPackage, "listen")) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 582 | return; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 583 | } |
| 584 | |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 585 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 586 | synchronized (mRecords) { |
| 587 | // register |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 588 | IBinder b = callback.asBinder(); |
| 589 | Record r = add(b); |
| 590 | |
| 591 | if (r == null) { |
| 592 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 593 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 594 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 595 | r.context = mContext; |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 596 | r.callback = callback; |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 597 | r.callingPackage = callingPackage; |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 598 | r.callerUid = Binder.getCallingUid(); |
| 599 | r.callerPid = Binder.getCallingPid(); |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 600 | // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, |
| 601 | // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID |
Wink Saville | a54bf65 | 2014-12-11 13:37:50 -0800 | [diff] [blame] | 602 | if (!SubscriptionManager.isValidSubscriptionId(subId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 603 | r.subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 604 | } else {//APP specify subID |
| 605 | r.subId = subId; |
| 606 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 607 | r.phoneId = phoneId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | r.events = events; |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 609 | if (DBG) { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 610 | log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 611 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 612 | if (notifyNow && validatePhoneId(phoneId)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 613 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 614 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 615 | if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 616 | r.callback.onServiceStateChanged( |
| 617 | new ServiceState(mServiceState[phoneId])); |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 618 | } catch (RemoteException ex) { |
| 619 | remove(r.binder); |
| 620 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 621 | } |
| 622 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 623 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 624 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 625 | .getGsmSignalStrength(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 626 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 627 | : gsmSignalStrength)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 628 | } catch (RemoteException ex) { |
| 629 | remove(r.binder); |
| 630 | } |
| 631 | } |
| 632 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 633 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 634 | r.callback.onMessageWaitingIndicatorChanged( |
| 635 | mMessageWaiting[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 636 | } catch (RemoteException ex) { |
| 637 | remove(r.binder); |
| 638 | } |
| 639 | } |
| 640 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 641 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 642 | r.callback.onCallForwardingIndicatorChanged( |
| 643 | mCallForwarding[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 644 | } catch (RemoteException ex) { |
| 645 | remove(r.binder); |
| 646 | } |
| 647 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 648 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 649 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 650 | if (DBG_LOC) log("listen: mCellLocation = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 651 | + mCellLocation[phoneId]); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 652 | if (checkLocationAccess(r)) { |
| 653 | r.callback.onCellLocationChanged( |
| 654 | new Bundle(mCellLocation[phoneId])); |
| 655 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 656 | } catch (RemoteException ex) { |
| 657 | remove(r.binder); |
| 658 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 659 | } |
| 660 | if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 661 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 662 | r.callback.onCallStateChanged(mCallState[phoneId], |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 663 | getCallIncomingNumber(r, phoneId)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 664 | } catch (RemoteException ex) { |
| 665 | remove(r.binder); |
| 666 | } |
| 667 | } |
| 668 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 669 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 670 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 671 | mDataConnectionNetworkType[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 672 | } catch (RemoteException ex) { |
| 673 | remove(r.binder); |
| 674 | } |
| 675 | } |
| 676 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 677 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 678 | r.callback.onDataActivity(mDataActivity[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 679 | } catch (RemoteException ex) { |
| 680 | remove(r.binder); |
| 681 | } |
| 682 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 683 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 684 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 685 | r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 686 | } catch (RemoteException ex) { |
| 687 | remove(r.binder); |
| 688 | } |
| 689 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 690 | if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 691 | try { |
| 692 | r.callback.onOtaspChanged(mOtaspMode); |
| 693 | } catch (RemoteException ex) { |
| 694 | remove(r.binder); |
| 695 | } |
| 696 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 697 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 698 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 699 | if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 700 | + mCellInfo.get(phoneId)); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 701 | if (checkLocationAccess(r)) { |
| 702 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
| 703 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 704 | } catch (RemoteException ex) { |
| 705 | remove(r.binder); |
| 706 | } |
| 707 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 708 | if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 709 | try { |
| 710 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 711 | } catch (RemoteException ex) { |
| 712 | remove(r.binder); |
| 713 | } |
| 714 | } |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 715 | if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { |
| 716 | try { |
| 717 | r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause, |
| 718 | mCallPreciseDisconnectCause); |
| 719 | } catch (RemoteException ex) { |
| 720 | remove(r.binder); |
| 721 | } |
| 722 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 723 | if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 724 | try { |
| 725 | r.callback.onPreciseDataConnectionStateChanged( |
| 726 | mPreciseDataConnectionState); |
| 727 | } catch (RemoteException ex) { |
| 728 | remove(r.binder); |
| 729 | } |
| 730 | } |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 731 | if ((events & PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE) != 0) { |
| 732 | try { |
| 733 | r.callback.onCarrierNetworkChange(mCarrierNetworkChangeState); |
| 734 | } catch (RemoteException ex) { |
| 735 | remove(r.binder); |
| 736 | } |
| 737 | } |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 738 | if ((events & PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) !=0) { |
| 739 | try { |
| 740 | r.callback.onVoiceActivationStateChanged(mVoiceActivationState[phoneId]); |
| 741 | } catch (RemoteException ex) { |
| 742 | remove(r.binder); |
| 743 | } |
| 744 | } |
| 745 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) !=0) { |
| 746 | try { |
| 747 | r.callback.onDataActivationStateChanged(mDataActivationState[phoneId]); |
| 748 | } catch (RemoteException ex) { |
| 749 | remove(r.binder); |
| 750 | } |
| 751 | } |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 752 | if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) { |
| 753 | try { |
| 754 | r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]); |
| 755 | } catch (RemoteException ex) { |
| 756 | remove(r.binder); |
| 757 | } |
| 758 | } |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 759 | if ((events & PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) != 0) { |
| 760 | try { |
| 761 | r.callback.onPhysicalChannelConfigurationChanged( |
| 762 | mPhysicalChannelConfigs.get(phoneId)); |
| 763 | } catch (RemoteException ex) { |
| 764 | remove(r.binder); |
| 765 | } |
| 766 | } |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 767 | if ((events & PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE) != 0) { |
| 768 | try { |
| 769 | r.callback.onPhoneCapabilityChanged(mPhoneCapability); |
| 770 | } catch (RemoteException ex) { |
| 771 | remove(r.binder); |
| 772 | } |
| 773 | } |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 774 | if ((events & PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE) != 0) { |
| 775 | try { |
| 776 | r.callback.onPreferredDataSubIdChanged(mPreferredDataSubId); |
| 777 | } catch (RemoteException ex) { |
| 778 | remove(r.binder); |
| 779 | } |
| 780 | } |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 781 | if ((events & PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED) != 0) { |
| 782 | try { |
| 783 | r.callback.onRadioPowerStateChanged(mRadioPowerState); |
| 784 | } catch (RemoteException ex) { |
| 785 | remove(r.binder); |
| 786 | } |
| 787 | } |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 788 | if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) { |
| 789 | try { |
| 790 | r.callback.onSrvccStateChanged(mSrvccState[phoneId]); |
| 791 | } catch (RemoteException ex) { |
| 792 | remove(r.binder); |
| 793 | } |
| 794 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | } else { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 798 | if(DBG) log("listen: Unregister"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 799 | remove(callback.asBinder()); |
| 800 | } |
| 801 | } |
| 802 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 803 | private String getCallIncomingNumber(Record record, int phoneId) { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 804 | // Only reveal the incoming number if the record has read call log permission. |
| 805 | return record.canReadCallLog() ? mCallIncomingNumber[phoneId] : ""; |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 806 | } |
| 807 | |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 808 | private Record add(IBinder binder) { |
| 809 | Record r; |
| 810 | |
| 811 | synchronized (mRecords) { |
| 812 | final int N = mRecords.size(); |
| 813 | for (int i = 0; i < N; i++) { |
| 814 | r = mRecords.get(i); |
| 815 | if (binder == r.binder) { |
| 816 | // Already existed. |
| 817 | return r; |
| 818 | } |
| 819 | } |
| 820 | r = new Record(); |
| 821 | r.binder = binder; |
| 822 | r.deathRecipient = new TelephonyRegistryDeathRecipient(binder); |
| 823 | |
| 824 | try { |
| 825 | binder.linkToDeath(r.deathRecipient, 0); |
| 826 | } catch (RemoteException e) { |
| 827 | if (VDBG) log("LinkToDeath remote exception sending to r=" + r + " e=" + e); |
| 828 | // Binder already died. Return null. |
| 829 | return null; |
| 830 | } |
| 831 | |
| 832 | mRecords.add(r); |
| 833 | if (DBG) log("add new record"); |
| 834 | } |
| 835 | |
| 836 | return r; |
| 837 | } |
| 838 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 839 | private void remove(IBinder binder) { |
| 840 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 841 | final int recordCount = mRecords.size(); |
| 842 | for (int i = 0; i < recordCount; i++) { |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 843 | Record r = mRecords.get(i); |
| 844 | if (r.binder == binder) { |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 845 | if (DBG) { |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 846 | log("remove: binder=" + binder + " r.callingPackage " + r.callingPackage |
| 847 | + " r.callback " + r.callback); |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 848 | } |
Malcolm Chen | abbfac2 | 2018-02-12 19:15:59 -0800 | [diff] [blame] | 849 | |
| 850 | if (r.deathRecipient != null) { |
| 851 | try { |
| 852 | binder.unlinkToDeath(r.deathRecipient, 0); |
| 853 | } catch (NoSuchElementException e) { |
| 854 | if (VDBG) log("UnlinkToDeath NoSuchElementException sending to r=" |
| 855 | + r + " e=" + e); |
| 856 | } |
| 857 | } |
| 858 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 859 | mRecords.remove(i); |
| 860 | return; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | } |
| 865 | |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 866 | public void notifyCallState(int state, String phoneNumber) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 867 | if (!checkNotifyPermission("notifyCallState()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 868 | return; |
| 869 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 870 | |
| 871 | if (VDBG) { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 872 | log("notifyCallState: state=" + state + " phoneNumber=" + phoneNumber); |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 873 | } |
| 874 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 875 | synchronized (mRecords) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 876 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 877 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 878 | (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 879 | try { |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 880 | // Ensure the listener has read call log permission; if they do not return |
| 881 | // an empty phone number. |
| 882 | String phoneNumberOrEmpty = r.canReadCallLog() ? phoneNumber : ""; |
| 883 | r.callback.onCallStateChanged(state, phoneNumberOrEmpty); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 884 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 885 | mRemoveList.add(r.binder); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 886 | } |
| 887 | } |
| 888 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 889 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 890 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 891 | |
| 892 | // Called only by Telecomm to communicate call state across different phone accounts. So |
| 893 | // there is no need to add a valid subId or slotId. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 894 | broadcastCallStateChanged(state, phoneNumber, |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 895 | SubscriptionManager.INVALID_PHONE_INDEX, |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 896 | SubscriptionManager.INVALID_SUBSCRIPTION_ID); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 897 | } |
| 898 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 899 | public void notifyCallStateForPhoneId(int phoneId, int subId, int state, |
| 900 | String incomingNumber) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 901 | if (!checkNotifyPermission("notifyCallState()")) { |
| 902 | return; |
| 903 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 904 | if (VDBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 905 | log("notifyCallStateForPhoneId: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 906 | + " state=" + state + " incomingNumber=" + incomingNumber); |
| 907 | } |
| 908 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 909 | if (validatePhoneId(phoneId)) { |
| 910 | mCallState[phoneId] = state; |
| 911 | mCallIncomingNumber[phoneId] = incomingNumber; |
| 912 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 913 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_CALL_STATE) && |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 914 | (r.subId == subId) && |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 915 | (r.subId != SubscriptionManager.DEFAULT_SUBSCRIPTION_ID)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 916 | try { |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 917 | String incomingNumberOrEmpty = getCallIncomingNumber(r, phoneId); |
| 918 | r.callback.onCallStateChanged(state, incomingNumberOrEmpty); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 919 | } catch (RemoteException ex) { |
| 920 | mRemoveList.add(r.binder); |
| 921 | } |
| 922 | } |
| 923 | } |
| 924 | } |
| 925 | handleRemoveListLocked(); |
| 926 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 927 | broadcastCallStateChanged(state, incomingNumber, phoneId, subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 928 | } |
| 929 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 930 | public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 931 | if (!checkNotifyPermission("notifyServiceState()")){ |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 932 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 933 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 934 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 935 | synchronized (mRecords) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 936 | String str = "notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId |
| 937 | + " state=" + state; |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 938 | if (VDBG) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 939 | log(str); |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 940 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 941 | mLocalLog.log(str); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 942 | if (validatePhoneId(phoneId)) { |
| 943 | mServiceState[phoneId] = state; |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 944 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 945 | for (Record r : mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 946 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 947 | log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 948 | + " phoneId=" + phoneId + " state=" + state); |
| 949 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 950 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SERVICE_STATE) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 951 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 952 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 953 | if (DBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 954 | log("notifyServiceStateForSubscriber: callback.onSSC r=" + r |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 955 | + " subId=" + subId + " phoneId=" + phoneId |
| 956 | + " state=" + state); |
| 957 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 958 | r.callback.onServiceStateChanged(new ServiceState(state)); |
| 959 | } catch (RemoteException ex) { |
| 960 | mRemoveList.add(r.binder); |
| 961 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 962 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 963 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 964 | } else { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 965 | log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 966 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 967 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 968 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 969 | broadcastServiceStateChanged(state, phoneId, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 970 | } |
| 971 | |
fionaxu | 12312f6 | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 972 | public void notifySimActivationStateChangedForPhoneId(int phoneId, int subId, |
| 973 | int activationType, int activationState) { |
| 974 | if (!checkNotifyPermission("notifySimActivationState()")){ |
| 975 | return; |
| 976 | } |
| 977 | if (VDBG) { |
| 978 | log("notifySimActivationStateForPhoneId: subId=" + subId + " phoneId=" + phoneId |
| 979 | + "type=" + activationType + " state=" + activationState); |
| 980 | } |
| 981 | synchronized (mRecords) { |
| 982 | if (validatePhoneId(phoneId)) { |
| 983 | switch (activationType) { |
| 984 | case PhoneConstants.SIM_ACTIVATION_TYPE_VOICE: |
| 985 | mVoiceActivationState[phoneId] = activationState; |
| 986 | break; |
| 987 | case PhoneConstants.SIM_ACTIVATION_TYPE_DATA: |
| 988 | mDataActivationState[phoneId] = activationState; |
| 989 | break; |
| 990 | default: |
| 991 | return; |
| 992 | } |
| 993 | for (Record r : mRecords) { |
| 994 | if (VDBG) { |
| 995 | log("notifySimActivationStateForPhoneId: r=" + r + " subId=" + subId |
| 996 | + " phoneId=" + phoneId + "type=" + activationType |
| 997 | + " state=" + activationState); |
| 998 | } |
| 999 | try { |
| 1000 | if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_VOICE) && |
| 1001 | r.matchPhoneStateListenerEvent( |
| 1002 | PhoneStateListener.LISTEN_VOICE_ACTIVATION_STATE) && |
| 1003 | idMatch(r.subId, subId, phoneId)) { |
| 1004 | if (DBG) { |
| 1005 | log("notifyVoiceActivationStateForPhoneId: callback.onVASC r=" + r |
| 1006 | + " subId=" + subId + " phoneId=" + phoneId |
| 1007 | + " state=" + activationState); |
| 1008 | } |
| 1009 | r.callback.onVoiceActivationStateChanged(activationState); |
| 1010 | } |
| 1011 | if ((activationType == PhoneConstants.SIM_ACTIVATION_TYPE_DATA) && |
| 1012 | r.matchPhoneStateListenerEvent( |
| 1013 | PhoneStateListener.LISTEN_DATA_ACTIVATION_STATE) && |
| 1014 | idMatch(r.subId, subId, phoneId)) { |
| 1015 | if (DBG) { |
| 1016 | log("notifyDataActivationStateForPhoneId: callback.onDASC r=" + r |
| 1017 | + " subId=" + subId + " phoneId=" + phoneId |
| 1018 | + " state=" + activationState); |
| 1019 | } |
| 1020 | r.callback.onDataActivationStateChanged(activationState); |
| 1021 | } |
| 1022 | } catch (RemoteException ex) { |
| 1023 | mRemoveList.add(r.binder); |
| 1024 | } |
| 1025 | } |
| 1026 | } else { |
| 1027 | log("notifySimActivationStateForPhoneId: INVALID phoneId=" + phoneId); |
| 1028 | } |
| 1029 | handleRemoveListLocked(); |
| 1030 | } |
| 1031 | } |
| 1032 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1033 | public void notifySignalStrengthForPhoneId(int phoneId, int subId, |
| 1034 | SignalStrength signalStrength) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1035 | if (!checkNotifyPermission("notifySignalStrength()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1036 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1037 | } |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1038 | if (VDBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1039 | log("notifySignalStrengthForPhoneId: subId=" + subId |
| 1040 | +" phoneId=" + phoneId + " signalStrength=" + signalStrength); |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1041 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1042 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1043 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1044 | if (validatePhoneId(phoneId)) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1045 | if (VDBG) log("notifySignalStrengthForPhoneId: valid phoneId=" + phoneId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1046 | mSignalStrength[phoneId] = signalStrength; |
| 1047 | for (Record r : mRecords) { |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1048 | if (VDBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1049 | log("notifySignalStrengthForPhoneId: r=" + r + " subId=" + subId |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1050 | + " phoneId=" + phoneId + " ss=" + signalStrength); |
| 1051 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1052 | if (r.matchPhoneStateListenerEvent( |
| 1053 | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1054 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1055 | try { |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1056 | if (DBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1057 | log("notifySignalStrengthForPhoneId: callback.onSsS r=" + r |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1058 | + " subId=" + subId + " phoneId=" + phoneId |
| 1059 | + " ss=" + signalStrength); |
| 1060 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1061 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 1062 | } catch (RemoteException ex) { |
| 1063 | mRemoveList.add(r.binder); |
| 1064 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1065 | } |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1066 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_SIGNAL_STRENGTH) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1067 | idMatch(r.subId, subId, phoneId)){ |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1068 | try { |
| 1069 | int gsmSignalStrength = signalStrength.getGsmSignalStrength(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1070 | int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength); |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1071 | if (DBG) { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1072 | log("notifySignalStrengthForPhoneId: callback.onSS r=" + r |
Amit Mahajan | 1466a9c | 2015-04-27 22:58:29 +0000 | [diff] [blame] | 1073 | + " subId=" + subId + " phoneId=" + phoneId |
| 1074 | + " gsmSS=" + gsmSignalStrength + " ss=" + ss); |
| 1075 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1076 | r.callback.onSignalStrengthChanged(ss); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1077 | } catch (RemoteException ex) { |
| 1078 | mRemoveList.add(r.binder); |
| 1079 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1080 | } |
| 1081 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1082 | } else { |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1083 | log("notifySignalStrengthForPhoneId: invalid phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1084 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1085 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1086 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1087 | broadcastSignalStrengthChanged(signalStrength, phoneId, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1088 | } |
| 1089 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1090 | @Override |
| 1091 | public void notifyCarrierNetworkChange(boolean active) { |
Andrew Flynn | ceaed68 | 2015-06-09 12:36:58 +0000 | [diff] [blame] | 1092 | enforceNotifyPermissionOrCarrierPrivilege("notifyCarrierNetworkChange()"); |
| 1093 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1094 | if (VDBG) { |
| 1095 | log("notifyCarrierNetworkChange: active=" + active); |
| 1096 | } |
| 1097 | |
| 1098 | synchronized (mRecords) { |
| 1099 | mCarrierNetworkChangeState = active; |
| 1100 | for (Record r : mRecords) { |
| 1101 | if (r.matchPhoneStateListenerEvent( |
| 1102 | PhoneStateListener.LISTEN_CARRIER_NETWORK_CHANGE)) { |
| 1103 | try { |
| 1104 | r.callback.onCarrierNetworkChange(active); |
| 1105 | } catch (RemoteException ex) { |
| 1106 | mRemoveList.add(r.binder); |
| 1107 | } |
| 1108 | } |
| 1109 | } |
| 1110 | handleRemoveListLocked(); |
| 1111 | } |
| 1112 | } |
| 1113 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 1114 | public void notifyCellInfo(List<CellInfo> cellInfo) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1115 | notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellInfo); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1118 | public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1119 | if (!checkNotifyPermission("notifyCellInfo()")) { |
| 1120 | return; |
| 1121 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1122 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1123 | log("notifyCellInfoForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1124 | + " cellInfo=" + cellInfo); |
| 1125 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1126 | int phoneId = SubscriptionManager.getPhoneId(subId); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1127 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1128 | if (validatePhoneId(phoneId)) { |
| 1129 | mCellInfo.set(phoneId, cellInfo); |
| 1130 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1131 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) && |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 1132 | idMatch(r.subId, subId, phoneId) && |
| 1133 | checkLocationAccess(r)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1134 | try { |
| 1135 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1136 | log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1137 | } |
| 1138 | r.callback.onCellInfoChanged(cellInfo); |
| 1139 | } catch (RemoteException ex) { |
| 1140 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1141 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1142 | } |
| 1143 | } |
| 1144 | } |
| 1145 | handleRemoveListLocked(); |
| 1146 | } |
| 1147 | } |
| 1148 | |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 1149 | public void notifyPhysicalChannelConfiguration(List<PhysicalChannelConfig> configs) { |
| 1150 | notifyPhysicalChannelConfigurationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, |
| 1151 | configs); |
| 1152 | } |
| 1153 | |
| 1154 | public void notifyPhysicalChannelConfigurationForSubscriber(int subId, |
| 1155 | List<PhysicalChannelConfig> configs) { |
| 1156 | if (!checkNotifyPermission("notifyPhysicalChannelConfiguration()")) { |
| 1157 | return; |
| 1158 | } |
| 1159 | |
| 1160 | if (VDBG) { |
| 1161 | log("notifyPhysicalChannelConfiguration: subId=" + subId + " configs=" + configs); |
| 1162 | } |
| 1163 | |
| 1164 | synchronized (mRecords) { |
| 1165 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 1166 | if (validatePhoneId(phoneId)) { |
| 1167 | mPhysicalChannelConfigs.set(phoneId, configs); |
| 1168 | for (Record r : mRecords) { |
| 1169 | if (r.matchPhoneStateListenerEvent( |
| 1170 | PhoneStateListener.LISTEN_PHYSICAL_CHANNEL_CONFIGURATION) |
| 1171 | && idMatch(r.subId, subId, phoneId)) { |
| 1172 | try { |
| 1173 | if (DBG_LOC) { |
| 1174 | log("notifyPhysicalChannelConfiguration: mPhysicalChannelConfigs=" |
| 1175 | + configs + " r=" + r); |
| 1176 | } |
| 1177 | r.callback.onPhysicalChannelConfigurationChanged(configs); |
| 1178 | } catch (RemoteException ex) { |
| 1179 | mRemoveList.add(r.binder); |
| 1180 | } |
| 1181 | } |
| 1182 | } |
| 1183 | } |
| 1184 | handleRemoveListLocked(); |
| 1185 | } |
| 1186 | } |
| 1187 | |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1188 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1189 | public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1190 | if (!checkNotifyPermission("notifyMessageWaitingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1191 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1192 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1193 | if (VDBG) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1194 | log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1195 | + " mwi=" + mwi); |
| 1196 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1197 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1198 | if (validatePhoneId(phoneId)) { |
| 1199 | mMessageWaiting[phoneId] = mwi; |
| 1200 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1201 | if (r.matchPhoneStateListenerEvent( |
| 1202 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1203 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1204 | try { |
| 1205 | r.callback.onMessageWaitingIndicatorChanged(mwi); |
| 1206 | } catch (RemoteException ex) { |
| 1207 | mRemoveList.add(r.binder); |
| 1208 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1209 | } |
| 1210 | } |
| 1211 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1212 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1213 | } |
| 1214 | } |
| 1215 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1216 | public void notifyUserMobileDataStateChangedForPhoneId(int phoneId, int subId, boolean state) { |
| 1217 | if (!checkNotifyPermission("notifyUserMobileDataStateChanged()")) { |
| 1218 | return; |
| 1219 | } |
| 1220 | if (VDBG) { |
| 1221 | log("notifyUserMobileDataStateChangedForSubscriberPhoneID: subId=" + phoneId |
| 1222 | + " state=" + state); |
| 1223 | } |
| 1224 | synchronized (mRecords) { |
| 1225 | if (validatePhoneId(phoneId)) { |
| 1226 | mMessageWaiting[phoneId] = state; |
| 1227 | for (Record r : mRecords) { |
| 1228 | if (r.matchPhoneStateListenerEvent( |
| 1229 | PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) && |
| 1230 | idMatch(r.subId, subId, phoneId)) { |
| 1231 | try { |
| 1232 | r.callback.onUserMobileDataStateChanged(state); |
| 1233 | } catch (RemoteException ex) { |
| 1234 | mRemoveList.add(r.binder); |
| 1235 | } |
| 1236 | } |
| 1237 | } |
| 1238 | } |
| 1239 | handleRemoveListLocked(); |
| 1240 | } |
| 1241 | } |
| 1242 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1243 | public void notifyCallForwardingChanged(boolean cfi) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1244 | notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cfi); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1245 | } |
| 1246 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1247 | public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1248 | if (!checkNotifyPermission("notifyCallForwardingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1249 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1250 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1251 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1252 | log("notifyCallForwardingChangedForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1253 | + " cfi=" + cfi); |
| 1254 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1255 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1256 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1257 | if (validatePhoneId(phoneId)) { |
| 1258 | mCallForwarding[phoneId] = cfi; |
| 1259 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1260 | if (r.matchPhoneStateListenerEvent( |
| 1261 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) && |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 1262 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1263 | try { |
| 1264 | r.callback.onCallForwardingIndicatorChanged(cfi); |
| 1265 | } catch (RemoteException ex) { |
| 1266 | mRemoveList.add(r.binder); |
| 1267 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1268 | } |
| 1269 | } |
| 1270 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1271 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1272 | } |
| 1273 | } |
| 1274 | |
| 1275 | public void notifyDataActivity(int state) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1276 | notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1277 | } |
| 1278 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1279 | public void notifyDataActivityForSubscriber(int subId, int state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1280 | if (!checkNotifyPermission("notifyDataActivity()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1281 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1282 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1283 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1284 | synchronized (mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1285 | if (validatePhoneId(phoneId)) { |
| 1286 | mDataActivity[phoneId] = state; |
| 1287 | for (Record r : mRecords) { |
xu.peng | 9071ced | 2016-03-22 18:21:28 +0800 | [diff] [blame] | 1288 | // Notify by correct subId. |
| 1289 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_DATA_ACTIVITY) && |
| 1290 | idMatch(r.subId, subId, phoneId)) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1291 | try { |
| 1292 | r.callback.onDataActivity(state); |
| 1293 | } catch (RemoteException ex) { |
| 1294 | mRemoveList.add(r.binder); |
| 1295 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1296 | } |
| 1297 | } |
| 1298 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1299 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1300 | } |
| 1301 | } |
| 1302 | |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1303 | public void notifyDataConnection(int state, boolean isDataAllowed, |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 1304 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 1305 | NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1306 | notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, state, |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1307 | isDataAllowed,reason, apn, apnType, linkProperties, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1308 | networkCapabilities, networkType, roaming); |
| 1309 | } |
| 1310 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1311 | public void notifyDataConnectionForSubscriber(int subId, int state, |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1312 | boolean isDataAllowed, String reason, String apn, String apnType, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1313 | LinkProperties linkProperties, NetworkCapabilities networkCapabilities, |
| 1314 | int networkType, boolean roaming) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1315 | if (!checkNotifyPermission("notifyDataConnection()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1316 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1317 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1318 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1319 | log("notifyDataConnectionForSubscriber: subId=" + subId |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1320 | + " state=" + state + " isDataAllowed=" + isDataAllowed |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1321 | + " reason='" + reason |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1322 | + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 1323 | + " mRecords.size()=" + mRecords.size()); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 1324 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1325 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1326 | synchronized (mRecords) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1327 | if (validatePhoneId(phoneId)) { |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1328 | // We only call the callback when the change is for default APN type. |
| 1329 | if (PhoneConstants.APN_TYPE_DEFAULT.equals(apnType) |
| 1330 | && (mDataConnectionState[phoneId] != state |
| 1331 | || mDataConnectionNetworkType[phoneId] != networkType)) { |
| 1332 | String str = "onDataConnectionStateChanged(" + state |
| 1333 | + ", " + networkType + ")"; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1334 | log(str); |
| 1335 | mLocalLog.log(str); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1336 | for (Record r : mRecords) { |
| 1337 | if (r.matchPhoneStateListenerEvent( |
| 1338 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) && |
| 1339 | idMatch(r.subId, subId, phoneId)) { |
| 1340 | try { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1341 | if (DBG) { |
| 1342 | log("Notify data connection state changed on sub: " + subId); |
| 1343 | } |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1344 | r.callback.onDataConnectionStateChanged(state, networkType); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1345 | } catch (RemoteException ex) { |
| 1346 | mRemoveList.add(r.binder); |
| 1347 | } |
| 1348 | } |
| 1349 | } |
| 1350 | handleRemoveListLocked(); |
Jack Yu | b1bac54 | 2018-03-14 16:23:38 -0700 | [diff] [blame] | 1351 | |
| 1352 | mDataConnectionState[phoneId] = state; |
| 1353 | mDataConnectionNetworkType[phoneId] = networkType; |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1354 | } |
| 1355 | mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, |
| 1356 | apnType, apn, reason, linkProperties, ""); |
| 1357 | for (Record r : mRecords) { |
| 1358 | if (r.matchPhoneStateListenerEvent( |
| 1359 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { |
| 1360 | try { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1361 | r.callback.onPreciseDataConnectionStateChanged( |
| 1362 | mPreciseDataConnectionState); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1363 | } catch (RemoteException ex) { |
| 1364 | mRemoveList.add(r.binder); |
| 1365 | } |
Wink Saville | 2d1ee98 | 2014-11-20 20:29:51 +0000 | [diff] [blame] | 1366 | } |
| 1367 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1368 | } |
| 1369 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1370 | } |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1371 | broadcastDataConnectionStateChanged(state, isDataAllowed, reason, apn, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1372 | apnType, linkProperties, networkCapabilities, roaming, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1373 | broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, |
| 1374 | linkProperties, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1375 | } |
| 1376 | |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 1377 | public void notifyDataConnectionFailed(String reason, String apnType) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1378 | notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1379 | reason, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1380 | } |
| 1381 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1382 | public void notifyDataConnectionFailedForSubscriber(int subId, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1383 | String reason, String apnType) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1384 | if (!checkNotifyPermission("notifyDataConnectionFailed()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1385 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1386 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1387 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1388 | log("notifyDataConnectionFailedForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1389 | + " reason=" + reason + " apnType=" + apnType); |
| 1390 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1391 | synchronized (mRecords) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1392 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 1393 | TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1394 | apnType, "", reason, null, ""); |
| 1395 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1396 | if (r.matchPhoneStateListenerEvent( |
| 1397 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1398 | try { |
| 1399 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 1400 | } catch (RemoteException ex) { |
| 1401 | mRemoveList.add(r.binder); |
| 1402 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1403 | } |
| 1404 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1405 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1406 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1407 | broadcastDataConnectionFailed(reason, apnType, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1408 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 1409 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1410 | } |
| 1411 | |
| 1412 | public void notifyCellLocation(Bundle cellLocation) { |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1413 | notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUBSCRIPTION_ID, cellLocation); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1414 | } |
| 1415 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1416 | public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1417 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1418 | + " cellLocation=" + cellLocation); |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1419 | if (!checkNotifyPermission("notifyCellLocation()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1420 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1421 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1422 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 1423 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1424 | + " cellLocation=" + cellLocation); |
| 1425 | } |
yifan.bai | e620ce7 | 2017-12-22 14:59:57 +0800 | [diff] [blame] | 1426 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1427 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1428 | if (validatePhoneId(phoneId)) { |
| 1429 | mCellLocation[phoneId] = cellLocation; |
| 1430 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 1431 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) && |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 1432 | idMatch(r.subId, subId, phoneId) && |
| 1433 | checkLocationAccess(r)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1434 | try { |
| 1435 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1436 | log("notifyCellLocation: cellLocation=" + cellLocation |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1437 | + " r=" + r); |
| 1438 | } |
| 1439 | r.callback.onCellLocationChanged(new Bundle(cellLocation)); |
| 1440 | } catch (RemoteException ex) { |
| 1441 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1442 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1443 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1444 | } |
| 1445 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1446 | handleRemoveListLocked(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1447 | } |
| 1448 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1449 | |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1450 | public void notifyOtaspChanged(int otaspMode) { |
| 1451 | if (!checkNotifyPermission("notifyOtaspChanged()" )) { |
| 1452 | return; |
| 1453 | } |
| 1454 | synchronized (mRecords) { |
| 1455 | mOtaspMode = otaspMode; |
| 1456 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1457 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_OTASP_CHANGED)) { |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1458 | try { |
| 1459 | r.callback.onOtaspChanged(otaspMode); |
| 1460 | } catch (RemoteException ex) { |
| 1461 | mRemoveList.add(r.binder); |
| 1462 | } |
| 1463 | } |
| 1464 | } |
| 1465 | handleRemoveListLocked(); |
| 1466 | } |
| 1467 | } |
| 1468 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1469 | public void notifyPreciseCallState(int ringingCallState, int foregroundCallState, |
| 1470 | int backgroundCallState) { |
| 1471 | if (!checkNotifyPermission("notifyPreciseCallState()")) { |
| 1472 | return; |
| 1473 | } |
| 1474 | synchronized (mRecords) { |
| 1475 | mRingingCallState = ringingCallState; |
| 1476 | mForegroundCallState = foregroundCallState; |
| 1477 | mBackgroundCallState = backgroundCallState; |
| 1478 | mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState, |
| 1479 | backgroundCallState, |
| 1480 | DisconnectCause.NOT_VALID, |
| 1481 | PreciseDisconnectCause.NOT_VALID); |
| 1482 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1483 | if (r.matchPhoneStateListenerEvent(PhoneStateListener.LISTEN_PRECISE_CALL_STATE)) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1484 | try { |
| 1485 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 1486 | } catch (RemoteException ex) { |
| 1487 | mRemoveList.add(r.binder); |
| 1488 | } |
| 1489 | } |
| 1490 | } |
| 1491 | handleRemoveListLocked(); |
| 1492 | } |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1493 | broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, |
| 1494 | backgroundCallState); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1495 | } |
| 1496 | |
| 1497 | public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) { |
| 1498 | if (!checkNotifyPermission("notifyDisconnectCause()")) { |
| 1499 | return; |
| 1500 | } |
| 1501 | synchronized (mRecords) { |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1502 | mCallDisconnectCause = disconnectCause; |
| 1503 | mCallPreciseDisconnectCause = preciseDisconnectCause; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1504 | for (Record r : mRecords) { |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1505 | if (r.matchPhoneStateListenerEvent(PhoneStateListener |
| 1506 | .LISTEN_CALL_DISCONNECT_CAUSES)) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1507 | try { |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1508 | r.callback.onCallDisconnectCauseChanged(mCallDisconnectCause, |
| 1509 | mCallPreciseDisconnectCause); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1510 | } catch (RemoteException ex) { |
| 1511 | mRemoveList.add(r.binder); |
| 1512 | } |
| 1513 | } |
| 1514 | } |
| 1515 | handleRemoveListLocked(); |
| 1516 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1517 | } |
| 1518 | |
| 1519 | public void notifyPreciseDataConnectionFailed(String reason, String apnType, |
| 1520 | String apn, String failCause) { |
| 1521 | if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) { |
| 1522 | return; |
| 1523 | } |
| 1524 | synchronized (mRecords) { |
| 1525 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 1526 | TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1527 | apnType, apn, reason, null, failCause); |
| 1528 | for (Record r : mRecords) { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1529 | if (r.matchPhoneStateListenerEvent( |
| 1530 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE)) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1531 | try { |
| 1532 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 1533 | } catch (RemoteException ex) { |
| 1534 | mRemoveList.add(r.binder); |
| 1535 | } |
| 1536 | } |
| 1537 | } |
| 1538 | handleRemoveListLocked(); |
| 1539 | } |
| 1540 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 1541 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); |
| 1542 | } |
| 1543 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1544 | @Override |
| 1545 | public void notifySrvccStateChanged(int subId, @TelephonyManager.SrvccState int state) { |
| 1546 | if (!checkNotifyPermission("notifySrvccStateChanged()")) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1547 | return; |
| 1548 | } |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1549 | if (VDBG) { |
| 1550 | log("notifySrvccStateChanged: subId=" + subId + " srvccState=" + state); |
| 1551 | } |
| 1552 | int phoneId = SubscriptionManager.getPhoneId(subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1553 | synchronized (mRecords) { |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1554 | if (validatePhoneId(phoneId)) { |
| 1555 | mSrvccState[phoneId] = state; |
| 1556 | for (Record r : mRecords) { |
| 1557 | if (r.matchPhoneStateListenerEvent( |
| 1558 | PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) && |
| 1559 | idMatch(r.subId, subId, phoneId)) { |
| 1560 | try { |
| 1561 | if (DBG_LOC) { |
| 1562 | log("notifySrvccStateChanged: mSrvccState=" + state + " r=" + r); |
| 1563 | } |
| 1564 | r.callback.onSrvccStateChanged(state); |
| 1565 | } catch (RemoteException ex) { |
| 1566 | mRemoveList.add(r.binder); |
| 1567 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1568 | } |
| 1569 | } |
| 1570 | } |
| 1571 | handleRemoveListLocked(); |
| 1572 | } |
| 1573 | } |
| 1574 | |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1575 | public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) { |
| 1576 | if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) { |
| 1577 | return; |
| 1578 | } |
| 1579 | |
| 1580 | synchronized (mRecords) { |
| 1581 | for (Record r : mRecords) { |
| 1582 | if (VDBG) { |
| 1583 | log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); |
| 1584 | } |
| 1585 | if ((r.matchPhoneStateListenerEvent( |
| 1586 | PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT)) && |
| 1587 | ((r.subId == subId) || |
| 1588 | (r.subId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID))) { |
| 1589 | try { |
| 1590 | r.callback.onOemHookRawEvent(rawData); |
| 1591 | } catch (RemoteException ex) { |
| 1592 | mRemoveList.add(r.binder); |
| 1593 | } |
| 1594 | } |
| 1595 | } |
| 1596 | handleRemoveListLocked(); |
| 1597 | } |
| 1598 | } |
| 1599 | |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1600 | public void notifyPhoneCapabilityChanged(PhoneCapability capability) { |
| 1601 | if (!checkNotifyPermission("notifyPhoneCapabilityChanged()")) { |
| 1602 | return; |
| 1603 | } |
| 1604 | |
| 1605 | if (VDBG) { |
| 1606 | log("notifyPhoneCapabilityChanged: capability=" + capability); |
| 1607 | } |
| 1608 | |
| 1609 | synchronized (mRecords) { |
| 1610 | mPhoneCapability = capability; |
| 1611 | |
| 1612 | for (Record r : mRecords) { |
| 1613 | if (r.matchPhoneStateListenerEvent( |
| 1614 | PhoneStateListener.LISTEN_PHONE_CAPABILITY_CHANGE)) { |
| 1615 | try { |
| 1616 | r.callback.onPhoneCapabilityChanged(capability); |
| 1617 | } catch (RemoteException ex) { |
| 1618 | mRemoveList.add(r.binder); |
| 1619 | } |
| 1620 | } |
| 1621 | } |
| 1622 | handleRemoveListLocked(); |
| 1623 | } |
| 1624 | } |
| 1625 | |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1626 | public void notifyPreferredDataSubIdChanged(int preferredSubId) { |
| 1627 | if (!checkNotifyPermission("notifyPreferredDataSubIdChanged()")) { |
| 1628 | return; |
| 1629 | } |
| 1630 | |
| 1631 | if (VDBG) { |
| 1632 | log("notifyPreferredDataSubIdChanged: preferredSubId=" + preferredSubId); |
| 1633 | } |
| 1634 | |
| 1635 | synchronized (mRecords) { |
| 1636 | mPreferredDataSubId = preferredSubId; |
| 1637 | |
| 1638 | for (Record r : mRecords) { |
| 1639 | if (r.matchPhoneStateListenerEvent( |
| 1640 | PhoneStateListener.LISTEN_PREFERRED_DATA_SUBID_CHANGE)) { |
| 1641 | try { |
| 1642 | r.callback.onPreferredDataSubIdChanged(preferredSubId); |
| 1643 | } catch (RemoteException ex) { |
| 1644 | mRemoveList.add(r.binder); |
| 1645 | } |
| 1646 | } |
| 1647 | } |
| 1648 | handleRemoveListLocked(); |
| 1649 | } |
| 1650 | } |
| 1651 | |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 1652 | public void notifyRadioPowerStateChanged(@TelephonyManager.RadioPowerState int state) { |
| 1653 | if (!checkNotifyPermission("notifyRadioPowerStateChanged()")) { |
| 1654 | return; |
| 1655 | } |
| 1656 | |
| 1657 | if (VDBG) { |
| 1658 | log("notifyRadioPowerStateChanged: state= " + state); |
| 1659 | } |
| 1660 | |
| 1661 | synchronized (mRecords) { |
| 1662 | mRadioPowerState = state; |
| 1663 | |
| 1664 | for (Record r : mRecords) { |
| 1665 | if (r.matchPhoneStateListenerEvent( |
| 1666 | PhoneStateListener.LISTEN_RADIO_POWER_STATE_CHANGED)) { |
| 1667 | try { |
| 1668 | r.callback.onRadioPowerStateChanged(state); |
| 1669 | } catch (RemoteException ex) { |
| 1670 | mRemoveList.add(r.binder); |
| 1671 | } |
| 1672 | } |
| 1673 | } |
| 1674 | handleRemoveListLocked(); |
| 1675 | } |
| 1676 | } |
| 1677 | |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1678 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1679 | @Override |
sqian | bf165bc | 2018-12-07 17:09:39 -0800 | [diff] [blame] | 1680 | public void notifyEmergencyNumberList(List<EmergencyNumber> emergencyNumberList) { |
| 1681 | // TODO checkPermission, modify Listener constent documentation |
| 1682 | // TODO implement multisim emergency number list update in listener |
| 1683 | // TODO implement PhoneStateListenerTest |
| 1684 | } |
| 1685 | |
| 1686 | |
| 1687 | @Override |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1688 | public void dump(FileDescriptor fd, PrintWriter writer, String[] args) { |
| 1689 | final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); |
| 1690 | |
Jeff Sharkey | fe9a53b | 2017-03-31 14:08:23 -0600 | [diff] [blame] | 1691 | if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return; |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1692 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1693 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1694 | final int recordCount = mRecords.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1695 | pw.println("last known state:"); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1696 | pw.increaseIndent(); |
Sandeep Gutta | 2f32ac2 | 2014-07-16 03:14:03 +0530 | [diff] [blame] | 1697 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1698 | pw.println("Phone Id=" + i); |
| 1699 | pw.increaseIndent(); |
| 1700 | pw.println("mCallState=" + mCallState[i]); |
| 1701 | pw.println("mCallIncomingNumber=" + mCallIncomingNumber[i]); |
| 1702 | pw.println("mServiceState=" + mServiceState[i]); |
| 1703 | pw.println("mVoiceActivationState= " + mVoiceActivationState[i]); |
| 1704 | pw.println("mDataActivationState= " + mDataActivationState[i]); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1705 | pw.println("mUserMobileDataState= " + mUserMobileDataState[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1706 | pw.println("mSignalStrength=" + mSignalStrength[i]); |
| 1707 | pw.println("mMessageWaiting=" + mMessageWaiting[i]); |
| 1708 | pw.println("mCallForwarding=" + mCallForwarding[i]); |
| 1709 | pw.println("mDataActivity=" + mDataActivity[i]); |
| 1710 | pw.println("mDataConnectionState=" + mDataConnectionState[i]); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1711 | pw.println("mCellLocation=" + mCellLocation[i]); |
| 1712 | pw.println("mCellInfo=" + mCellInfo.get(i)); |
| 1713 | pw.decreaseIndent(); |
Sandeep Gutta | 2f32ac2 | 2014-07-16 03:14:03 +0530 | [diff] [blame] | 1714 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1715 | pw.println("mPreciseDataConnectionState=" + mPreciseDataConnectionState); |
| 1716 | pw.println("mPreciseCallState=" + mPreciseCallState); |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1717 | pw.println("mCallDisconnectCause=" + mCallDisconnectCause); |
| 1718 | pw.println("mCallPreciseDisconnectCause=" + mCallPreciseDisconnectCause); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1719 | pw.println("mCarrierNetworkChangeState=" + mCarrierNetworkChangeState); |
| 1720 | pw.println("mRingingCallState=" + mRingingCallState); |
| 1721 | pw.println("mForegroundCallState=" + mForegroundCallState); |
| 1722 | pw.println("mBackgroundCallState=" + mBackgroundCallState); |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1723 | pw.println("mSrvccState=" + mSrvccState); |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1724 | pw.println("mPhoneCapability=" + mPhoneCapability); |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1725 | pw.println("mPreferredDataSubId=" + mPreferredDataSubId); |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 1726 | pw.println("mRadioPowerState=" + mRadioPowerState); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1727 | |
| 1728 | pw.decreaseIndent(); |
| 1729 | |
| 1730 | pw.println("local logs:"); |
| 1731 | pw.increaseIndent(); |
| 1732 | mLocalLog.dump(fd, pw, args); |
| 1733 | pw.decreaseIndent(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1734 | pw.println("registrations: count=" + recordCount); |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1735 | pw.increaseIndent(); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 1736 | for (Record r : mRecords) { |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1737 | pw.println(r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1738 | } |
Jack Yu | d19b6ae | 2017-04-05 14:12:09 -0700 | [diff] [blame] | 1739 | pw.decreaseIndent(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1740 | } |
| 1741 | } |
| 1742 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1743 | // |
| 1744 | // the legacy intent broadcasting |
| 1745 | // |
| 1746 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1747 | private void broadcastServiceStateChanged(ServiceState state, int phoneId, int subId) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1748 | long ident = Binder.clearCallingIdentity(); |
| 1749 | try { |
| 1750 | mBatteryStats.notePhoneState(state.getState()); |
| 1751 | } catch (RemoteException re) { |
| 1752 | // Can't do much |
| 1753 | } finally { |
| 1754 | Binder.restoreCallingIdentity(ident); |
| 1755 | } |
| 1756 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1757 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
Christopher Tate | 42a386b | 2016-11-07 12:21:21 -0800 | [diff] [blame] | 1758 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1759 | Bundle data = new Bundle(); |
| 1760 | state.fillInNotifierBundle(data); |
| 1761 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1762 | // Pass the subscription along with the intent. |
| 1763 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
chen xu | 379e531 | 2018-09-28 15:53:43 -0700 | [diff] [blame] | 1764 | intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1765 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1766 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1767 | } |
| 1768 | |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1769 | private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int phoneId, |
| 1770 | int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1771 | long ident = Binder.clearCallingIdentity(); |
| 1772 | try { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1773 | mBatteryStats.notePhoneSignalStrength(signalStrength); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1774 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1775 | /* The remote entity disappeared, we can safely ignore the exception. */ |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1776 | } finally { |
| 1777 | Binder.restoreCallingIdentity(ident); |
| 1778 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1779 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1780 | Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1781 | Bundle data = new Bundle(); |
| 1782 | signalStrength.fillInNotifierBundle(data); |
| 1783 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1784 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1785 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1786 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1787 | } |
| 1788 | |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 1789 | /** |
| 1790 | * Broadcasts an intent notifying apps of a phone state change. {@code subId} can be |
| 1791 | * a valid subId, in which case this function fires a subId-specific intent, or it |
| 1792 | * can be {@code SubscriptionManager.INVALID_SUBSCRIPTION_ID}, in which case we send |
| 1793 | * a global state change broadcast ({@code TelephonyManager.ACTION_PHONE_STATE_CHANGED}). |
| 1794 | */ |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1795 | private void broadcastCallStateChanged(int state, String incomingNumber, int phoneId, |
| 1796 | int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1797 | long ident = Binder.clearCallingIdentity(); |
| 1798 | try { |
| 1799 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
| 1800 | mBatteryStats.notePhoneOff(); |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 1801 | StatsLog.write(StatsLog.PHONE_STATE_CHANGED, |
| 1802 | StatsLog.PHONE_STATE_CHANGED__STATE__OFF); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1803 | } else { |
| 1804 | mBatteryStats.notePhoneOn(); |
Yangster | 4ccebea | 2018-10-09 17:09:02 -0700 | [diff] [blame] | 1805 | StatsLog.write(StatsLog.PHONE_STATE_CHANGED, |
| 1806 | StatsLog.PHONE_STATE_CHANGED__STATE__ON); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1807 | } |
| 1808 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1809 | /* 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] | 1810 | } finally { |
| 1811 | Binder.restoreCallingIdentity(ident); |
| 1812 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1813 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1814 | Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1815 | intent.putExtra(PhoneConstants.STATE_KEY, |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 1816 | PhoneConstantConversions.convertCallState(state).toString()); |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 1817 | |
| 1818 | // If a valid subId was specified, we should fire off a subId-specific state |
| 1819 | // change intent and include the subId. |
| 1820 | if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { |
| 1821 | intent.setAction(PhoneConstants.ACTION_SUBSCRIPTION_PHONE_STATE_CHANGED); |
| 1822 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
chen xu | 379e531 | 2018-09-28 15:53:43 -0700 | [diff] [blame] | 1823 | intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId); |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 1824 | } |
Shishir Agrawal | f7e59c1 | 2016-04-13 09:55:55 -0700 | [diff] [blame] | 1825 | // If the phoneId is invalid, the broadcast is for overall call state. |
| 1826 | if (phoneId != SubscriptionManager.INVALID_PHONE_INDEX) { |
| 1827 | intent.putExtra(PhoneConstants.SLOT_KEY, phoneId); |
| 1828 | } |
Sharvil Nanavati | 61a3ab0 | 2015-04-23 13:57:24 -0700 | [diff] [blame] | 1829 | |
Brad Ebinger | 51de96a | 2017-04-21 17:05:18 -0700 | [diff] [blame] | 1830 | // Wakeup apps for the (SUBSCRIPTION_)PHONE_STATE broadcast. |
| 1831 | intent.addFlags(Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND); |
| 1832 | |
Tyler Gunn | b8bd19e | 2018-06-19 09:55:43 -0700 | [diff] [blame] | 1833 | // Create a version of the intent with the number always populated. |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1834 | Intent intentWithPhoneNumber = new Intent(intent); |
Tyler Gunn | b8bd19e | 2018-06-19 09:55:43 -0700 | [diff] [blame] | 1835 | intentWithPhoneNumber.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); |
| 1836 | |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 1837 | // Send broadcast twice, once for apps that have PRIVILEGED permission and once for those |
| 1838 | // that have the runtime one |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1839 | mContext.sendBroadcastAsUser(intentWithPhoneNumber, UserHandle.ALL, |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 1840 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1841 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
Svet Ganov | 16a1689 | 2015-04-16 10:32:04 -0700 | [diff] [blame] | 1842 | android.Manifest.permission.READ_PHONE_STATE, |
| 1843 | AppOpsManager.OP_READ_PHONE_STATE); |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 1844 | mContext.sendBroadcastAsUserMultiplePermissions(intentWithPhoneNumber, UserHandle.ALL, |
| 1845 | new String[] { android.Manifest.permission.READ_PHONE_STATE, |
| 1846 | android.Manifest.permission.READ_CALL_LOG}); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1847 | } |
| 1848 | |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 1849 | private void broadcastDataConnectionStateChanged(int state, |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1850 | boolean isDataAllowed, |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1851 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1852 | NetworkCapabilities networkCapabilities, boolean roaming, int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1853 | // Note: not reporting to the battery stats service here, because the |
| 1854 | // status bar takes care of that after taking into account all of the |
| 1855 | // required info. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1856 | Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1857 | intent.putExtra(PhoneConstants.STATE_KEY, |
Nathan Harold | 5a0618e | 2016-12-14 10:48:00 -0800 | [diff] [blame] | 1858 | PhoneConstantConversions.convertDataState(state).toString()); |
Jack Yu | baeec62 | 2017-05-01 17:01:11 -0700 | [diff] [blame] | 1859 | if (!isDataAllowed) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1860 | intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1861 | } |
| 1862 | if (reason != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1863 | intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1864 | } |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 1865 | if (linkProperties != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1866 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
Irfan Sheriff | ed5d7d1 | 2010-10-01 16:08:28 -0700 | [diff] [blame] | 1867 | String iface = linkProperties.getInterfaceName(); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1868 | if (iface != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1869 | intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1870 | } |
| 1871 | } |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 1872 | if (networkCapabilities != null) { |
| 1873 | intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities); |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1874 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1875 | if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true); |
Robert Greenwalt | a6d4248 | 2011-09-02 15:19:31 -0700 | [diff] [blame] | 1876 | |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1877 | intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 1878 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1879 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1880 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1881 | } |
| 1882 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1883 | private void broadcastDataConnectionFailed(String reason, String apnType, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 1884 | int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1885 | Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1886 | intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason); |
| 1887 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1888 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1889 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1890 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1891 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1892 | private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState, |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1893 | int backgroundCallState) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1894 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED); |
| 1895 | intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState); |
| 1896 | intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState); |
| 1897 | intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1898 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1899 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1900 | } |
| 1901 | |
| 1902 | private void broadcastPreciseDataConnectionStateChanged(int state, int networkType, |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1903 | String apnType, String apn, String reason, LinkProperties linkProperties, |
| 1904 | String failCause) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1905 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 1906 | intent.putExtra(PhoneConstants.STATE_KEY, state); |
| 1907 | intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType); |
| 1908 | if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
| 1909 | if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
| 1910 | if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 1911 | if (linkProperties != null) { |
| 1912 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY,linkProperties); |
| 1913 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1914 | if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause); |
| 1915 | |
| 1916 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1917 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1918 | } |
| 1919 | |
Andrew Flynn | ceaed68 | 2015-06-09 12:36:58 +0000 | [diff] [blame] | 1920 | private void enforceNotifyPermissionOrCarrierPrivilege(String method) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 1921 | if (checkNotifyPermission()) { |
Andrew Flynn | ceaed68 | 2015-06-09 12:36:58 +0000 | [diff] [blame] | 1922 | return; |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1923 | } |
| 1924 | |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 1925 | TelephonyPermissions.enforceCallingOrSelfCarrierPrivilege( |
| 1926 | SubscriptionManager.getDefaultSubscriptionId(), method); |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1927 | } |
| 1928 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1929 | private boolean checkNotifyPermission(String method) { |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1930 | if (checkNotifyPermission()) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1931 | return true; |
| 1932 | } |
| 1933 | String msg = "Modify Phone State Permission Denial: " + method + " from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1934 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1935 | if (DBG) log(msg); |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1936 | return false; |
| 1937 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1938 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1939 | private boolean checkNotifyPermission() { |
| 1940 | return mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 1941 | == PackageManager.PERMISSION_GRANTED; |
| 1942 | } |
| 1943 | |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 1944 | private boolean checkListenerPermission( |
| 1945 | int events, int subId, String callingPackage, String message) { |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 1946 | if ((events & ENFORCE_COARSE_LOCATION_PERMISSION_MASK) != 0) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1947 | mContext.enforceCallingOrSelfPermission( |
| 1948 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
Hall Liu | 70bbc16 | 2018-03-02 17:44:46 -0800 | [diff] [blame] | 1949 | if (mAppOps.noteOp(AppOpsManager.OP_COARSE_LOCATION, Binder.getCallingUid(), |
| 1950 | callingPackage) != AppOpsManager.MODE_ALLOWED) { |
| 1951 | return false; |
| 1952 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1953 | } |
| 1954 | |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 1955 | if ((events & ENFORCE_PHONE_STATE_PERMISSION_MASK) != 0) { |
Jeff Davidson | 29da89f | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 1956 | if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState( |
| 1957 | mContext, subId, callingPackage, message)) { |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 1958 | return false; |
Amit Mahajan | 1cfd457 | 2015-07-09 11:12:19 -0700 | [diff] [blame] | 1959 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1960 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1961 | |
| 1962 | if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) { |
| 1963 | mContext.enforceCallingOrSelfPermission( |
| 1964 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1965 | } |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 1966 | |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1967 | if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) { |
| 1968 | mContext.enforceCallingOrSelfPermission( |
| 1969 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 1970 | } |
| 1971 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1972 | if ((events & PhoneStateListener.LISTEN_SRVCC_STATE_CHANGED) != 0) { |
| 1973 | mContext.enforceCallingOrSelfPermission( |
| 1974 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 1975 | } |
| 1976 | |
| 1977 | |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame^] | 1978 | if ((events & PhoneStateListener.LISTEN_CALL_DISCONNECT_CAUSES) != 0) { |
| 1979 | mContext.enforceCallingOrSelfPermission( |
| 1980 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 1981 | } |
| 1982 | |
Jeff Davidson | d7bf38a | 2018-02-13 18:11:37 -0800 | [diff] [blame] | 1983 | return true; |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1984 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1985 | |
| 1986 | private void handleRemoveListLocked() { |
Wink Saville | a374c3d | 2014-11-11 11:48:04 -0800 | [diff] [blame] | 1987 | int size = mRemoveList.size(); |
| 1988 | if (VDBG) log("handleRemoveListLocked: mRemoveList.size()=" + size); |
| 1989 | if (size > 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1990 | for (IBinder b: mRemoveList) { |
| 1991 | remove(b); |
| 1992 | } |
| 1993 | mRemoveList.clear(); |
| 1994 | } |
| 1995 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1996 | |
| 1997 | private boolean validateEventsAndUserLocked(Record r, int events) { |
| 1998 | int foregroundUser; |
| 1999 | long callingIdentity = Binder.clearCallingIdentity(); |
| 2000 | boolean valid = false; |
| 2001 | try { |
| 2002 | foregroundUser = ActivityManager.getCurrentUser(); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2003 | valid = UserHandle.getUserId(r.callerUid) == foregroundUser |
| 2004 | && r.matchPhoneStateListenerEvent(events); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 2005 | if (DBG | DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2006 | log("validateEventsAndUserLocked: valid=" + valid |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2007 | + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 2008 | + " r.events=" + r.events + " events=" + events); |
| 2009 | } |
| 2010 | } finally { |
| 2011 | Binder.restoreCallingIdentity(callingIdentity); |
| 2012 | } |
| 2013 | return valid; |
| 2014 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2015 | |
| 2016 | private boolean validatePhoneId(int phoneId) { |
| 2017 | boolean valid = (phoneId >= 0) && (phoneId < mNumPhones); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2018 | if (VDBG) log("validatePhoneId: " + valid); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 2019 | return valid; |
| 2020 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 2021 | |
| 2022 | private static void log(String s) { |
| 2023 | Rlog.d(TAG, s); |
| 2024 | } |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 2025 | |
xinhe | 8b79fb6 | 2014-11-05 14:55:03 -0800 | [diff] [blame] | 2026 | boolean idMatch(int rSubId, int subId, int phoneId) { |
xinhe | ac11ae9 | 2014-12-18 10:02:14 -0800 | [diff] [blame] | 2027 | |
| 2028 | if(subId < 0) { |
| 2029 | // Invalid case, we need compare phoneId with default one. |
| 2030 | return (mDefaultPhoneId == phoneId); |
| 2031 | } |
Wink Saville | d09c4ca | 2014-11-22 10:08:16 -0800 | [diff] [blame] | 2032 | if(rSubId == SubscriptionManager.DEFAULT_SUBSCRIPTION_ID) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2033 | return (subId == mDefaultSubId); |
| 2034 | } else { |
| 2035 | return (rSubId == subId); |
| 2036 | } |
| 2037 | } |
| 2038 | |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2039 | private boolean checkLocationAccess(Record r) { |
| 2040 | long token = Binder.clearCallingIdentity(); |
| 2041 | try { |
| 2042 | return LocationAccessPolicy.canAccessCellLocation(mContext, |
Svet Ganov | 33b1509 | 2018-03-07 19:53:43 -0800 | [diff] [blame] | 2043 | r.callingPackage, r.callerUid, r.callerPid, |
| 2044 | /*throwOnDeniedPermission*/ false); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2045 | } finally { |
| 2046 | Binder.restoreCallingIdentity(token); |
| 2047 | } |
| 2048 | } |
| 2049 | |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2050 | private void checkPossibleMissNotify(Record r, int phoneId) { |
| 2051 | int events = r.events; |
| 2052 | |
| 2053 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 2054 | try { |
| 2055 | if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" + |
| 2056 | mServiceState[phoneId]); |
| 2057 | r.callback.onServiceStateChanged( |
| 2058 | new ServiceState(mServiceState[phoneId])); |
| 2059 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2060 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2061 | } |
| 2062 | } |
| 2063 | |
| 2064 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 2065 | try { |
| 2066 | SignalStrength signalStrength = mSignalStrength[phoneId]; |
| 2067 | if (DBG) { |
| 2068 | log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength); |
| 2069 | } |
| 2070 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 2071 | } catch (RemoteException ex) { |
| 2072 | mRemoveList.add(r.binder); |
| 2073 | } |
| 2074 | } |
| 2075 | |
| 2076 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 2077 | try { |
| 2078 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 2079 | .getGsmSignalStrength(); |
| 2080 | if (DBG) { |
| 2081 | log("checkPossibleMissNotify: onSignalStrengthChanged SS=" + |
| 2082 | gsmSignalStrength); |
| 2083 | } |
| 2084 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 2085 | : gsmSignalStrength)); |
| 2086 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2087 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2088 | } |
| 2089 | } |
| 2090 | |
| 2091 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
| 2092 | try { |
| 2093 | if (DBG_LOC) { |
| 2094 | log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = " |
| 2095 | + mCellInfo.get(phoneId)); |
| 2096 | } |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2097 | if (checkLocationAccess(r)) { |
| 2098 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
| 2099 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2100 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2101 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2102 | } |
| 2103 | } |
| 2104 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 2105 | if ((events & PhoneStateListener.LISTEN_USER_MOBILE_DATA_STATE) != 0) { |
| 2106 | try { |
| 2107 | if (VDBG) { |
| 2108 | log("checkPossibleMissNotify: onUserMobileDataStateChanged phoneId=" |
| 2109 | + phoneId + " umds=" + mUserMobileDataState[phoneId]); |
| 2110 | } |
| 2111 | r.callback.onUserMobileDataStateChanged(mUserMobileDataState[phoneId]); |
| 2112 | } catch (RemoteException ex) { |
| 2113 | mRemoveList.add(r.binder); |
| 2114 | } |
| 2115 | } |
| 2116 | |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2117 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 2118 | try { |
| 2119 | if (VDBG) { |
| 2120 | log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId=" |
| 2121 | + phoneId + " mwi=" + mMessageWaiting[phoneId]); |
| 2122 | } |
| 2123 | r.callback.onMessageWaitingIndicatorChanged( |
| 2124 | mMessageWaiting[phoneId]); |
| 2125 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2126 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2127 | } |
| 2128 | } |
| 2129 | |
| 2130 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 2131 | try { |
| 2132 | if (VDBG) { |
| 2133 | log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId=" |
| 2134 | + phoneId + " cfi=" + mCallForwarding[phoneId]); |
| 2135 | } |
| 2136 | r.callback.onCallForwardingIndicatorChanged( |
| 2137 | mCallForwarding[phoneId]); |
| 2138 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2139 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2140 | } |
| 2141 | } |
| 2142 | |
| 2143 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
| 2144 | try { |
| 2145 | if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = " |
| 2146 | + mCellLocation[phoneId]); |
Hall Liu | 5fb337f | 2017-11-22 17:38:15 -0800 | [diff] [blame] | 2147 | if (checkLocationAccess(r)) { |
| 2148 | r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId])); |
| 2149 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2150 | } catch (RemoteException ex) { |
| 2151 | mRemoveList.add(r.binder); |
| 2152 | } |
| 2153 | } |
| 2154 | |
| 2155 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 2156 | try { |
| 2157 | if (DBG) { |
| 2158 | log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState" |
| 2159 | + "=" + mDataConnectionState[phoneId] |
| 2160 | + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId] |
| 2161 | + ")"); |
| 2162 | } |
| 2163 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 2164 | mDataConnectionNetworkType[phoneId]); |
| 2165 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 2166 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 2167 | } |
| 2168 | } |
| 2169 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2170 | } |