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