Loading framework/java/android/bluetooth/BluetoothAdapter.java +8 −4 Original line number Diff line number Diff line Loading @@ -4233,14 +4233,18 @@ public final class BluetoothAdapter { /*package*/ IBluetooth getBluetoothService() { synchronized (sServiceLock) { if (sProxyServiceStateCallbacks.isEmpty()) { throw new IllegalStateException( "Anonymous service access requires at least one lifecycle in process"); } return sService; } } /** * Registers a IBluetoothManagerCallback and returns the cached * Bluetooth service proxy object. * * TODO: rename this API to registerBlueoothManagerCallback or something? * the current name does not match what it does very well. * * / @UnsupportedAppUsage /*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) { Objects.requireNonNull(cb); Loading framework/java/android/bluetooth/BluetoothDevice.java +34 −76 Original line number Diff line number Diff line Loading @@ -1278,55 +1278,14 @@ public final class BluetoothDevice implements Parcelable, Attributable { private static final String NULL_MAC_ADDRESS = "00:00:00:00:00:00"; /** * Lazy initialization. Guaranteed final after first object constructed, or * getService() called. * TODO: Unify implementation of sService amongst BluetoothFoo API's */ private static volatile IBluetooth sService; private final String mAddress; @AddressType private final int mAddressType; private AttributionSource mAttributionSource; /*package*/ static IBluetooth getService() { synchronized (BluetoothDevice.class) { if (sService == null) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); sService = adapter.getBluetoothService(sStateChangeCallback); } } return sService; } static IBluetoothManagerCallback sStateChangeCallback = new IBluetoothManagerCallback.Stub() { public void onBluetoothServiceUp(IBluetooth bluetoothService) throws RemoteException { synchronized (BluetoothDevice.class) { if (sService == null) { sService = bluetoothService; } return BluetoothAdapter.getDefaultAdapter().getBluetoothService(); } } public void onBluetoothServiceDown() throws RemoteException { synchronized (BluetoothDevice.class) { sService = null; } } public void onBrEdrDown() { if (DBG) Log.d(TAG, "onBrEdrDown: reached BLE ON state"); } public void onOobData(@Transport int transport, OobData oobData) { if (DBG) Log.d(TAG, "onOobData: got data"); } }; /** * Create a new BluetoothDevice. Loading @@ -1340,7 +1299,6 @@ public final class BluetoothDevice implements Parcelable, Attributable { * @hide */ /*package*/ BluetoothDevice(String address, int addressType) { getService(); // ensures sService is initialized if (!BluetoothAdapter.checkBluetoothAddress(address)) { throw new IllegalArgumentException(address + " is not a valid Bluetooth address"); } Loading Loading @@ -1488,7 +1446,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public @Nullable String getIdentityAddress() { if (DBG) log("getIdentityAddress()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get identity address"); Loading Loading @@ -1518,7 +1476,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public String getName() { if (DBG) log("getName()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device name"); Loading Loading @@ -1553,7 +1511,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public int getType() { if (DBG) log("getType()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = DEVICE_TYPE_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device type"); Loading Loading @@ -1582,7 +1540,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public String getAlias() { if (DBG) log("getAlias()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device Alias"); Loading Loading @@ -1643,7 +1601,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { throw new IllegalArgumentException("alias cannot be the empty string"); } if (DBG) log("setAlias(" + alias + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set Remote Device name"); Loading Loading @@ -1677,7 +1635,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @IntRange(from = -100, to = 100) int getBatteryLevel() { if (DBG) log("getBatteryLevel()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BATTERY_LEVEL_BLUETOOTH_OFF; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth disabled. Cannot get remote device battery level"); Loading Loading @@ -1772,7 +1730,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { private boolean createBondInternal(int transport, @Nullable OobData remoteP192Data, @Nullable OobData remoteP256Data) { if (DBG) log("createBondOutOfBand()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "BT not enabled, createBondOutOfBand failed"); Loading Loading @@ -1805,7 +1763,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isBondingInitiatedLocally() { if (DBG) log("isBondingInitiatedLocally()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "BT not enabled, isBondingInitiatedLocally failed"); Loading @@ -1832,7 +1790,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean cancelBondProcess() { if (DBG) log("cancelBondProcess()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot cancel Remote Device bond"); Loading Loading @@ -1865,7 +1823,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean removeBond() { if (DBG) log("removeBond()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot remove Remote Device bond"); Loading Loading @@ -1955,7 +1913,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @SuppressLint("AndroidFrameworkRequiresPermission") public int getBondState() { if (DBG) log("getBondState(" + getAnonymizedAddress() + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); if (service == null) { Log.e(TAG, "BT not enabled. Cannot get bond state"); if (DBG) log(Log.getStackTraceString(new Throwable())); Loading Loading @@ -1988,7 +1946,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean canBondWithoutDialog() { if (DBG) log("canBondWithoutDialog, device: " + this); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot check if we can skip pairing dialog"); Loading Loading @@ -2042,7 +2000,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (!BluetoothAdapter.checkBluetoothAddress(getAddress())) { throw new IllegalArgumentException("device cannot have an invalid address"); } final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot connect to remote device."); Loading Loading @@ -2089,7 +2047,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (!BluetoothAdapter.checkBluetoothAddress(getAddress())) { throw new IllegalArgumentException("device cannot have an invalid address"); } final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot disconnect to remote device."); Loading Loading @@ -2121,7 +2079,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isConnected() { if (DBG) log("isConnected()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = CONNECTION_STATE_DISCONNECTED; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2153,7 +2111,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isEncrypted() { if (DBG) log("isEncrypted()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = CONNECTION_STATE_DISCONNECTED; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2182,7 +2140,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public BluetoothClass getBluetoothClass() { if (DBG) log("getBluetoothClass()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = 0; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Bluetooth Class"); Loading Loading @@ -2216,7 +2174,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public ParcelUuid[] getUuids() { if (DBG) log("getUuids()"); final IBluetooth service = sService; final IBluetooth service = getService(); final ParcelUuid[] defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get remote device Uuids"); Loading Loading @@ -2283,7 +2241,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean fetchUuidsWithSdp(@Transport int transport) { if (DBG) log("fetchUuidsWithSdp()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot fetchUuidsWithSdp"); Loading Loading @@ -2325,7 +2283,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean sdpSearch(ParcelUuid uuid) { if (DBG) log("sdpSearch()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot query remote device sdp records"); Loading @@ -2352,7 +2310,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean setPin(byte[] pin) { if (DBG) log("setPin()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set Remote Device pin"); Loading Loading @@ -2398,7 +2356,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setPairingConfirmation(boolean confirm) { if (DBG) log("setPairingConfirmation()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set pairing confirmation"); Loading Loading @@ -2437,7 +2395,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getPhonebookAccessPermission() { if (DBG) log("getPhonebookAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2484,7 +2442,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setSilenceMode(boolean silence) { if (DBG) log("setSilenceMode()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { throw new IllegalStateException("Bluetooth is not turned ON"); Loading Loading @@ -2514,7 +2472,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean isInSilenceMode() { if (DBG) log("isInSilenceMode()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { throw new IllegalStateException("Bluetooth is not turned ON"); Loading Loading @@ -2545,7 +2503,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setPhonebookAccessPermission(@AccessPermission int value) { if (DBG) log("setPhonebookAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2574,7 +2532,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getMessageAccessPermission() { if (DBG) log("getMessageAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2611,7 +2569,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { throw new IllegalArgumentException(value + "is not a valid AccessPermission value"); } if (DBG) log("setMessageAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2640,7 +2598,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getSimAccessPermission() { if (DBG) log("getSimAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2673,7 +2631,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setSimAccessPermission(int value) { if (DBG) log("setSimAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -3184,7 +3142,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setMetadata(@MetadataKey int key, @NonNull byte[] value) { if (DBG) log("setMetadata()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot set metadata"); Loading Loading @@ -3219,7 +3177,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public byte[] getMetadata(@MetadataKey int key) { if (DBG) log("getMetadata()"); final IBluetooth service = sService; final IBluetooth service = getService(); final byte[] defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot get metadata"); Loading Loading @@ -3262,7 +3220,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setLowLatencyAudioAllowed(boolean allowed) { if (DBG) log("setLowLatencyAudioAllowed(" + allowed + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot allow low latency"); Loading Loading
framework/java/android/bluetooth/BluetoothAdapter.java +8 −4 Original line number Diff line number Diff line Loading @@ -4233,14 +4233,18 @@ public final class BluetoothAdapter { /*package*/ IBluetooth getBluetoothService() { synchronized (sServiceLock) { if (sProxyServiceStateCallbacks.isEmpty()) { throw new IllegalStateException( "Anonymous service access requires at least one lifecycle in process"); } return sService; } } /** * Registers a IBluetoothManagerCallback and returns the cached * Bluetooth service proxy object. * * TODO: rename this API to registerBlueoothManagerCallback or something? * the current name does not match what it does very well. * * / @UnsupportedAppUsage /*package*/ IBluetooth getBluetoothService(IBluetoothManagerCallback cb) { Objects.requireNonNull(cb); Loading
framework/java/android/bluetooth/BluetoothDevice.java +34 −76 Original line number Diff line number Diff line Loading @@ -1278,55 +1278,14 @@ public final class BluetoothDevice implements Parcelable, Attributable { private static final String NULL_MAC_ADDRESS = "00:00:00:00:00:00"; /** * Lazy initialization. Guaranteed final after first object constructed, or * getService() called. * TODO: Unify implementation of sService amongst BluetoothFoo API's */ private static volatile IBluetooth sService; private final String mAddress; @AddressType private final int mAddressType; private AttributionSource mAttributionSource; /*package*/ static IBluetooth getService() { synchronized (BluetoothDevice.class) { if (sService == null) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); sService = adapter.getBluetoothService(sStateChangeCallback); } } return sService; } static IBluetoothManagerCallback sStateChangeCallback = new IBluetoothManagerCallback.Stub() { public void onBluetoothServiceUp(IBluetooth bluetoothService) throws RemoteException { synchronized (BluetoothDevice.class) { if (sService == null) { sService = bluetoothService; } return BluetoothAdapter.getDefaultAdapter().getBluetoothService(); } } public void onBluetoothServiceDown() throws RemoteException { synchronized (BluetoothDevice.class) { sService = null; } } public void onBrEdrDown() { if (DBG) Log.d(TAG, "onBrEdrDown: reached BLE ON state"); } public void onOobData(@Transport int transport, OobData oobData) { if (DBG) Log.d(TAG, "onOobData: got data"); } }; /** * Create a new BluetoothDevice. Loading @@ -1340,7 +1299,6 @@ public final class BluetoothDevice implements Parcelable, Attributable { * @hide */ /*package*/ BluetoothDevice(String address, int addressType) { getService(); // ensures sService is initialized if (!BluetoothAdapter.checkBluetoothAddress(address)) { throw new IllegalArgumentException(address + " is not a valid Bluetooth address"); } Loading Loading @@ -1488,7 +1446,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public @Nullable String getIdentityAddress() { if (DBG) log("getIdentityAddress()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get identity address"); Loading Loading @@ -1518,7 +1476,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public String getName() { if (DBG) log("getName()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device name"); Loading Loading @@ -1553,7 +1511,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public int getType() { if (DBG) log("getType()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = DEVICE_TYPE_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device type"); Loading Loading @@ -1582,7 +1540,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public String getAlias() { if (DBG) log("getAlias()"); final IBluetooth service = sService; final IBluetooth service = getService(); final String defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Remote Device Alias"); Loading Loading @@ -1643,7 +1601,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { throw new IllegalArgumentException("alias cannot be the empty string"); } if (DBG) log("setAlias(" + alias + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set Remote Device name"); Loading Loading @@ -1677,7 +1635,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @IntRange(from = -100, to = 100) int getBatteryLevel() { if (DBG) log("getBatteryLevel()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BATTERY_LEVEL_BLUETOOTH_OFF; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth disabled. Cannot get remote device battery level"); Loading Loading @@ -1772,7 +1730,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { private boolean createBondInternal(int transport, @Nullable OobData remoteP192Data, @Nullable OobData remoteP256Data) { if (DBG) log("createBondOutOfBand()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "BT not enabled, createBondOutOfBand failed"); Loading Loading @@ -1805,7 +1763,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isBondingInitiatedLocally() { if (DBG) log("isBondingInitiatedLocally()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "BT not enabled, isBondingInitiatedLocally failed"); Loading @@ -1832,7 +1790,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean cancelBondProcess() { if (DBG) log("cancelBondProcess()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot cancel Remote Device bond"); Loading Loading @@ -1865,7 +1823,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean removeBond() { if (DBG) log("removeBond()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot remove Remote Device bond"); Loading Loading @@ -1955,7 +1913,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @SuppressLint("AndroidFrameworkRequiresPermission") public int getBondState() { if (DBG) log("getBondState(" + getAnonymizedAddress() + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); if (service == null) { Log.e(TAG, "BT not enabled. Cannot get bond state"); if (DBG) log(Log.getStackTraceString(new Throwable())); Loading Loading @@ -1988,7 +1946,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean canBondWithoutDialog() { if (DBG) log("canBondWithoutDialog, device: " + this); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot check if we can skip pairing dialog"); Loading Loading @@ -2042,7 +2000,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (!BluetoothAdapter.checkBluetoothAddress(getAddress())) { throw new IllegalArgumentException("device cannot have an invalid address"); } final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot connect to remote device."); Loading Loading @@ -2089,7 +2047,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { if (!BluetoothAdapter.checkBluetoothAddress(getAddress())) { throw new IllegalArgumentException("device cannot have an invalid address"); } final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = BluetoothStatusCodes.ERROR_BLUETOOTH_NOT_ENABLED; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot disconnect to remote device."); Loading Loading @@ -2121,7 +2079,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isConnected() { if (DBG) log("isConnected()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = CONNECTION_STATE_DISCONNECTED; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2153,7 +2111,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean isEncrypted() { if (DBG) log("isEncrypted()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = CONNECTION_STATE_DISCONNECTED; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2182,7 +2140,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public BluetoothClass getBluetoothClass() { if (DBG) log("getBluetoothClass()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = 0; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get Bluetooth Class"); Loading Loading @@ -2216,7 +2174,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public ParcelUuid[] getUuids() { if (DBG) log("getUuids()"); final IBluetooth service = sService; final IBluetooth service = getService(); final ParcelUuid[] defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot get remote device Uuids"); Loading Loading @@ -2283,7 +2241,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean fetchUuidsWithSdp(@Transport int transport) { if (DBG) log("fetchUuidsWithSdp()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot fetchUuidsWithSdp"); Loading Loading @@ -2325,7 +2283,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean sdpSearch(ParcelUuid uuid) { if (DBG) log("sdpSearch()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot query remote device sdp records"); Loading @@ -2352,7 +2310,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public boolean setPin(byte[] pin) { if (DBG) log("setPin()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set Remote Device pin"); Loading Loading @@ -2398,7 +2356,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setPairingConfirmation(boolean confirm) { if (DBG) log("setPairingConfirmation()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "BT not enabled. Cannot set pairing confirmation"); Loading Loading @@ -2437,7 +2395,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getPhonebookAccessPermission() { if (DBG) log("getPhonebookAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2484,7 +2442,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setSilenceMode(boolean silence) { if (DBG) log("setSilenceMode()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { throw new IllegalStateException("Bluetooth is not turned ON"); Loading Loading @@ -2514,7 +2472,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean isInSilenceMode() { if (DBG) log("isInSilenceMode()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { throw new IllegalStateException("Bluetooth is not turned ON"); Loading Loading @@ -2545,7 +2503,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setPhonebookAccessPermission(@AccessPermission int value) { if (DBG) log("setPhonebookAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2574,7 +2532,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getMessageAccessPermission() { if (DBG) log("getMessageAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2611,7 +2569,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { throw new IllegalArgumentException(value + "is not a valid AccessPermission value"); } if (DBG) log("setMessageAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2640,7 +2598,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { @RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT) public @AccessPermission int getSimAccessPermission() { if (DBG) log("getSimAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final int defaultValue = ACCESS_UNKNOWN; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -2673,7 +2631,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setSimAccessPermission(int value) { if (DBG) log("setSimAccessPermission()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.w(TAG, "Proxy not attached to service"); Loading Loading @@ -3184,7 +3142,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setMetadata(@MetadataKey int key, @NonNull byte[] value) { if (DBG) log("setMetadata()"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot set metadata"); Loading Loading @@ -3219,7 +3177,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public byte[] getMetadata(@MetadataKey int key) { if (DBG) log("getMetadata()"); final IBluetooth service = sService; final IBluetooth service = getService(); final byte[] defaultValue = null; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot get metadata"); Loading Loading @@ -3262,7 +3220,7 @@ public final class BluetoothDevice implements Parcelable, Attributable { }) public boolean setLowLatencyAudioAllowed(boolean allowed) { if (DBG) log("setLowLatencyAudioAllowed(" + allowed + ")"); final IBluetooth service = sService; final IBluetooth service = getService(); final boolean defaultValue = false; if (service == null || !isBluetoothEnabled()) { Log.e(TAG, "Bluetooth is not enabled. Cannot allow low latency"); Loading