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 | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 36 | import android.telephony.TelephonyManager; |
| 37 | import android.telephony.SubscriptionManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | import android.telephony.PhoneStateListener; |
| 39 | import android.telephony.ServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 40 | import android.telephony.SignalStrength; |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 41 | import android.telephony.CellInfo; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 42 | import android.telephony.VoLteServiceState; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | import android.telephony.TelephonyManager; |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 44 | import android.telephony.DisconnectCause; |
| 45 | import android.telephony.PreciseCallState; |
| 46 | import android.telephony.PreciseDataConnectionState; |
| 47 | import android.telephony.PreciseDisconnectCause; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | import android.text.TextUtils; |
Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 49 | import android.util.Slog; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | |
| 51 | import java.util.ArrayList; |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 52 | import java.util.List; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | import java.io.FileDescriptor; |
| 54 | import java.io.PrintWriter; |
| 55 | |
| 56 | import com.android.internal.app.IBatteryStats; |
| 57 | import com.android.internal.telephony.ITelephonyRegistry; |
| 58 | import com.android.internal.telephony.IPhoneStateListener; |
| 59 | import com.android.internal.telephony.DefaultPhoneNotifier; |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 60 | import com.android.internal.telephony.PhoneConstants; |
Wink Saville | c9330dd | 2011-01-12 13:37:38 -0800 | [diff] [blame] | 61 | import com.android.internal.telephony.ServiceStateTracker; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 62 | import com.android.internal.telephony.TelephonyIntents; |
| 63 | import com.android.server.am.BatteryStatsService; |
| 64 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | /** |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 66 | * Since phone process can be restarted, this class provides a centralized place |
| 67 | * that applications can register and be called back from. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | */ |
| 69 | class TelephonyRegistry extends ITelephonyRegistry.Stub { |
| 70 | private static final String TAG = "TelephonyRegistry"; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 71 | private static final boolean DBG = false; // STOPSHIP if true |
| 72 | private static final boolean DBG_LOC = false; // STOPSHIP if true |
| 73 | private static final boolean VDBG = false; // STOPSHIP if true |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | |
| 75 | private static class Record { |
| 76 | String pkgForDebug; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 77 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | IBinder binder; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 79 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 80 | IPhoneStateListener callback; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 81 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 82 | int callerUid; |
| 83 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | int events; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 85 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 86 | long subId; |
| 87 | |
| 88 | boolean isLegacyApp; |
| 89 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 90 | @Override |
| 91 | public String toString() { |
| 92 | return "{pkgForDebug=" + pkgForDebug + " callerUid=" + callerUid + |
| 93 | " events=" + Integer.toHexString(events) + "}"; |
| 94 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | private final Context mContext; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 98 | |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 99 | // access should be inside synchronized (mRecords) for these two fields |
| 100 | private final ArrayList<IBinder> mRemoveList = new ArrayList<IBinder>(); |
| 101 | private final ArrayList<Record> mRecords = new ArrayList<Record>(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 102 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 103 | private final IBatteryStats mBatteryStats; |
| 104 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 105 | private int mNumPhones; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 106 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 107 | private int[] mCallState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 108 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 109 | private String[] mCallIncomingNumber; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 110 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 111 | private ServiceState[] mServiceState; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 112 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 113 | private SignalStrength[] mSignalStrength; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 114 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 115 | private boolean[] mMessageWaiting; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 116 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 117 | private boolean[] mCallForwarding; |
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[] mDataActivity; |
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 int[] mDataConnectionState; |
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 boolean[] mDataConnectionPossible; |
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 String[] mDataConnectionReason; |
| 126 | |
| 127 | private String[] mDataConnectionApn; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 128 | |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 129 | private ArrayList<String> mConnectedApns; |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 130 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 131 | private LinkProperties[] mDataConnectionLinkProperties; |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 132 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 133 | private NetworkCapabilities[] mDataConnectionNetworkCapabilities; |
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 Bundle[] mCellLocation; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 136 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 137 | private int[] mDataConnectionNetworkType; |
Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 138 | |
Wink Saville | c9330dd | 2011-01-12 13:37:38 -0800 | [diff] [blame] | 139 | private int mOtaspMode = ServiceStateTracker.OTASP_UNKNOWN; |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 140 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 141 | private ArrayList<List<CellInfo>> mCellInfo = null; |
| 142 | |
| 143 | private VoLteServiceState mVoLteServiceState = new VoLteServiceState(); |
| 144 | |
| 145 | private long mDefaultSubId; |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 146 | |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 147 | private DataConnectionRealTimeInfo mDcRtInfo = new DataConnectionRealTimeInfo(); |
| 148 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 149 | private int mRingingCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 150 | |
| 151 | private int mForegroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 152 | |
| 153 | private int mBackgroundCallState = PreciseCallState.PRECISE_CALL_STATE_IDLE; |
| 154 | |
| 155 | private PreciseCallState mPreciseCallState = new PreciseCallState(); |
| 156 | |
| 157 | private PreciseDataConnectionState mPreciseDataConnectionState = |
| 158 | new PreciseDataConnectionState(); |
| 159 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 160 | static final int PHONE_STATE_PERMISSION_MASK = |
| 161 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | |
| 162 | PhoneStateListener.LISTEN_CALL_STATE | |
| 163 | PhoneStateListener.LISTEN_DATA_ACTIVITY | |
| 164 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 165 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR | |
| 166 | PhoneStateListener.LISTEN_VOLTE_STATE;; |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 167 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 168 | static final int PRECISE_PHONE_STATE_PERMISSION_MASK = |
| 169 | PhoneStateListener.LISTEN_PRECISE_CALL_STATE | |
| 170 | PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE; |
| 171 | |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 172 | private static final int MSG_USER_SWITCHED = 1; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 173 | private static final int MSG_UPDATE_DEFAULT_SUB = 2; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 174 | |
| 175 | private final Handler mHandler = new Handler() { |
| 176 | @Override |
| 177 | public void handleMessage(Message msg) { |
| 178 | switch (msg.what) { |
| 179 | case MSG_USER_SWITCHED: { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 180 | Slog.d(TAG, "MSG_USER_SWITCHED userId=" + msg.arg1); |
| 181 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
| 182 | for (int sub = 0; sub < numPhones; sub++) { |
| 183 | TelephonyRegistry.this.notifyCellLocationUsingSubId(sub, mCellLocation[sub]); |
| 184 | } |
| 185 | break; |
| 186 | } |
| 187 | case MSG_UPDATE_DEFAULT_SUB: { |
| 188 | Slog.d(TAG, "MSG_UPDATE_DEFAULT_SUB subid=" + mDefaultSubId); |
| 189 | // Default subscription id changed, update the changed default subscription |
| 190 | // id in all the legacy application listener records. |
| 191 | synchronized (mRecords) { |
| 192 | for (Record r : mRecords) { |
| 193 | // FIXME: Be sure we're using isLegacyApp correctly! |
| 194 | if (r.isLegacyApp == true) { |
| 195 | r.subId = mDefaultSubId; |
| 196 | } |
| 197 | } |
| 198 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 199 | break; |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | private final BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() { |
| 206 | @Override |
| 207 | public void onReceive(Context context, Intent intent) { |
| 208 | String action = intent.getAction(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 209 | Slog.d(TAG, "mBroadcastReceiver: action=" + action); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 210 | if (Intent.ACTION_USER_SWITCHED.equals(action)) { |
| 211 | mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHED, |
| 212 | intent.getIntExtra(Intent.EXTRA_USER_HANDLE, 0), 0)); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 213 | } else if (action.equals(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED)) { |
| 214 | mDefaultSubId = intent.getLongExtra(PhoneConstants.SUBSCRIPTION_KEY, |
| 215 | SubscriptionManager.getDefaultSubId()); |
| 216 | mHandler.sendMessage(mHandler.obtainMessage(MSG_UPDATE_DEFAULT_SUB, 0, 0)); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | }; |
| 220 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 221 | // we keep a copy of all of the state so we can send it out when folks |
| 222 | // register for it |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 223 | // |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 224 | // In these calls we call with the lock held. This is safe becasuse remote |
| 225 | // calls go through a oneway interface and local calls going through a |
| 226 | // handler before they get to app code. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 227 | |
| 228 | TelephonyRegistry(Context context) { |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 229 | CellLocation location = CellLocation.getEmpty(); |
| 230 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 231 | mContext = context; |
| 232 | mBatteryStats = BatteryStatsService.getService(); |
| 233 | mConnectedApns = new ArrayList<String>(); |
| 234 | |
| 235 | // Initialize default subscription to be used for single standby. |
| 236 | mDefaultSubId = SubscriptionManager.getDefaultSubId(); |
| 237 | |
| 238 | int numPhones = TelephonyManager.getDefault().getPhoneCount(); |
| 239 | if (DBG) Slog.d(TAG, "TelephonyRegistor: ctor numPhones=" + numPhones); |
| 240 | mNumPhones = numPhones; |
| 241 | mCallState = new int[numPhones]; |
| 242 | mDataActivity = new int[numPhones]; |
| 243 | mDataConnectionState = new int[numPhones]; |
| 244 | mDataConnectionNetworkType = new int[numPhones]; |
| 245 | mCallIncomingNumber = new String[numPhones]; |
| 246 | mServiceState = new ServiceState[numPhones]; |
| 247 | mSignalStrength = new SignalStrength[numPhones]; |
| 248 | mMessageWaiting = new boolean[numPhones]; |
| 249 | mDataConnectionPossible = new boolean[numPhones]; |
| 250 | mDataConnectionReason = new String[numPhones]; |
| 251 | mDataConnectionApn = new String[numPhones]; |
| 252 | mCallForwarding = new boolean[numPhones]; |
| 253 | mCellLocation = new Bundle[numPhones]; |
| 254 | mDataConnectionLinkProperties = new LinkProperties[numPhones]; |
| 255 | mDataConnectionNetworkCapabilities = new NetworkCapabilities[numPhones]; |
| 256 | mCellInfo = new ArrayList<List<CellInfo>>(); |
| 257 | for (int i = 0; i < numPhones; i++) { |
| 258 | mCallState[i] = TelephonyManager.CALL_STATE_IDLE; |
| 259 | mDataActivity[i] = TelephonyManager.DATA_ACTIVITY_NONE; |
| 260 | mDataConnectionState[i] = TelephonyManager.DATA_UNKNOWN; |
| 261 | mCallIncomingNumber[i] = ""; |
| 262 | mServiceState[i] = new ServiceState(); |
| 263 | mSignalStrength[i] = new SignalStrength(); |
| 264 | mMessageWaiting[i] = false; |
| 265 | mCallForwarding[i] = false; |
| 266 | mDataConnectionPossible[i] = false; |
| 267 | mDataConnectionReason[i] = ""; |
| 268 | mDataConnectionApn[i] = ""; |
| 269 | mCellLocation[i] = new Bundle(); |
| 270 | mCellInfo.add(i, null); |
| 271 | } |
| 272 | |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 273 | // Note that location can be null for non-phone builds like |
| 274 | // like the generic one. |
| 275 | if (location != null) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 276 | for (int i = 0; i < numPhones; i++) { |
| 277 | location.fillInNotifierBundle(mCellLocation[i]); |
| 278 | } |
David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 279 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 280 | mConnectedApns = new ArrayList<String>(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | } |
| 282 | |
Svetoslav Ganov | a002715 | 2013-06-25 14:59:53 -0700 | [diff] [blame] | 283 | public void systemRunning() { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 284 | // Watch for interesting updates |
| 285 | final IntentFilter filter = new IntentFilter(); |
| 286 | filter.addAction(Intent.ACTION_USER_SWITCHED); |
| 287 | filter.addAction(Intent.ACTION_USER_REMOVED); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 288 | filter.addAction(TelephonyIntents.ACTION_DEFAULT_SUBSCRIPTION_CHANGED); |
| 289 | Slog.d(TAG, "systemRunning register for intents"); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 290 | mContext.registerReceiver(mBroadcastReceiver, filter); |
| 291 | } |
| 292 | |
| 293 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 294 | public void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 295 | boolean notifyNow) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 296 | listen(pkgForDebug, callback, events, notifyNow, mDefaultSubId, true); |
| 297 | } |
| 298 | |
| 299 | @Override |
| 300 | public void listenUsingSubId(long subId, String pkgForDebug, IPhoneStateListener callback, |
| 301 | int events, boolean notifyNow) { |
| 302 | listen(pkgForDebug, callback, events, notifyNow, subId, false); |
| 303 | } |
| 304 | |
| 305 | private void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 306 | boolean notifyNow, long subId, boolean isLegacyApp) { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 307 | int callerUid = UserHandle.getCallingUserId(); |
| 308 | int myUid = UserHandle.myUserId(); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 309 | if (VDBG) { |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 310 | Slog.d(TAG, "listen: E pkg=" + pkgForDebug + " events=0x" + Integer.toHexString(events) |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 311 | + " notifyNow=" + notifyNow + " subId=" + subId |
| 312 | + " isLegacyApp=" + isLegacyApp |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 313 | + " myUid=" + myUid |
| 314 | + " callerUid=" + callerUid); |
| 315 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 316 | if (events != 0) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 317 | /* Checks permission and throws Security exception */ |
| 318 | checkListenerPermission(events); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 319 | |
| 320 | synchronized (mRecords) { |
| 321 | // register |
| 322 | Record r = null; |
| 323 | find_and_add: { |
| 324 | IBinder b = callback.asBinder(); |
| 325 | final int N = mRecords.size(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 326 | for (int i = 0; i < N; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 327 | r = mRecords.get(i); |
| 328 | if (b == r.binder) { |
| 329 | break find_and_add; |
| 330 | } |
| 331 | } |
| 332 | r = new Record(); |
| 333 | r.binder = b; |
| 334 | r.callback = callback; |
| 335 | r.pkgForDebug = pkgForDebug; |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 336 | r.callerUid = callerUid; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 337 | r.subId = subId; |
| 338 | r.isLegacyApp = isLegacyApp; |
| 339 | // Legacy applications pass invalid subId(-1), based on |
| 340 | // the received subId value update the isLegacyApp field |
| 341 | if ((r.subId <= 0) || (r.subId == SubscriptionManager.INVALID_SUB_ID)) { |
| 342 | r.subId = mDefaultSubId; |
| 343 | r.isLegacyApp = true; // FIXME: is this needed ?? |
| 344 | } |
| 345 | if (r.subId == SubscriptionManager.DEFAULT_SUB_ID) { |
| 346 | r.subId = mDefaultSubId; |
| 347 | if (DBG) Slog.i(TAG, "listen: DEFAULT_SUB_ID"); |
| 348 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 349 | mRecords.add(r); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 350 | if (DBG) Slog.i(TAG, "listen: add new record=" + r); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 351 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 352 | int phoneId = SubscriptionManager.getPhoneId(subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 353 | int send = events & (events ^ r.events); |
| 354 | r.events = events; |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 355 | if (notifyNow && validatePhoneId(phoneId)) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 356 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 357 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 358 | r.callback.onServiceStateChanged( |
| 359 | new ServiceState(mServiceState[phoneId])); |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 360 | } catch (RemoteException ex) { |
| 361 | remove(r.binder); |
| 362 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 363 | } |
| 364 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 365 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 366 | int gsmSignalStrength = mSignalStrength[phoneId] |
| 367 | .getGsmSignalStrength(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 368 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 369 | : gsmSignalStrength)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 370 | } catch (RemoteException ex) { |
| 371 | remove(r.binder); |
| 372 | } |
| 373 | } |
| 374 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 375 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 376 | r.callback.onMessageWaitingIndicatorChanged( |
| 377 | mMessageWaiting[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 378 | } catch (RemoteException ex) { |
| 379 | remove(r.binder); |
| 380 | } |
| 381 | } |
| 382 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 383 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 384 | r.callback.onCallForwardingIndicatorChanged( |
| 385 | mCallForwarding[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 386 | } catch (RemoteException ex) { |
| 387 | remove(r.binder); |
| 388 | } |
| 389 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 390 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION)) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 391 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 392 | if (DBG_LOC) Slog.d(TAG, "listen: mCellLocation = " |
| 393 | + mCellLocation[phoneId]); |
| 394 | r.callback.onCellLocationChanged( |
| 395 | new Bundle(mCellLocation[phoneId])); |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 396 | } catch (RemoteException ex) { |
| 397 | remove(r.binder); |
| 398 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 399 | } |
| 400 | if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 401 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 402 | r.callback.onCallStateChanged(mCallState[phoneId], |
| 403 | mCallIncomingNumber[phoneId]); |
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_DATA_CONNECTION_STATE) != 0) { |
| 409 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 410 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 411 | mDataConnectionNetworkType[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_DATA_ACTIVITY) != 0) { |
| 417 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 418 | r.callback.onDataActivity(mDataActivity[phoneId]); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | } catch (RemoteException ex) { |
| 420 | remove(r.binder); |
| 421 | } |
| 422 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 423 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 424 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 425 | r.callback.onSignalStrengthsChanged(mSignalStrength[phoneId]); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 426 | } catch (RemoteException ex) { |
| 427 | remove(r.binder); |
| 428 | } |
| 429 | } |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 430 | if ((events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 431 | try { |
| 432 | r.callback.onOtaspChanged(mOtaspMode); |
| 433 | } catch (RemoteException ex) { |
| 434 | remove(r.binder); |
| 435 | } |
| 436 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 437 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO)) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 438 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 439 | if (DBG_LOC) Slog.d(TAG, "listen: mCellInfo[" + phoneId + "] = " |
| 440 | + mCellInfo.get(phoneId)); |
| 441 | r.callback.onCellInfoChanged(mCellInfo.get(phoneId)); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 442 | } catch (RemoteException ex) { |
| 443 | remove(r.binder); |
| 444 | } |
| 445 | } |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 446 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO) != 0) { |
| 447 | try { |
| 448 | r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo); |
| 449 | } catch (RemoteException ex) { |
| 450 | remove(r.binder); |
| 451 | } |
| 452 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 453 | if ((events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 454 | try { |
| 455 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 456 | } catch (RemoteException ex) { |
| 457 | remove(r.binder); |
| 458 | } |
| 459 | } |
| 460 | if ((events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 461 | try { |
| 462 | r.callback.onPreciseDataConnectionStateChanged( |
| 463 | mPreciseDataConnectionState); |
| 464 | } catch (RemoteException ex) { |
| 465 | remove(r.binder); |
| 466 | } |
| 467 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 468 | } |
| 469 | } |
| 470 | } else { |
| 471 | remove(callback.asBinder()); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | private void remove(IBinder binder) { |
| 476 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 477 | final int recordCount = mRecords.size(); |
| 478 | for (int i = 0; i < recordCount; i++) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 479 | if (mRecords.get(i).binder == binder) { |
| 480 | mRecords.remove(i); |
| 481 | return; |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | public void notifyCallState(int state, String incomingNumber) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 488 | if (!checkNotifyPermission("notifyCallState()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 489 | return; |
| 490 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 491 | synchronized (mRecords) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 492 | for (Record r : mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 493 | if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && |
| 494 | (r.isLegacyApp == true)) { |
| 495 | // FIXME: why does isLegacyApp need to be true? |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 496 | try { |
| 497 | r.callback.onCallStateChanged(state, incomingNumber); |
| 498 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 499 | mRemoveList.add(r.binder); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 500 | } |
| 501 | } |
| 502 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 503 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 504 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 505 | broadcastCallStateChanged(state, incomingNumber, mDefaultSubId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 506 | } |
| 507 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 508 | public void notifyCallStateUsingSubId(long subId, int state, String incomingNumber) { |
| 509 | if (!checkNotifyPermission("notifyCallState()")) { |
| 510 | return; |
| 511 | } |
| 512 | if (VDBG) { |
| 513 | Slog.d(TAG, "notifyCallStateUsingSubId: subId=" + subId |
| 514 | + " state=" + state + " incomingNumber=" + incomingNumber); |
| 515 | } |
| 516 | synchronized (mRecords) { |
| 517 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 518 | if (validatePhoneId(phoneId)) { |
| 519 | mCallState[phoneId] = state; |
| 520 | mCallIncomingNumber[phoneId] = incomingNumber; |
| 521 | for (Record r : mRecords) { |
| 522 | if (((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) && |
| 523 | (r.subId == subId) && (r.isLegacyApp == false)) { |
| 524 | // FIXME: why isLegacyApp false? |
| 525 | try { |
| 526 | r.callback.onCallStateChanged(state, incomingNumber); |
| 527 | } catch (RemoteException ex) { |
| 528 | mRemoveList.add(r.binder); |
| 529 | } |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | handleRemoveListLocked(); |
| 534 | } |
| 535 | broadcastCallStateChanged(state, incomingNumber, subId); |
| 536 | } |
| 537 | |
| 538 | public void notifyServiceState(ServiceState state) { |
| 539 | notifyServiceStateUsingSubId(mDefaultSubId, state); |
| 540 | } |
| 541 | |
| 542 | public void notifyServiceStateUsingSubId(long subId, ServiceState state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 543 | if (!checkNotifyPermission("notifyServiceState()")){ |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 544 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 545 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 546 | if (subId == SubscriptionManager.DEFAULT_SUB_ID) { |
| 547 | subId = mDefaultSubId; |
| 548 | Slog.d(TAG, "notifyServiceStateUsingSubId: using mDefaultSubId=" + mDefaultSubId); |
| 549 | } |
| 550 | if (VDBG) { |
| 551 | Slog.d(TAG, "notifyServiceStateUsingSubId: subId=" + subId |
| 552 | + " state=" + state); |
Dianne Hackborn | 2ffa11e | 2014-04-21 15:56:18 -0700 | [diff] [blame] | 553 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 554 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 555 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 556 | if (validatePhoneId(phoneId)) { |
| 557 | mServiceState[phoneId] = state; |
| 558 | for (Record r : mRecords) { |
| 559 | // FIXME: use DEFAULT_SUB_ID instead?? |
| 560 | if (((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) && |
| 561 | (r.subId == subId)) { |
| 562 | try { |
| 563 | r.callback.onServiceStateChanged(new ServiceState(state)); |
| 564 | } catch (RemoteException ex) { |
| 565 | mRemoveList.add(r.binder); |
| 566 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 567 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 569 | } else { |
| 570 | Slog.d(TAG, "notifyServiceStateUsingSubId: INVALID phoneId=" + phoneId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 571 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 572 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 573 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 574 | broadcastServiceStateChanged(state, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 575 | } |
| 576 | |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 577 | public void notifySignalStrength(SignalStrength signalStrength) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 578 | notifySignalStrengthUsingSubId(mDefaultSubId, signalStrength); |
| 579 | } |
| 580 | |
| 581 | public void notifySignalStrengthUsingSubId(long subId, SignalStrength signalStrength) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 582 | if (!checkNotifyPermission("notifySignalStrength()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 583 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 584 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 585 | if (VDBG) { |
| 586 | Slog.d(TAG, "notifySignalStrengthUsingSubId: subId=" + subId |
| 587 | + " signalStrength=" + signalStrength); |
| 588 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 589 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 590 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 591 | if (validatePhoneId(phoneId)) { |
| 592 | mSignalStrength[phoneId] = signalStrength; |
| 593 | for (Record r : mRecords) { |
| 594 | if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) && |
| 595 | (r.subId == subId)){ |
| 596 | try { |
| 597 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 598 | } catch (RemoteException ex) { |
| 599 | mRemoveList.add(r.binder); |
| 600 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 601 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 602 | if (((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) && |
| 603 | (r.subId == subId)) { |
| 604 | try { |
| 605 | int gsmSignalStrength = signalStrength.getGsmSignalStrength(); |
| 606 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 607 | : gsmSignalStrength)); |
| 608 | } catch (RemoteException ex) { |
| 609 | mRemoveList.add(r.binder); |
| 610 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 611 | } |
| 612 | } |
| 613 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 614 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 615 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 616 | broadcastSignalStrengthChanged(signalStrength, subId); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 617 | } |
| 618 | |
Wink Saville | b208a24 | 2012-07-25 14:08:09 -0700 | [diff] [blame] | 619 | public void notifyCellInfo(List<CellInfo> cellInfo) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 620 | notifyCellInfoUsingSubId(mDefaultSubId, cellInfo); |
| 621 | } |
| 622 | |
| 623 | public void notifyCellInfoUsingSubId(long subId, List<CellInfo> cellInfo) { |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 624 | if (!checkNotifyPermission("notifyCellInfo()")) { |
| 625 | return; |
| 626 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 627 | if (VDBG) { |
| 628 | Slog.d(TAG, "notifyCellInfoUsingSubId: subId=" + subId |
| 629 | + " cellInfo=" + cellInfo); |
| 630 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 631 | |
| 632 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 633 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 634 | if (validatePhoneId(phoneId)) { |
| 635 | mCellInfo.set(phoneId, cellInfo); |
| 636 | for (Record r : mRecords) { |
| 637 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_INFO) |
| 638 | && r.subId == subId) { |
| 639 | try { |
| 640 | if (DBG_LOC) { |
| 641 | Slog.d(TAG, "notifyCellInfo: mCellInfo=" + cellInfo + " r=" + r); |
| 642 | } |
| 643 | r.callback.onCellInfoChanged(cellInfo); |
| 644 | } catch (RemoteException ex) { |
| 645 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 646 | } |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 647 | } |
| 648 | } |
| 649 | } |
| 650 | handleRemoveListLocked(); |
| 651 | } |
| 652 | } |
| 653 | |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 654 | public void notifyDataConnectionRealTimeInfo(DataConnectionRealTimeInfo dcRtInfo) { |
| 655 | if (!checkNotifyPermission("notifyDataConnectionRealTimeInfo()")) { |
| 656 | return; |
| 657 | } |
| 658 | |
| 659 | synchronized (mRecords) { |
| 660 | mDcRtInfo = dcRtInfo; |
| 661 | for (Record r : mRecords) { |
| 662 | if (validateEventsAndUserLocked(r, |
| 663 | PhoneStateListener.LISTEN_DATA_CONNECTION_REAL_TIME_INFO)) { |
| 664 | try { |
| 665 | if (DBG_LOC) { |
| 666 | Slog.d(TAG, "notifyDataConnectionRealTimeInfo: mDcRtInfo=" |
| 667 | + mDcRtInfo + " r=" + r); |
| 668 | } |
| 669 | r.callback.onDataConnectionRealTimeInfoChanged(mDcRtInfo); |
| 670 | } catch (RemoteException ex) { |
| 671 | mRemoveList.add(r.binder); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | handleRemoveListLocked(); |
| 676 | } |
| 677 | } |
| 678 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 679 | public void notifyMessageWaitingChanged(boolean mwi) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 680 | notifyMessageWaitingChangedUsingSubId(mDefaultSubId, mwi); |
| 681 | } |
| 682 | |
| 683 | public void notifyMessageWaitingChangedUsingSubId(long subId, boolean mwi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 684 | if (!checkNotifyPermission("notifyMessageWaitingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 685 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 686 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 687 | if (VDBG) { |
| 688 | Slog.d(TAG, "notifyMessageWaitingChangedUsingSubId: subId=" + subId |
| 689 | + " mwi=" + mwi); |
| 690 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | mMessageWaiting[phoneId] = mwi; |
| 695 | for (Record r : mRecords) { |
| 696 | if (((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) && |
| 697 | (r.subId == subId)) { |
| 698 | try { |
| 699 | r.callback.onMessageWaitingIndicatorChanged(mwi); |
| 700 | } catch (RemoteException ex) { |
| 701 | mRemoveList.add(r.binder); |
| 702 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 706 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 707 | } |
| 708 | } |
| 709 | |
| 710 | public void notifyCallForwardingChanged(boolean cfi) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 711 | notifyCallForwardingChangedUsingSubId(mDefaultSubId, cfi); |
| 712 | } |
| 713 | |
| 714 | public void notifyCallForwardingChangedUsingSubId(long subId, boolean cfi) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 715 | if (!checkNotifyPermission("notifyCallForwardingChanged()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 716 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 717 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 718 | if (VDBG) { |
| 719 | Slog.d(TAG, "notifyCallForwardingChangedUsingSubId: subId=" + subId |
| 720 | + " cfi=" + cfi); |
| 721 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 722 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 723 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 724 | if (validatePhoneId(phoneId)) { |
| 725 | mCallForwarding[phoneId] = cfi; |
| 726 | for (Record r : mRecords) { |
| 727 | if (((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) && |
| 728 | (r.subId == subId)) { |
| 729 | try { |
| 730 | r.callback.onCallForwardingIndicatorChanged(cfi); |
| 731 | } catch (RemoteException ex) { |
| 732 | mRemoveList.add(r.binder); |
| 733 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 734 | } |
| 735 | } |
| 736 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 737 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 738 | } |
| 739 | } |
| 740 | |
| 741 | public void notifyDataActivity(int state) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 742 | notifyDataActivityUsingSubId(mDefaultSubId, state); |
| 743 | } |
| 744 | |
| 745 | public void notifyDataActivityUsingSubId(long subId, int state) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 746 | if (!checkNotifyPermission("notifyDataActivity()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 747 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 748 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 749 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 750 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 751 | mDataActivity[phoneId] = state; |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 752 | for (Record r : mRecords) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 753 | if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 754 | try { |
| 755 | r.callback.onDataActivity(state); |
| 756 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 757 | mRemoveList.add(r.binder); |
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 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 765 | public void notifyDataConnection(int state, boolean isDataConnectivityPossible, |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 766 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 767 | NetworkCapabilities networkCapabilities, int networkType, boolean roaming) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 768 | notifyDataConnectionUsingSubId(mDefaultSubId, state, isDataConnectivityPossible, |
| 769 | reason, apn, apnType, linkProperties, |
| 770 | networkCapabilities, networkType, roaming); |
| 771 | } |
| 772 | |
| 773 | public void notifyDataConnectionUsingSubId(long subId, int state, |
| 774 | boolean isDataConnectivityPossible, String reason, String apn, String apnType, |
| 775 | LinkProperties linkProperties, NetworkCapabilities networkCapabilities, |
| 776 | int networkType, boolean roaming) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 777 | if (!checkNotifyPermission("notifyDataConnection()" )) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 778 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 779 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 780 | if (VDBG) { |
| 781 | Slog.i(TAG, "notifyDataConnectionUsingSubId: subId=" + subId |
| 782 | + " state=" + state + " isDataConnectivityPossible=" + isDataConnectivityPossible |
| 783 | + " reason='" + reason |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 784 | + "' apn='" + apn + "' apnType=" + apnType + " networkType=" + networkType |
| 785 | + " mRecords.size()=" + mRecords.size() + " mRecords=" + mRecords); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 786 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 787 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 788 | int phoneId = SubscriptionManager.getPhoneId(subId); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 789 | boolean modified = false; |
| 790 | if (state == TelephonyManager.DATA_CONNECTED) { |
| 791 | if (!mConnectedApns.contains(apnType)) { |
| 792 | mConnectedApns.add(apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 793 | if (mDataConnectionState[phoneId] != state) { |
| 794 | mDataConnectionState[phoneId] = state; |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 795 | modified = true; |
| 796 | } |
| 797 | } |
| 798 | } else { |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 799 | if (mConnectedApns.remove(apnType)) { |
| 800 | if (mConnectedApns.isEmpty()) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 801 | mDataConnectionState[phoneId] = state; |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 802 | modified = true; |
| 803 | } else { |
| 804 | // leave mDataConnectionState as is and |
| 805 | // send out the new status for the APN in question. |
| 806 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 807 | } |
| 808 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 809 | mDataConnectionPossible[phoneId] = isDataConnectivityPossible; |
| 810 | mDataConnectionReason[phoneId] = reason; |
| 811 | mDataConnectionLinkProperties[phoneId] = linkProperties; |
| 812 | mDataConnectionNetworkCapabilities[phoneId] = networkCapabilities; |
| 813 | if (mDataConnectionNetworkType[phoneId] != networkType) { |
| 814 | mDataConnectionNetworkType[phoneId] = networkType; |
Robert Greenwalt | 8e7e0a9 | 2010-11-09 10:24:40 -0800 | [diff] [blame] | 815 | // need to tell registered listeners about the new network type |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 816 | modified = true; |
| 817 | } |
| 818 | if (modified) { |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 819 | if (DBG) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 820 | Slog.d(TAG, "onDataConnectionStateChanged(" + mDataConnectionState[phoneId] |
| 821 | + ", " + mDataConnectionNetworkType[phoneId] + ")"); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 822 | } |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 823 | for (Record r : mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 824 | if (((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) && |
| 825 | (r.subId == subId)) { |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 826 | try { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 827 | Slog.d(TAG,"Notify data connection state changed on sub: " + |
| 828 | subId); |
| 829 | r.callback.onDataConnectionStateChanged(mDataConnectionState[phoneId], |
| 830 | mDataConnectionNetworkType[phoneId]); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 831 | } catch (RemoteException ex) { |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 832 | mRemoveList.add(r.binder); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 833 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | } |
| 835 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 836 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 838 | mPreciseDataConnectionState = new PreciseDataConnectionState(state, networkType, |
| 839 | apnType, apn, reason, linkProperties, ""); |
| 840 | for (Record r : mRecords) { |
| 841 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 842 | try { |
| 843 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 844 | } catch (RemoteException ex) { |
| 845 | mRemoveList.add(r.binder); |
| 846 | } |
| 847 | } |
| 848 | } |
| 849 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 850 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 851 | broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 852 | apnType, linkProperties, networkCapabilities, roaming, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 853 | broadcastPreciseDataConnectionStateChanged(state, networkType, apnType, apn, reason, |
| 854 | linkProperties, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 855 | } |
| 856 | |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 857 | public void notifyDataConnectionFailed(String reason, String apnType) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 858 | notifyDataConnectionFailedUsingSubId(mDefaultSubId, reason, apnType); |
| 859 | } |
| 860 | |
| 861 | public void notifyDataConnectionFailedUsingSubId(long subId, |
| 862 | String reason, String apnType) { |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 863 | if (!checkNotifyPermission("notifyDataConnectionFailed()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 864 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 865 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 866 | if (VDBG) { |
| 867 | Slog.d(TAG, "notifyDataConnectionFailedUsingSubId: subId=" + subId |
| 868 | + " reason=" + reason + " apnType=" + apnType); |
| 869 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 870 | synchronized (mRecords) { |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 871 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 872 | TelephonyManager.DATA_UNKNOWN,TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 873 | apnType, "", reason, null, ""); |
| 874 | for (Record r : mRecords) { |
| 875 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 876 | try { |
| 877 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 878 | } catch (RemoteException ex) { |
| 879 | mRemoveList.add(r.binder); |
| 880 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 881 | } |
| 882 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 883 | handleRemoveListLocked(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 884 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 885 | broadcastDataConnectionFailed(reason, apnType, subId); |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 886 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 887 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, "", reason, null, ""); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 888 | } |
| 889 | |
| 890 | public void notifyCellLocation(Bundle cellLocation) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 891 | notifyCellLocationUsingSubId(mDefaultSubId, cellLocation); |
| 892 | } |
| 893 | |
| 894 | public void notifyCellLocationUsingSubId(long subId, Bundle cellLocation) { |
| 895 | Slog.d(TAG, "notifyCellLocationUsingSubId: subId=" + subId |
| 896 | + " cellLocation=" + cellLocation); |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 897 | if (!checkNotifyPermission("notifyCellLocation()")) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 898 | return; |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 899 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 900 | if (VDBG) { |
| 901 | Slog.d(TAG, "notifyCellLocationUsingSubId: subId=" + subId |
| 902 | + " cellLocation=" + cellLocation); |
| 903 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 904 | synchronized (mRecords) { |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 905 | int phoneId = SubscriptionManager.getPhoneId(subId); |
| 906 | if (validatePhoneId(phoneId)) { |
| 907 | mCellLocation[phoneId] = cellLocation; |
| 908 | for (Record r : mRecords) { |
| 909 | if (validateEventsAndUserLocked(r, PhoneStateListener.LISTEN_CELL_LOCATION) |
| 910 | && r.subId == subId) { |
| 911 | try { |
| 912 | if (DBG_LOC) { |
| 913 | Slog.d(TAG, "notifyCellLocation: cellLocation=" + cellLocation |
| 914 | + " r=" + r); |
| 915 | } |
| 916 | r.callback.onCellLocationChanged(new Bundle(cellLocation)); |
| 917 | } catch (RemoteException ex) { |
| 918 | mRemoveList.add(r.binder); |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 919 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 920 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 921 | } |
| 922 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 923 | handleRemoveListLocked(); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 924 | } |
| 925 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 926 | |
Wink Saville | fd2d013 | 2010-10-28 14:22:26 -0700 | [diff] [blame] | 927 | public void notifyOtaspChanged(int otaspMode) { |
| 928 | if (!checkNotifyPermission("notifyOtaspChanged()" )) { |
| 929 | return; |
| 930 | } |
| 931 | synchronized (mRecords) { |
| 932 | mOtaspMode = otaspMode; |
| 933 | for (Record r : mRecords) { |
| 934 | if ((r.events & PhoneStateListener.LISTEN_OTASP_CHANGED) != 0) { |
| 935 | try { |
| 936 | r.callback.onOtaspChanged(otaspMode); |
| 937 | } catch (RemoteException ex) { |
| 938 | mRemoveList.add(r.binder); |
| 939 | } |
| 940 | } |
| 941 | } |
| 942 | handleRemoveListLocked(); |
| 943 | } |
| 944 | } |
| 945 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 946 | public void notifyPreciseCallState(int ringingCallState, int foregroundCallState, |
| 947 | int backgroundCallState) { |
| 948 | if (!checkNotifyPermission("notifyPreciseCallState()")) { |
| 949 | return; |
| 950 | } |
| 951 | synchronized (mRecords) { |
| 952 | mRingingCallState = ringingCallState; |
| 953 | mForegroundCallState = foregroundCallState; |
| 954 | mBackgroundCallState = backgroundCallState; |
| 955 | mPreciseCallState = new PreciseCallState(ringingCallState, foregroundCallState, |
| 956 | backgroundCallState, |
| 957 | DisconnectCause.NOT_VALID, |
| 958 | PreciseDisconnectCause.NOT_VALID); |
| 959 | for (Record r : mRecords) { |
| 960 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 961 | try { |
| 962 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 963 | } catch (RemoteException ex) { |
| 964 | mRemoveList.add(r.binder); |
| 965 | } |
| 966 | } |
| 967 | } |
| 968 | handleRemoveListLocked(); |
| 969 | } |
| 970 | broadcastPreciseCallStateChanged(ringingCallState, foregroundCallState, backgroundCallState, |
| 971 | DisconnectCause.NOT_VALID, |
| 972 | PreciseDisconnectCause.NOT_VALID); |
| 973 | } |
| 974 | |
| 975 | public void notifyDisconnectCause(int disconnectCause, int preciseDisconnectCause) { |
| 976 | if (!checkNotifyPermission("notifyDisconnectCause()")) { |
| 977 | return; |
| 978 | } |
| 979 | synchronized (mRecords) { |
| 980 | mPreciseCallState = new PreciseCallState(mRingingCallState, mForegroundCallState, |
| 981 | mBackgroundCallState, disconnectCause, preciseDisconnectCause); |
| 982 | for (Record r : mRecords) { |
| 983 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_CALL_STATE) != 0) { |
| 984 | try { |
| 985 | r.callback.onPreciseCallStateChanged(mPreciseCallState); |
| 986 | } catch (RemoteException ex) { |
| 987 | mRemoveList.add(r.binder); |
| 988 | } |
| 989 | } |
| 990 | } |
| 991 | handleRemoveListLocked(); |
| 992 | } |
| 993 | broadcastPreciseCallStateChanged(mRingingCallState, mForegroundCallState, |
| 994 | mBackgroundCallState, disconnectCause, preciseDisconnectCause); |
| 995 | } |
| 996 | |
| 997 | public void notifyPreciseDataConnectionFailed(String reason, String apnType, |
| 998 | String apn, String failCause) { |
| 999 | if (!checkNotifyPermission("notifyPreciseDataConnectionFailed()")) { |
| 1000 | return; |
| 1001 | } |
| 1002 | synchronized (mRecords) { |
| 1003 | mPreciseDataConnectionState = new PreciseDataConnectionState( |
| 1004 | TelephonyManager.DATA_UNKNOWN, TelephonyManager.NETWORK_TYPE_UNKNOWN, |
| 1005 | apnType, apn, reason, null, failCause); |
| 1006 | for (Record r : mRecords) { |
| 1007 | if ((r.events & PhoneStateListener.LISTEN_PRECISE_DATA_CONNECTION_STATE) != 0) { |
| 1008 | try { |
| 1009 | r.callback.onPreciseDataConnectionStateChanged(mPreciseDataConnectionState); |
| 1010 | } catch (RemoteException ex) { |
| 1011 | mRemoveList.add(r.binder); |
| 1012 | } |
| 1013 | } |
| 1014 | } |
| 1015 | handleRemoveListLocked(); |
| 1016 | } |
| 1017 | broadcastPreciseDataConnectionStateChanged(TelephonyManager.DATA_UNKNOWN, |
| 1018 | TelephonyManager.NETWORK_TYPE_UNKNOWN, apnType, apn, reason, null, failCause); |
| 1019 | } |
| 1020 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1021 | public void notifyVoLteServiceStateChanged(VoLteServiceState lteState) { |
| 1022 | if (!checkNotifyPermission("notifyVoLteServiceStateChanged()")) { |
| 1023 | return; |
| 1024 | } |
| 1025 | synchronized (mRecords) { |
| 1026 | mVoLteServiceState = lteState; |
| 1027 | for (Record r : mRecords) { |
| 1028 | if ((r.events & PhoneStateListener.LISTEN_VOLTE_STATE) != 0) { |
| 1029 | try { |
| 1030 | r.callback.onVoLteServiceStateChanged( |
| 1031 | new VoLteServiceState(mVoLteServiceState)); |
| 1032 | } catch (RemoteException ex) { |
| 1033 | mRemoveList.add(r.binder); |
| 1034 | } |
| 1035 | } |
| 1036 | } |
| 1037 | handleRemoveListLocked(); |
| 1038 | } |
| 1039 | } |
| 1040 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1041 | @Override |
| 1042 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 1043 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 1044 | != PackageManager.PERMISSION_GRANTED) { |
| 1045 | pw.println("Permission Denial: can't dump telephony.registry from from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1046 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1047 | return; |
| 1048 | } |
| 1049 | synchronized (mRecords) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1050 | final int recordCount = mRecords.size(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1051 | pw.println("last known state:"); |
| 1052 | pw.println(" mCallState=" + mCallState); |
| 1053 | pw.println(" mCallIncomingNumber=" + mCallIncomingNumber); |
| 1054 | pw.println(" mServiceState=" + mServiceState); |
| 1055 | pw.println(" mSignalStrength=" + mSignalStrength); |
| 1056 | pw.println(" mMessageWaiting=" + mMessageWaiting); |
| 1057 | pw.println(" mCallForwarding=" + mCallForwarding); |
| 1058 | pw.println(" mDataActivity=" + mDataActivity); |
| 1059 | pw.println(" mDataConnectionState=" + mDataConnectionState); |
| 1060 | pw.println(" mDataConnectionPossible=" + mDataConnectionPossible); |
| 1061 | pw.println(" mDataConnectionReason=" + mDataConnectionReason); |
| 1062 | pw.println(" mDataConnectionApn=" + mDataConnectionApn); |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1063 | pw.println(" mDataConnectionLinkProperties=" + mDataConnectionLinkProperties); |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 1064 | pw.println(" mDataConnectionNetworkCapabilities=" + |
| 1065 | mDataConnectionNetworkCapabilities); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1066 | pw.println(" mCellLocation=" + mCellLocation); |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1067 | pw.println(" mCellInfo=" + mCellInfo); |
Wink Saville | 070e061 | 2014-04-15 22:04:10 -0700 | [diff] [blame] | 1068 | pw.println(" mDcRtInfo=" + mDcRtInfo); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1069 | pw.println("registrations: count=" + recordCount); |
Robert Greenwalt | 02648a4 | 2010-05-18 10:52:51 -0700 | [diff] [blame] | 1070 | for (Record r : mRecords) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1071 | pw.println(" " + r.pkgForDebug + " 0x" + Integer.toHexString(r.events)); |
| 1072 | } |
| 1073 | } |
| 1074 | } |
| 1075 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1076 | // |
| 1077 | // the legacy intent broadcasting |
| 1078 | // |
| 1079 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1080 | private void broadcastServiceStateChanged(ServiceState state, long subId) { |
| 1081 | long ident = Binder.clearCallingIdentity(); |
| 1082 | try { |
| 1083 | mBatteryStats.notePhoneState(state.getState()); |
| 1084 | } catch (RemoteException re) { |
| 1085 | // Can't do much |
| 1086 | } finally { |
| 1087 | Binder.restoreCallingIdentity(ident); |
| 1088 | } |
| 1089 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1090 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| 1091 | Bundle data = new Bundle(); |
| 1092 | state.fillInNotifierBundle(data); |
| 1093 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1094 | // Pass the subscription along with the intent. |
| 1095 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1096 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1097 | } |
| 1098 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1099 | private void broadcastSignalStrengthChanged(SignalStrength signalStrength, long subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1100 | long ident = Binder.clearCallingIdentity(); |
| 1101 | try { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1102 | mBatteryStats.notePhoneSignalStrength(signalStrength); |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1103 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1104 | /* The remote entity disappeared, we can safely ignore the exception. */ |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1105 | } finally { |
| 1106 | Binder.restoreCallingIdentity(ident); |
| 1107 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1108 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1109 | Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); |
Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 1110 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1111 | Bundle data = new Bundle(); |
| 1112 | signalStrength.fillInNotifierBundle(data); |
| 1113 | intent.putExtras(data); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1114 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1115 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1116 | } |
| 1117 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1118 | private void broadcastCallStateChanged(int state, String incomingNumber, long subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1119 | long ident = Binder.clearCallingIdentity(); |
| 1120 | try { |
| 1121 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
| 1122 | mBatteryStats.notePhoneOff(); |
| 1123 | } else { |
| 1124 | mBatteryStats.notePhoneOn(); |
| 1125 | } |
| 1126 | } catch (RemoteException e) { |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1127 | /* 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] | 1128 | } finally { |
| 1129 | Binder.restoreCallingIdentity(ident); |
| 1130 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1131 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1132 | Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1133 | intent.putExtra(PhoneConstants.STATE_KEY, |
| 1134 | DefaultPhoneNotifier.convertCallState(state).toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1135 | if (!TextUtils.isEmpty(incomingNumber)) { |
| 1136 | intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); |
| 1137 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1138 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1139 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1140 | android.Manifest.permission.READ_PHONE_STATE); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1141 | } |
| 1142 | |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 1143 | private void broadcastDataConnectionStateChanged(int state, |
| 1144 | boolean isDataConnectivityPossible, |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1145 | String reason, String apn, String apnType, LinkProperties linkProperties, |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1146 | NetworkCapabilities networkCapabilities, boolean roaming, long subId) { |
Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 1147 | // Note: not reporting to the battery stats service here, because the |
| 1148 | // status bar takes care of that after taking into account all of the |
| 1149 | // required info. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1150 | Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1151 | intent.putExtra(PhoneConstants.STATE_KEY, |
| 1152 | DefaultPhoneNotifier.convertDataState(state).toString()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1153 | if (!isDataConnectivityPossible) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1154 | intent.putExtra(PhoneConstants.NETWORK_UNAVAILABLE_KEY, true); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1155 | } |
| 1156 | if (reason != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1157 | intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1158 | } |
Robert Greenwalt | 37e65eb | 2010-08-30 10:56:47 -0700 | [diff] [blame] | 1159 | if (linkProperties != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1160 | intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
Irfan Sheriff | ed5d7d1 | 2010-10-01 16:08:28 -0700 | [diff] [blame] | 1161 | String iface = linkProperties.getInterfaceName(); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1162 | if (iface != null) { |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1163 | intent.putExtra(PhoneConstants.DATA_IFACE_NAME_KEY, iface); |
Robert Greenwalt | 47f69fe | 2010-06-15 15:43:39 -0700 | [diff] [blame] | 1164 | } |
| 1165 | } |
Robert Greenwalt | f9cb86a | 2014-04-08 17:34:00 -0700 | [diff] [blame] | 1166 | if (networkCapabilities != null) { |
| 1167 | intent.putExtra(PhoneConstants.DATA_NETWORK_CAPABILITIES_KEY, networkCapabilities); |
Wink Saville | f61101f | 2010-09-16 16:36:42 -0700 | [diff] [blame] | 1168 | } |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1169 | if (roaming) intent.putExtra(PhoneConstants.DATA_NETWORK_ROAMING_KEY, true); |
Robert Greenwalt | a6d4248 | 2011-09-02 15:19:31 -0700 | [diff] [blame] | 1170 | |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1171 | intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 1172 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1173 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1174 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1175 | } |
| 1176 | |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1177 | private void broadcastDataConnectionFailed(String reason, String apnType, |
| 1178 | long subId) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1179 | Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); |
Wink Saville | a639b31 | 2012-07-10 12:37:54 -0700 | [diff] [blame] | 1180 | intent.putExtra(PhoneConstants.FAILURE_REASON_KEY, reason); |
| 1181 | intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1182 | intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, subId); |
Dianne Hackborn | 5ac72a2 | 2012-08-29 18:32:08 -0700 | [diff] [blame] | 1183 | mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1184 | } |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1185 | |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1186 | private void broadcastPreciseCallStateChanged(int ringingCallState, int foregroundCallState, |
| 1187 | int backgroundCallState, int disconnectCause, int preciseDisconnectCause) { |
| 1188 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_CALL_STATE_CHANGED); |
| 1189 | intent.putExtra(TelephonyManager.EXTRA_RINGING_CALL_STATE, ringingCallState); |
| 1190 | intent.putExtra(TelephonyManager.EXTRA_FOREGROUND_CALL_STATE, foregroundCallState); |
| 1191 | intent.putExtra(TelephonyManager.EXTRA_BACKGROUND_CALL_STATE, backgroundCallState); |
| 1192 | intent.putExtra(TelephonyManager.EXTRA_DISCONNECT_CAUSE, disconnectCause); |
| 1193 | intent.putExtra(TelephonyManager.EXTRA_PRECISE_DISCONNECT_CAUSE, preciseDisconnectCause); |
| 1194 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1195 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1196 | } |
| 1197 | |
| 1198 | private void broadcastPreciseDataConnectionStateChanged(int state, int networkType, |
| 1199 | String apnType, String apn, String reason, LinkProperties linkProperties, String failCause) { |
| 1200 | Intent intent = new Intent(TelephonyManager.ACTION_PRECISE_DATA_CONNECTION_STATE_CHANGED); |
| 1201 | intent.putExtra(PhoneConstants.STATE_KEY, state); |
| 1202 | intent.putExtra(PhoneConstants.DATA_NETWORK_TYPE_KEY, networkType); |
| 1203 | if (reason != null) intent.putExtra(PhoneConstants.STATE_CHANGE_REASON_KEY, reason); |
| 1204 | if (apnType != null) intent.putExtra(PhoneConstants.DATA_APN_TYPE_KEY, apnType); |
| 1205 | if (apn != null) intent.putExtra(PhoneConstants.DATA_APN_KEY, apn); |
| 1206 | if (linkProperties != null) intent.putExtra(PhoneConstants.DATA_LINK_PROPERTIES_KEY, linkProperties); |
| 1207 | if (failCause != null) intent.putExtra(PhoneConstants.DATA_FAILURE_CAUSE_KEY, failCause); |
| 1208 | |
| 1209 | mContext.sendBroadcastAsUser(intent, UserHandle.ALL, |
| 1210 | android.Manifest.permission.READ_PRECISE_PHONE_STATE); |
| 1211 | } |
| 1212 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1213 | private boolean checkNotifyPermission(String method) { |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1214 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 1215 | == PackageManager.PERMISSION_GRANTED) { |
| 1216 | return true; |
| 1217 | } |
| 1218 | String msg = "Modify Phone State Permission Denial: " + method + " from pid=" |
Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 1219 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); |
Wink Saville | c9acde9 | 2011-09-21 11:05:43 -0700 | [diff] [blame] | 1220 | if (DBG) Slog.w(TAG, msg); |
The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 1221 | return false; |
| 1222 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1223 | |
| 1224 | private void checkListenerPermission(int events) { |
| 1225 | if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 1226 | mContext.enforceCallingOrSelfPermission( |
| 1227 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
| 1228 | |
| 1229 | } |
| 1230 | |
John Wang | 963db55d | 2012-03-30 16:04:06 -0700 | [diff] [blame] | 1231 | if ((events & PhoneStateListener.LISTEN_CELL_INFO) != 0) { |
| 1232 | mContext.enforceCallingOrSelfPermission( |
| 1233 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
| 1234 | |
| 1235 | } |
| 1236 | |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1237 | if ((events & PHONE_STATE_PERMISSION_MASK) != 0) { |
| 1238 | mContext.enforceCallingOrSelfPermission( |
| 1239 | android.Manifest.permission.READ_PHONE_STATE, null); |
| 1240 | } |
Antonio Marín Cerezuela | c5ac15a | 2013-05-27 11:36:36 +0200 | [diff] [blame] | 1241 | |
| 1242 | if ((events & PRECISE_PHONE_STATE_PERMISSION_MASK) != 0) { |
| 1243 | mContext.enforceCallingOrSelfPermission( |
| 1244 | android.Manifest.permission.READ_PRECISE_PHONE_STATE, null); |
| 1245 | |
| 1246 | } |
Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 1247 | } |
Joe Onorato | 163d8d9 | 2010-10-21 13:21:20 -0400 | [diff] [blame] | 1248 | |
| 1249 | private void handleRemoveListLocked() { |
| 1250 | if (mRemoveList.size() > 0) { |
| 1251 | for (IBinder b: mRemoveList) { |
| 1252 | remove(b); |
| 1253 | } |
| 1254 | mRemoveList.clear(); |
| 1255 | } |
| 1256 | } |
Wink Saville | a12a7b3 | 2012-09-20 10:09:45 -0700 | [diff] [blame] | 1257 | |
| 1258 | private boolean validateEventsAndUserLocked(Record r, int events) { |
| 1259 | int foregroundUser; |
| 1260 | long callingIdentity = Binder.clearCallingIdentity(); |
| 1261 | boolean valid = false; |
| 1262 | try { |
| 1263 | foregroundUser = ActivityManager.getCurrentUser(); |
| 1264 | valid = r.callerUid == foregroundUser && (r.events & events) != 0; |
| 1265 | if (DBG | DBG_LOC) { |
| 1266 | Slog.d(TAG, "validateEventsAndUserLocked: valid=" + valid |
| 1267 | + " r.callerUid=" + r.callerUid + " foregroundUser=" + foregroundUser |
| 1268 | + " r.events=" + r.events + " events=" + events); |
| 1269 | } |
| 1270 | } finally { |
| 1271 | Binder.restoreCallingIdentity(callingIdentity); |
| 1272 | } |
| 1273 | return valid; |
| 1274 | } |
Wink Saville | fb40dd4 | 2014-06-12 17:02:31 -0700 | [diff] [blame^] | 1275 | |
| 1276 | private boolean validatePhoneId(int phoneId) { |
| 1277 | boolean valid = (phoneId >= 0) && (phoneId < mNumPhones); |
| 1278 | if (VDBG) Slog.d(TAG, "validatePhoneId: " + valid); |
| 1279 | return valid; |
| 1280 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1281 | } |