summaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothDevice.java
diff options
context:
space:
mode:
authorScott Lobdell <slobdell@google.com>2022-04-08 23:25:07 +0000
committerScott Lobdell <slobdell@google.com>2022-04-08 23:32:12 +0000
commite5ec0e08a69df03eb56f53559b6a64f28ff385c9 (patch)
treee49e68665bc4141856486ba71e22dad4f3ada4d6 /framework/java/android/bluetooth/BluetoothDevice.java
parent4c7dc59bef24cc991251f9a7924ceada90c6bd63 (diff)
parentdb0e5050ed5e49464783bc37e246871396cdc738 (diff)
Merge TP1A.220404.001
Change-Id: Ie978b3464b876dfaba2bf22ab195875f4fb4856a
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothDevice.java62
1 files changed, 31 insertions, 31 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java
index bf3d9697b0..b6da4fd11f 100644
--- a/framework/java/android/bluetooth/BluetoothDevice.java
+++ b/framework/java/android/bluetooth/BluetoothDevice.java
@@ -1638,7 +1638,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getIdentityAddress()");
final IBluetooth service = sService;
final String defaultValue = null;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get identity address");
} else {
try {
@@ -1668,7 +1668,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getName()");
final IBluetooth service = sService;
final String defaultValue = null;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get Remote Device name");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -1703,7 +1703,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getType()");
final IBluetooth service = sService;
final int defaultValue = DEVICE_TYPE_UNKNOWN;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get Remote Device type");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -1732,7 +1732,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getAlias()");
final IBluetooth service = sService;
final String defaultValue = null;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get Remote Device Alias");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -1793,7 +1793,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setAlias(" + alias + ")");
final IBluetooth service = sService;
final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot set Remote Device name");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -1827,7 +1827,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getBatteryLevel()");
final IBluetooth service = sService;
final int defaultValue = BATTERY_LEVEL_BLUETOOTH_OFF;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "Bluetooth disabled. Cannot get remote device battery level");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -1922,7 +1922,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("createBondOutOfBand()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "BT not enabled, createBondOutOfBand failed");
return false;
}
@@ -1965,7 +1965,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("isBondingInitiatedLocally()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "BT not enabled, isBondingInitiatedLocally failed");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2011,7 +2011,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("cancelBondProcess()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot cancel Remote Device bond");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2044,7 +2044,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("removeBond()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot remove Remote Device bond");
return false;
}
@@ -2097,7 +2097,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getBondState() uncached");
final IBluetooth service = sService;
final int defaultValue = BOND_NONE;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get bond state");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2169,7 +2169,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("canBondWithoutDialog, device: " + this);
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot check if we can skip pairing dialog");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2223,7 +2223,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
}
final IBluetooth service = sService;
final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot connect to remote device.");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2270,7 +2270,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
}
final IBluetooth service = sService;
final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot disconnect to remote device.");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2302,7 +2302,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("isConnected()");
final IBluetooth service = sService;
final int defaultValue = CONNECTION_STATE_DISCONNECTED;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2334,7 +2334,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("isEncrypted()");
final IBluetooth service = sService;
final int defaultValue = CONNECTION_STATE_DISCONNECTED;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2363,7 +2363,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getBluetoothClass()");
final IBluetooth service = sService;
final int defaultValue = 0;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot get Bluetooth Class");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2506,7 +2506,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("sdpSearch()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot query remote device sdp records");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2574,7 +2574,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setPin()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot set Remote Device pin");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2620,7 +2620,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setPairingConfirmation()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "BT not enabled. Cannot set pairing confirmation");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2659,7 +2659,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getPhonebookAccessPermission()");
final IBluetooth service = sService;
final int defaultValue = ACCESS_UNKNOWN;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2706,7 +2706,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setSilenceMode()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
throw new IllegalStateException("Bluetooth is not turned ON");
} else {
try {
@@ -2736,7 +2736,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("isInSilenceMode()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
throw new IllegalStateException("Bluetooth is not turned ON");
} else {
try {
@@ -2767,7 +2767,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setPhonebookAccessPermission()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2796,7 +2796,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getMessageAccessPermission()");
final IBluetooth service = sService;
final int defaultValue = ACCESS_UNKNOWN;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2833,7 +2833,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setMessageAccessPermission()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2862,7 +2862,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getSimAccessPermission()");
final IBluetooth service = sService;
final int defaultValue = ACCESS_UNKNOWN;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -2895,7 +2895,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setSimAccessPermission()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.w(TAG, "Proxy not attached to service");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -3448,7 +3448,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setMetadata()");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "Bluetooth is not enabled. Cannot set metadata");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else if (value.length > METADATA_MAX_LENGTH) {
@@ -3483,7 +3483,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("getMetadata()");
final IBluetooth service = sService;
final byte[] defaultValue = null;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "Bluetooth is not enabled. Cannot get metadata");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {
@@ -3564,7 +3564,7 @@ public final class BluetoothDevice implements Parcelable, Attributable {
if (DBG) log("setLowLatencyAudioAllowed(" + allowed + ")");
final IBluetooth service = sService;
final boolean defaultValue = false;
- if (service == null) {
+ if (service == null || !isBluetoothEnabled()) {
Log.e(TAG, "Bluetooth is not enabled. Cannot allow low latency");
if (DBG) log(Log.getStackTraceString(new Throwable()));
} else {