diff options
author | Jaikumar Ganesh <jaikumar@google.com> | 2012-01-25 16:14:50 -0800 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-13 22:22:51 -0700 |
commit | 1abb1cb3a8fe17f7866150604c2fd73751da787e (patch) | |
tree | a2f4fa365665fc5b25fc66c6f7b90ea3ca719cfc /services/java/com/android/server/power/ShutdownThread.java | |
parent | 34196187365687d3f144a6de5fef811b52545ac0 (diff) |
Changes to Bluetooth Service structure.
Changes to make Bluetooth Service part of the system_service.
These changes may be temporary.
Changes to update to the new disable API.
Change-Id: If89dba17e6e6c6daa53c37684221763a2da076e9
Conflicts:
services/java/com/android/server/pm/PackageManagerService.java
Diffstat (limited to 'services/java/com/android/server/power/ShutdownThread.java')
-rw-r--r-- | services/java/com/android/server/power/ShutdownThread.java | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/services/java/com/android/server/power/ShutdownThread.java b/services/java/com/android/server/power/ShutdownThread.java index 5f2f428f56dc..82f72f741153 100644 --- a/services/java/com/android/server/power/ShutdownThread.java +++ b/services/java/com/android/server/power/ShutdownThread.java @@ -324,9 +324,68 @@ public final class ShutdownThread extends Thread { } catch (RemoteException e) { } } + + final ITelephony phone = + ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); + final IBluetooth bluetooth = + IBluetooth.Stub.asInterface(ServiceManager.checkService( + BluetoothAdapter.BLUETOOTH_SERVICE)); + + final IMountService mount = + IMountService.Stub.asInterface( + ServiceManager.checkService("mount")); + + try { + bluetoothOff = bluetooth == null || + bluetooth.getState() == BluetoothAdapter.STATE_OFF; + if (!bluetoothOff) { + Log.w(TAG, "Disabling Bluetooth..."); + //TODO(BT) + bluetooth.disable(); // disable but don't persist new state + } + } catch (RemoteException ex) { + Log.e(TAG, "RemoteException during bluetooth shutdown", ex); + bluetoothOff = true; + } - // Shutdown radios. - shutdownRadios(MAX_RADIO_WAIT_TIME); + try { + radioOff = phone == null || !phone.isRadioOn(); + if (!radioOff) { + Log.w(TAG, "Turning off radio..."); + phone.setRadio(false); + } + } catch (RemoteException ex) { + Log.e(TAG, "RemoteException during radio shutdown", ex); + radioOff = true; + } + + Log.i(TAG, "Waiting for Bluetooth and Radio..."); + + // Wait a max of 32 seconds for clean shutdown + for (int i = 0; i < MAX_NUM_PHONE_STATE_READS; i++) { + if (!bluetoothOff) { + try { + bluetoothOff = + bluetooth.getState() == BluetoothAdapter.STATE_OFF; + } catch (RemoteException ex) { + Log.e(TAG, "RemoteException during bluetooth shutdown", ex); + bluetoothOff = true; + } + } + if (!radioOff) { + try { + radioOff = !phone.isRadioOn(); + } catch (RemoteException ex) { + Log.e(TAG, "RemoteException during radio shutdown", ex); + radioOff = true; + } + } + if (radioOff && bluetoothOff) { + Log.i(TAG, "Radio and Bluetooth shutdown complete."); + break; + } + SystemClock.sleep(PHONE_STATE_POLL_SLEEP_MSEC); + } // Shutdown MountService to ensure media is in a safe state IMountShutdownObserver observer = new IMountShutdownObserver.Stub() { |