From 694c0b833b4235b396ec1b798610d617d0ec7b5c Mon Sep 17 00:00:00 2001 From: Matthew Xie Date: Wed, 7 Sep 2011 23:32:51 -0700 Subject: Apply timeout for powerdown event and reset state machine when bluez crashes The powerdown event was missed some time for unknown reasons and bluez could crash for unknown reasons. We will debug on the issue. But for the time being, we add a powerdown timer and process power up event to recover from bluez crash bug 5239719 Change-Id: Ie7315fb01e029747951e1a97a2d2f1dce53a997b --- core/java/android/server/BluetoothEventLoop.java | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'core/java/android/server/BluetoothEventLoop.java') diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 6eff796..e4f2d32 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -59,9 +59,8 @@ class BluetoothEventLoop { // from remote device when Android is in Suspend state. private PowerManager.WakeLock mWakeLock; - private static final int EVENT_RESTART_BLUETOOTH = 1; - private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 2; - private static final int EVENT_AGENT_CANCEL = 3; + private static final int EVENT_PAIRING_CONSENT_DELAYED_ACCEPT = 1; + private static final int EVENT_AGENT_CANCEL = 2; private static final int CREATE_DEVICE_ALREADY_EXISTS = 1; private static final int CREATE_DEVICE_SUCCESS = 0; @@ -75,9 +74,6 @@ class BluetoothEventLoop { public void handleMessage(Message msg) { String address = null; switch (msg.what) { - case EVENT_RESTART_BLUETOOTH: - mBluetoothService.restart(); - break; case EVENT_PAIRING_CONSENT_DELAYED_ACCEPT: address = (String)msg.obj; if (address != null) { @@ -375,9 +371,6 @@ class BluetoothEventLoop { } else if (name.equals("Powered")) { mBluetoothState.sendMessage(BluetoothAdapterStateMachine.POWER_STATE_CHANGED, propValues[1].equals("true") ? new Boolean(true) : new Boolean(false)); - // bluetoothd has restarted, re-read all our properties. - // Note: bluez only sends this property change when it restarts. - onRestartRequired(); } else if (name.equals("DiscoverableTimeout")) { adapterProperties.setProperty(name, propValues[1]); } @@ -1033,14 +1026,6 @@ class BluetoothEventLoop { mBluetoothService.onHealthDeviceChannelChanged(devicePath, channelPath, exists); } - private void onRestartRequired() { - if (mBluetoothService.isEnabled()) { - Log.e(TAG, "*** A serious error occurred (did bluetoothd crash?) - " + - "restarting Bluetooth ***"); - mHandler.sendEmptyMessage(EVENT_RESTART_BLUETOOTH); - } - } - private static void log(String msg) { Log.d(TAG, msg); } -- cgit v1.1