diff options
| author | Nick Pelly <> | 2009-03-24 20:44:48 -0700 | 
|---|---|---|
| committer | The Android Open Source Project <initial-contribution@android.com> | 2009-03-24 20:44:48 -0700 | 
| commit | 997c7612a8cf63748165144b423ff2ae8e73c3e9 (patch) | |
| tree | 634b796197894be44da6bd9e20b600e584bcfab3 /core | |
| parent | a9f95fbee978e2d134052c2dceea2559b64badb4 (diff) | |
| download | frameworks_base-997c7612a8cf63748165144b423ff2ae8e73c3e9.zip frameworks_base-997c7612a8cf63748165144b423ff2ae8e73c3e9.tar.gz frameworks_base-997c7612a8cf63748165144b423ff2ae8e73c3e9.tar.bz2 | |
Automated import from //branches/donutburger/...@141696,141696
Diffstat (limited to 'core')
| -rw-r--r-- | core/java/android/server/BluetoothDeviceService.java | 20 | ||||
| -rw-r--r-- | core/java/android/server/BluetoothEventLoop.java | 4 | 
2 files changed, 21 insertions, 3 deletions
| diff --git a/core/java/android/server/BluetoothDeviceService.java b/core/java/android/server/BluetoothDeviceService.java index a815e57..c61b25a 100644 --- a/core/java/android/server/BluetoothDeviceService.java +++ b/core/java/android/server/BluetoothDeviceService.java @@ -63,8 +63,10 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {      private BluetoothEventLoop mEventLoop;      private IntentFilter mIntentFilter;      private boolean mIsAirplaneSensitive; -    private final BondState mBondState = new BondState();  // local cache of bondings      private int mBluetoothState; +    private boolean mRestart = false;  // need to call enable() after disable() + +    private final BondState mBondState = new BondState();  // local cache of bondings      private boolean mIsDiscovering;      private final IBatteryStats mBatteryStats; @@ -218,6 +220,11 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {          } finally {              Binder.restoreCallingIdentity(ident);          } + +        if (mRestart) { +            mRestart = false; +            enable(); +        }      }      /** Bring up BT and persist BT on in settings */ @@ -252,6 +259,17 @@ public class BluetoothDeviceService extends IBluetoothDevice.Stub {          return true;      } +    /** Forcibly restart Bluetooth if it is on */ +    /* package */ synchronized void restart() { +        if (mBluetoothState != BluetoothDevice.BLUETOOTH_STATE_ON) { +            return; +        } +        mRestart = true; +        if (!disable(false)) { +            mRestart = false; +        } +    }    +      private synchronized void setBluetoothState(int state) {          if (state == mBluetoothState) {              return; diff --git a/core/java/android/server/BluetoothEventLoop.java b/core/java/android/server/BluetoothEventLoop.java index 6eabea4..11c297c 100644 --- a/core/java/android/server/BluetoothEventLoop.java +++ b/core/java/android/server/BluetoothEventLoop.java @@ -76,8 +76,7 @@ class BluetoothEventLoop {                  }                  break;              case EVENT_RESTART_BLUETOOTH: -                mBluetoothService.disable(); -                mBluetoothService.enable(); +                mBluetoothService.restart();                  break;              }          } @@ -170,6 +169,7 @@ class BluetoothEventLoop {          if (mode >= 0) {              Intent intent = new Intent(BluetoothIntent.SCAN_MODE_CHANGED_ACTION);              intent.putExtra(BluetoothIntent.SCAN_MODE, mode); +            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);              mContext.sendBroadcast(intent, BLUETOOTH_PERM);          }      } | 
