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