The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.server; |
| 18 | |
| 19 | import android.bluetooth.BluetoothA2dp; |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 20 | import android.bluetooth.BluetoothAdapter; |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 21 | import android.bluetooth.BluetoothClass; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | import android.bluetooth.BluetoothDevice; |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 23 | import android.bluetooth.BluetoothUuid; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.content.Intent; |
| 26 | import android.os.Handler; |
| 27 | import android.os.Message; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 28 | import android.util.Log; |
| 29 | |
| 30 | import java.util.HashMap; |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 31 | import java.util.UUID; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * TODO: Move this to |
| 35 | * java/services/com/android/server/BluetoothEventLoop.java |
| 36 | * and make the contructor package private again. |
| 37 | * |
| 38 | * @hide |
| 39 | */ |
| 40 | class BluetoothEventLoop { |
| 41 | private static final String TAG = "BluetoothEventLoop"; |
| 42 | private static final boolean DBG = false; |
| 43 | |
| 44 | private int mNativeData; |
| 45 | private Thread mThread; |
The Android Open Source Project | b2a3dd8 | 2009-03-09 11:52:12 -0700 | [diff] [blame] | 46 | private boolean mStarted; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | private boolean mInterrupted; |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 48 | |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 49 | private final HashMap<String, Integer> mPasskeyAgentRequestData; |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 50 | private final BluetoothService mBluetoothService; |
| 51 | private final BluetoothAdapter mAdapter; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 52 | private final Context mContext; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 53 | |
| 54 | private static final int EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 1; |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 55 | private static final int EVENT_RESTART_BLUETOOTH = 2; |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 56 | private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 3; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | |
| 58 | // The time (in millisecs) to delay the pairing attempt after the first |
| 59 | // auto pairing attempt fails. We use an exponential delay with |
| 60 | // INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY as the initial value and |
| 61 | // MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY as the max value. |
| 62 | private static final long INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 3000; |
| 63 | private static final long MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY = 12000; |
| 64 | |
| 65 | private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN; |
| 66 | private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH; |
| 67 | |
| 68 | private final Handler mHandler = new Handler() { |
| 69 | @Override |
| 70 | public void handleMessage(Message msg) { |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 71 | String address = null; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | switch (msg.what) { |
| 73 | case EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY: |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 74 | address = (String)msg.obj; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | if (address != null) { |
| 76 | mBluetoothService.createBond(address); |
| 77 | return; |
| 78 | } |
| 79 | break; |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 80 | case EVENT_RESTART_BLUETOOTH: |
Nick Pelly | 37b5a10 | 2009-03-24 20:46:18 -0700 | [diff] [blame] | 81 | mBluetoothService.restart(); |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 82 | break; |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 83 | case EVENT_PAIRING_CONSENT_DELAYED_ACCEPT: |
| 84 | address = (String)msg.obj; |
| 85 | if (address != null) { |
| 86 | mBluetoothService.setPairingConfirmation(address, true); |
| 87 | } |
| 88 | break; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | } |
| 90 | } |
| 91 | }; |
| 92 | |
| 93 | static { classInitNative(); } |
| 94 | private static native void classInitNative(); |
| 95 | |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 96 | /* pacakge */ BluetoothEventLoop(Context context, BluetoothAdapter adapter, |
| 97 | BluetoothService bluetoothService) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | mBluetoothService = bluetoothService; |
| 99 | mContext = context; |
| 100 | mPasskeyAgentRequestData = new HashMap(); |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 101 | mAdapter = adapter; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 102 | initializeNativeDataNative(); |
| 103 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 104 | |
| 105 | protected void finalize() throws Throwable { |
| 106 | try { |
| 107 | cleanupNativeDataNative(); |
| 108 | } finally { |
| 109 | super.finalize(); |
| 110 | } |
| 111 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 113 | /* package */ HashMap<String, Integer> getPasskeyAgentRequestData() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | return mPasskeyAgentRequestData; |
| 115 | } |
| 116 | |
Robert Greenwalt | 28d139f | 2009-04-02 22:41:08 -0700 | [diff] [blame] | 117 | /* package */ void start() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 118 | |
Robert Greenwalt | 28d139f | 2009-04-02 22:41:08 -0700 | [diff] [blame] | 119 | if (!isEventLoopRunningNative()) { |
| 120 | if (DBG) log("Starting Event Loop thread"); |
| 121 | startEventLoopNative(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 122 | } |
| 123 | } |
| 124 | |
Robert Greenwalt | 28d139f | 2009-04-02 22:41:08 -0700 | [diff] [blame] | 125 | public void stop() { |
| 126 | if (isEventLoopRunningNative()) { |
| 127 | if (DBG) log("Stopping Event Loop thread"); |
| 128 | stopEventLoopNative(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | public boolean isEventLoopRunning() { |
| 133 | return isEventLoopRunningNative(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 134 | } |
| 135 | |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 136 | private void addDevice(String address, String[] properties) { |
| 137 | mBluetoothService.addRemoteDeviceProperties(address, properties); |
| 138 | String rssi = mBluetoothService.getRemoteDeviceProperty(address, "RSSI"); |
| 139 | String classValue = mBluetoothService.getRemoteDeviceProperty(address, "Class"); |
| 140 | String name = mBluetoothService.getRemoteDeviceProperty(address, "Name"); |
| 141 | short rssiValue; |
| 142 | // For incoming connections, we don't get the RSSI value. Use a default of MIN_VALUE. |
| 143 | // If we accept the pairing, we will automatically show it at the top of the list. |
| 144 | if (rssi != null) { |
| 145 | rssiValue = (short)Integer.valueOf(rssi).intValue(); |
| 146 | } else { |
| 147 | rssiValue = Short.MIN_VALUE; |
| 148 | } |
| 149 | if (classValue != null) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 150 | Intent intent = new Intent(BluetoothDevice.ACTION_FOUND); |
| 151 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 152 | intent.putExtra(BluetoothDevice.EXTRA_CLASS, |
| 153 | new BluetoothClass(Integer.valueOf(classValue))); |
| 154 | intent.putExtra(BluetoothDevice.EXTRA_RSSI, rssiValue); |
| 155 | intent.putExtra(BluetoothDevice.EXTRA_NAME, name); |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 156 | |
| 157 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 158 | } else { |
| 159 | log ("ClassValue: " + classValue + " for remote device: " + address + " is null"); |
| 160 | } |
| 161 | } |
| 162 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 163 | private void onDeviceFound(String address, String[] properties) { |
| 164 | if (properties == null) { |
| 165 | Log.e(TAG, "ERROR: Remote device properties are null"); |
| 166 | return; |
| 167 | } |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 168 | addDevice(address, properties); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 169 | } |
| 170 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 171 | private void onDeviceDisappeared(String address) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 172 | Intent intent = new Intent(BluetoothDevice.ACTION_DISAPPEARED); |
| 173 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 174 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 175 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | |
Jaikumar Ganesh | 5e59ca8 | 2009-09-11 12:16:19 -0700 | [diff] [blame] | 177 | private void onDeviceDisconnectRequested(String deviceObjectPath) { |
| 178 | String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); |
| 179 | if (address == null) { |
| 180 | Log.e(TAG, "onDeviceDisconnectRequested: Address of the remote device in null"); |
| 181 | return; |
| 182 | } |
| 183 | Intent intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED); |
| 184 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 185 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 186 | } |
| 187 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 188 | private void onCreatePairedDeviceResult(String address, int result) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | address = address.toUpperCase(); |
Nick Pelly | b24e11b | 2009-09-08 17:40:43 -0700 | [diff] [blame] | 190 | if (result == BluetoothDevice.BOND_SUCCESS) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED); |
| 192 | if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) { |
| 193 | mBluetoothService.getBondState().clearPinAttempts(address); |
| 194 | } |
| 195 | } else if (result == BluetoothDevice.UNBOND_REASON_AUTH_FAILED && |
| 196 | mBluetoothService.getBondState().getAttempt(address) == 1) { |
| 197 | mBluetoothService.getBondState().addAutoPairingFailure(address); |
| 198 | pairingAttempt(address, result); |
| 199 | } else if (result == BluetoothDevice.UNBOND_REASON_REMOTE_DEVICE_DOWN && |
| 200 | mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) { |
| 201 | pairingAttempt(address, result); |
| 202 | } else { |
| 203 | mBluetoothService.getBondState().setBondState(address, |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 204 | BluetoothDevice.BOND_NONE, result); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 205 | if (mBluetoothService.getBondState().isAutoPairingAttemptsInProgress(address)) { |
| 206 | mBluetoothService.getBondState().clearPinAttempts(address); |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | private void pairingAttempt(String address, int result) { |
| 212 | // This happens when our initial guess of "0000" as the pass key |
| 213 | // fails. Try to create the bond again and display the pin dialog |
| 214 | // to the user. Use back-off while posting the delayed |
| 215 | // message. The initial value is |
| 216 | // INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY and the max value is |
| 217 | // MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY. If the max value is |
| 218 | // reached, display an error to the user. |
| 219 | int attempt = mBluetoothService.getBondState().getAttempt(address); |
| 220 | if (attempt * INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY > |
| 221 | MAX_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY) { |
| 222 | mBluetoothService.getBondState().clearPinAttempts(address); |
| 223 | mBluetoothService.getBondState().setBondState(address, |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 224 | BluetoothDevice.BOND_NONE, result); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 225 | return; |
| 226 | } |
| 227 | |
| 228 | Message message = mHandler.obtainMessage(EVENT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY); |
| 229 | message.obj = address; |
| 230 | boolean postResult = mHandler.sendMessageDelayed(message, |
| 231 | attempt * INIT_AUTO_PAIRING_FAILURE_ATTEMPT_DELAY); |
| 232 | if (!postResult) { |
| 233 | mBluetoothService.getBondState().clearPinAttempts(address); |
| 234 | mBluetoothService.getBondState().setBondState(address, |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 235 | BluetoothDevice.BOND_NONE, result); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | return; |
| 237 | } |
| 238 | mBluetoothService.getBondState().attempt(address); |
| 239 | } |
| 240 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 241 | private void onDeviceCreated(String deviceObjectPath) { |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 242 | String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); |
| 243 | if (!mBluetoothService.isRemoteDeviceInCache(address)) { |
| 244 | // Incoming connection, we haven't seen this device, add to cache. |
| 245 | String[] properties = mBluetoothService.getRemoteDeviceProperties(address); |
| 246 | if (properties != null) { |
| 247 | addDevice(address, properties); |
| 248 | } |
| 249 | } |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 250 | mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDING); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 251 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 254 | private void onDeviceRemoved(String deviceObjectPath) { |
| 255 | String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); |
| 256 | if (address != null) |
| 257 | mBluetoothService.getBondState().setBondState(address.toUpperCase(), |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 258 | BluetoothDevice.BOND_NONE, BluetoothDevice.UNBOND_REASON_REMOVED); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 259 | } |
| 260 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 261 | /*package*/ void onPropertyChanged(String[] propValues) { |
Jaikumar Ganesh | 9519ce7 | 2009-09-08 21:37:32 -0700 | [diff] [blame] | 262 | if (mBluetoothService.isAdapterPropertiesEmpty()) { |
| 263 | // We have got a property change before |
| 264 | // we filled up our cache. |
| 265 | mBluetoothService.getAllProperties(); |
| 266 | } |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 267 | String name = propValues[0]; |
| 268 | if (name.equals("Name")) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 269 | Intent intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED); |
| 270 | intent.putExtra(BluetoothDevice.EXTRA_NAME, propValues[1]); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 271 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 272 | mBluetoothService.setProperty(name, propValues[1]); |
| 273 | } else if (name.equals("Pairable") || name.equals("Discoverable")) { |
| 274 | String pairable = name.equals("Pairable") ? propValues[1] : |
| 275 | mBluetoothService.getProperty("Pairable"); |
| 276 | String discoverable = name.equals("Discoverable") ? propValues[1] : |
| 277 | mBluetoothService.getProperty("Discoverable"); |
| 278 | |
| 279 | // This shouldn't happen, unless Adapter Properties are null. |
| 280 | if (pairable == null || discoverable == null) |
| 281 | return; |
| 282 | |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 283 | int mode = BluetoothService.bluezStringToScanMode( |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 284 | pairable.equals("true"), |
| 285 | discoverable.equals("true")); |
| 286 | if (mode >= 0) { |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 287 | Intent intent = new Intent(BluetoothAdapter.ACTION_SCAN_MODE_CHANGED); |
| 288 | intent.putExtra(BluetoothAdapter.EXTRA_SCAN_MODE, mode); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 289 | intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT); |
| 290 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 291 | } |
| 292 | mBluetoothService.setProperty(name, propValues[1]); |
| 293 | } else if (name.equals("Discovering")) { |
| 294 | Intent intent; |
| 295 | if (propValues[1].equals("true")) { |
| 296 | mBluetoothService.setIsDiscovering(true); |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 297 | intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_STARTED); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 298 | } else { |
| 299 | // Stop the discovery. |
| 300 | mBluetoothService.cancelDiscovery(); |
| 301 | mBluetoothService.setIsDiscovering(false); |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 302 | intent = new Intent(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 303 | } |
| 304 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 305 | mBluetoothService.setProperty(name, propValues[1]); |
| 306 | } else if (name.equals("Devices")) { |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 307 | String value = null; |
| 308 | int len = Integer.valueOf(propValues[1]); |
| 309 | if (len > 0) { |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 310 | StringBuilder str = new StringBuilder(); |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 311 | for (int i = 2; i < propValues.length; i++) { |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 312 | str.append(propValues[i]); |
| 313 | str.append(","); |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 314 | } |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 315 | value = str.toString(); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 316 | } |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 317 | mBluetoothService.setProperty(name, value); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 318 | } else if (name.equals("Powered")) { |
| 319 | // bluetoothd has restarted, re-read all our properties. |
| 320 | // Note: bluez only sends this property change when it restarts. |
| 321 | if (propValues[1].equals("true")) |
| 322 | onRestartRequired(); |
| 323 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 324 | } |
| 325 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 326 | private void onDevicePropertyChanged(String deviceObjectPath, String[] propValues) { |
| 327 | String name = propValues[0]; |
| 328 | String address = mBluetoothService.getAddressFromObjectPath(deviceObjectPath); |
| 329 | if (address == null) { |
| 330 | Log.e(TAG, "onDevicePropertyChanged: Address of the remote device in null"); |
| 331 | return; |
| 332 | } |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 333 | BluetoothDevice device = mAdapter.getRemoteDevice(address); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 334 | if (name.equals("Name")) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 335 | Intent intent = new Intent(BluetoothDevice.ACTION_NAME_CHANGED); |
| 336 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); |
| 337 | intent.putExtra(BluetoothDevice.EXTRA_NAME, propValues[1]); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 338 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 339 | mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); |
| 340 | } else if (name.equals("Class")) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 341 | Intent intent = new Intent(BluetoothDevice.ACTION_CLASS_CHANGED); |
| 342 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); |
| 343 | intent.putExtra(BluetoothDevice.EXTRA_CLASS, |
| 344 | new BluetoothClass(Integer.valueOf(propValues[1]))); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 345 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 346 | mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); |
| 347 | } else if (name.equals("Connected")) { |
| 348 | Intent intent = null; |
| 349 | if (propValues[1].equals("true")) { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 350 | intent = new Intent(BluetoothDevice.ACTION_ACL_CONNECTED); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 351 | } else { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 352 | intent = new Intent(BluetoothDevice.ACTION_ACL_DISCONNECTED); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 353 | } |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 354 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 355 | mContext.sendBroadcast(intent, BLUETOOTH_PERM); |
| 356 | mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); |
| 357 | } else if (name.equals("UUIDs")) { |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 358 | String uuid = null; |
| 359 | int len = Integer.valueOf(propValues[1]); |
| 360 | if (len > 0) { |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 361 | StringBuilder str = new StringBuilder(); |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 362 | for (int i = 2; i < propValues.length; i++) { |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 363 | str.append(propValues[i]); |
| 364 | str.append(","); |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 365 | } |
Jaikumar Ganesh | efa3367 | 2009-08-28 13:48:55 -0700 | [diff] [blame] | 366 | uuid = str.toString(); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 367 | } |
Jaikumar Ganesh | 8bc8ce4 | 2009-06-24 16:42:51 -0700 | [diff] [blame] | 368 | mBluetoothService.setRemoteDeviceProperty(address, name, uuid); |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 369 | } else if (name.equals("Paired")) { |
| 370 | if (propValues[1].equals("true")) { |
| 371 | mBluetoothService.getBondState().setBondState(address, BluetoothDevice.BOND_BONDED); |
| 372 | } else { |
| 373 | mBluetoothService.getBondState().setBondState(address, |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 374 | BluetoothDevice.BOND_NONE); |
Lixin Yue | efa1dd7 | 2009-08-31 15:55:13 +0800 | [diff] [blame] | 375 | mBluetoothService.setRemoteDeviceProperty(address, "Trusted", "false"); |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 376 | } |
Lixin Yue | efa1dd7 | 2009-08-31 15:55:13 +0800 | [diff] [blame] | 377 | } else if (name.equals("Trusted")) { |
| 378 | if (DBG) |
| 379 | log("set trust state succeded, value is " + propValues[1]); |
| 380 | mBluetoothService.setRemoteDeviceProperty(address, name, propValues[1]); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 381 | } |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 382 | } |
| 383 | |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 384 | private String checkPairingRequestAndGetAddress(String objectPath, int nativeData) { |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 385 | String address = mBluetoothService.getAddressFromObjectPath(objectPath); |
| 386 | if (address == null) { |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 387 | Log.e(TAG, "Unable to get device address in checkPairingRequestAndGetAddress, " + |
| 388 | "returning null"); |
| 389 | return null; |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 390 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 391 | address = address.toUpperCase(); |
| 392 | mPasskeyAgentRequestData.put(address, new Integer(nativeData)); |
| 393 | |
Nick Pelly | de893f5 | 2009-09-08 13:15:33 -0700 | [diff] [blame] | 394 | if (mBluetoothService.getBluetoothState() == BluetoothAdapter.STATE_TURNING_OFF) { |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 395 | // shutdown path |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 396 | mBluetoothService.cancelPairingUserInput(address); |
| 397 | return null; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 398 | } |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 399 | return address; |
| 400 | } |
| 401 | |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 402 | private void onRequestPairingConsent(String objectPath, int nativeData) { |
| 403 | String address = checkPairingRequestAndGetAddress(objectPath, nativeData); |
| 404 | if (address == null) return; |
| 405 | |
| 406 | /* The link key will not be stored if the incoming request has MITM |
| 407 | * protection switched on. Unfortunately, some devices have MITM |
| 408 | * switched on even though their capabilities are NoInputNoOutput, |
| 409 | * so we may get this request many times. Also if we respond immediately, |
| 410 | * the other end is unable to handle it. Delay sending the message. |
| 411 | */ |
| 412 | if (mBluetoothService.getBondState().getBondState(address) == BluetoothDevice.BOND_BONDED) { |
| 413 | Message message = mHandler.obtainMessage(EVENT_PAIRING_CONSENT_DELAYED_ACCEPT); |
| 414 | message.obj = address; |
| 415 | mHandler.sendMessageDelayed(message, 1500); |
| 416 | return; |
| 417 | } |
| 418 | |
| 419 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); |
| 420 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 421 | intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, |
| 422 | BluetoothDevice.PAIRING_VARIANT_CONSENT); |
| 423 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
| 424 | return; |
| 425 | } |
| 426 | |
| 427 | private void onRequestPasskeyConfirmation(String objectPath, int passkey, int nativeData) { |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 428 | String address = checkPairingRequestAndGetAddress(objectPath, nativeData); |
| 429 | if (address == null) return; |
| 430 | |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 431 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); |
| 432 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 433 | intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); |
| 434 | intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 435 | BluetoothDevice.PAIRING_VARIANT_PASSKEY_CONFIRMATION); |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 436 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
| 437 | return; |
| 438 | } |
| 439 | |
| 440 | private void onRequestPasskey(String objectPath, int nativeData) { |
| 441 | String address = checkPairingRequestAndGetAddress(objectPath, nativeData); |
| 442 | if (address == null) return; |
| 443 | |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 444 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); |
| 445 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 446 | intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, |
| 447 | BluetoothDevice.PAIRING_VARIANT_PASSKEY); |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 448 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | private void onRequestPinCode(String objectPath, int nativeData) { |
| 453 | String address = checkPairingRequestAndGetAddress(objectPath, nativeData); |
| 454 | if (address == null) return; |
The Android Open Source Project | 1059253 | 2009-03-18 17:39:46 -0700 | [diff] [blame] | 455 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 456 | if (mBluetoothService.getBondState().getBondState(address) == |
| 457 | BluetoothDevice.BOND_BONDING) { |
| 458 | // we initiated the bonding |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 459 | BluetoothClass btClass = new BluetoothClass(mBluetoothService.getRemoteClass(address)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 460 | |
| 461 | // try 0000 once if the device looks dumb |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 462 | switch (btClass.getDeviceClass()) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 463 | case BluetoothClass.Device.AUDIO_VIDEO_WEARABLE_HEADSET: |
| 464 | case BluetoothClass.Device.AUDIO_VIDEO_HANDSFREE: |
| 465 | case BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES: |
| 466 | case BluetoothClass.Device.AUDIO_VIDEO_PORTABLE_AUDIO: |
| 467 | case BluetoothClass.Device.AUDIO_VIDEO_CAR_AUDIO: |
| 468 | case BluetoothClass.Device.AUDIO_VIDEO_HIFI_AUDIO: |
| 469 | if (!mBluetoothService.getBondState().hasAutoPairingFailed(address) && |
| 470 | !mBluetoothService.getBondState().isAutoPairingBlacklisted(address)) { |
| 471 | mBluetoothService.getBondState().attempt(address); |
| 472 | mBluetoothService.setPin(address, BluetoothDevice.convertPinToBytes("0000")); |
| 473 | return; |
| 474 | } |
| 475 | } |
| 476 | } |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 477 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); |
| 478 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 479 | intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, BluetoothDevice.PAIRING_VARIANT_PIN); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 480 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 481 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 482 | } |
| 483 | |
Jaikumar Ganesh | 32d8571 | 2009-09-10 22:00:05 -0700 | [diff] [blame^] | 484 | private void onDisplayPasskey(String objectPath, int passkey, int nativeData) { |
| 485 | String address = checkPairingRequestAndGetAddress(objectPath, nativeData); |
| 486 | if (address == null) return; |
| 487 | |
| 488 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_REQUEST); |
| 489 | intent.putExtra(BluetoothDevice.EXTRA_DEVICE, mAdapter.getRemoteDevice(address)); |
| 490 | intent.putExtra(BluetoothDevice.EXTRA_PASSKEY, passkey); |
| 491 | intent.putExtra(BluetoothDevice.EXTRA_PAIRING_VARIANT, |
| 492 | BluetoothDevice.PAIRING_VARIANT_DISPLAY_PASSKEY); |
| 493 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
| 494 | } |
| 495 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 496 | private boolean onAgentAuthorize(String objectPath, String deviceUuid) { |
| 497 | String address = mBluetoothService.getAddressFromObjectPath(objectPath); |
| 498 | if (address == null) { |
| 499 | Log.e(TAG, "Unable to get device address in onAuthAgentAuthorize"); |
| 500 | return false; |
| 501 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 502 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 503 | boolean authorized = false; |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 504 | UUID uuid = UUID.fromString(deviceUuid); |
Nick Pelly | b23d445 | 2009-08-26 09:33:40 -0700 | [diff] [blame] | 505 | // Bluez sends the UUID of the local service being accessed, _not_ the |
| 506 | // remote service |
Jaikumar Ganesh | ade4052 | 2009-07-30 13:32:25 -0700 | [diff] [blame] | 507 | if (mBluetoothService.isEnabled() && |
Nick Pelly | b23d445 | 2009-08-26 09:33:40 -0700 | [diff] [blame] | 508 | (BluetoothUuid.isAudioSource(uuid) || BluetoothUuid.isAvrcpTarget(uuid) |
Jaikumar Ganesh | 9488cbd | 2009-08-03 17:17:37 -0700 | [diff] [blame] | 509 | || BluetoothUuid.isAdvAudioDist(uuid))) { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 510 | BluetoothA2dp a2dp = new BluetoothA2dp(mContext); |
Nick Pelly | bd022f4 | 2009-08-14 18:33:38 -0700 | [diff] [blame] | 511 | BluetoothDevice device = mAdapter.getRemoteDevice(address); |
| 512 | authorized = a2dp.getSinkPriority(device) > BluetoothA2dp.PRIORITY_OFF; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 513 | if (authorized) { |
Jaikumar Ganesh | ade4052 | 2009-07-30 13:32:25 -0700 | [diff] [blame] | 514 | Log.i(TAG, "Allowing incoming A2DP / AVRCP connection from " + address); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 515 | } else { |
Jaikumar Ganesh | ade4052 | 2009-07-30 13:32:25 -0700 | [diff] [blame] | 516 | Log.i(TAG, "Rejecting incoming A2DP / AVRCP connection from " + address); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 517 | } |
| 518 | } else { |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 519 | Log.i(TAG, "Rejecting incoming " + deviceUuid + " connection from " + address); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 520 | } |
Nick Pelly | b23d445 | 2009-08-26 09:33:40 -0700 | [diff] [blame] | 521 | log("onAgentAuthorize(" + objectPath + ", " + deviceUuid + ") = " + authorized); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 522 | return authorized; |
| 523 | } |
| 524 | |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 525 | private void onAgentCancel() { |
Nick Pelly | 005b228 | 2009-09-10 10:21:56 -0700 | [diff] [blame] | 526 | Intent intent = new Intent(BluetoothDevice.ACTION_PAIRING_CANCEL); |
Jaikumar Ganesh | b0eca41 | 2009-07-16 18:26:28 -0700 | [diff] [blame] | 527 | mContext.sendBroadcast(intent, BLUETOOTH_ADMIN_PERM); |
| 528 | return; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 529 | } |
| 530 | |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 531 | private void onRestartRequired() { |
| 532 | if (mBluetoothService.isEnabled()) { |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 533 | Log.e(TAG, "*** A serious error occured (did bluetoothd crash?) - " + |
| 534 | "restarting Bluetooth ***"); |
The Android Open Source Project | c39a6e0 | 2009-03-11 12:11:56 -0700 | [diff] [blame] | 535 | mHandler.sendEmptyMessage(EVENT_RESTART_BLUETOOTH); |
| 536 | } |
| 537 | } |
| 538 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 539 | private static void log(String msg) { |
| 540 | Log.d(TAG, msg); |
| 541 | } |
Jaikumar Ganesh | d5ac1ae | 2009-05-05 22:26:12 -0700 | [diff] [blame] | 542 | |
| 543 | private native void initializeNativeDataNative(); |
| 544 | private native void startEventLoopNative(); |
| 545 | private native void stopEventLoopNative(); |
| 546 | private native boolean isEventLoopRunningNative(); |
| 547 | private native void cleanupNativeDataNative(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | } |