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