Kenny Root | 15a4d2f | 2010-03-11 18:20:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 17 | package android.telephony; |
| 18 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 19 | import android.Manifest; |
Nathan Harold | c9bad6e | 2018-04-25 12:53:04 -0700 | [diff] [blame] | 20 | import android.annotation.NonNull; |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 21 | import android.annotation.RequiresPermission; |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 22 | import android.annotation.SystemApi; |
Shuo Qian | 134334b | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 23 | import android.annotation.TestApi; |
Hall Liu | ed6d6e6 | 2020-03-26 19:09:30 -0700 | [diff] [blame] | 24 | import android.compat.annotation.ChangeId; |
Artur Satayev | df43959 | 2019-12-10 17:47:53 +0000 | [diff] [blame] | 25 | import android.compat.annotation.UnsupportedAppUsage; |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 26 | import android.os.Binder; |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 27 | import android.os.Build; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.os.Handler; |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 29 | import android.os.HandlerExecutor; |
Dianne Hackborn | 2ffa11e | 2014-04-21 15:56:18 -0700 | [diff] [blame] | 30 | import android.os.Looper; |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 31 | import android.telephony.Annotation.CallState; |
| 32 | import android.telephony.Annotation.RadioPowerState; |
| 33 | import android.telephony.Annotation.SimActivationState; |
| 34 | import android.telephony.Annotation.SrvccState; |
sqian | 46c0c30 | 2018-12-27 14:12:11 -0800 | [diff] [blame] | 35 | import android.telephony.emergency.EmergencyNumber; |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 36 | import android.telephony.ims.ImsReasonInfo; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 37 | |
Chen Xu | 1f6cfa5 | 2019-10-13 17:30:32 -0700 | [diff] [blame] | 38 | import com.android.internal.annotations.VisibleForTesting; |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 39 | import com.android.internal.telephony.IPhoneStateListener; |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 40 | |
Malcolm Chen | f028c3b | 2019-09-04 16:10:34 -0700 | [diff] [blame] | 41 | import dalvik.system.VMRuntime; |
| 42 | |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 43 | import java.lang.ref.WeakReference; |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 44 | import java.util.List; |
sqian | 46c0c30 | 2018-12-27 14:12:11 -0800 | [diff] [blame] | 45 | import java.util.Map; |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 46 | import java.util.concurrent.Executor; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 47 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | /** |
| 49 | * A listener class for monitoring changes in specific telephony states |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 50 | * on the device, including service state, signal strength, message |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | * waiting indicator (voicemail), and others. |
| 52 | * <p> |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 53 | * Override the methods for the state that you wish to receive updates for, and |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | * pass your PhoneStateListener object, along with bitwise-or of the LISTEN_ |
Jordan Liu | 91b2555e | 2019-02-11 11:36:49 -0800 | [diff] [blame] | 55 | * flags to {@link TelephonyManager#listen TelephonyManager.listen()}. Methods are |
Jordan Liu | 45da505 | 2019-02-12 10:29:24 -0800 | [diff] [blame] | 56 | * called when the state changes, as well as once on initial registration. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | * <p> |
| 58 | * Note that access to some telephony information is |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 59 | * permission-protected. Your application won't receive updates for protected |
| 60 | * information unless it has the appropriate permissions declared in |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | * its manifest file. Where permissions apply, they are noted in the |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 62 | * appropriate LISTEN_ flags. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | */ |
| 64 | public class PhoneStateListener { |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 65 | private static final String LOG_TAG = "PhoneStateListener"; |
| 66 | private static final boolean DBG = false; // STOPSHIP if true |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
Hall Liu | ed6d6e6 | 2020-03-26 19:09:30 -0700 | [diff] [blame] | 69 | * Experiment flag to set the per-pid registration limit for PhoneStateListeners |
| 70 | * |
Hall Liu | 2da50cf | 2020-03-18 16:24:04 -0700 | [diff] [blame] | 71 | * Limit on registrations of {@link PhoneStateListener}s on a per-pid |
| 72 | * basis. When this limit is exceeded, any calls to {@link TelephonyManager#listen} will fail |
| 73 | * with an {@link IllegalStateException}. |
| 74 | * |
| 75 | * {@link android.os.Process#PHONE_UID}, {@link android.os.Process#SYSTEM_UID}, and the uid that |
| 76 | * TelephonyRegistry runs under are exempt from this limit. |
Hall Liu | ed6d6e6 | 2020-03-26 19:09:30 -0700 | [diff] [blame] | 77 | * |
| 78 | * If the value of the flag is less than 1, enforcement of the limit will be disabled. |
Hall Liu | 2da50cf | 2020-03-18 16:24:04 -0700 | [diff] [blame] | 79 | * @hide |
| 80 | */ |
Hall Liu | ed6d6e6 | 2020-03-26 19:09:30 -0700 | [diff] [blame] | 81 | public static final String FLAG_PER_PID_REGISTRATION_LIMIT = |
| 82 | "phone_state_listener_per_pid_registration_limit"; |
| 83 | |
| 84 | /** |
| 85 | * Default value for the per-pid registation limit. |
| 86 | * See {@link #FLAG_PER_PID_REGISTRATION_LIMIT}. |
| 87 | * @hide |
| 88 | */ |
| 89 | public static final int DEFAULT_PER_PID_REGISTRATION_LIMIT = 50; |
| 90 | |
| 91 | /** |
| 92 | * This change enables a limit on the number of {@link PhoneStateListener} objects any process |
| 93 | * may register via {@link TelephonyManager#listen}. The default limit is 50, which may change |
| 94 | * via remote device config updates. |
| 95 | * |
| 96 | * This limit is enforced via an {@link IllegalStateException} thrown from |
| 97 | * {@link TelephonyManager#listen} when the offending process attempts to register one too many |
| 98 | * listeners. |
| 99 | * |
| 100 | * @hide |
| 101 | */ |
| 102 | @ChangeId |
| 103 | public static final long PHONE_STATE_LISTENER_LIMIT_CHANGE_ID = 150880553L; |
Hall Liu | 2da50cf | 2020-03-18 16:24:04 -0700 | [diff] [blame] | 104 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | /** |
| 106 | * Stop listening for updates. |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 107 | * |
| 108 | * The PhoneStateListener is not tied to any subscription and unregistered for any update. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | */ |
| 110 | public static final int LISTEN_NONE = 0; |
| 111 | |
| 112 | /** |
| 113 | * Listen for changes to the network service state (cellular). |
| 114 | * |
| 115 | * @see #onServiceStateChanged |
| 116 | * @see ServiceState |
| 117 | */ |
| 118 | public static final int LISTEN_SERVICE_STATE = 0x00000001; |
| 119 | |
| 120 | /** |
| 121 | * Listen for changes to the network signal strength (cellular). |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 122 | * {@more} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 123 | * |
| 124 | * @see #onSignalStrengthChanged |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 125 | * |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 126 | * @deprecated by {@link #LISTEN_SIGNAL_STRENGTHS} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 127 | */ |
Wink Saville | cc6ff2b | 2009-12-02 09:46:38 -0800 | [diff] [blame] | 128 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | public static final int LISTEN_SIGNAL_STRENGTH = 0x00000002; |
| 130 | |
| 131 | /** |
| 132 | * Listen for changes to the message-waiting indicator. |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 133 | * {@more} |
| 134 | * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE |
Jeff Davidson | 01efe5e | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 135 | * READ_PHONE_STATE} or that the calling app has carrier privileges (see |
| 136 | * {@link TelephonyManager#hasCarrierPrivileges}). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | * <p> |
| 138 | * Example: The status bar uses this to determine when to display the |
| 139 | * voicemail icon. |
| 140 | * |
| 141 | * @see #onMessageWaitingIndicatorChanged |
| 142 | */ |
| 143 | public static final int LISTEN_MESSAGE_WAITING_INDICATOR = 0x00000004; |
| 144 | |
| 145 | /** |
| 146 | * Listen for changes to the call-forwarding indicator. |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 147 | * {@more} |
| 148 | * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE |
Jeff Davidson | 01efe5e | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 149 | * READ_PHONE_STATE} or that the calling app has carrier privileges (see |
| 150 | * {@link TelephonyManager#hasCarrierPrivileges}). |
| 151 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 152 | * @see #onCallForwardingIndicatorChanged |
| 153 | */ |
| 154 | public static final int LISTEN_CALL_FORWARDING_INDICATOR = 0x00000008; |
| 155 | |
| 156 | /** |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 157 | * Listen for changes to the device's cell location. Note that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 158 | * this will result in frequent callbacks to the listener. |
| 159 | * {@more} |
Hall Liu | ba2884a | 2020-06-08 17:40:12 -0700 | [diff] [blame^] | 160 | * Requires Permission: {@link android.Manifest.permission#ACCESS_FINE_LOCATION |
| 161 | * ACCESS_FINE_LOCATION} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | * <p> |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 163 | * If you need regular location updates but want more control over |
| 164 | * the update interval or location precision, you can set up a listener |
| 165 | * through the {@link android.location.LocationManager location manager} |
| 166 | * instead. |
| 167 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | * @see #onCellLocationChanged |
| 169 | */ |
| 170 | public static final int LISTEN_CELL_LOCATION = 0x00000010; |
| 171 | |
| 172 | /** |
| 173 | * Listen for changes to the device call state. |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 174 | * {@more} |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 175 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | * @see #onCallStateChanged |
| 177 | */ |
| 178 | public static final int LISTEN_CALL_STATE = 0x00000020; |
| 179 | |
| 180 | /** |
| 181 | * Listen for changes to the data connection state (cellular). |
| 182 | * |
| 183 | * @see #onDataConnectionStateChanged |
| 184 | */ |
| 185 | public static final int LISTEN_DATA_CONNECTION_STATE = 0x00000040; |
| 186 | |
| 187 | /** |
| 188 | * Listen for changes to the direction of data traffic on the data |
| 189 | * connection (cellular). |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 190 | * {@more} |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 191 | * Example: The status bar uses this to display the appropriate |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 192 | * data-traffic icon. |
| 193 | * |
| 194 | * @see #onDataActivity |
| 195 | */ |
| 196 | public static final int LISTEN_DATA_ACTIVITY = 0x00000080; |
| 197 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 198 | /** |
| 199 | * Listen for changes to the network signal strengths (cellular). |
| 200 | * <p> |
| 201 | * Example: The status bar uses this to control the signal-strength |
| 202 | * icon. |
| 203 | * |
| 204 | * @see #onSignalStrengthsChanged |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 205 | */ |
| 206 | public static final int LISTEN_SIGNAL_STRENGTHS = 0x00000100; |
| 207 | |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 208 | /** |
sqian | dfdee63 | 2020-01-30 14:14:43 -0800 | [diff] [blame] | 209 | * Listen for changes of the network signal strengths (cellular) always reported from modem, |
Shuo Qian | 93642d4 | 2020-01-16 20:57:02 -0800 | [diff] [blame] | 210 | * even in some situations such as the screen of the device is off. |
| 211 | * |
sqian | dfdee63 | 2020-01-30 14:14:43 -0800 | [diff] [blame] | 212 | * @see #onSignalStrengthsChanged |
| 213 | * |
Shuo Qian | 93642d4 | 2020-01-16 20:57:02 -0800 | [diff] [blame] | 214 | * @hide |
| 215 | */ |
| 216 | @RequiresPermission(android.Manifest.permission.LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH) |
Shuo Qian | 93642d4 | 2020-01-16 20:57:02 -0800 | [diff] [blame] | 217 | public static final int LISTEN_ALWAYS_REPORTED_SIGNAL_STRENGTH = 0x00000200; |
| 218 | |
| 219 | /** |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 220 | * Listen for changes to observed cell info. |
| 221 | * |
| 222 | * @see #onCellInfoChanged |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 223 | */ |
| 224 | public static final int LISTEN_CELL_INFO = 0x00000400; |
| 225 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 226 | /** |
Chen Xu | f85cf99 | 2019-10-02 00:20:43 -0700 | [diff] [blame] | 227 | * Listen for {@link android.telephony.Annotation.PreciseCallStates} of ringing, |
| 228 | * background and foreground calls. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 229 | * |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 230 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} |
| 231 | * or the calling app has carrier privileges |
| 232 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
| 233 | * |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 234 | * @hide |
| 235 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 236 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 237 | @SystemApi |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 238 | public static final int LISTEN_PRECISE_CALL_STATE = 0x00000800; |
| 239 | |
| 240 | /** |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 241 | * Listen for {@link PreciseDataConnectionState} on the data connection (cellular). |
| 242 | * |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 243 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 244 | * or the calling app has carrier privileges |
| 245 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
chen xu | 896e3d4 | 2018-12-11 18:09:41 -0800 | [diff] [blame] | 246 | * |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 247 | * @see #onPreciseDataConnectionStateChanged |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 248 | */ |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 249 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 250 | public static final int LISTEN_PRECISE_DATA_CONNECTION_STATE = 0x00001000; |
| 251 | |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 252 | /** |
| 253 | * Listen for real time info for all data connections (cellular)). |
| 254 | * {@more} |
| 255 | * Requires Permission: {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE |
| 256 | * READ_PRECISE_PHONE_STATE} |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 257 | * @see #onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo) |
Nathan Harold | 8216236 | 2016-01-21 12:20:26 -0800 | [diff] [blame] | 258 | * |
| 259 | * @deprecated Use {@link TelephonyManager#getModemActivityInfo()} |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 260 | * @hide |
| 261 | */ |
Nathan Harold | 8216236 | 2016-01-21 12:20:26 -0800 | [diff] [blame] | 262 | @Deprecated |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 263 | public static final int LISTEN_DATA_CONNECTION_REAL_TIME_INFO = 0x00002000; |
| 264 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 265 | /** |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 266 | * Listen for changes to the SRVCC state of the active call. |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 267 | * |
| 268 | * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} |
| 269 | * |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 270 | * @see #onServiceStateChanged(ServiceState) |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 271 | * @hide |
| 272 | */ |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 273 | @SystemApi |
| 274 | @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) |
| 275 | public static final int LISTEN_SRVCC_STATE_CHANGED = 0x00004000; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 276 | |
New Author Steven Liu | 485f209 | 2014-09-11 10:18:45 -0500 | [diff] [blame] | 277 | /** |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 278 | * Listen for OEM hook raw event |
| 279 | * |
| 280 | * @see #onOemHookRawEvent |
| 281 | * @hide |
| 282 | * @deprecated OEM needs a vendor-extension hal and their apps should use that instead |
| 283 | */ |
| 284 | @Deprecated |
| 285 | public static final int LISTEN_OEM_HOOK_RAW_EVENT = 0x00008000; |
| 286 | |
| 287 | /** |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 288 | * Listen for carrier network changes indicated by a carrier app. |
| 289 | * |
| 290 | * @see #onCarrierNetworkRequest |
| 291 | * @see TelephonyManager#notifyCarrierNetworkChange(boolean) |
| 292 | * @hide |
| 293 | */ |
| 294 | public static final int LISTEN_CARRIER_NETWORK_CHANGE = 0x00010000; |
| 295 | |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 296 | /** |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 297 | * Listen for changes to the sim voice activation state |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 298 | * |
| 299 | * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} |
| 300 | * |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 301 | * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATING |
| 302 | * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED |
| 303 | * @see TelephonyManager#SIM_ACTIVATION_STATE_DEACTIVATED |
| 304 | * @see TelephonyManager#SIM_ACTIVATION_STATE_RESTRICTED |
| 305 | * @see TelephonyManager#SIM_ACTIVATION_STATE_UNKNOWN |
| 306 | * {@more} |
| 307 | * Example: TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED indicates voice service has been |
| 308 | * fully activated |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 309 | * |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 310 | * @see #onVoiceActivationStateChanged |
| 311 | * @hide |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 312 | */ |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 313 | @SystemApi |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 314 | @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 315 | public static final int LISTEN_VOICE_ACTIVATION_STATE = 0x00020000; |
| 316 | |
| 317 | /** |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 318 | * Listen for changes to the sim data activation state |
| 319 | * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATING |
| 320 | * @see TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED |
| 321 | * @see TelephonyManager#SIM_ACTIVATION_STATE_DEACTIVATED |
| 322 | * @see TelephonyManager#SIM_ACTIVATION_STATE_RESTRICTED |
| 323 | * @see TelephonyManager#SIM_ACTIVATION_STATE_UNKNOWN |
| 324 | * {@more} |
| 325 | * Example: TelephonyManager#SIM_ACTIVATION_STATE_ACTIVATED indicates data service has been |
| 326 | * fully activated |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 327 | * |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 328 | * @see #onDataActivationStateChanged |
| 329 | * @hide |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 330 | */ |
| 331 | public static final int LISTEN_DATA_ACTIVATION_STATE = 0x00040000; |
| 332 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 333 | /** |
| 334 | * Listen for changes to the user mobile data state |
| 335 | * |
| 336 | * @see #onUserMobileDataStateChanged |
| 337 | */ |
| 338 | public static final int LISTEN_USER_MOBILE_DATA_STATE = 0x00080000; |
| 339 | |
Eric Schwarzenbach | 5c6b3a3 | 2018-01-18 17:15:51 -0800 | [diff] [blame] | 340 | /** |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 341 | * Listen for display info changed event. |
| 342 | * |
| 343 | * @see #onDisplayInfoChanged |
| 344 | */ |
| 345 | public static final int LISTEN_DISPLAY_INFO_CHANGED = 0x00100000; |
| 346 | |
| 347 | /** |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 348 | * Listen for changes to the phone capability. |
| 349 | * |
| 350 | * @see #onPhoneCapabilityChanged |
| 351 | * @hide |
| 352 | */ |
| 353 | public static final int LISTEN_PHONE_CAPABILITY_CHANGE = 0x00200000; |
| 354 | |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 355 | /** |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 356 | * Listen for changes to active data subId. Active data subscription is |
| 357 | * the current subscription used to setup Cellular Internet data. For example, |
| 358 | * it could be the current active opportunistic subscription in use, or the |
| 359 | * subscription user selected as default data subscription in DSDS mode. |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 360 | * |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 361 | * @see #onActiveDataSubscriptionIdChanged |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 362 | */ |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 363 | public static final int LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE = 0x00400000; |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 364 | |
| 365 | /** |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 366 | * Listen for changes to the radio power state. |
| 367 | * |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 368 | * <p>Requires permission {@link android.Manifest.permission#READ_PRIVILEGED_PHONE_STATE} |
| 369 | * |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 370 | * @see #onRadioPowerStateChanged |
| 371 | * @hide |
| 372 | */ |
| 373 | @SystemApi |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 374 | @RequiresPermission(Manifest.permission.READ_PRIVILEGED_PHONE_STATE) |
chen xu | b591f9d | 2018-10-18 14:24:58 -0700 | [diff] [blame] | 375 | public static final int LISTEN_RADIO_POWER_STATE_CHANGED = 0x00800000; |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 376 | |
sqian | 5ac293f0 | 2018-10-17 16:31:31 -0700 | [diff] [blame] | 377 | /** |
| 378 | * Listen for changes to emergency number list based on all active subscriptions. |
| 379 | * |
| 380 | * <p>Requires permission {@link android.Manifest.permission#READ_PHONE_STATE} or the calling |
| 381 | * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). |
| 382 | */ |
| 383 | public static final int LISTEN_EMERGENCY_NUMBER_LIST = 0x01000000; |
| 384 | |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 385 | /** |
| 386 | * Listen for call disconnect causes which contains {@link DisconnectCause} and |
| 387 | * {@link PreciseDisconnectCause}. |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 388 | * |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 389 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} |
| 390 | * or the calling app has carrier privileges |
| 391 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
| 392 | * |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 393 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 394 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 395 | public static final int LISTEN_CALL_DISCONNECT_CAUSES = 0x02000000; |
| 396 | |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 397 | /** |
| 398 | * Listen for changes to the call attributes of a currently active call. |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 399 | * |
| 400 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} |
| 401 | * or the calling app has carrier privileges |
| 402 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 403 | * |
| 404 | * @see #onCallAttributesChanged |
| 405 | * @hide |
| 406 | */ |
| 407 | @SystemApi |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 408 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 409 | public static final int LISTEN_CALL_ATTRIBUTES_CHANGED = 0x04000000; |
| 410 | |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 411 | /** |
| 412 | * Listen for IMS call disconnect causes which contains |
| 413 | * {@link android.telephony.ims.ImsReasonInfo} |
| 414 | * |
Rambo Wang | 82a46e2 | 2020-01-02 14:42:57 -0800 | [diff] [blame] | 415 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} |
| 416 | * or the calling app has carrier privileges |
| 417 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
| 418 | * |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 419 | * @see #onImsCallDisconnectCauseChanged(ImsReasonInfo) |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 420 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 421 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 422 | public static final int LISTEN_IMS_CALL_DISCONNECT_CAUSES = 0x08000000; |
| 423 | |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 424 | /** |
| 425 | * Listen for the emergency number placed from an outgoing call. |
| 426 | * |
| 427 | * <p>Requires permission {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} |
| 428 | * |
| 429 | * @see #onOutgoingEmergencyCall |
| 430 | * @hide |
| 431 | */ |
| 432 | @SystemApi |
Shuo Qian | 134334b | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 433 | @TestApi |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 434 | @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) |
Shuo Qian | d966376 | 2019-10-04 13:20:45 -0700 | [diff] [blame] | 435 | public static final int LISTEN_OUTGOING_EMERGENCY_CALL = 0x10000000; |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 436 | |
| 437 | /** |
| 438 | * Listen for the emergency number placed from an outgoing SMS. |
| 439 | * |
| 440 | * <p>Requires permission {@link android.Manifest.permission#READ_ACTIVE_EMERGENCY_SESSION} |
| 441 | * |
| 442 | * @see #onOutgoingEmergencySms |
| 443 | * @hide |
| 444 | */ |
| 445 | @SystemApi |
Shuo Qian | 134334b | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 446 | @TestApi |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 447 | @RequiresPermission(Manifest.permission.READ_ACTIVE_EMERGENCY_SESSION) |
Shuo Qian | d966376 | 2019-10-04 13:20:45 -0700 | [diff] [blame] | 448 | public static final int LISTEN_OUTGOING_EMERGENCY_SMS = 0x20000000; |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 449 | |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 450 | /** |
| 451 | * Listen for Registration Failures. |
| 452 | * |
| 453 | * Listen for indications that a registration procedure has failed in either the CS or PS |
| 454 | * domain. This indication does not necessarily indicate a change of service state, which should |
| 455 | * be tracked via {@link #LISTEN_SERVICE_STATE}. |
| 456 | * |
Nathan Harold | 0d9a92b | 2020-02-06 20:59:18 -0800 | [diff] [blame] | 457 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or |
| 458 | * the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 459 | * |
Andrew Sapperstein | 8fe35e5 | 2020-04-28 12:29:20 -0700 | [diff] [blame] | 460 | * @see #onRegistrationFailed |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 461 | */ |
Nathan Harold | 0d9a92b | 2020-02-06 20:59:18 -0800 | [diff] [blame] | 462 | @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 463 | public static final int LISTEN_REGISTRATION_FAILURE = 0x40000000; |
| 464 | |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 465 | /** |
| 466 | * Listen for Barring Information for the current registered / camped cell. |
| 467 | * |
Nathan Harold | 0d9a92b | 2020-02-06 20:59:18 -0800 | [diff] [blame] | 468 | * <p>Requires permission {@link android.Manifest.permission#READ_PRECISE_PHONE_STATE} or |
| 469 | * the calling app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 470 | * |
Andrew Sapperstein | 8fe35e5 | 2020-04-28 12:29:20 -0700 | [diff] [blame] | 471 | * @see #onBarringInfoChanged |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 472 | */ |
Nathan Harold | 0d9a92b | 2020-02-06 20:59:18 -0800 | [diff] [blame] | 473 | @RequiresPermission(Manifest.permission.READ_PRECISE_PHONE_STATE) |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 474 | public static final int LISTEN_BARRING_INFO = 0x80000000; |
| 475 | |
Eric Schwarzenbach | 5c6b3a3 | 2018-01-18 17:15:51 -0800 | [diff] [blame] | 476 | /* |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 477 | * Subscription used to listen to the phone state changes |
| 478 | * @hide |
| 479 | */ |
| 480 | /** @hide */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 481 | @UnsupportedAppUsage |
Ta-wei Yen | 05f9112 | 2016-11-10 12:11:56 -0800 | [diff] [blame] | 482 | protected Integer mSubId; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 483 | |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 484 | /** |
| 485 | * @hide |
| 486 | */ |
| 487 | @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) |
| 488 | @UnsupportedAppUsage |
| 489 | public final IPhoneStateListener callback; |
Dianne Hackborn | 2ffa11e | 2014-04-21 15:56:18 -0700 | [diff] [blame] | 490 | |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 491 | /** |
| 492 | * Create a PhoneStateListener for the Phone with the default subscription. |
Karol Wrótniak | 69d3e55 | 2014-11-27 21:29:15 +0100 | [diff] [blame] | 493 | * This class requires Looper.myLooper() not return null. |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 494 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | public PhoneStateListener() { |
Ta-wei Yen | 05f9112 | 2016-11-10 12:11:56 -0800 | [diff] [blame] | 496 | this(null, Looper.myLooper()); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 497 | } |
| 498 | |
| 499 | /** |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 500 | * Create a PhoneStateListener for the Phone with the default subscription |
| 501 | * using a particular non-null Looper. |
| 502 | * @hide |
| 503 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 504 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 505 | public PhoneStateListener(Looper looper) { |
Ta-wei Yen | 05f9112 | 2016-11-10 12:11:56 -0800 | [diff] [blame] | 506 | this(null, looper); |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | /** |
| 510 | * Create a PhoneStateListener for the Phone using the specified subscription. |
| 511 | * This class requires Looper.myLooper() not return null. To supply your |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame] | 512 | * own non-null Looper use PhoneStateListener(int subId, Looper looper) below. |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 513 | * @hide |
| 514 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 515 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Ta-wei Yen | 05f9112 | 2016-11-10 12:11:56 -0800 | [diff] [blame] | 516 | public PhoneStateListener(Integer subId) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 517 | this(subId, Looper.myLooper()); |
chen xu | 84a9087 | 2019-03-28 15:44:12 -0700 | [diff] [blame] | 518 | if (subId != null && VMRuntime.getRuntime().getTargetSdkVersion() |
| 519 | >= Build.VERSION_CODES.Q) { |
| 520 | throw new IllegalArgumentException("PhoneStateListener with subId: " |
| 521 | + subId + " is not supported, use default constructor"); |
| 522 | } |
Dianne Hackborn | 2ffa11e | 2014-04-21 15:56:18 -0700 | [diff] [blame] | 523 | } |
Wink Saville | 2e40ba9 | 2014-09-03 15:28:12 -0700 | [diff] [blame] | 524 | /** |
| 525 | * Create a PhoneStateListener for the Phone using the specified subscription |
| 526 | * and non-null Looper. |
| 527 | * @hide |
| 528 | */ |
chen xu | f4c5c6e | 2018-11-18 18:56:00 -0800 | [diff] [blame] | 529 | @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
Ta-wei Yen | 05f9112 | 2016-11-10 12:11:56 -0800 | [diff] [blame] | 530 | public PhoneStateListener(Integer subId, Looper looper) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 531 | this(subId, new HandlerExecutor(new Handler(looper))); |
chen xu | 84a9087 | 2019-03-28 15:44:12 -0700 | [diff] [blame] | 532 | if (subId != null && VMRuntime.getRuntime().getTargetSdkVersion() |
| 533 | >= Build.VERSION_CODES.Q) { |
| 534 | throw new IllegalArgumentException("PhoneStateListener with subId: " |
| 535 | + subId + " is not supported, use default constructor"); |
| 536 | } |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | /** |
| 540 | * Create a PhoneStateListener for the Phone using the specified Executor |
| 541 | * |
| 542 | * <p>Create a PhoneStateListener with a specified Executor for handling necessary callbacks. |
| 543 | * The Executor must not be null. |
| 544 | * |
| 545 | * @param executor a non-null Executor that will execute callbacks for the PhoneStateListener. |
| 546 | */ |
| 547 | public PhoneStateListener(@NonNull Executor executor) { |
| 548 | this(null, executor); |
| 549 | } |
| 550 | |
| 551 | private PhoneStateListener(Integer subId, Executor e) { |
| 552 | if (e == null) { |
| 553 | throw new IllegalArgumentException("PhoneStateListener Executor must be non-null"); |
| 554 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 555 | mSubId = subId; |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 556 | callback = new IPhoneStateListenerStub(this, e); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 557 | } |
| 558 | |
| 559 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 560 | * Callback invoked when device service state changes on the registered subscription. |
| 561 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 562 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 563 | * If this TelephonyManager object was created with |
| 564 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 565 | * subId. Otherwise, this callback applies to |
| 566 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 567 | * |
| 568 | * @see ServiceState#STATE_EMERGENCY_ONLY |
| 569 | * @see ServiceState#STATE_IN_SERVICE |
| 570 | * @see ServiceState#STATE_OUT_OF_SERVICE |
| 571 | * @see ServiceState#STATE_POWER_OFF |
| 572 | */ |
| 573 | public void onServiceStateChanged(ServiceState serviceState) { |
| 574 | // default implementation empty |
| 575 | } |
| 576 | |
| 577 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 578 | * Callback invoked when network signal strength changes on the registered subscription. |
| 579 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 580 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 581 | * If this TelephonyManager object was created with |
| 582 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 583 | * subId. Otherwise, this callback applies to |
| 584 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 585 | * |
| 586 | * @see ServiceState#STATE_EMERGENCY_ONLY |
| 587 | * @see ServiceState#STATE_IN_SERVICE |
| 588 | * @see ServiceState#STATE_OUT_OF_SERVICE |
| 589 | * @see ServiceState#STATE_POWER_OFF |
Scott Main | b149ee8 | 2009-12-15 10:47:31 -0800 | [diff] [blame] | 590 | * @deprecated Use {@link #onSignalStrengthsChanged(SignalStrength)} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 591 | */ |
Dianne Hackborn | 4a51c20 | 2009-08-21 15:14:02 -0700 | [diff] [blame] | 592 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 593 | public void onSignalStrengthChanged(int asu) { |
| 594 | // default implementation empty |
| 595 | } |
| 596 | |
| 597 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 598 | * Callback invoked when the message-waiting indicator changes on the registered subscription. |
| 599 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 600 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 601 | * If this TelephonyManager object was created with |
| 602 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 603 | * subId. Otherwise, this callback applies to |
| 604 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 605 | */ |
| 606 | public void onMessageWaitingIndicatorChanged(boolean mwi) { |
| 607 | // default implementation empty |
| 608 | } |
| 609 | |
| 610 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 611 | * Callback invoked when the call-forwarding indicator changes on the registered subscription. |
| 612 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 613 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 614 | * If this TelephonyManager object was created with |
| 615 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 616 | * subId. Otherwise, this callback applies to |
| 617 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 618 | */ |
| 619 | public void onCallForwardingIndicatorChanged(boolean cfi) { |
| 620 | // default implementation empty |
| 621 | } |
| 622 | |
| 623 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 624 | * Callback invoked when device cell location changes on the registered subscription. |
| 625 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 626 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 627 | * If this TelephonyManager object was created with |
| 628 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 629 | * subId. Otherwise, this callback applies to |
| 630 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 631 | */ |
| 632 | public void onCellLocationChanged(CellLocation location) { |
| 633 | // default implementation empty |
| 634 | } |
| 635 | |
| 636 | /** |
Wink Saville | 767a662 | 2009-04-02 01:37:02 -0700 | [diff] [blame] | 637 | * Callback invoked when device call state changes. |
Tyler Gunn | 5f7265e | 2018-03-13 15:56:37 -0700 | [diff] [blame] | 638 | * <p> |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 639 | * Reports the state of Telephony (mobile) calls on the device for the registered subscription. |
| 640 | * <p> |
| 641 | * Note: the registration subId comes from {@link TelephonyManager} object which registers |
| 642 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 643 | * If this TelephonyManager object was created with |
| 644 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 645 | * subId. Otherwise, this callback applies to |
| 646 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
Tyler Gunn | 5f7265e | 2018-03-13 15:56:37 -0700 | [diff] [blame] | 647 | * <p> |
| 648 | * Note: The state returned here may differ from that returned by |
| 649 | * {@link TelephonyManager#getCallState()}. Receivers of this callback should be aware that |
| 650 | * calling {@link TelephonyManager#getCallState()} from within this callback may return a |
| 651 | * different state than the callback reports. |
| 652 | * |
Fyodor Kupolov | 309b2f63 | 2015-06-03 16:29:01 -0700 | [diff] [blame] | 653 | * @param state call state |
Jeff Davidson | 3463ee1 | 2017-11-10 15:58:20 -0800 | [diff] [blame] | 654 | * @param phoneNumber call phone number. If application does not have |
Tyler Gunn | f955e56 | 2018-04-26 14:43:31 -0700 | [diff] [blame] | 655 | * {@link android.Manifest.permission#READ_CALL_LOG READ_CALL_LOG} permission or carrier |
Jeff Davidson | 01efe5e | 2018-02-28 17:50:16 -0800 | [diff] [blame] | 656 | * privileges (see {@link TelephonyManager#hasCarrierPrivileges}), an empty string will be |
| 657 | * passed as an argument. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 658 | */ |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 659 | public void onCallStateChanged(@CallState int state, String phoneNumber) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 660 | // default implementation empty |
| 661 | } |
| 662 | |
| 663 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 664 | * Callback invoked when connection state changes on the registered subscription. |
| 665 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 666 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 667 | * If this TelephonyManager object was created with |
| 668 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 669 | * subId. Otherwise, this callback applies to |
| 670 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 671 | * |
| 672 | * @see TelephonyManager#DATA_DISCONNECTED |
| 673 | * @see TelephonyManager#DATA_CONNECTING |
| 674 | * @see TelephonyManager#DATA_CONNECTED |
| 675 | * @see TelephonyManager#DATA_SUSPENDED |
| 676 | */ |
| 677 | public void onDataConnectionStateChanged(int state) { |
| 678 | // default implementation empty |
| 679 | } |
| 680 | |
| 681 | /** |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 682 | * same as above, but with the network type. Both called. |
| 683 | */ |
| 684 | public void onDataConnectionStateChanged(int state, int networkType) { |
| 685 | } |
| 686 | |
| 687 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 688 | * Callback invoked when data activity state changes on the registered subscription. |
| 689 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 690 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 691 | * If this TelephonyManager object was created with |
| 692 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 693 | * subId. Otherwise, this callback applies to |
| 694 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 695 | * |
| 696 | * @see TelephonyManager#DATA_ACTIVITY_NONE |
| 697 | * @see TelephonyManager#DATA_ACTIVITY_IN |
| 698 | * @see TelephonyManager#DATA_ACTIVITY_OUT |
| 699 | * @see TelephonyManager#DATA_ACTIVITY_INOUT |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 700 | * @see TelephonyManager#DATA_ACTIVITY_DORMANT |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 701 | */ |
| 702 | public void onDataActivity(int direction) { |
| 703 | // default implementation empty |
| 704 | } |
| 705 | |
| 706 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 707 | * Callback invoked when network signal strengths changes on the registered subscription. |
| 708 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 709 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 710 | * If this TelephonyManager object was created with |
| 711 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 712 | * subId. Otherwise, this callback applies to |
| 713 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 714 | */ |
| 715 | public void onSignalStrengthsChanged(SignalStrength signalStrength) { |
| 716 | // default implementation empty |
| 717 | } |
| 718 | |
| 719 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 720 | * Callback invoked when a observed cell info has changed or new cells have been added |
| 721 | * or removed on the registered subscription. |
| 722 | * Note, the registration subId s from {@link TelephonyManager} object which registers |
| 723 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 724 | * If this TelephonyManager object was created with |
| 725 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 726 | * subId. Otherwise, this callback applies to |
| 727 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 728 | * |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 729 | * @param cellInfo is the list of currently visible cells. |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 730 | */ |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 731 | public void onCellInfoChanged(List<CellInfo> cellInfo) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 732 | } |
| 733 | |
| 734 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 735 | * Callback invoked when precise device call state changes on the registered subscription. |
| 736 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 737 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 738 | * If this TelephonyManager object was created with |
| 739 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 740 | * subId. Otherwise, this callback applies to |
| 741 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 742 | * @param callState {@link PreciseCallState} |
| 743 | * @hide |
| 744 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 745 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 746 | @SystemApi |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 747 | public void onPreciseCallStateChanged(@NonNull PreciseCallState callState) { |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 748 | // default implementation empty |
| 749 | } |
| 750 | |
| 751 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 752 | * Callback invoked when call disconnect cause changes on the registered subscription. |
| 753 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 754 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 755 | * If this TelephonyManager object was created with |
| 756 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 757 | * subId. Otherwise, this callback applies to |
| 758 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 759 | * |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 760 | * @param disconnectCause {@link DisconnectCause}. |
| 761 | * @param preciseDisconnectCause {@link PreciseDisconnectCause}. |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 762 | * |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 763 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 764 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 765 | public void onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 766 | // default implementation empty |
| 767 | } |
| 768 | |
| 769 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 770 | * Callback invoked when Ims call disconnect cause changes on the registered subscription. |
| 771 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 772 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 773 | * If this TelephonyManager object was created with |
| 774 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 775 | * subId. Otherwise, this callback applies to |
| 776 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 777 | * |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 778 | * @param imsReasonInfo {@link ImsReasonInfo} contains details on why IMS call failed. |
| 779 | * |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 780 | */ |
chen xu | 7621ff2 | 2019-02-21 19:17:22 -0800 | [diff] [blame] | 781 | @RequiresPermission((android.Manifest.permission.READ_PRECISE_PHONE_STATE)) |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 782 | public void onImsCallDisconnectCauseChanged(@NonNull ImsReasonInfo imsReasonInfo) { |
| 783 | // default implementation empty |
| 784 | } |
| 785 | |
| 786 | /** |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 787 | * Callback providing update about the default/internet data connection on the registered |
| 788 | * subscription. |
| 789 | * |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 790 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 791 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 792 | * If this TelephonyManager object was created with |
| 793 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 794 | * subId. Otherwise, this callback applies to |
| 795 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 796 | * |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 797 | * <p>Requires permission {@link android.Manifest.permission#MODIFY_PHONE_STATE} |
| 798 | * or the calling app has carrier privileges |
| 799 | * (see {@link TelephonyManager#hasCarrierPrivileges}). |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 800 | * |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 801 | * @param dataConnectionState {@link PreciseDataConnectionState} |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 802 | */ |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 803 | @RequiresPermission((android.Manifest.permission.MODIFY_PHONE_STATE)) |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 804 | public void onPreciseDataConnectionStateChanged( |
chen xu | 8165386 | 2019-02-28 10:44:54 -0800 | [diff] [blame] | 805 | @NonNull PreciseDataConnectionState dataConnectionState) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 806 | // default implementation empty |
| 807 | } |
| 808 | |
| 809 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 810 | * Callback invoked when data connection real time info changes on the registered subscription. |
| 811 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 812 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 813 | * If this TelephonyManager object was created with |
| 814 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 815 | * subId. Otherwise, this callback applies to |
| 816 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 817 | * |
| 818 | * @hide |
| 819 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 820 | @UnsupportedAppUsage |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 821 | public void onDataConnectionRealTimeInfoChanged( |
| 822 | DataConnectionRealTimeInfo dcRtInfo) { |
| 823 | // default implementation empty |
| 824 | } |
| 825 | |
| 826 | /** |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 827 | * Callback invoked when there has been a change in the Single Radio Voice Call Continuity |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 828 | * (SRVCC) state for the currently active call on the registered subscription. |
| 829 | * |
| 830 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 831 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 832 | * If this TelephonyManager object was created with |
| 833 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 834 | * subId. Otherwise, this callback applies to |
| 835 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 836 | * |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 837 | * @hide |
| 838 | */ |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 839 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 840 | public void onSrvccStateChanged(@SrvccState int srvccState) { |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 841 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 845 | * Callback invoked when the SIM voice activation state has changed on the registered |
| 846 | * subscription. |
| 847 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 848 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 849 | * If this TelephonyManager object was created with |
| 850 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 851 | * subId. Otherwise, this callback applies to |
| 852 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 853 | * |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 854 | * @param state is the current SIM voice activation state |
| 855 | * @hide |
| 856 | */ |
chen xu | 63b0a34 | 2018-11-10 11:31:49 -0800 | [diff] [blame] | 857 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 858 | public void onVoiceActivationStateChanged(@SimActivationState int state) { |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 862 | * Callback invoked when the SIM data activation state has changed on the registered |
| 863 | * subscription. |
| 864 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 865 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 866 | * If this TelephonyManager object was created with |
| 867 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 868 | * subId. Otherwise, this callback applies to |
| 869 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 870 | * |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 871 | * @param state is the current SIM data activation state |
| 872 | * @hide |
| 873 | */ |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 874 | public void onDataActivationStateChanged(@SimActivationState int state) { |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 878 | * Callback invoked when the user mobile data state has changed on the registered subscription. |
| 879 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 880 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 881 | * If this TelephonyManager object was created with |
| 882 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 883 | * subId. Otherwise, this callback applies to |
| 884 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 885 | * |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 886 | * @param enabled indicates whether the current user mobile data state is enabled or disabled. |
| 887 | */ |
| 888 | public void onUserMobileDataStateChanged(boolean enabled) { |
| 889 | // default implementation empty |
| 890 | } |
| 891 | |
| 892 | /** |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 893 | * Callback invoked when the display info has changed on the registered subscription. |
Jack Yu | ac3ca33 | 2020-03-18 14:53:32 -0700 | [diff] [blame] | 894 | * <p> The {@link TelephonyDisplayInfo} contains status information shown to the user based on |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 895 | * carrier policy. |
| 896 | * |
| 897 | * Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE} or that the calling |
| 898 | * app has carrier privileges (see {@link TelephonyManager#hasCarrierPrivileges}). |
| 899 | * |
Jack Yu | ac3ca33 | 2020-03-18 14:53:32 -0700 | [diff] [blame] | 900 | * @param telephonyDisplayInfo The display information. |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 901 | */ |
| 902 | @RequiresPermission((android.Manifest.permission.READ_PHONE_STATE)) |
Jack Yu | ac3ca33 | 2020-03-18 14:53:32 -0700 | [diff] [blame] | 903 | public void onDisplayInfoChanged(@NonNull TelephonyDisplayInfo telephonyDisplayInfo) { |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 904 | // default implementation empty |
| 905 | } |
| 906 | |
| 907 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 908 | * Callback invoked when the current emergency number list has changed on the registered |
| 909 | * subscription. |
| 910 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 911 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 912 | * If this TelephonyManager object was created with |
| 913 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 914 | * subId. Otherwise, this callback applies to |
| 915 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
sqian | 46c0c30 | 2018-12-27 14:12:11 -0800 | [diff] [blame] | 916 | * |
| 917 | * @param emergencyNumberList Map including the key as the active subscription ID |
| 918 | * (Note: if there is no active subscription, the key is |
| 919 | * {@link SubscriptionManager#getDefaultSubscriptionId}) |
| 920 | * and the value as the list of {@link EmergencyNumber}; |
| 921 | * null if this information is not available. |
| 922 | * @hide |
| 923 | */ |
| 924 | public void onEmergencyNumberListChanged( |
| 925 | @NonNull Map<Integer, List<EmergencyNumber>> emergencyNumberList) { |
| 926 | // default implementation empty |
| 927 | } |
| 928 | |
| 929 | /** |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 930 | * Callback invoked when an outgoing call is placed to an emergency number. |
| 931 | * |
| 932 | * @param placedEmergencyNumber the emergency number {@link EmergencyNumber} the call is placed |
| 933 | * to. |
| 934 | * @hide |
| 935 | */ |
Shuo Qian | 134334b | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 936 | @SystemApi |
Shuo Qian | 650ff64 | 2019-10-02 15:22:21 -0700 | [diff] [blame] | 937 | @TestApi |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 938 | public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber) { |
| 939 | // default implementation empty |
| 940 | } |
| 941 | |
| 942 | /** |
| 943 | * Callback invoked when an outgoing SMS is placed to an emergency number. |
| 944 | * |
| 945 | * @param sentEmergencyNumber the emergency number {@link EmergencyNumber} the SMS is sent to. |
| 946 | * @hide |
| 947 | */ |
Shuo Qian | 134334b | 2019-09-12 17:00:31 -0700 | [diff] [blame] | 948 | @SystemApi |
Shuo Qian | 650ff64 | 2019-10-02 15:22:21 -0700 | [diff] [blame] | 949 | @TestApi |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 950 | public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { |
| 951 | // default implementation empty |
| 952 | } |
| 953 | |
| 954 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 955 | * Callback invoked when OEM hook raw event is received on the registered subscription. |
| 956 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 957 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 958 | * If this TelephonyManager object was created with |
| 959 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 960 | * subId. Otherwise, this callback applies to |
| 961 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 962 | * |
| 963 | * Requires the READ_PRIVILEGED_PHONE_STATE permission. |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 964 | * @param rawData is the byte array of the OEM hook raw data. |
| 965 | * @hide |
| 966 | */ |
Mathew Inwood | a838206 | 2018-08-16 17:01:12 +0100 | [diff] [blame] | 967 | @UnsupportedAppUsage |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 968 | public void onOemHookRawEvent(byte[] rawData) { |
| 969 | // default implementation empty |
| 970 | } |
| 971 | |
| 972 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 973 | * Callback invoked when phone capability changes. |
| 974 | * Note, this callback triggers regardless of registered subscription. |
| 975 | * |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 976 | * @param capability the new phone capability |
| 977 | * @hide |
| 978 | */ |
| 979 | public void onPhoneCapabilityChanged(PhoneCapability capability) { |
| 980 | // default implementation empty |
| 981 | } |
| 982 | |
| 983 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 984 | * Callback invoked when active data subId changes. |
| 985 | * Note, this callback triggers regardless of registered subscription. |
| 986 | * |
| 987 | * Requires the READ_PHONE_STATE permission. |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 988 | * @param subId current subscription used to setup Cellular Internet data. |
| 989 | * For example, it could be the current active opportunistic subscription in use, |
| 990 | * or the subscription user selected as default data subscription in DSDS mode. |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 991 | */ |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 992 | public void onActiveDataSubscriptionIdChanged(int subId) { |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 993 | // default implementation empty |
| 994 | } |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 995 | |
| 996 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 997 | * Callback invoked when the call attributes changes on the registered subscription. |
| 998 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 999 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 1000 | * If this TelephonyManager object was created with |
| 1001 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 1002 | * subId. Otherwise, this callback applies to |
| 1003 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 1004 | * |
Rambo Wang | feed16d | 2020-01-20 16:55:36 -0800 | [diff] [blame] | 1005 | * Requires the READ_PRECISE_PHONE_STATE permission. |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 1006 | * @param callAttributes the call attributes |
| 1007 | * @hide |
| 1008 | */ |
| 1009 | @SystemApi |
Jordan Liu | eae57b2 | 2019-01-22 16:17:35 -0800 | [diff] [blame] | 1010 | public void onCallAttributesChanged(@NonNull CallAttributes callAttributes) { |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 1011 | // default implementation empty |
| 1012 | } |
| 1013 | |
| 1014 | /** |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1015 | * Callback invoked when modem radio power state changes on the registered subscription. |
| 1016 | * Note, the registration subId comes from {@link TelephonyManager} object which registers |
| 1017 | * PhoneStateListener by {@link TelephonyManager#listen(PhoneStateListener, int)}. |
| 1018 | * If this TelephonyManager object was created with |
| 1019 | * {@link TelephonyManager#createForSubscriptionId(int)}, then the callback applies to the |
| 1020 | * subId. Otherwise, this callback applies to |
| 1021 | * {@link SubscriptionManager#getDefaultSubscriptionId()}. |
| 1022 | * |
Shi Lu | 12645d1 | 2019-11-21 17:51:07 +0000 | [diff] [blame] | 1023 | * @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE} |
Malcolm Chen | 27de0e5 | 2018-11-12 19:34:38 -0800 | [diff] [blame] | 1024 | * @param state the modem radio power state |
| 1025 | * @hide |
| 1026 | */ |
| 1027 | @SystemApi |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1028 | public void onRadioPowerStateChanged(@RadioPowerState int state) { |
Malcolm Chen | 27de0e5 | 2018-11-12 19:34:38 -0800 | [diff] [blame] | 1029 | // default implementation empty |
| 1030 | } |
| 1031 | |
| 1032 | /** |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1033 | * Callback invoked when telephony has received notice from a carrier |
| 1034 | * app that a network action that could result in connectivity loss |
| 1035 | * has been requested by an app using |
| 1036 | * {@link android.telephony.TelephonyManager#notifyCarrierNetworkChange(boolean)} |
| 1037 | * |
chen xu | d5deeb1 | 2019-04-29 13:57:42 -0700 | [diff] [blame] | 1038 | * Note, this callback is pinned to the registered subscription and will be invoked when |
| 1039 | * the notifying carrier app has carrier privilege rule on the registered |
| 1040 | * subscription. {@link android.telephony.TelephonyManager#hasCarrierPrivileges} |
| 1041 | * |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1042 | * @param active Whether the carrier network change is or shortly |
| 1043 | * will be active. This value is true to indicate |
| 1044 | * showing alternative UI and false to stop. |
| 1045 | * |
| 1046 | * @hide |
| 1047 | */ |
| 1048 | public void onCarrierNetworkChange(boolean active) { |
| 1049 | // default implementation empty |
| 1050 | } |
| 1051 | |
| 1052 | /** |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1053 | * Report that Registration or a Location/Routing/Tracking Area update has failed. |
| 1054 | * |
| 1055 | * <p>Indicate whenever a registration procedure, including a location, routing, or tracking |
| 1056 | * area update fails. This includes procedures that do not necessarily result in a change of |
| 1057 | * the modem's registration status. If the modem's registration status changes, that is |
| 1058 | * reflected in the onNetworkStateChanged() and subsequent get{Voice/Data}RegistrationState(). |
| 1059 | * |
| 1060 | * <p>Because registration failures are ephemeral, this callback is not sticky. |
| 1061 | * Registrants will not receive the most recent past value when registering. |
| 1062 | * |
| 1063 | * @param cellIdentity the CellIdentity, which must include the globally unique identifier |
| 1064 | * for the cell (for example, all components of the CGI or ECGI). |
| 1065 | * @param chosenPlmn a 5 or 6 digit alphanumeric PLMN (MCC|MNC) among those broadcast by the |
| 1066 | * cell that was chosen for the failed registration attempt. |
| 1067 | * @param domain DOMAIN_CS, DOMAIN_PS or both in case of a combined procedure. |
| 1068 | * @param causeCode the primary failure cause code of the procedure. |
| 1069 | * For GSM/UMTS (MM), values are in TS 24.008 Sec 10.5.95 |
| 1070 | * For GSM/UMTS (GMM), values are in TS 24.008 Sec 10.5.147 |
| 1071 | * For LTE (EMM), cause codes are TS 24.301 Sec 9.9.3.9 |
| 1072 | * For NR (5GMM), cause codes are TS 24.501 Sec 9.11.3.2 |
| 1073 | * Integer.MAX_VALUE if this value is unused. |
| 1074 | * @param additionalCauseCode the cause code of any secondary/combined procedure if appropriate. |
| 1075 | * For UMTS, if a combined attach succeeds for PS only, then the GMM cause code shall be |
| 1076 | * included as an additionalCauseCode. For LTE (ESM), cause codes are in |
| 1077 | * TS 24.301 9.9.4.4. Integer.MAX_VALUE if this value is unused. |
| 1078 | */ |
| 1079 | public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, @NonNull String chosenPlmn, |
Chen Xu | 546ce5e | 2020-01-10 08:38:31 -0800 | [diff] [blame] | 1080 | int domain, int causeCode, int additionalCauseCode) { |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1081 | // default implementation empty |
| 1082 | } |
| 1083 | |
| 1084 | /** |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 1085 | * Report updated barring information for the current camped/registered cell. |
| 1086 | * |
| 1087 | * <p>Barring info is provided for all services applicable to the current camped/registered |
| 1088 | * cell, for the registered PLMN and current access class/access category. |
| 1089 | * |
| 1090 | * @param barringInfo for all services on the current cell. |
| 1091 | * |
| 1092 | * @see android.telephony.BarringInfo |
| 1093 | */ |
| 1094 | public void onBarringInfoChanged(@NonNull BarringInfo barringInfo) { |
| 1095 | // default implementation empty |
| 1096 | } |
| 1097 | |
| 1098 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1099 | * The callback methods need to be called on the handler thread where |
| 1100 | * this object was created. If the binder did that for us it'd be nice. |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1101 | * |
| 1102 | * Using a static class and weak reference here to avoid memory leak caused by the |
| 1103 | * IPhoneStateListener.Stub callback retaining references to the outside PhoneStateListeners: |
| 1104 | * even caller has been destroyed and "un-registered" the PhoneStateListener, it is still not |
| 1105 | * eligible for GC given the references coming from: |
| 1106 | * Native Stack --> PhoneStateListener --> Context (Activity). |
| 1107 | * memory of caller's context will be collected after GC from service side get triggered |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1108 | */ |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1109 | private static class IPhoneStateListenerStub extends IPhoneStateListener.Stub { |
| 1110 | private WeakReference<PhoneStateListener> mPhoneStateListenerWeakRef; |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1111 | private Executor mExecutor; |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1112 | |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1113 | IPhoneStateListenerStub(PhoneStateListener phoneStateListener, Executor executor) { |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1114 | mPhoneStateListenerWeakRef = new WeakReference<PhoneStateListener>(phoneStateListener); |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1115 | mExecutor = executor; |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1116 | } |
| 1117 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1118 | public void onServiceStateChanged(ServiceState serviceState) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1119 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1120 | if (psl == null) return; |
| 1121 | |
| 1122 | Binder.withCleanCallingIdentity( |
| 1123 | () -> mExecutor.execute(() -> psl.onServiceStateChanged(serviceState))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1124 | } |
| 1125 | |
| 1126 | public void onSignalStrengthChanged(int asu) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1127 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1128 | if (psl == null) return; |
| 1129 | |
| 1130 | Binder.withCleanCallingIdentity( |
| 1131 | () -> mExecutor.execute(() -> psl.onSignalStrengthChanged(asu))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | public void onMessageWaitingIndicatorChanged(boolean mwi) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1135 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1136 | if (psl == null) return; |
| 1137 | |
| 1138 | Binder.withCleanCallingIdentity( |
| 1139 | () -> mExecutor.execute(() -> psl.onMessageWaitingIndicatorChanged(mwi))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1140 | } |
| 1141 | |
| 1142 | public void onCallForwardingIndicatorChanged(boolean cfi) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1143 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1144 | if (psl == null) return; |
| 1145 | |
| 1146 | Binder.withCleanCallingIdentity( |
| 1147 | () -> mExecutor.execute(() -> psl.onCallForwardingIndicatorChanged(cfi))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1148 | } |
| 1149 | |
Meng Wang | d75f97d | 2019-12-06 18:27:38 -0800 | [diff] [blame] | 1150 | public void onCellLocationChanged(CellIdentity cellIdentity) { |
| 1151 | // There is no system/public API to create an CellIdentity in system server, |
| 1152 | // so the server pass a null to indicate an empty initial location. |
| 1153 | CellLocation location = |
| 1154 | cellIdentity == null ? CellLocation.getEmpty() : cellIdentity.asCellLocation(); |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1155 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1156 | if (psl == null) return; |
| 1157 | |
| 1158 | Binder.withCleanCallingIdentity( |
| 1159 | () -> mExecutor.execute(() -> psl.onCellLocationChanged(location))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1160 | } |
| 1161 | |
| 1162 | public void onCallStateChanged(int state, String incomingNumber) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1163 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1164 | if (psl == null) return; |
| 1165 | |
| 1166 | Binder.withCleanCallingIdentity( |
| 1167 | () -> mExecutor.execute(() -> psl.onCallStateChanged(state, incomingNumber))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1168 | } |
| 1169 | |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 1170 | public void onDataConnectionStateChanged(int state, int networkType) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1171 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1172 | if (psl == null) return; |
| 1173 | |
Nathan Harold | 4d340f1 | 2019-12-05 17:27:56 -0800 | [diff] [blame] | 1174 | if (state == TelephonyManager.DATA_DISCONNECTING |
| 1175 | && VMRuntime.getRuntime().getTargetSdkVersion() < Build.VERSION_CODES.R) { |
| 1176 | Binder.withCleanCallingIdentity(() -> mExecutor.execute( |
| 1177 | () -> { |
| 1178 | psl.onDataConnectionStateChanged( |
| 1179 | TelephonyManager.DATA_CONNECTED, networkType); |
| 1180 | psl.onDataConnectionStateChanged(TelephonyManager.DATA_CONNECTED); |
| 1181 | })); |
| 1182 | } else { |
| 1183 | Binder.withCleanCallingIdentity(() -> mExecutor.execute( |
| 1184 | () -> { |
| 1185 | psl.onDataConnectionStateChanged(state, networkType); |
| 1186 | psl.onDataConnectionStateChanged(state); |
| 1187 | })); |
| 1188 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1189 | } |
| 1190 | |
| 1191 | public void onDataActivity(int direction) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1192 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1193 | if (psl == null) return; |
| 1194 | |
| 1195 | Binder.withCleanCallingIdentity( |
| 1196 | () -> mExecutor.execute(() -> psl.onDataActivity(direction))); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1197 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1198 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1199 | public void onSignalStrengthsChanged(SignalStrength signalStrength) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1200 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1201 | if (psl == null) return; |
| 1202 | |
| 1203 | Binder.withCleanCallingIdentity( |
| 1204 | () -> mExecutor.execute(() -> psl.onSignalStrengthsChanged(signalStrength))); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1205 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 1206 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 1207 | public void onCellInfoChanged(List<CellInfo> cellInfo) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1208 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1209 | if (psl == null) return; |
| 1210 | |
| 1211 | Binder.withCleanCallingIdentity( |
| 1212 | () -> mExecutor.execute(() -> psl.onCellInfoChanged(cellInfo))); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1213 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1214 | |
| 1215 | public void onPreciseCallStateChanged(PreciseCallState callState) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1216 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1217 | if (psl == null) return; |
| 1218 | |
| 1219 | Binder.withCleanCallingIdentity( |
| 1220 | () -> mExecutor.execute(() -> psl.onPreciseCallStateChanged(callState))); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1221 | } |
| 1222 | |
chen xu | 970d779 | 2018-12-12 19:59:30 -0800 | [diff] [blame] | 1223 | public void onCallDisconnectCauseChanged(int disconnectCause, int preciseDisconnectCause) { |
| 1224 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1225 | if (psl == null) return; |
| 1226 | |
| 1227 | Binder.withCleanCallingIdentity( |
| 1228 | () -> mExecutor.execute(() -> psl.onCallDisconnectCauseChanged( |
| 1229 | disconnectCause, preciseDisconnectCause))); |
| 1230 | } |
| 1231 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1232 | public void onPreciseDataConnectionStateChanged( |
| 1233 | PreciseDataConnectionState dataConnectionState) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1234 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1235 | if (psl == null) return; |
| 1236 | |
| 1237 | Binder.withCleanCallingIdentity( |
| 1238 | () -> mExecutor.execute( |
| 1239 | () -> psl.onPreciseDataConnectionStateChanged(dataConnectionState))); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1240 | } |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 1241 | |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1242 | public void onDataConnectionRealTimeInfoChanged(DataConnectionRealTimeInfo dcRtInfo) { |
| 1243 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1244 | if (psl == null) return; |
| 1245 | |
| 1246 | Binder.withCleanCallingIdentity( |
| 1247 | () -> mExecutor.execute( |
| 1248 | () -> psl.onDataConnectionRealTimeInfoChanged(dcRtInfo))); |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 1249 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1250 | |
Brad Ebinger | efed982 | 2018-10-26 10:25:57 -0700 | [diff] [blame] | 1251 | public void onSrvccStateChanged(int state) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1252 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1253 | if (psl == null) return; |
| 1254 | |
| 1255 | Binder.withCleanCallingIdentity( |
| 1256 | () -> mExecutor.execute(() -> psl.onSrvccStateChanged(state))); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1257 | } |
New Author Steven Liu | 485f209 | 2014-09-11 10:18:45 -0500 | [diff] [blame] | 1258 | |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1259 | public void onVoiceActivationStateChanged(int activationState) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1260 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1261 | if (psl == null) return; |
| 1262 | |
| 1263 | Binder.withCleanCallingIdentity( |
| 1264 | () -> mExecutor.execute( |
| 1265 | () -> psl.onVoiceActivationStateChanged(activationState))); |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1266 | } |
| 1267 | |
| 1268 | public void onDataActivationStateChanged(int activationState) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1269 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1270 | if (psl == null) return; |
| 1271 | |
| 1272 | Binder.withCleanCallingIdentity( |
| 1273 | () -> mExecutor.execute( |
| 1274 | () -> psl.onDataActivationStateChanged(activationState))); |
fionaxu | 64eebba | 2016-11-14 13:32:14 -0800 | [diff] [blame] | 1275 | } |
| 1276 | |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1277 | public void onUserMobileDataStateChanged(boolean enabled) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1278 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1279 | if (psl == null) return; |
| 1280 | |
| 1281 | Binder.withCleanCallingIdentity( |
| 1282 | () -> mExecutor.execute( |
| 1283 | () -> psl.onUserMobileDataStateChanged(enabled))); |
zxuan | 35a4702 | 2018-01-04 11:24:04 -0800 | [diff] [blame] | 1284 | } |
| 1285 | |
Jack Yu | ac3ca33 | 2020-03-18 14:53:32 -0700 | [diff] [blame] | 1286 | public void onDisplayInfoChanged(TelephonyDisplayInfo telephonyDisplayInfo) { |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 1287 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1288 | if (psl == null) return; |
| 1289 | |
| 1290 | Binder.withCleanCallingIdentity( |
| 1291 | () -> mExecutor.execute( |
Jack Yu | ac3ca33 | 2020-03-18 14:53:32 -0700 | [diff] [blame] | 1292 | () -> psl.onDisplayInfoChanged(telephonyDisplayInfo))); |
Jack Yu | 73036c4 | 2020-02-06 13:33:04 -0800 | [diff] [blame] | 1293 | } |
| 1294 | |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1295 | public void onOemHookRawEvent(byte[] rawData) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1296 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1297 | if (psl == null) return; |
| 1298 | |
| 1299 | Binder.withCleanCallingIdentity( |
| 1300 | () -> mExecutor.execute(() -> psl.onOemHookRawEvent(rawData))); |
Shuo Qian | 066e865 | 2018-04-25 21:02:35 +0000 | [diff] [blame] | 1301 | } |
| 1302 | |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1303 | public void onCarrierNetworkChange(boolean active) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1304 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1305 | if (psl == null) return; |
| 1306 | |
| 1307 | Binder.withCleanCallingIdentity( |
| 1308 | () -> mExecutor.execute(() -> psl.onCarrierNetworkChange(active))); |
Andrew Flynn | 1f45264 | 2015-04-14 22:16:04 -0400 | [diff] [blame] | 1309 | } |
Eric Schwarzenbach | 4ce04dd | 2018-01-24 13:21:27 -0800 | [diff] [blame] | 1310 | |
sqian | 46c0c30 | 2018-12-27 14:12:11 -0800 | [diff] [blame] | 1311 | public void onEmergencyNumberListChanged(Map emergencyNumberList) { |
| 1312 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1313 | if (psl == null) return; |
| 1314 | |
| 1315 | Binder.withCleanCallingIdentity( |
| 1316 | () -> mExecutor.execute( |
| 1317 | () -> psl.onEmergencyNumberListChanged(emergencyNumberList))); |
| 1318 | } |
| 1319 | |
Shuo Qian | 7a1eb6d | 2019-09-04 16:21:10 -0700 | [diff] [blame] | 1320 | public void onOutgoingEmergencyCall(@NonNull EmergencyNumber placedEmergencyNumber) { |
| 1321 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1322 | if (psl == null) return; |
| 1323 | |
| 1324 | Binder.withCleanCallingIdentity( |
| 1325 | () -> mExecutor.execute( |
| 1326 | () -> psl.onOutgoingEmergencyCall(placedEmergencyNumber))); |
| 1327 | } |
| 1328 | |
| 1329 | public void onOutgoingEmergencySms(@NonNull EmergencyNumber sentEmergencyNumber) { |
| 1330 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1331 | if (psl == null) return; |
| 1332 | |
| 1333 | Binder.withCleanCallingIdentity( |
| 1334 | () -> mExecutor.execute( |
| 1335 | () -> psl.onOutgoingEmergencySms(sentEmergencyNumber))); |
| 1336 | } |
| 1337 | |
Malcolm Chen | 5ee5c14 | 2018-08-08 20:27:45 -0700 | [diff] [blame] | 1338 | public void onPhoneCapabilityChanged(PhoneCapability capability) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1339 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1340 | if (psl == null) return; |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 1341 | |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1342 | Binder.withCleanCallingIdentity( |
| 1343 | () -> mExecutor.execute(() -> psl.onPhoneCapabilityChanged(capability))); |
Malcolm Chen | 27de0e5 | 2018-11-12 19:34:38 -0800 | [diff] [blame] | 1344 | } |
| 1345 | |
Chen Xu | c9d4ee1 | 2019-09-26 16:11:59 -0700 | [diff] [blame] | 1346 | public void onRadioPowerStateChanged(@RadioPowerState int state) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1347 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1348 | if (psl == null) return; |
| 1349 | |
| 1350 | Binder.withCleanCallingIdentity( |
| 1351 | () -> mExecutor.execute(() -> psl.onRadioPowerStateChanged(state))); |
chen xu | 760729c | 2018-10-11 13:18:26 -0700 | [diff] [blame] | 1352 | } |
Malcolm Chen | c1873af | 2018-09-24 20:01:32 -0700 | [diff] [blame] | 1353 | |
Jordan Liu | fd59a81 | 2018-10-23 14:17:39 -0700 | [diff] [blame] | 1354 | public void onCallAttributesChanged(CallAttributes callAttributes) { |
| 1355 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1356 | if (psl == null) return; |
| 1357 | |
| 1358 | Binder.withCleanCallingIdentity( |
| 1359 | () -> mExecutor.execute(() -> psl.onCallAttributesChanged(callAttributes))); |
| 1360 | } |
| 1361 | |
Malcolm Chen | 026451d | 2019-02-14 19:50:19 -0800 | [diff] [blame] | 1362 | public void onActiveDataSubIdChanged(int subId) { |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1363 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1364 | if (psl == null) return; |
| 1365 | |
| 1366 | Binder.withCleanCallingIdentity( |
Nazanin Bakhshi | 026c42d | 2019-03-01 10:10:22 -0800 | [diff] [blame] | 1367 | () -> mExecutor.execute(() -> psl.onActiveDataSubscriptionIdChanged(subId))); |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1368 | } |
chen xu | 0f49468 | 2019-01-24 14:14:13 -0800 | [diff] [blame] | 1369 | |
| 1370 | public void onImsCallDisconnectCauseChanged(ImsReasonInfo disconnectCause) { |
| 1371 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1372 | if (psl == null) return; |
| 1373 | |
| 1374 | Binder.withCleanCallingIdentity( |
| 1375 | () -> mExecutor.execute( |
| 1376 | () -> psl.onImsCallDisconnectCauseChanged(disconnectCause))); |
| 1377 | |
| 1378 | } |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1379 | |
| 1380 | public void onRegistrationFailed(@NonNull CellIdentity cellIdentity, |
Chen Xu | 546ce5e | 2020-01-10 08:38:31 -0800 | [diff] [blame] | 1381 | @NonNull String chosenPlmn, int domain, |
Nathan Harold | 5e6e983 | 2019-12-17 13:06:54 -0800 | [diff] [blame] | 1382 | int causeCode, int additionalCauseCode) { |
| 1383 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1384 | if (psl == null) return; |
| 1385 | |
| 1386 | Binder.withCleanCallingIdentity( |
| 1387 | () -> mExecutor.execute(() -> psl.onRegistrationFailed( |
| 1388 | cellIdentity, chosenPlmn, domain, causeCode, additionalCauseCode))); |
| 1389 | // default implementation empty |
| 1390 | } |
Nathan Harold | c564b1d | 2019-12-26 17:10:15 -0800 | [diff] [blame] | 1391 | |
| 1392 | public void onBarringInfoChanged(BarringInfo barringInfo) { |
| 1393 | PhoneStateListener psl = mPhoneStateListenerWeakRef.get(); |
| 1394 | if (psl == null) return; |
| 1395 | |
| 1396 | Binder.withCleanCallingIdentity( |
| 1397 | () -> mExecutor.execute(() -> psl.onBarringInfoChanged(barringInfo))); |
| 1398 | } |
fionaxu | f5d7c58 | 2016-03-22 15:09:55 -0700 | [diff] [blame] | 1399 | } |
| 1400 | |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 1401 | |
| 1402 | private void log(String s) { |
| 1403 | Rlog.d(LOG_TAG, s); |
| 1404 | } |
Nathan Harold | 7581efd | 2018-10-25 10:32:10 -0700 | [diff] [blame] | 1405 | } |