Bluetooth: prevent enabling BLE in airplane mode

am: a80d745c65

Change-Id: I05a57fa747abedab24e0509c1fb7ab8737b2256a
This commit is contained in:
Marie Janssen
2016-10-27 00:20:17 +00:00
committed by android-build-merger
2 changed files with 13 additions and 13 deletions

View File

@@ -765,19 +765,13 @@ public final class BluetoothAdapter {
public boolean enableBLE() {
if (!isBleScanAlwaysAvailable()) return false;
if (isLeEnabled() == true) {
if (DBG) Log.d(TAG, "enableBLE(): BT is already enabled..!");
try {
mManagerService.updateBleAppCount(mToken, true);
} catch (RemoteException e) {
Log.e(TAG, "", e);
}
return true;
}
try {
if (DBG) Log.d(TAG, "Calling enableBLE");
mManagerService.updateBleAppCount(mToken, true);
if (isLeEnabled()) {
if (DBG) Log.d(TAG, "enableBLE(): Bluetooth already enabled");
return true;
}
if (DBG) Log.d(TAG, "enableBLE(): Calling enable");
return mManagerService.enable();
} catch (RemoteException e) {
Log.e(TAG, "", e);

View File

@@ -217,6 +217,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
mBluetoothLock.readLock().lock();
if (mBluetooth != null) {
mBluetooth.onBrEdrDown();
mEnable = false;
mEnableExternal = false;
}
} catch (RemoteException e) {
@@ -449,14 +450,16 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
class ClientDeathRecipient implements IBinder.DeathRecipient {
public void binderDied() {
if (DBG) Slog.d(TAG, "Binder is dead - unregister Ble App");
if (DBG) Slog.d(TAG, "Binder is dead - unregister Ble App");
if (mBleAppCount > 0) --mBleAppCount;
if (mBleAppCount == 0) {
if (DBG) Slog.d(TAG, "Disabling LE only mode after application crash");
try {
mBluetoothLock.readLock().lock();
if (mBluetooth != null) {
if (mBluetooth != null &&
mBluetooth.getState() == BluetoothAdapter.STATE_BLE_ON) {
mEnable = false;
mBluetooth.onBrEdrDown();
}
} catch (RemoteException e) {
@@ -473,6 +476,9 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
@Override
public boolean isBleScanAlwaysAvailable() {
if (isAirplaneModeOn() && !mEnable) {
return false;
}
try {
return (Settings.Global.getInt(mContentResolver,
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE)) != 0;