The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.server; |
| 18 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 19 | import android.app.ActivityManager; |
| 20 | import android.content.BroadcastReceiver; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.Intent; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 23 | import android.content.IntentFilter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.content.pm.PackageManager; |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 25 | import android.net.LinkProperties; |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 26 | import android.net.NetworkCapabilities; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.os.Binder; |
| 28 | import android.os.Bundle; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 29 | import android.os.Handler; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | import android.os.IBinder; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 31 | import android.os.Message; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | import android.os.RemoteException; |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 33 | import android.os.UserHandle; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | import android.telephony.CellLocation; |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 35 | import android.telephony.DataConnectionRealTimeInfo; |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 36 | import android.telephony.Rlog; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 37 | import android.telephony.TelephonyManager; |
| 38 | import android.telephony.SubscriptionManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | import android.telephony.PhoneStateListener; |
| 40 | import android.telephony.ServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 41 | import android.telephony.SignalStrength; |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 42 | import android.telephony.CellInfo; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 43 | import android.telephony.VoLteServiceState; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | import android.telephony.TelephonyManager; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 45 | import android.telephony.DisconnectCause; |
| 46 | import android.telephony.PreciseCallState; |
| 47 | import android.telephony.PreciseDataConnectionState; |
| 48 | import android.telephony.PreciseDisconnectCause; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | import android.text.TextUtils; |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 50 | import android.text.format.Time; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | |
| 52 | import java.util.ArrayList; |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 53 | import java.util.Calendar; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 54 | import java.util.List; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | import java.io.FileDescriptor; |
| 56 | import java.io.PrintWriter; |
| 57 | |
| 58 | import com.android.internal.app.IBatteryStats; |
| 59 | import com.android.internal.telephony.ITelephonyRegistry; |
| 60 | import com.android.internal.telephony.IPhoneStateListener; |
| 61 | import com.android.internal.telephony.DefaultPhoneNotifier; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 62 | import com.android.internal.telephony.PhoneConstants; |
Wink Saville | c9330dd | 2011-01-12 13:37:38 -0800 | [diff] [blame] | 63 | import com.android.internal.telephony.ServiceStateTracker; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 64 | import com.android.internal.telephony.TelephonyIntents; |
| 65 | import com.android.server.am.BatteryStatsService; |
| 66 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 68 | * Since phone process can be restarted, this class provides a centralized place |
| 69 | * that applications can register and be called back from. |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 70 | * |
| 71 | * Change-Id: I450c968bda93767554b5188ee63e10c9f43c5aa4 fixes bugs 16148026 |
| 72 | * and 15973975 by saving the phoneId of the registrant and then using the |
| 73 | * phoneId when deciding to to make a callback. This is necessary because |
| 74 | * a subId changes from to a dummy value when a SIM is removed and thus won't |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 75 | * compare properly. Because SubscriptionManager.getPhoneId(int subId) handles |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 76 | * the dummy value conversion we properly do the callbacks. |
| 77 | * |
| 78 | * Eventually we may want to remove the notion of dummy value but for now this |
| 79 | * looks like the best approach. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | */ |
| 81 | class TelephonyRegistry extends ITelephonyRegistry.Stub { |
| 82 | private static final String TAG = "TelephonyRegistry"; |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 83 | private static final boolean DBG = false; // STOPSHIP if true |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 84 | private static final boolean DBG_LOC = false; // STOPSHIP if true |
Wink Saville | 6d13bc8 | 2014-08-01 11:13:40 -0700 | [diff] [blame] | 85 | private static final boolean VDBG = false; // STOPSHIP if true |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | |
| 87 | private static class Record { |
| 88 | String pkgForDebug; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 89 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 90 | IBinder binder; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 91 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 92 | IPhoneStateListener callback; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 93 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 94 | int callerUid; |
| 95 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | int events; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 97 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 98 | int subId; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 99 | |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 100 | int phoneId; |
| 101 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 102 | @Override |
| 103 | public String toString() { |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 104 | return "{pkgForDebug=" + pkgForDebug + " callerUid=" + callerUid + " subId=" + subId + |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 105 | " phoneId=" + phoneId + " events=" + Integer.toHexString(events) + "}"; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 106 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | private final Context mContext; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 110 | |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 111 | // access should be inside synchronized (mRecords) for these two fields |
| 112 | private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>(); |
| 113 | private final ArrayList<Record> mRecords = new ArrayList<Record>(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 114 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 115 | private final IBatteryStats mBatteryStats; |
| 116 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 117 | private int mNumPhones; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 118 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 119 | private int[] mCallState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 120 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 121 | private String[] mCallIncomingNumber; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 122 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 123 | private ServiceState[] mServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 124 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 125 | private SignalStrength[] mSignalStrength; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 126 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 127 | private boolean[] mMessageWaiting; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 128 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 129 | private boolean[] mCallForwarding; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 130 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 131 | private int[] mDataActivity; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 132 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 133 | private int[] mDataConnectionState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 134 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 135 | private boolean[] mDataConnectionPossible; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 136 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 137 | private String[] mDataConnectionReason; |
| 138 | |
| 139 | private String[] mDataConnectionApn; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 140 | |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 141 | private ArrayList<String> mConnectedApns; |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 142 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 143 | private LinkProperties[] mDataConnectionLinkProperties; |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 144 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 145 | private NetworkCapabilities[] mDataConnectionNetworkCapabilities; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 146 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 147 | private Bundle[] mCellLocation; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 148 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 149 | private int[] mDataConnectionNetworkType; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 150 | |
Wink Saville | c9330dd | 2011-01-12 13:37:38 -0800 | [diff] [blame] | 151 | private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN; |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 152 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 153 | private ArrayList<List<CellInfo>> mCellInfo = null; |
| 154 | |
| 155 | private VoLteServiceState mVoLteServiceState = new VoLteServiceState(); |
| 156 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 157 | private int mDefaultSubId = SubscriptionManager.INVALID_SUB_ID; |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 158 | |
| 159 | private int mDefaultPhoneId = SubscriptionManager.INVALID_PHONE_ID; |
| 160 | |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 161 | private DataConnectionRealTimeInfo mDcRtInfo = new DataConnectionRealTimeInfo(); |
| 162 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 163 | private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 164 | |
| 165 | private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 166 | |
| 167 | private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 168 | |
| 169 | private PreciseCallState mPreciseCallState = new PreciseCallState(); |
| 170 | |
| 171 | private PreciseDataConnectionState mPreciseDataConnectionState = |
| 172 | new PreciseDataConnectionState(); |
| 173 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 174 | static final int PHONE_STATE_PERMISSION_MASK = |
| 175 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | |
| 176 | PhoneStateListener.LISTEN_CALL_STATE | |
| 177 | PhoneStateListener.LISTEN_DATA_ACTIVITY | |
| 178 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 179 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR | |
| 180 | PhoneStateListener.LISTEN_VOLTE_STATE;; |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 181 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 182 | static final int PRECISE_PHONE_STATE_PERMISSION_MASK = |
| 183 | PhoneStateListener.LISTEN_PRECISE_CALL_STATE | |
| 184 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; |
| 185 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 186 | private static final int MSG_USER_SWITCHED = 1; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 187 | private static final int MSG_UPDATE_DEFAULT_SUB = 2; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 188 | |
| 189 | private final Handler mHandler = new Handler() { |
| 190 | @Override |
| 191 | public void handleMessage(Message msg) { |
| 192 | switch (msg.what) { |
| 193 | case MSG_USER_SWITCHED: { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 194 | if (VDBG) log("MSG_USER_SWITCHED userId=" + msg.arg1); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 195 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
| 196 | for (int sub = 0; sub < numPhones; sub++) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 197 | TelephonyRegistry.this.notifyCellLocationForSubscriber(sub, |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 198 | mCellLocation[sub]); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 199 | } |
| 200 | break; |
| 201 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 202 | case MSG_UPDATE_DEFAULT_SUB: { |
| 203 | int newDefaultPhoneId = msg.arg1; |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 204 | int newDefaultSubId = (Integer)(msg.obj); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 205 | if (VDBG) { |
| 206 | log("MSG_UPDATE_DEFAULT_SUB:current mDefaultSubId=" + mDefaultSubId |
| 207 | + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= " |
| 208 | + newDefaultSubId + " newDefaultPhoneId=" + newDefaultPhoneId); |
| 209 | } |
| 210 | |
| 211 | //Due to possible risk condition,(notify call back using the new |
| 212 | //defaultSubId comes before new defaultSubId update) we need to recall all |
| 213 | //possible missed notify callback |
| 214 | synchronized (mRecords) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 215 | for (Record r : mRecords) { |
| 216 | if(r.subId == SubscriptionManager.DEFAULT_SUB_ID) { |
| 217 | checkPossibleMissNotify(r, newDefaultPhoneId); |
| 218 | } |
| 219 | } |
| 220 | handleRemoveListLocked(); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 221 | } |
| 222 | mDefaultSubId = newDefaultSubId; |
| 223 | mDefaultPhoneId = newDefaultPhoneId; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 224 | } |
| 225 | } |
| 226 | } |
| 227 | }; |
| 228 | |
| 229 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 230 | @Override |
| 231 | public void onReceive(Context context, Intent intent) { |
| 232 | String action = intent.getAction(); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 233 | if (VDBG) log("mBroadcastReceiver: action=" + action); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 234 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 235 | int userHandle = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 236 | if (DBG) log("onReceive: userHandle=" + userHandle); |
Wink Saville | eeacf93 | 2014-06-18 01:07:10 -0700 | [diff] [blame] | 237 | mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, userHandle, 0)); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 238 | } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) { |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 239 | Integer newDefaultSubIdObj = new Integer(intent.getIntExtra( |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 240 | PhoneConstants.SUBSCRIPTION_KEY, SubscriptionManager.getDefaultSubId())); |
| 241 | int newDefaultPhoneId = intent.getIntExtra(PhoneConstants.SLOT_KEY, |
| 242 | SubscriptionManager.getPhoneId(mDefaultSubId)); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 243 | if (DBG) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 244 | log("onReceive:current mDefaultSubId=" + mDefaultSubId |
| 245 | + " current mDefaultPhoneId=" + mDefaultPhoneId + " newDefaultSubId= " |
| 246 | + newDefaultSubIdObj + " newDefaultPhoneId=" + newDefaultPhoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 247 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 248 | |
| 249 | if(validatePhoneId(newDefaultPhoneId) && (newDefaultSubIdObj.equals(mDefaultSubId) |
| 250 | || (newDefaultPhoneId != mDefaultPhoneId))) { |
| 251 | mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB, |
| 252 | newDefaultPhoneId, 0, newDefaultSubIdObj)); |
| 253 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | }; |
| 257 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 258 | // we keep a copy of all of the state so we can send it out when folks |
| 259 | // register for it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 260 | // |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 261 | // In these calls we call with the lock held. This is safe becasuse remote |
| 262 | // calls go through a oneway interface and local calls going through a |
| 263 | // handler before they get to app code. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 264 | |
| 265 | TelephonyRegistry(Context context) { |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 266 | CellLocation location = CellLocation.getEmpty(); |
| 267 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 268 | mContext = context; |
| 269 | mBatteryStats = BatteryStatsService.getService(); |
| 270 | mConnectedApns = new ArrayList<String>(); |
| 271 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 272 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 273 | if (DBG) log("TelephonyRegistor: ctor numPhones=" + numPhones); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 274 | mNumPhones = numPhones; |
| 275 | mCallState = new int[numPhones]; |
| 276 | mDataActivity = new int[numPhones]; |
| 277 | mDataConnectionState = new int[numPhones]; |
| 278 | mDataConnectionNetworkType = new int[numPhones]; |
| 279 | mCallIncomingNumber = new String[numPhones]; |
| 280 | mServiceState = new ServiceState[numPhones]; |
| 281 | mSignalStrength = new SignalStrength[numPhones]; |
| 282 | mMessageWaiting = new boolean[numPhones]; |
| 283 | mDataConnectionPossible = new boolean[numPhones]; |
| 284 | mDataConnectionReason = new String[numPhones]; |
| 285 | mDataConnectionApn = new String[numPhones]; |
| 286 | mCallForwarding = new boolean[numPhones]; |
| 287 | mCellLocation = new Bundle[numPhones]; |
| 288 | mDataConnectionLinkProperties = new LinkProperties[numPhones]; |
| 289 | mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones]; |
| 290 | mCellInfo = new ArrayList<List<CellInfo>>(); |
| 291 | for (int i = 0; i < numPhones; i++) { |
| 292 | mCallState[i] = TelephonyManager.CALL_STATE_IDLE; |
| 293 | mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; |
| 294 | mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN; |
| 295 | mCallIncomingNumber[i] = ""; |
| 296 | mServiceState[i] = new ServiceState(); |
| 297 | mSignalStrength[i] = new SignalStrength(); |
| 298 | mMessageWaiting[i] = false; |
| 299 | mCallForwarding[i] = false; |
| 300 | mDataConnectionPossible[i] = false; |
| 301 | mDataConnectionReason[i] = ""; |
| 302 | mDataConnectionApn[i] = ""; |
| 303 | mCellLocation[i] = new Bundle(); |
| 304 | mCellInfo.add(i, null); |
| 305 | } |
| 306 | |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 307 | // Note that location can be null for non-phone builds like |
| 308 | // like the generic one. |
| 309 | if (location != null) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 310 | for (int i = 0; i < numPhones; i++) { |
| 311 | location.fillInNotifierBundle(mCellLocation[i]); |
| 312 | } |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 313 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 314 | mConnectedApns = new ArrayList<String>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 315 | } |
| 316 | |
Svetoslav Ganov | a002715 | 2013-06-25 14:59:53 -0700 | [diff] [blame] | 317 | public void systemRunning() { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 318 | // Watch for interesting updates |
| 319 | final IntentFilter filter = new IntentFilter(); |
| 320 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
| 321 | filter.addAction(Intent.ACTION_USER_REMOVED); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 322 | filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 323 | log("systemRunning register for intents"); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 324 | mContext.registerReceiver(mBroadcastReceiver, filter); |
| 325 | } |
| 326 | |
| 327 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 328 | public void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 329 | boolean notifyNow) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 330 | listenForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, pkgForDebug, callback, events, |
| 331 | notifyNow); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 335 | public void listenForSubscriber(int subId, String pkgForDebug, IPhoneStateListener callback, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 336 | int events, boolean notifyNow) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 337 | listen(pkgForDebug, callback, events, notifyNow, subId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | private void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 341 | boolean notifyNow, int subId) { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 342 | int callerUid = UserHandle.getCallingUserId(); |
| 343 | int myUid = UserHandle.myUserId(); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 344 | if (VDBG) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 345 | log("listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 346 | + " notifyNow=" + notifyNow + " subId=" + subId + " myUid=" + myUid |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 347 | + " callerUid=" + callerUid); |
| 348 | } |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 349 | |
| 350 | if (events != PhoneStateListener.LISTEN_NONE) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 351 | /* Checks permission and throws Security exception */ |
| 352 | checkListenerPermission(events); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | synchronized (mRecords) { |
| 354 | // register |
| 355 | Record r = null; |
| 356 | find_and_add: { |
| 357 | IBinder b = callback.asBinder(); |
| 358 | final int N = mRecords.size(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 359 | for (int i = 0; i < N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 360 | r = mRecords.get(i); |
| 361 | if (b == r.binder) { |
| 362 | break find_and_add; |
| 363 | } |
| 364 | } |
| 365 | r = new Record(); |
| 366 | r.binder = b; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 367 | mRecords.add(r); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 368 | if (DBG) log("listen: add new record"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 369 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 370 | |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 371 | r.callback = callback; |
| 372 | r.pkgForDebug = pkgForDebug; |
| 373 | r.callerUid = callerUid; |
| 374 | // Legacy applications pass SubscriptionManager.DEFAULT_SUB_ID, |
| 375 | // force all illegal subId to SubscriptionManager.DEFAULT_SUB_ID |
| 376 | if (!SubscriptionManager.isValidSubId(subId)) { |
| 377 | r.subId = SubscriptionManager.DEFAULT_SUB_ID; |
| 378 | } else {//APP specify subID |
| 379 | r.subId = subId; |
| 380 | } |
| 381 | r.phoneId = SubscriptionManager.getPhoneId(r.subId); |
| 382 | |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 383 | int phoneId = r.phoneId; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 384 | r.events = events; |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 385 | if (DBG) { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 386 | log("listen: Register r=" + r + " r.subId=" + r.subId + " phoneId=" + phoneId); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 387 | } |
| 388 | if (VDBG) toStringLogSSC("listen"); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 389 | if (notifyNow && validatePhoneId(phoneId)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 391 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 392 | if (VDBG) log("listen: call onSSC state=" + mServiceState[phoneId]); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 393 | r.callback.onServiceStateChanged( |
| 394 | new ServiceState(mServiceState[phoneId])); |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 395 | } catch (RemoteException ex) { |
| 396 | remove(r.binder); |
| 397 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 398 | } |
| 399 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 400 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 401 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 402 | .getGsmSignalStrength(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 403 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 404 | : gsmSignalStrength)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 405 | } catch (RemoteException ex) { |
| 406 | remove(r.binder); |
| 407 | } |
| 408 | } |
| 409 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 410 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 411 | r.callback.onMessageWaitingIndicatorChanged( |
| 412 | mMessageWaiting[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 413 | } catch (RemoteException ex) { |
| 414 | remove(r.binder); |
| 415 | } |
| 416 | } |
| 417 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 418 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 419 | r.callback.onCallForwardingIndicatorChanged( |
| 420 | mCallForwarding[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 421 | } catch (RemoteException ex) { |
| 422 | remove(r.binder); |
| 423 | } |
| 424 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 425 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 426 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 427 | if (DBG_LOC) log("listen: mCellLocation = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 428 | + mCellLocation[phoneId]); |
| 429 | r.callback.onCellLocationChanged( |
| 430 | new Bundle(mCellLocation[phoneId])); |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 431 | } catch (RemoteException ex) { |
| 432 | remove(r.binder); |
| 433 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | } |
| 435 | if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 436 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 437 | r.callback.onCallStateChanged(mCallState[phoneId], |
| 438 | mCallIncomingNumber[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 439 | } catch (RemoteException ex) { |
| 440 | remove(r.binder); |
| 441 | } |
| 442 | } |
| 443 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 444 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 445 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 446 | mDataConnectionNetworkType[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 447 | } catch (RemoteException ex) { |
| 448 | remove(r.binder); |
| 449 | } |
| 450 | } |
| 451 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 452 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 453 | r.callback.onDataActivity(mDataActivity[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 454 | } catch (RemoteException ex) { |
| 455 | remove(r.binder); |
| 456 | } |
| 457 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 458 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 459 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 460 | r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 461 | } catch (RemoteException ex) { |
| 462 | remove(r.binder); |
| 463 | } |
| 464 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 465 | if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 466 | try { |
| 467 | r.callback.onOtaspChanged(mOtaspMode); |
| 468 | } catch (RemoteException ex) { |
| 469 | remove(r.binder); |
| 470 | } |
| 471 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 472 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 473 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 474 | if (DBG_LOC) log("listen: mCellInfo[" + phoneId + "] = " |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 475 | + mCellInfo.get(phoneId)); |
| 476 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 477 | } catch (RemoteException ex) { |
| 478 | remove(r.binder); |
| 479 | } |
| 480 | } |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 481 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) { |
| 482 | try { |
| 483 | r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo); |
| 484 | } catch (RemoteException ex) { |
| 485 | remove(r.binder); |
| 486 | } |
| 487 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 488 | if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 489 | try { |
| 490 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 491 | } catch (RemoteException ex) { |
| 492 | remove(r.binder); |
| 493 | } |
| 494 | } |
| 495 | if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 496 | try { |
| 497 | r.callback.onPreciseDataConnectionStateChanged( |
| 498 | mPreciseDataConnectionState); |
| 499 | } catch (RemoteException ex) { |
| 500 | remove(r.binder); |
| 501 | } |
| 502 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | } |
| 504 | } |
| 505 | } else { |
xinhe | 75c2c15 | 2014-10-16 11:49:45 -0700 | [diff] [blame] | 506 | if(DBG) log("listen: Unregister"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | remove(callback.asBinder()); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | private void remove(IBinder binder) { |
| 512 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 513 | final int recordCount = mRecords.size(); |
| 514 | for (int i = 0; i < recordCount; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | if (mRecords.get(i).binder == binder) { |
| 516 | mRecords.remove(i); |
| 517 | return; |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | public void notifyCallState(int state, String incomingNumber) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 524 | if (!checkNotifyPermission("notifyCallState()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 525 | return; |
| 526 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 527 | |
| 528 | if (VDBG) { |
| 529 | log("notifyCallState: state=" + state + " incomingNumber=" + incomingNumber); |
| 530 | } |
| 531 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 532 | synchronized (mRecords) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 533 | for (Record r : mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 534 | if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 535 | (r.subId == SubscriptionManager.DEFAULT_SUB_ID)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 536 | try { |
| 537 | r.callback.onCallStateChanged(state, incomingNumber); |
| 538 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 539 | mRemoveList.add(r.binder); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 543 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 545 | broadcastCallStateChanged(state, incomingNumber, SubscriptionManager.DEFAULT_SUB_ID); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 546 | } |
| 547 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 548 | public void notifyCallStateForSubscriber(int subId, int state, String incomingNumber) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 549 | if (!checkNotifyPermission("notifyCallState()")) { |
| 550 | return; |
| 551 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 552 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 553 | log("notifyCallStateForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 554 | + " state=" + state + " incomingNumber=" + incomingNumber); |
| 555 | } |
| 556 | synchronized (mRecords) { |
| 557 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 558 | if (validatePhoneId(phoneId)) { |
| 559 | mCallState[phoneId] = state; |
| 560 | mCallIncomingNumber[phoneId] = incomingNumber; |
| 561 | for (Record r : mRecords) { |
| 562 | if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 563 | (r.subId == subId) && |
| 564 | (r.subId != SubscriptionManager.DEFAULT_SUB_ID)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 565 | try { |
| 566 | r.callback.onCallStateChanged(state, incomingNumber); |
| 567 | } catch (RemoteException ex) { |
| 568 | mRemoveList.add(r.binder); |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | handleRemoveListLocked(); |
| 574 | } |
| 575 | broadcastCallStateChanged(state, incomingNumber, subId); |
| 576 | } |
| 577 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 578 | public void notifyServiceStateForPhoneId(int phoneId, int subId, ServiceState state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 579 | if (!checkNotifyPermission("notifyServiceState()")){ |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 580 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 581 | } |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 582 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 583 | synchronized (mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 584 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 585 | log("notifyServiceStateForSubscriber: subId=" + subId + " phoneId=" + phoneId |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 586 | + " state=" + state); |
| 587 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 588 | if (validatePhoneId(phoneId)) { |
| 589 | mServiceState[phoneId] = state; |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 590 | logServiceStateChanged("notifyServiceStateForSubscriber", subId, phoneId, state); |
| 591 | if (VDBG) toStringLogSSC("notifyServiceStateForSubscriber"); |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 592 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 593 | for (Record r : mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 594 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 595 | log("notifyServiceStateForSubscriber: r=" + r + " subId=" + subId |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 596 | + " phoneId=" + phoneId + " state=" + state); |
| 597 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 598 | if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 599 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 600 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 601 | if (DBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 602 | log("notifyServiceStateForSubscriber: callback.onSSC r=" + r |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 603 | + " subId=" + subId + " phoneId=" + phoneId |
| 604 | + " state=" + state); |
| 605 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 606 | r.callback.onServiceStateChanged(new ServiceState(state)); |
| 607 | } catch (RemoteException ex) { |
| 608 | mRemoveList.add(r.binder); |
| 609 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 610 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 612 | } else { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 613 | log("notifyServiceStateForSubscriber: INVALID phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 614 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 615 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 616 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 617 | broadcastServiceStateChanged(state, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 618 | } |
| 619 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 620 | public void notifySignalStrength(SignalStrength signalStrength) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 621 | notifySignalStrengthForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, signalStrength); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 622 | } |
| 623 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 624 | public void notifySignalStrengthForSubscriber(int subId, SignalStrength signalStrength) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 625 | if (!checkNotifyPermission("notifySignalStrength()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 626 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 627 | } |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 628 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 629 | log("notifySignalStrengthForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 630 | + " signalStrength=" + signalStrength); |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 631 | toStringLogSSC("notifySignalStrengthForSubscriber"); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 632 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 633 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 634 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 635 | if (validatePhoneId(phoneId)) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 636 | if (VDBG) log("notifySignalStrengthForSubscriber: valid phoneId=" + phoneId); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 637 | mSignalStrength[phoneId] = signalStrength; |
| 638 | for (Record r : mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 639 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 640 | log("notifySignalStrengthForSubscriber: r=" + r + " subId=" + subId |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 641 | + " phoneId=" + phoneId + " ss=" + signalStrength); |
| 642 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 643 | if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 644 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 645 | try { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 646 | if (DBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 647 | log("notifySignalStrengthForSubscriber: callback.onSsS r=" + r |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 648 | + " subId=" + subId + " phoneId=" + phoneId |
| 649 | + " ss=" + signalStrength); |
| 650 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 651 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 652 | } catch (RemoteException ex) { |
| 653 | mRemoveList.add(r.binder); |
| 654 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 655 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 656 | if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 657 | subIdMatch(r.subId, subId)){ |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 658 | try { |
| 659 | int gsmSignalStrength = signalStrength.getGsmSignalStrength(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 660 | int ss = (gsmSignalStrength == 99 ? -1 : gsmSignalStrength); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 661 | if (DBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 662 | log("notifySignalStrengthForSubscriber: callback.onSS r=" + r |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 663 | + " subId=" + subId + " phoneId=" + phoneId |
| 664 | + " gsmSS=" + gsmSignalStrength + " ss=" + ss); |
| 665 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 666 | r.callback.onSignalStrengthChanged(ss); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 667 | } catch (RemoteException ex) { |
| 668 | mRemoveList.add(r.binder); |
| 669 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 670 | } |
| 671 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 672 | } else { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 673 | log("notifySignalStrengthForSubscriber: invalid phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 674 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 675 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 676 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 677 | broadcastSignalStrengthChanged(signalStrength, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 678 | } |
| 679 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 680 | public void notifyCellInfo(List<CellInfo> cellInfo) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 681 | notifyCellInfoForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellInfo); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 684 | public void notifyCellInfoForSubscriber(int subId, List<CellInfo> cellInfo) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 685 | if (!checkNotifyPermission("notifyCellInfo()")) { |
| 686 | return; |
| 687 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 688 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 689 | log("notifyCellInfoForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 690 | + " cellInfo=" + cellInfo); |
| 691 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 692 | |
| 693 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 694 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 695 | if (validatePhoneId(phoneId)) { |
| 696 | mCellInfo.set(phoneId, cellInfo); |
| 697 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 698 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 699 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 700 | try { |
| 701 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 702 | log("notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 703 | } |
| 704 | r.callback.onCellInfoChanged(cellInfo); |
| 705 | } catch (RemoteException ex) { |
| 706 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 707 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 708 | } |
| 709 | } |
| 710 | } |
| 711 | handleRemoveListLocked(); |
| 712 | } |
| 713 | } |
| 714 | |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 715 | public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) { |
| 716 | if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) { |
| 717 | return; |
| 718 | } |
| 719 | |
| 720 | synchronized (mRecords) { |
| 721 | mDcRtInfo = dcRtInfo; |
| 722 | for (Record r : mRecords) { |
| 723 | if (validateEventsAndUserLocked(r, |
| 724 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) { |
| 725 | try { |
| 726 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 727 | log("notifyDataConnectionRealTimeInfo: mDcRtInfo=" |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 728 | + mDcRtInfo + " r=" + r); |
| 729 | } |
| 730 | r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo); |
| 731 | } catch (RemoteException ex) { |
| 732 | mRemoveList.add(r.binder); |
| 733 | } |
| 734 | } |
| 735 | } |
| 736 | handleRemoveListLocked(); |
| 737 | } |
| 738 | } |
| 739 | |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 740 | @Override |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 741 | public void notifyMessageWaitingChangedForPhoneId(int phoneId, int subId, boolean mwi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 742 | if (!checkNotifyPermission("notifyMessageWaitingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 743 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 744 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 745 | if (VDBG) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 746 | log("notifyMessageWaitingChangedForSubscriberPhoneID: subId=" + phoneId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 747 | + " mwi=" + mwi); |
| 748 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 749 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 750 | if (validatePhoneId(phoneId)) { |
| 751 | mMessageWaiting[phoneId] = mwi; |
| 752 | for (Record r : mRecords) { |
| 753 | if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 754 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 755 | try { |
| 756 | r.callback.onMessageWaitingIndicatorChanged(mwi); |
| 757 | } catch (RemoteException ex) { |
| 758 | mRemoveList.add(r.binder); |
| 759 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 760 | } |
| 761 | } |
| 762 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 763 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 764 | } |
| 765 | } |
| 766 | |
| 767 | public void notifyCallForwardingChanged(boolean cfi) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 768 | notifyCallForwardingChangedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cfi); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 769 | } |
| 770 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 771 | public void notifyCallForwardingChangedForSubscriber(int subId, boolean cfi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 772 | if (!checkNotifyPermission("notifyCallForwardingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 773 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 774 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 775 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 776 | log("notifyCallForwardingChangedForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 777 | + " cfi=" + cfi); |
| 778 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 779 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 780 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 781 | if (validatePhoneId(phoneId)) { |
| 782 | mCallForwarding[phoneId] = cfi; |
| 783 | for (Record r : mRecords) { |
| 784 | if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 785 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 786 | try { |
| 787 | r.callback.onCallForwardingIndicatorChanged(cfi); |
| 788 | } catch (RemoteException ex) { |
| 789 | mRemoveList.add(r.binder); |
| 790 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 791 | } |
| 792 | } |
| 793 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 794 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 795 | } |
| 796 | } |
| 797 | |
| 798 | public void notifyDataActivity(int state) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 799 | notifyDataActivityForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 800 | } |
| 801 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 802 | public void notifyDataActivityForSubscriber(int subId, int state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 803 | if (!checkNotifyPermission("notifyDataActivity()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 804 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 805 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 806 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 807 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 808 | mDataActivity[phoneId] = state; |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 809 | for (Record r : mRecords) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 810 | if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 811 | try { |
| 812 | r.callback.onDataActivity(state); |
| 813 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 814 | mRemoveList.add(r.binder); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 815 | } |
| 816 | } |
| 817 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 818 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 819 | } |
| 820 | } |
| 821 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 822 | public void notifyDataConnection(int state, boolean isDataConnectivityPossible, |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 823 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 824 | NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 825 | notifyDataConnectionForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, state, |
| 826 | isDataConnectivityPossible,reason, apn, apnType, linkProperties, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 827 | networkCapabilities, networkType, roaming); |
| 828 | } |
| 829 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 830 | public void notifyDataConnectionForSubscriber(int subId, int state, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 831 | boolean isDataConnectivityPossible, String reason, String apn, String apnType, |
| 832 | LinkProperties linkProperties, NetworkCapabilities networkCapabilities, |
| 833 | int networkType, boolean roaming) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 834 | if (!checkNotifyPermission("notifyDataConnection()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 835 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 836 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 837 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 838 | log("notifyDataConnectionForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 839 | + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible |
| 840 | + " reason='" + reason |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 841 | + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType |
| 842 | + " mRecords.size()=" + mRecords.size() + " mRecords=" + mRecords); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 843 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 844 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 845 | int phoneId = SubscriptionManager.getPhoneId(subId); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 846 | boolean modified = false; |
| 847 | if (state == TelephonyManager.DATA_CONNECTED) { |
| 848 | if (!mConnectedApns.contains(apnType)) { |
| 849 | mConnectedApns.add(apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 850 | if (mDataConnectionState[phoneId] != state) { |
| 851 | mDataConnectionState[phoneId] = state; |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 852 | modified = true; |
| 853 | } |
| 854 | } |
| 855 | } else { |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 856 | if (mConnectedApns.remove(apnType)) { |
| 857 | if (mConnectedApns.isEmpty()) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 858 | mDataConnectionState[phoneId] = state; |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 859 | modified = true; |
| 860 | } else { |
| 861 | // leave mDataConnectionState as is and |
| 862 | // send out the new status for the APN in question. |
| 863 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 864 | } |
| 865 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 866 | mDataConnectionPossible[phoneId] = isDataConnectivityPossible; |
| 867 | mDataConnectionReason[phoneId] = reason; |
| 868 | mDataConnectionLinkProperties[phoneId] = linkProperties; |
| 869 | mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities; |
| 870 | if (mDataConnectionNetworkType[phoneId] != networkType) { |
| 871 | mDataConnectionNetworkType[phoneId] = networkType; |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 872 | // need to tell registered listeners about the new network type |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 873 | modified = true; |
| 874 | } |
| 875 | if (modified) { |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 876 | if (DBG) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 877 | log("onDataConnectionStateChanged(" + mDataConnectionState[phoneId] |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 878 | + ", " + mDataConnectionNetworkType[phoneId] + ")"); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 879 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 880 | for (Record r : mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 881 | if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 882 | subIdMatch(r.subId, subId)) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 883 | try { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 884 | log("Notify data connection state changed on sub: " + |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 885 | subId); |
| 886 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 887 | mDataConnectionNetworkType[phoneId]); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 888 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 889 | mRemoveList.add(r.binder); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 890 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 891 | } |
| 892 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 893 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 894 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 895 | mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, |
| 896 | apnType, apn, reason, linkProperties, ""); |
| 897 | for (Record r : mRecords) { |
| 898 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 899 | try { |
| 900 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 901 | } catch (RemoteException ex) { |
| 902 | mRemoveList.add(r.binder); |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 907 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 908 | broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 909 | apnType, linkProperties, networkCapabilities, roaming, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 910 | broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, |
| 911 | linkProperties, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 912 | } |
| 913 | |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 914 | public void notifyDataConnectionFailed(String reason, String apnType) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 915 | notifyDataConnectionFailedForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, |
| 916 | reason, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 917 | } |
| 918 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 919 | public void notifyDataConnectionFailedForSubscriber(int subId, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 920 | String reason, String apnType) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 921 | if (!checkNotifyPermission("notifyDataConnectionFailed()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 922 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 923 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 924 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 925 | log("notifyDataConnectionFailedForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 926 | + " reason=" + reason + " apnType=" + apnType); |
| 927 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 928 | synchronized (mRecords) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 929 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 930 | TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 931 | apnType, "", reason, null, ""); |
| 932 | for (Record r : mRecords) { |
| 933 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 934 | try { |
| 935 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 936 | } catch (RemoteException ex) { |
| 937 | mRemoveList.add(r.binder); |
| 938 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 939 | } |
| 940 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 941 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 942 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 943 | broadcastDataConnectionFailed(reason, apnType, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 944 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 945 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 946 | } |
| 947 | |
| 948 | public void notifyCellLocation(Bundle cellLocation) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 949 | notifyCellLocationForSubscriber(SubscriptionManager.DEFAULT_SUB_ID, cellLocation); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 950 | } |
| 951 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 952 | public void notifyCellLocationForSubscriber(int subId, Bundle cellLocation) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 953 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 954 | + " cellLocation=" + cellLocation); |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 955 | if (!checkNotifyPermission("notifyCellLocation()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 956 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 957 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 958 | if (VDBG) { |
Wink Saville | bc02727 | 2014-09-08 14:50:58 -0700 | [diff] [blame] | 959 | log("notifyCellLocationForSubscriber: subId=" + subId |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 960 | + " cellLocation=" + cellLocation); |
| 961 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 962 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 963 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 964 | if (validatePhoneId(phoneId)) { |
| 965 | mCellLocation[phoneId] = cellLocation; |
| 966 | for (Record r : mRecords) { |
xinhe | 43c5029 | 2014-09-18 17:56:48 -0700 | [diff] [blame] | 967 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) && |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 968 | subIdMatch(r.subId, subId)) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 969 | try { |
| 970 | if (DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 971 | log("notifyCellLocation: cellLocation=" + cellLocation |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 972 | + " r=" + r); |
| 973 | } |
| 974 | r.callback.onCellLocationChanged(new Bundle(cellLocation)); |
| 975 | } catch (RemoteException ex) { |
| 976 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 977 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 978 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 979 | } |
| 980 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 981 | handleRemoveListLocked(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 982 | } |
| 983 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 984 | |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 985 | public void notifyOtaspChanged(int otaspMode) { |
| 986 | if (!checkNotifyPermission("notifyOtaspChanged()" )) { |
| 987 | return; |
| 988 | } |
| 989 | synchronized (mRecords) { |
| 990 | mOtaspMode = otaspMode; |
| 991 | for (Record r : mRecords) { |
| 992 | if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 993 | try { |
| 994 | r.callback.onOtaspChanged(otaspMode); |
| 995 | } catch (RemoteException ex) { |
| 996 | mRemoveList.add(r.binder); |
| 997 | } |
| 998 | } |
| 999 | } |
| 1000 | handleRemoveListLocked(); |
| 1001 | } |
| 1002 | } |
| 1003 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1004 | public void notifyPreciseCallState(int ringingCallState, int foregroundCallState, |
| 1005 | int backgroundCallState) { |
| 1006 | if (!checkNotifyPermission("notifyPreciseCallState()")) { |
| 1007 | return; |
| 1008 | } |
| 1009 | synchronized (mRecords) { |
| 1010 | mRingingCallState = ringingCallState; |
| 1011 | mForegroundCallState = foregroundCallState; |
| 1012 | mBackgroundCallState = backgroundCallState; |
| 1013 | mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState, |
| 1014 | backgroundCallState, |
| 1015 | DisconnectCause.NOT_VALID, |
| 1016 | PreciseDisconnectCause.NOT_VALID); |
| 1017 | for (Record r : mRecords) { |
| 1018 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 1019 | try { |
| 1020 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 1021 | } catch (RemoteException ex) { |
| 1022 | mRemoveList.add(r.binder); |
| 1023 | } |
| 1024 | } |
| 1025 | } |
| 1026 | handleRemoveListLocked(); |
| 1027 | } |
| 1028 | broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState, |
| 1029 | DisconnectCause.NOT_VALID, |
| 1030 | PreciseDisconnectCause.NOT_VALID); |
| 1031 | } |
| 1032 | |
| 1033 | public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) { |
| 1034 | if (!checkNotifyPermission("notifyDisconnectCause()")) { |
| 1035 | return; |
| 1036 | } |
| 1037 | synchronized (mRecords) { |
| 1038 | mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, |
| 1039 | mBackgroundCallState, disconnectCause, preciseDisconnectCause); |
| 1040 | for (Record r : mRecords) { |
| 1041 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 1042 | try { |
| 1043 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 1044 | } catch (RemoteException ex) { |
| 1045 | mRemoveList.add(r.binder); |
| 1046 | } |
| 1047 | } |
| 1048 | } |
| 1049 | handleRemoveListLocked(); |
| 1050 | } |
| 1051 | broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState, |
| 1052 | mBackgroundCallState, disconnectCause, preciseDisconnectCause); |
| 1053 | } |
| 1054 | |
| 1055 | public void notifyPreciseDataConnectionFailed(String reason, String apnType, |
| 1056 | String apn, String failCause) { |
| 1057 | if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) { |
| 1058 | return; |
| 1059 | } |
| 1060 | synchronized (mRecords) { |
| 1061 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 1062 | TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1063 | apnType, apn, reason, null, failCause); |
| 1064 | for (Record r : mRecords) { |
| 1065 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 1066 | try { |
| 1067 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 1068 | } catch (RemoteException ex) { |
| 1069 | mRemoveList.add(r.binder); |
| 1070 | } |
| 1071 | } |
| 1072 | } |
| 1073 | handleRemoveListLocked(); |
| 1074 | } |
| 1075 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 1076 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); |
| 1077 | } |
| 1078 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1079 | public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) { |
| 1080 | if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) { |
| 1081 | return; |
| 1082 | } |
| 1083 | synchronized (mRecords) { |
| 1084 | mVoLteServiceState = lteState; |
| 1085 | for (Record r : mRecords) { |
| 1086 | if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) { |
| 1087 | try { |
| 1088 | r.callback.onVoLteServiceStateChanged( |
| 1089 | new VoLteServiceState(mVoLteServiceState)); |
| 1090 | } catch (RemoteException ex) { |
| 1091 | mRemoveList.add(r.binder); |
| 1092 | } |
| 1093 | } |
| 1094 | } |
| 1095 | handleRemoveListLocked(); |
| 1096 | } |
| 1097 | } |
| 1098 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1099 | public void notifyOemHookRawEventForSubscriber(int subId, byte[] rawData) { |
New Author Steven Liu | 485f209 | 2014-09-11 10:18:45 -0500 | [diff] [blame] | 1100 | if (!checkNotifyPermission("notifyOemHookRawEventForSubscriber")) { |
| 1101 | return; |
| 1102 | } |
| 1103 | |
| 1104 | synchronized (mRecords) { |
| 1105 | for (Record r : mRecords) { |
| 1106 | if (VDBG) { |
| 1107 | log("notifyOemHookRawEventForSubscriber: r=" + r + " subId=" + subId); |
| 1108 | } |
| 1109 | if (((r.events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) && |
| 1110 | ((r.subId == subId) || |
| 1111 | (r.subId == SubscriptionManager.DEFAULT_SUB_ID))) { |
| 1112 | try { |
| 1113 | r.callback.onOemHookRawEvent(rawData); |
| 1114 | } catch (RemoteException ex) { |
| 1115 | mRemoveList.add(r.binder); |
| 1116 | } |
| 1117 | } |
| 1118 | } |
| 1119 | handleRemoveListLocked(); |
| 1120 | } |
| 1121 | } |
| 1122 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1123 | @Override |
| 1124 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1125 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 1126 | != PackageManager.PERMISSION_GRANTED) { |
| 1127 | pw.println("Permission Denial: can't dump telephony.registry from from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1128 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1129 | return; |
| 1130 | } |
| 1131 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1132 | final int recordCount = mRecords.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1133 | pw.println("last known state:"); |
Sandeep Gutta | 2f32ac2 | 2014-07-16 03:14:03 +0530 | [diff] [blame] | 1134 | for (int i = 0; i < TelephonyManager.getDefault().getPhoneCount(); i++) { |
| 1135 | pw.println(" Phone Id=" + i); |
| 1136 | pw.println(" mCallState=" + mCallState[i]); |
| 1137 | pw.println(" mCallIncomingNumber=" + mCallIncomingNumber[i]); |
| 1138 | pw.println(" mServiceState=" + mServiceState[i]); |
| 1139 | pw.println(" mSignalStrength=" + mSignalStrength[i]); |
| 1140 | pw.println(" mMessageWaiting=" + mMessageWaiting[i]); |
| 1141 | pw.println(" mCallForwarding=" + mCallForwarding[i]); |
| 1142 | pw.println(" mDataActivity=" + mDataActivity[i]); |
| 1143 | pw.println(" mDataConnectionState=" + mDataConnectionState[i]); |
| 1144 | pw.println(" mDataConnectionPossible=" + mDataConnectionPossible[i]); |
| 1145 | pw.println(" mDataConnectionReason=" + mDataConnectionReason[i]); |
| 1146 | pw.println(" mDataConnectionApn=" + mDataConnectionApn[i]); |
| 1147 | pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties[i]); |
| 1148 | pw.println(" mDataConnectionNetworkCapabilities=" + |
| 1149 | mDataConnectionNetworkCapabilities[i]); |
| 1150 | pw.println(" mCellLocation=" + mCellLocation[i]); |
| 1151 | pw.println(" mCellInfo=" + mCellInfo.get(i)); |
| 1152 | } |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 1153 | pw.println(" mDcRtInfo=" + mDcRtInfo); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1154 | pw.println("registrations: count=" + recordCount); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 1155 | for (Record r : mRecords) { |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1156 | pw.println(" " + r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1157 | } |
| 1158 | } |
| 1159 | } |
| 1160 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1161 | // |
| 1162 | // the legacy intent broadcasting |
| 1163 | // |
| 1164 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1165 | private void broadcastServiceStateChanged(ServiceState state, int subId) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1166 | long ident = Binder.clearCallingIdentity(); |
| 1167 | try { |
| 1168 | mBatteryStats.notePhoneState(state.getState()); |
| 1169 | } catch (RemoteException re) { |
| 1170 | // Can't do much |
| 1171 | } finally { |
| 1172 | Binder.restoreCallingIdentity(ident); |
| 1173 | } |
| 1174 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1175 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 1176 | Bundle data = new Bundle(); |
| 1177 | state.fillInNotifierBundle(data); |
| 1178 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1179 | // Pass the subscription along with the intent. |
| 1180 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1181 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1182 | } |
| 1183 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1184 | private void broadcastSignalStrengthChanged(SignalStrength signalStrength, int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1185 | long ident = Binder.clearCallingIdentity(); |
| 1186 | try { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1187 | mBatteryStats.notePhoneSignalStrength(signalStrength); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1188 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1189 | /* The remote entity disappeared, we can safely ignore the exception. */ |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1190 | } finally { |
| 1191 | Binder.restoreCallingIdentity(ident); |
| 1192 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1193 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1194 | Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1195 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1196 | Bundle data = new Bundle(); |
| 1197 | signalStrength.fillInNotifierBundle(data); |
| 1198 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1199 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1200 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1201 | } |
| 1202 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1203 | private void broadcastCallStateChanged(int state, String incomingNumber, int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1204 | long ident = Binder.clearCallingIdentity(); |
| 1205 | try { |
| 1206 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
| 1207 | mBatteryStats.notePhoneOff(); |
| 1208 | } else { |
| 1209 | mBatteryStats.notePhoneOn(); |
| 1210 | } |
| 1211 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1212 | /* The remote entity disappeared, we can safely ignore the exception. */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1213 | } finally { |
| 1214 | Binder.restoreCallingIdentity(ident); |
| 1215 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1216 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1217 | Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1218 | intent.putExtra(PhoneConstants.STATE_KEY, |
| 1219 | DefaultPhoneNotifier.convertCallState(state).toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1220 | if (!TextUtils.isEmpty(incomingNumber)) { |
| 1221 | intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); |
| 1222 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1223 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1224 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1225 | android.Manifest.permission.READ_PHONE_STATE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1226 | } |
| 1227 | |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 1228 | private void broadcastDataConnectionStateChanged(int state, |
| 1229 | boolean isDataConnectivityPossible, |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1230 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1231 | NetworkCapabilities networkCapabilities, boolean roaming, int subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1232 | // Note: not reporting to the battery stats service here, because the |
| 1233 | // status bar takes care of that after taking into account all of the |
| 1234 | // required info. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1235 | Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1236 | intent.putExtra(PhoneConstants.STATE_KEY, |
| 1237 | DefaultPhoneNotifier.convertDataState(state).toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1238 | if (!isDataConnectivityPossible) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1239 | intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1240 | } |
| 1241 | if (reason != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1242 | intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1243 | } |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 1244 | if (linkProperties != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1245 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
Irfan Sheriff | ed5d7d1 | 2010-10-01 16:08:28 -0700 | [diff] [blame] | 1246 | String iface = linkProperties.getInterfaceName(); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1247 | if (iface != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1248 | intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1249 | } |
| 1250 | } |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 1251 | if (networkCapabilities != null) { |
| 1252 | intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities); |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1253 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1254 | if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true); |
Robert Greenwalt | a6d4248 | 2011-09-02 15:19:31 -0700 | [diff] [blame] | 1255 | |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1256 | intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 1257 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1258 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1259 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1260 | } |
| 1261 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1262 | private void broadcastDataConnectionFailed(String reason, String apnType, |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1263 | int subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1264 | Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1265 | intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason); |
| 1266 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1267 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1268 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1269 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1270 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1271 | private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState, |
| 1272 | int backgroundCallState, int disconnectCause, int preciseDisconnectCause) { |
| 1273 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED); |
| 1274 | intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState); |
| 1275 | intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState); |
| 1276 | intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState); |
| 1277 | intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause); |
| 1278 | intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause); |
| 1279 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1280 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1281 | } |
| 1282 | |
| 1283 | private void broadcastPreciseDataConnectionStateChanged(int state, int networkType, |
| 1284 | String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) { |
| 1285 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 1286 | intent.putExtra(PhoneConstants.STATE_KEY, state); |
| 1287 | intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType); |
| 1288 | if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
| 1289 | if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
| 1290 | if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 1291 | if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
| 1292 | if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause); |
| 1293 | |
| 1294 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1295 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1296 | } |
| 1297 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1298 | private boolean checkNotifyPermission(String method) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1299 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 1300 | == PackageManager.PERMISSION_GRANTED) { |
| 1301 | return true; |
| 1302 | } |
| 1303 | String msg = "Modify Phone State Permission Denial: " + method + " from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1304 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1305 | if (DBG) log(msg); |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1306 | return false; |
| 1307 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1308 | |
| 1309 | private void checkListenerPermission(int events) { |
| 1310 | if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 1311 | mContext.enforceCallingOrSelfPermission( |
| 1312 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
| 1313 | |
| 1314 | } |
| 1315 | |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1316 | if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) { |
| 1317 | mContext.enforceCallingOrSelfPermission( |
| 1318 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
| 1319 | |
| 1320 | } |
| 1321 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1322 | if ((events & PHONE_STATE_PERMISSION_MASK) != 0) { |
| 1323 | mContext.enforceCallingOrSelfPermission( |
| 1324 | android.Manifest.permission.READ_PHONE_STATE, null); |
| 1325 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1326 | |
| 1327 | if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) { |
| 1328 | mContext.enforceCallingOrSelfPermission( |
| 1329 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 1330 | |
| 1331 | } |
New Author Steven Liu | 485f209 | 2014-09-11 10:18:45 -0500 | [diff] [blame] | 1332 | |
| 1333 | if ((events & PhoneStateListener.LISTEN_OEM_HOOK_RAW_EVENT) != 0) { |
| 1334 | mContext.enforceCallingOrSelfPermission( |
| 1335 | android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE, null); |
| 1336 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1337 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1338 | |
| 1339 | private void handleRemoveListLocked() { |
| 1340 | if (mRemoveList.size() > 0) { |
| 1341 | for (IBinder b: mRemoveList) { |
| 1342 | remove(b); |
| 1343 | } |
| 1344 | mRemoveList.clear(); |
| 1345 | } |
| 1346 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1347 | |
| 1348 | private boolean validateEventsAndUserLocked(Record r, int events) { |
| 1349 | int foregroundUser; |
| 1350 | long callingIdentity = Binder.clearCallingIdentity(); |
| 1351 | boolean valid = false; |
| 1352 | try { |
| 1353 | foregroundUser = ActivityManager.getCurrentUser(); |
| 1354 | valid = r.callerUid == foregroundUser && (r.events & events) != 0; |
| 1355 | if (DBG | DBG_LOC) { |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1356 | log("validateEventsAndUserLocked: valid=" + valid |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1357 | + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser |
| 1358 | + " r.events=" + r.events + " events=" + events); |
| 1359 | } |
| 1360 | } finally { |
| 1361 | Binder.restoreCallingIdentity(callingIdentity); |
| 1362 | } |
| 1363 | return valid; |
| 1364 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1365 | |
| 1366 | private boolean validatePhoneId(int phoneId) { |
| 1367 | boolean valid = (phoneId >= 0) && (phoneId < mNumPhones); |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1368 | if (VDBG) log("validatePhoneId: " + valid); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame] | 1369 | return valid; |
| 1370 | } |
Wink Saville | f4cd25b | 2014-07-08 19:03:20 -0700 | [diff] [blame] | 1371 | |
| 1372 | private static void log(String s) { |
| 1373 | Rlog.d(TAG, s); |
| 1374 | } |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1375 | |
| 1376 | private static class LogSSC { |
| 1377 | private Time mTime; |
| 1378 | private String mS; |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1379 | private int mSubId; |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1380 | private int mPhoneId; |
| 1381 | private ServiceState mState; |
| 1382 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1383 | public void set(Time t, String s, int subId, int phoneId, ServiceState state) { |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1384 | mTime = t; mS = s; mSubId = subId; mPhoneId = phoneId; mState = state; |
| 1385 | } |
| 1386 | |
| 1387 | @Override |
| 1388 | public String toString() { |
| 1389 | return mS + " " + mTime.toString() + " " + mSubId + " " + mPhoneId + " " + mState; |
| 1390 | } |
| 1391 | } |
| 1392 | |
| 1393 | private LogSSC logSSC [] = new LogSSC[10]; |
| 1394 | private int next = 0; |
| 1395 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1396 | private void logServiceStateChanged(String s, int subId, int phoneId, ServiceState state) { |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1397 | if (logSSC == null || logSSC.length == 0) { |
| 1398 | return; |
| 1399 | } |
| 1400 | if (logSSC[next] == null) { |
| 1401 | logSSC[next] = new LogSSC(); |
| 1402 | } |
| 1403 | Time t = new Time(); |
| 1404 | t.setToNow(); |
| 1405 | logSSC[next].set(t, s, subId, phoneId, state); |
| 1406 | if (++next >= logSSC.length) { |
| 1407 | next = 0; |
| 1408 | } |
| 1409 | } |
| 1410 | |
| 1411 | private void toStringLogSSC(String prompt) { |
| 1412 | if (logSSC == null || logSSC.length == 0 || (next == 0 && logSSC[next] == null)) { |
| 1413 | log(prompt + ": logSSC is empty"); |
| 1414 | } else { |
| 1415 | // There is at least one element |
| 1416 | log(prompt + ": logSSC.length=" + logSSC.length + " next=" + next); |
| 1417 | int i = next; |
| 1418 | if (logSSC[i] == null) { |
| 1419 | // logSSC is not full so back to the beginning |
| 1420 | i = 0; |
| 1421 | } |
| 1422 | do { |
| 1423 | log(logSSC[i].toString()); |
| 1424 | if (++i >= logSSC.length) { |
| 1425 | i = 0; |
| 1426 | } |
| 1427 | } while (i != next); |
Wink Saville | e380b98 | 2014-07-26 18:24:22 -0700 | [diff] [blame] | 1428 | log(prompt + ": ----------------"); |
Wink Saville | 47d8d1b | 2014-07-10 13:01:52 -0700 | [diff] [blame] | 1429 | } |
| 1430 | } |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1431 | |
Wink Saville | 63f03dd | 2014-10-23 10:44:45 -0700 | [diff] [blame^] | 1432 | boolean subIdMatch(int rSubId, int subId) { |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1433 | if(rSubId == SubscriptionManager.DEFAULT_SUB_ID) { |
| 1434 | return (subId == mDefaultSubId); |
| 1435 | } else { |
| 1436 | return (rSubId == subId); |
| 1437 | } |
| 1438 | } |
| 1439 | |
| 1440 | private void checkPossibleMissNotify(Record r, int phoneId) { |
| 1441 | int events = r.events; |
| 1442 | |
| 1443 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 1444 | try { |
| 1445 | if (VDBG) log("checkPossibleMissNotify: onServiceStateChanged state=" + |
| 1446 | mServiceState[phoneId]); |
| 1447 | r.callback.onServiceStateChanged( |
| 1448 | new ServiceState(mServiceState[phoneId])); |
| 1449 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1450 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 1455 | try { |
| 1456 | SignalStrength signalStrength = mSignalStrength[phoneId]; |
| 1457 | if (DBG) { |
| 1458 | log("checkPossibleMissNotify: onSignalStrengthsChanged SS=" + signalStrength); |
| 1459 | } |
| 1460 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 1461 | } catch (RemoteException ex) { |
| 1462 | mRemoveList.add(r.binder); |
| 1463 | } |
| 1464 | } |
| 1465 | |
| 1466 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 1467 | try { |
| 1468 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 1469 | .getGsmSignalStrength(); |
| 1470 | if (DBG) { |
| 1471 | log("checkPossibleMissNotify: onSignalStrengthChanged SS=" + |
| 1472 | gsmSignalStrength); |
| 1473 | } |
| 1474 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 1475 | : gsmSignalStrength)); |
| 1476 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1477 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1478 | } |
| 1479 | } |
| 1480 | |
| 1481 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
| 1482 | try { |
| 1483 | if (DBG_LOC) { |
| 1484 | log("checkPossibleMissNotify: onCellInfoChanged[" + phoneId + "] = " |
| 1485 | + mCellInfo.get(phoneId)); |
| 1486 | } |
| 1487 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
| 1488 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1489 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1490 | } |
| 1491 | } |
| 1492 | |
| 1493 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 1494 | try { |
| 1495 | if (VDBG) { |
| 1496 | log("checkPossibleMissNotify: onMessageWaitingIndicatorChanged phoneId=" |
| 1497 | + phoneId + " mwi=" + mMessageWaiting[phoneId]); |
| 1498 | } |
| 1499 | r.callback.onMessageWaitingIndicatorChanged( |
| 1500 | mMessageWaiting[phoneId]); |
| 1501 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1502 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 1507 | try { |
| 1508 | if (VDBG) { |
| 1509 | log("checkPossibleMissNotify: onCallForwardingIndicatorChanged phoneId=" |
| 1510 | + phoneId + " cfi=" + mCallForwarding[phoneId]); |
| 1511 | } |
| 1512 | r.callback.onCallForwardingIndicatorChanged( |
| 1513 | mCallForwarding[phoneId]); |
| 1514 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1515 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1516 | } |
| 1517 | } |
| 1518 | |
| 1519 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
| 1520 | try { |
| 1521 | if (DBG_LOC) log("checkPossibleMissNotify: onCellLocationChanged mCellLocation = " |
| 1522 | + mCellLocation[phoneId]); |
| 1523 | r.callback.onCellLocationChanged(new Bundle(mCellLocation[phoneId])); |
| 1524 | } catch (RemoteException ex) { |
| 1525 | mRemoveList.add(r.binder); |
| 1526 | } |
| 1527 | } |
| 1528 | |
| 1529 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 1530 | try { |
| 1531 | if (DBG) { |
| 1532 | log("checkPossibleMissNotify: onDataConnectionStateChanged(mDataConnectionState" |
| 1533 | + "=" + mDataConnectionState[phoneId] |
| 1534 | + ", mDataConnectionNetworkType=" + mDataConnectionNetworkType[phoneId] |
| 1535 | + ")"); |
| 1536 | } |
| 1537 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 1538 | mDataConnectionNetworkType[phoneId]); |
| 1539 | } catch (RemoteException ex) { |
Etan Cohen | a33cf07 | 2014-09-30 10:35:24 -0700 | [diff] [blame] | 1540 | mRemoveList.add(r.binder); |
xinhe | e9f1640 | 2014-09-25 16:39:28 -0700 | [diff] [blame] | 1541 | } |
| 1542 | } |
| 1543 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1544 | } |