Implement isEnabled in terms of getState

Bug: 145171640
Test: compile & check everything works normally
Change-Id: I169e220ab83546d76317e518652c66c9bd2229a2
This commit is contained in:
Zach Johnson
2019-11-26 21:30:07 -08:00
parent 0f2c3d963d
commit 76236d77f4
2 changed files with 2 additions and 28 deletions

View File

@@ -830,18 +830,7 @@ public final class BluetoothAdapter {
*/
@RequiresPermission(Manifest.permission.BLUETOOTH)
public boolean isEnabled() {
try {
mServiceLock.readLock().lock();
if (mService != null) {
return mService.isEnabled();
}
} catch (RemoteException e) {
Log.e(TAG, "", e);
} finally {
mServiceLock.readLock().unlock();
}
return false;
return getState() == BluetoothAdapter.STATE_ON;
}
/**

View File

@@ -613,22 +613,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {
}
public boolean isEnabled() {
if ((Binder.getCallingUid() != Process.SYSTEM_UID) && (!checkIfCallerIsForegroundUser())) {
Slog.w(TAG, "isEnabled(): not allowed for non-active and non system user");
return false;
}
try {
mBluetoothLock.readLock().lock();
if (mBluetooth != null) {
return mBluetooth.isEnabled();
}
} catch (RemoteException e) {
Slog.e(TAG, "isEnabled()", e);
} finally {
mBluetoothLock.readLock().unlock();
}
return false;
return getState() == BluetoothAdapter.STATE_ON;
}
public int getState() {