| 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 | |
| 19 | import android.content.Context; |
| 20 | import android.content.Intent; |
| 21 | import android.content.pm.PackageManager; |
| Robert Greenwalt | 8afddad | 2010-08-20 10:01:55 -0700 | [diff] [blame] | 22 | import android.net.NetworkUtils; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | import android.os.Binder; |
| 24 | import android.os.Bundle; |
| 25 | import android.os.IBinder; |
| 26 | import android.os.RemoteException; |
| 27 | import android.telephony.CellLocation; |
| 28 | import android.telephony.PhoneStateListener; |
| 29 | import android.telephony.ServiceState; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 30 | import android.telephony.SignalStrength; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | import android.telephony.TelephonyManager; |
| 32 | import android.text.TextUtils; |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 33 | import android.util.Slog; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 34 | |
| 35 | import java.util.ArrayList; |
| 36 | import java.io.FileDescriptor; |
| 37 | import java.io.PrintWriter; |
| 38 | |
| 39 | import com.android.internal.app.IBatteryStats; |
| 40 | import com.android.internal.telephony.ITelephonyRegistry; |
| 41 | import com.android.internal.telephony.IPhoneStateListener; |
| 42 | import com.android.internal.telephony.DefaultPhoneNotifier; |
| 43 | import com.android.internal.telephony.Phone; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | import com.android.internal.telephony.TelephonyIntents; |
| 45 | import com.android.server.am.BatteryStatsService; |
| 46 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | /** |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 48 | * Since phone process can be restarted, this class provides a centralized place |
| 49 | * that applications can register and be called back from. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 50 | */ |
| 51 | class TelephonyRegistry extends ITelephonyRegistry.Stub { |
| 52 | private static final String TAG = "TelephonyRegistry"; |
| 53 | |
| 54 | private static class Record { |
| 55 | String pkgForDebug; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 56 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | IBinder binder; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 58 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | IPhoneStateListener callback; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 60 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 61 | int events; |
| 62 | } |
| 63 | |
| 64 | private final Context mContext; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 65 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | private final ArrayList<Record> mRecords = new ArrayList(); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 67 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 68 | private final IBatteryStats mBatteryStats; |
| 69 | |
| 70 | private int mCallState = TelephonyManager.CALL_STATE_IDLE; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 71 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | private String mCallIncomingNumber = ""; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 73 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | private ServiceState mServiceState = new ServiceState(); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 75 | |
| 76 | private SignalStrength mSignalStrength = new SignalStrength(); |
| 77 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | private boolean mMessageWaiting = false; |
| 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 | private boolean mCallForwarding = false; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 81 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | private int mDataActivity = TelephonyManager.DATA_ACTIVITY_NONE; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 83 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | private int mDataConnectionState = TelephonyManager.DATA_CONNECTED; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 85 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | private boolean mDataConnectionPossible = false; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 87 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | private String mDataConnectionReason = ""; |
| 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 | private String mDataConnectionApn = ""; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 91 | |
| Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 92 | private String[] mDataConnectionApnTypes = null; |
| 93 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 94 | private String mDataConnectionInterfaceName = ""; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 95 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | private Bundle mCellLocation = new Bundle(); |
| 97 | |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 98 | private int mDataConnectionNetworkType; |
| 99 | |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 100 | static final int PHONE_STATE_PERMISSION_MASK = |
| 101 | PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR | |
| 102 | PhoneStateListener.LISTEN_CALL_STATE | |
| 103 | PhoneStateListener.LISTEN_DATA_ACTIVITY | |
| 104 | PhoneStateListener.LISTEN_DATA_CONNECTION_STATE | |
| 105 | PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR; |
| 106 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 107 | // we keep a copy of all of the state so we can send it out when folks |
| 108 | // register for it |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | // |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 110 | // In these calls we call with the lock held. This is safe becasuse remote |
| 111 | // calls go through a oneway interface and local calls going through a |
| 112 | // handler before they get to app code. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | |
| 114 | TelephonyRegistry(Context context) { |
| David 'Digit' Turner | 4ef8ec3 | 2009-09-25 11:33:24 -0700 | [diff] [blame] | 115 | CellLocation location = CellLocation.getEmpty(); |
| 116 | |
| 117 | // Note that location can be null for non-phone builds like |
| 118 | // like the generic one. |
| 119 | if (location != null) { |
| 120 | location.fillInNotifierBundle(mCellLocation); |
| 121 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | mContext = context; |
| 123 | mBatteryStats = BatteryStatsService.getService(); |
| 124 | } |
| 125 | |
| 126 | public void listen(String pkgForDebug, IPhoneStateListener callback, int events, |
| 127 | boolean notifyNow) { |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 128 | // Slog.d(TAG, "listen pkg=" + pkgForDebug + " events=0x" + |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 129 | // Integer.toHexString(events)); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 130 | if (events != 0) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 131 | /* Checks permission and throws Security exception */ |
| 132 | checkListenerPermission(events); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 133 | |
| 134 | synchronized (mRecords) { |
| 135 | // register |
| 136 | Record r = null; |
| 137 | find_and_add: { |
| 138 | IBinder b = callback.asBinder(); |
| 139 | final int N = mRecords.size(); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 140 | for (int i = 0; i < N; i++) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 141 | r = mRecords.get(i); |
| 142 | if (b == r.binder) { |
| 143 | break find_and_add; |
| 144 | } |
| 145 | } |
| 146 | r = new Record(); |
| 147 | r.binder = b; |
| 148 | r.callback = callback; |
| 149 | r.pkgForDebug = pkgForDebug; |
| 150 | mRecords.add(r); |
| 151 | } |
| 152 | int send = events & (events ^ r.events); |
| 153 | r.events = events; |
| 154 | if (notifyNow) { |
| 155 | if ((events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 156 | sendServiceState(r, mServiceState); |
| 157 | } |
| 158 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 159 | try { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 160 | int gsmSignalStrength = mSignalStrength.getGsmSignalStrength(); |
| 161 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 162 | : gsmSignalStrength)); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 163 | } catch (RemoteException ex) { |
| 164 | remove(r.binder); |
| 165 | } |
| 166 | } |
| 167 | if ((events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 168 | try { |
| 169 | r.callback.onMessageWaitingIndicatorChanged(mMessageWaiting); |
| 170 | } catch (RemoteException ex) { |
| 171 | remove(r.binder); |
| 172 | } |
| 173 | } |
| 174 | if ((events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 175 | try { |
| 176 | r.callback.onCallForwardingIndicatorChanged(mCallForwarding); |
| 177 | } catch (RemoteException ex) { |
| 178 | remove(r.binder); |
| 179 | } |
| 180 | } |
| 181 | if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 182 | sendCellLocation(r, mCellLocation); |
| 183 | } |
| 184 | if ((events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 185 | try { |
| 186 | r.callback.onCallStateChanged(mCallState, mCallIncomingNumber); |
| 187 | } catch (RemoteException ex) { |
| 188 | remove(r.binder); |
| 189 | } |
| 190 | } |
| 191 | if ((events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 192 | try { |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 193 | r.callback.onDataConnectionStateChanged(mDataConnectionState, |
| 194 | mDataConnectionNetworkType); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 195 | } catch (RemoteException ex) { |
| 196 | remove(r.binder); |
| 197 | } |
| 198 | } |
| 199 | if ((events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 200 | try { |
| 201 | r.callback.onDataActivity(mDataActivity); |
| 202 | } catch (RemoteException ex) { |
| 203 | remove(r.binder); |
| 204 | } |
| 205 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 206 | if ((events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 207 | try { |
| 208 | r.callback.onSignalStrengthsChanged(mSignalStrength); |
| 209 | } catch (RemoteException ex) { |
| 210 | remove(r.binder); |
| 211 | } |
| 212 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 213 | } |
| 214 | } |
| 215 | } else { |
| 216 | remove(callback.asBinder()); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | private void remove(IBinder binder) { |
| 221 | synchronized (mRecords) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 222 | final int recordCount = mRecords.size(); |
| 223 | for (int i = 0; i < recordCount; i++) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 224 | if (mRecords.get(i).binder == binder) { |
| 225 | mRecords.remove(i); |
| 226 | return; |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | public void notifyCallState(int state, String incomingNumber) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 233 | if (!checkNotifyPermission("notifyCallState()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 234 | return; |
| 235 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | synchronized (mRecords) { |
| 237 | mCallState = state; |
| 238 | mCallIncomingNumber = incomingNumber; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 239 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 240 | Record r = mRecords.get(i); |
| 241 | if ((r.events & PhoneStateListener.LISTEN_CALL_STATE) != 0) { |
| 242 | try { |
| 243 | r.callback.onCallStateChanged(state, incomingNumber); |
| 244 | } catch (RemoteException ex) { |
| 245 | remove(r.binder); |
| 246 | } |
| 247 | } |
| 248 | } |
| 249 | } |
| 250 | broadcastCallStateChanged(state, incomingNumber); |
| 251 | } |
| 252 | |
| 253 | public void notifyServiceState(ServiceState state) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 254 | if (!checkNotifyPermission("notifyServiceState()")){ |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 255 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 256 | } |
| Joe Onorato | 431bb22 | 2010-10-18 19:13:23 -0400 | [diff] [blame] | 257 | Slog.i(TAG, "notifyServiceState: " + state); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 258 | synchronized (mRecords) { |
| 259 | mServiceState = state; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 260 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 261 | Record r = mRecords.get(i); |
| 262 | if ((r.events & PhoneStateListener.LISTEN_SERVICE_STATE) != 0) { |
| 263 | sendServiceState(r, state); |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | broadcastServiceStateChanged(state); |
| 268 | } |
| 269 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 270 | public void notifySignalStrength(SignalStrength signalStrength) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 271 | if (!checkNotifyPermission("notifySignalStrength()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 272 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 273 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 274 | synchronized (mRecords) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 275 | mSignalStrength = signalStrength; |
| 276 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 277 | Record r = mRecords.get(i); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 278 | if ((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTHS) != 0) { |
| 279 | sendSignalStrength(r, signalStrength); |
| 280 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 281 | if ((r.events & PhoneStateListener.LISTEN_SIGNAL_STRENGTH) != 0) { |
| 282 | try { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 283 | int gsmSignalStrength = signalStrength.getGsmSignalStrength(); |
| 284 | r.callback.onSignalStrengthChanged((gsmSignalStrength == 99 ? -1 |
| 285 | : gsmSignalStrength)); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | } catch (RemoteException ex) { |
| 287 | remove(r.binder); |
| 288 | } |
| 289 | } |
| 290 | } |
| 291 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 292 | broadcastSignalStrengthChanged(signalStrength); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | public void notifyMessageWaitingChanged(boolean mwi) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 296 | if (!checkNotifyPermission("notifyMessageWaitingChanged()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 297 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 298 | } |
| Joe Onorato | 431bb22 | 2010-10-18 19:13:23 -0400 | [diff] [blame] | 299 | Slog.i(TAG, "notifyMessageWaitingChanged: " + mwi); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 300 | synchronized (mRecords) { |
| 301 | mMessageWaiting = mwi; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 302 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 303 | Record r = mRecords.get(i); |
| 304 | if ((r.events & PhoneStateListener.LISTEN_MESSAGE_WAITING_INDICATOR) != 0) { |
| 305 | try { |
| 306 | r.callback.onMessageWaitingIndicatorChanged(mwi); |
| 307 | } catch (RemoteException ex) { |
| 308 | remove(r.binder); |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | public void notifyCallForwardingChanged(boolean cfi) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 316 | if (!checkNotifyPermission("notifyCallForwardingChanged()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 317 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 318 | } |
| Joe Onorato | 431bb22 | 2010-10-18 19:13:23 -0400 | [diff] [blame] | 319 | Slog.i(TAG, "notifyCallForwardingChanged: " + cfi); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 320 | synchronized (mRecords) { |
| 321 | mCallForwarding = cfi; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 322 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 323 | Record r = mRecords.get(i); |
| 324 | if ((r.events & PhoneStateListener.LISTEN_CALL_FORWARDING_INDICATOR) != 0) { |
| 325 | try { |
| 326 | r.callback.onCallForwardingIndicatorChanged(cfi); |
| 327 | } catch (RemoteException ex) { |
| 328 | remove(r.binder); |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | public void notifyDataActivity(int state) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 336 | if (!checkNotifyPermission("notifyDataActivity()" )) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 337 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 338 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 339 | synchronized (mRecords) { |
| 340 | mDataActivity = state; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 341 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 342 | Record r = mRecords.get(i); |
| 343 | if ((r.events & PhoneStateListener.LISTEN_DATA_ACTIVITY) != 0) { |
| 344 | try { |
| 345 | r.callback.onDataActivity(state); |
| 346 | } catch (RemoteException ex) { |
| 347 | remove(r.binder); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 354 | public void notifyDataConnection(int state, boolean isDataConnectivityPossible, |
| Robert Greenwalt | 8afddad | 2010-08-20 10:01:55 -0700 | [diff] [blame] | 355 | String reason, String apn, String[] apnTypes, String interfaceName, int networkType, |
| 356 | String gateway) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 357 | if (!checkNotifyPermission("notifyDataConnection()" )) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 358 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 359 | } |
| Joe Onorato | 431bb22 | 2010-10-18 19:13:23 -0400 | [diff] [blame] | 360 | Slog.i(TAG, "notifyDataConnection: state=" + state + " isDataConnectivityPossible=" |
| 361 | + isDataConnectivityPossible + " reason=" + reason |
| 362 | + " interfaceName=" + interfaceName + " networkType=" + networkType); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 363 | synchronized (mRecords) { |
| 364 | mDataConnectionState = state; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 365 | mDataConnectionPossible = isDataConnectivityPossible; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 366 | mDataConnectionReason = reason; |
| 367 | mDataConnectionApn = apn; |
| Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 368 | mDataConnectionApnTypes = apnTypes; |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 369 | mDataConnectionInterfaceName = interfaceName; |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 370 | mDataConnectionNetworkType = networkType; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 371 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 372 | Record r = mRecords.get(i); |
| 373 | if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_STATE) != 0) { |
| 374 | try { |
| Robert Greenwalt | 98e0b14 | 2009-10-08 21:15:52 -0700 | [diff] [blame] | 375 | r.callback.onDataConnectionStateChanged(state, networkType); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 376 | } catch (RemoteException ex) { |
| 377 | remove(r.binder); |
| 378 | } |
| 379 | } |
| 380 | } |
| 381 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 382 | broadcastDataConnectionStateChanged(state, isDataConnectivityPossible, reason, apn, |
| Robert Greenwalt | 8afddad | 2010-08-20 10:01:55 -0700 | [diff] [blame] | 383 | apnTypes, interfaceName, gateway); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | public void notifyDataConnectionFailed(String reason) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 387 | if (!checkNotifyPermission("notifyDataConnectionFailed()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 388 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 389 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 390 | /* |
| 391 | * This is commented out because there is on onDataConnectionFailed callback |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 392 | * on PhoneStateListener. There should be |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 393 | synchronized (mRecords) { |
| 394 | mDataConnectionFailedReason = reason; |
| 395 | final int N = mRecords.size(); |
| 396 | for (int i=N-1; i>=0; i--) { |
| 397 | Record r = mRecords.get(i); |
| 398 | if ((r.events & PhoneStateListener.LISTEN_DATA_CONNECTION_FAILED) != 0) { |
| 399 | // XXX |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | */ |
| 404 | broadcastDataConnectionFailed(reason); |
| 405 | } |
| 406 | |
| 407 | public void notifyCellLocation(Bundle cellLocation) { |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 408 | if (!checkNotifyPermission("notifyCellLocation()")) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 409 | return; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 410 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 411 | synchronized (mRecords) { |
| 412 | mCellLocation = cellLocation; |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 413 | for (int i = mRecords.size() - 1; i >= 0; i--) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 414 | Record r = mRecords.get(i); |
| 415 | if ((r.events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 416 | sendCellLocation(r, cellLocation); |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | } |
| 421 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 422 | /** |
| 423 | * Copy the service state object so they can't mess it up in the local calls |
| 424 | */ |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 425 | public void sendServiceState(Record r, ServiceState state) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 426 | try { |
| 427 | r.callback.onServiceStateChanged(new ServiceState(state)); |
| 428 | } catch (RemoteException ex) { |
| 429 | remove(r.binder); |
| 430 | } |
| 431 | } |
| 432 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 433 | private void sendCellLocation(Record r, Bundle cellLocation) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 434 | try { |
| 435 | r.callback.onCellLocationChanged(new Bundle(cellLocation)); |
| 436 | } catch (RemoteException ex) { |
| 437 | remove(r.binder); |
| 438 | } |
| 439 | } |
| 440 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 441 | private void sendSignalStrength(Record r, SignalStrength signalStrength) { |
| 442 | try { |
| 443 | r.callback.onSignalStrengthsChanged(new SignalStrength(signalStrength)); |
| 444 | } catch (RemoteException ex) { |
| 445 | remove(r.binder); |
| 446 | } |
| 447 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 448 | |
| 449 | @Override |
| 450 | public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { |
| 451 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) |
| 452 | != PackageManager.PERMISSION_GRANTED) { |
| 453 | pw.println("Permission Denial: can't dump telephony.registry from from pid=" |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 454 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid()); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 455 | return; |
| 456 | } |
| 457 | synchronized (mRecords) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 458 | final int recordCount = mRecords.size(); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 459 | pw.println("last known state:"); |
| 460 | pw.println(" mCallState=" + mCallState); |
| 461 | pw.println(" mCallIncomingNumber=" + mCallIncomingNumber); |
| 462 | pw.println(" mServiceState=" + mServiceState); |
| 463 | pw.println(" mSignalStrength=" + mSignalStrength); |
| 464 | pw.println(" mMessageWaiting=" + mMessageWaiting); |
| 465 | pw.println(" mCallForwarding=" + mCallForwarding); |
| 466 | pw.println(" mDataActivity=" + mDataActivity); |
| 467 | pw.println(" mDataConnectionState=" + mDataConnectionState); |
| 468 | pw.println(" mDataConnectionPossible=" + mDataConnectionPossible); |
| 469 | pw.println(" mDataConnectionReason=" + mDataConnectionReason); |
| 470 | pw.println(" mDataConnectionApn=" + mDataConnectionApn); |
| 471 | pw.println(" mDataConnectionInterfaceName=" + mDataConnectionInterfaceName); |
| 472 | pw.println(" mCellLocation=" + mCellLocation); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 473 | pw.println("registrations: count=" + recordCount); |
| 474 | for (int i = 0; i < recordCount; i++) { |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 475 | Record r = mRecords.get(i); |
| 476 | pw.println(" " + r.pkgForDebug + " 0x" + Integer.toHexString(r.events)); |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 481 | // |
| 482 | // the legacy intent broadcasting |
| 483 | // |
| 484 | |
| 485 | private void broadcastServiceStateChanged(ServiceState state) { |
| Amith Yamasani | 32dbefd | 2009-06-19 09:21:17 -0700 | [diff] [blame] | 486 | long ident = Binder.clearCallingIdentity(); |
| 487 | try { |
| Amith Yamasani | f37447b | 2009-10-08 18:28:01 -0700 | [diff] [blame] | 488 | mBatteryStats.notePhoneState(state.getState()); |
| Amith Yamasani | 32dbefd | 2009-06-19 09:21:17 -0700 | [diff] [blame] | 489 | } catch (RemoteException re) { |
| 490 | // Can't do much |
| 491 | } finally { |
| 492 | Binder.restoreCallingIdentity(ident); |
| 493 | } |
| 494 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 495 | Intent intent = new Intent(TelephonyIntents.ACTION_SERVICE_STATE_CHANGED); |
| Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 496 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 497 | Bundle data = new Bundle(); |
| 498 | state.fillInNotifierBundle(data); |
| 499 | intent.putExtras(data); |
| 500 | mContext.sendStickyBroadcast(intent); |
| 501 | } |
| 502 | |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 503 | private void broadcastSignalStrengthChanged(SignalStrength signalStrength) { |
| Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 504 | long ident = Binder.clearCallingIdentity(); |
| 505 | try { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 506 | mBatteryStats.notePhoneSignalStrength(signalStrength); |
| Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 507 | } catch (RemoteException e) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 508 | /* The remote entity disappeared, we can safely ignore the exception. */ |
| Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 509 | } finally { |
| 510 | Binder.restoreCallingIdentity(ident); |
| 511 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 512 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 513 | Intent intent = new Intent(TelephonyIntents.ACTION_SIGNAL_STRENGTH_CHANGED); |
| Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 514 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 515 | Bundle data = new Bundle(); |
| 516 | signalStrength.fillInNotifierBundle(data); |
| 517 | intent.putExtras(data); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 518 | mContext.sendStickyBroadcast(intent); |
| 519 | } |
| 520 | |
| 521 | private void broadcastCallStateChanged(int state, String incomingNumber) { |
| 522 | long ident = Binder.clearCallingIdentity(); |
| 523 | try { |
| 524 | if (state == TelephonyManager.CALL_STATE_IDLE) { |
| 525 | mBatteryStats.notePhoneOff(); |
| 526 | } else { |
| 527 | mBatteryStats.notePhoneOn(); |
| 528 | } |
| 529 | } catch (RemoteException e) { |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 530 | /* 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] | 531 | } finally { |
| 532 | Binder.restoreCallingIdentity(ident); |
| 533 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 534 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 535 | Intent intent = new Intent(TelephonyManager.ACTION_PHONE_STATE_CHANGED); |
| Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 536 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 537 | intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertCallState(state).toString()); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 538 | if (!TextUtils.isEmpty(incomingNumber)) { |
| 539 | intent.putExtra(TelephonyManager.EXTRA_INCOMING_NUMBER, incomingNumber); |
| 540 | } |
| 541 | mContext.sendBroadcast(intent, android.Manifest.permission.READ_PHONE_STATE); |
| 542 | } |
| 543 | |
| Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 544 | private void broadcastDataConnectionStateChanged(int state, |
| 545 | boolean isDataConnectivityPossible, |
| Robert Greenwalt | 8afddad | 2010-08-20 10:01:55 -0700 | [diff] [blame] | 546 | String reason, String apn, String[] apnTypes, String interfaceName, String gateway) { |
| Dianne Hackborn | 627bba7 | 2009-03-24 22:32:56 -0700 | [diff] [blame] | 547 | // Note: not reporting to the battery stats service here, because the |
| 548 | // status bar takes care of that after taking into account all of the |
| 549 | // required info. |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | Intent intent = new Intent(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED); |
| Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 551 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 552 | intent.putExtra(Phone.STATE_KEY, DefaultPhoneNotifier.convertDataState(state).toString()); |
| 553 | if (!isDataConnectivityPossible) { |
| 554 | intent.putExtra(Phone.NETWORK_UNAVAILABLE_KEY, true); |
| 555 | } |
| 556 | if (reason != null) { |
| 557 | intent.putExtra(Phone.STATE_CHANGE_REASON_KEY, reason); |
| 558 | } |
| 559 | intent.putExtra(Phone.DATA_APN_KEY, apn); |
| Robert Greenwalt | 75e1d31 | 2009-08-19 11:18:53 -0700 | [diff] [blame] | 560 | String types = new String(""); |
| 561 | if (apnTypes.length > 0) { |
| 562 | types = apnTypes[0]; |
| 563 | for (int i = 1; i < apnTypes.length; i++) { |
| 564 | types = types+","+apnTypes[i]; |
| 565 | } |
| Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 566 | } |
| 567 | intent.putExtra(Phone.DATA_APN_TYPES_KEY, types); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 568 | intent.putExtra(Phone.DATA_IFACE_NAME_KEY, interfaceName); |
| Robert Greenwalt | 8afddad | 2010-08-20 10:01:55 -0700 | [diff] [blame] | 569 | int gatewayAddr = 0; |
| 570 | if (gateway != null) { |
| 571 | gatewayAddr = NetworkUtils.v4StringToInt(gateway); |
| 572 | } |
| 573 | intent.putExtra(Phone.DATA_GATEWAY_KEY, gatewayAddr); |
| 574 | |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 575 | mContext.sendStickyBroadcast(intent); |
| 576 | } |
| 577 | |
| 578 | private void broadcastDataConnectionFailed(String reason) { |
| 579 | Intent intent = new Intent(TelephonyIntents.ACTION_DATA_CONNECTION_FAILED); |
| Dianne Hackborn | 1c633fc | 2009-12-08 19:45:14 -0800 | [diff] [blame] | 580 | intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING); |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 581 | intent.putExtra(Phone.FAILURE_REASON_KEY, reason); |
| 582 | mContext.sendStickyBroadcast(intent); |
| 583 | } |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 584 | |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 585 | private boolean checkNotifyPermission(String method) { |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 586 | if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.MODIFY_PHONE_STATE) |
| 587 | == PackageManager.PERMISSION_GRANTED) { |
| 588 | return true; |
| 589 | } |
| 590 | String msg = "Modify Phone State Permission Denial: " + method + " from pid=" |
| Wink Saville | e9b06d7 | 2009-05-18 21:47:50 -0700 | [diff] [blame] | 591 | + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid(); |
| Joe Onorato | 8a9b220 | 2010-02-26 18:56:32 -0800 | [diff] [blame] | 592 | Slog.w(TAG, msg); |
| The Android Open Source Project | ba87e3e | 2009-03-13 13:04:22 -0700 | [diff] [blame] | 593 | return false; |
| 594 | } |
| Jaikumar Ganesh | 4551565 | 2009-04-23 15:20:21 -0700 | [diff] [blame] | 595 | |
| 596 | private void checkListenerPermission(int events) { |
| 597 | if ((events & PhoneStateListener.LISTEN_CELL_LOCATION) != 0) { |
| 598 | mContext.enforceCallingOrSelfPermission( |
| 599 | android.Manifest.permission.ACCESS_COARSE_LOCATION, null); |
| 600 | |
| 601 | } |
| 602 | |
| 603 | if ((events & PHONE_STATE_PERMISSION_MASK) != 0) { |
| 604 | mContext.enforceCallingOrSelfPermission( |
| 605 | android.Manifest.permission.READ_PHONE_STATE, null); |
| 606 | } |
| 607 | } |
| The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 608 | } |