Merge "Set each function as default in BluetoothCallback"

This commit is contained in:
TreeHugger Robot
2018-08-08 04:17:53 +00:00
committed by Android (Google) Code Review
3 changed files with 8 additions and 34 deletions

View File

@@ -33,7 +33,7 @@ public interface BluetoothCallback {
* {@link android.bluetooth.BluetoothAdapter#STATE_ON},
* {@link android.bluetooth.BluetoothAdapter#STATE_TURNING_OFF}.
*/
void onBluetoothStateChanged(int bluetoothState);
default void onBluetoothStateChanged(int bluetoothState) {}
/**
* It will be called when the local Bluetooth adapter has started
@@ -43,7 +43,7 @@ public interface BluetoothCallback {
*
* @param started indicate the current process is started or finished.
*/
void onScanningStateChanged(boolean started);
default void onScanningStateChanged(boolean started) {}
/**
* It will be called in following situations:
@@ -54,7 +54,7 @@ public interface BluetoothCallback {
*
* @param cachedDevice the Bluetooth device.
*/
void onDeviceAdded(CachedBluetoothDevice cachedDevice);
default void onDeviceAdded(CachedBluetoothDevice cachedDevice) {}
/**
* It will be called when a remote device that was
@@ -63,7 +63,7 @@ public interface BluetoothCallback {
*
* @param cachedDevice the Bluetooth device.
*/
void onDeviceDeleted(CachedBluetoothDevice cachedDevice);
default void onDeviceDeleted(CachedBluetoothDevice cachedDevice) {}
/**
* It will be called when bond state of a remote device is changed.
@@ -75,7 +75,7 @@ public interface BluetoothCallback {
* {@link android.bluetooth.BluetoothDevice#BOND_BONDING},
* {@link android.bluetooth.BluetoothDevice#BOND_BONDED}.
*/
void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState);
default void onDeviceBondStateChanged(CachedBluetoothDevice cachedDevice, int bondState) {}
/**
* It will be called in following situations:
@@ -91,7 +91,7 @@ public interface BluetoothCallback {
* {@link android.bluetooth.BluetoothAdapter#STATE_CONNECTED},
* {@link android.bluetooth.BluetoothAdapter#STATE_DISCONNECTING}.
*/
void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state);
default void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) {}
/**
* It will be called when device been set as active for {@code bluetoothProfile}
@@ -103,7 +103,7 @@ public interface BluetoothCallback {
* @param activeDevice the active Bluetooth device.
* @param bluetoothProfile the profile of active Bluetooth device.
*/
void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile);
default void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) {}
/**
* It will be called in following situations:
@@ -113,7 +113,7 @@ public interface BluetoothCallback {
* {@link android.bluetooth.BluetoothHeadset#ACTION_AUDIO_STATE_CHANGED}
* {@link android.telephony.TelephonyManager#ACTION_PHONE_STATE_CHANGED}
*/
void onAudioModeChanged();
default void onAudioModeChanged() {}
/**
* It will be called when one of the bluetooth device profile connection state is changed.

View File

@@ -598,21 +598,6 @@ public class KeyboardUI extends SystemUI implements InputManager.OnTabletModeCha
mHandler.obtainMessage(MSG_ON_DEVICE_BOND_STATE_CHANGED,
bondState, 0, cachedDevice).sendToTarget();
}
@Override
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) { }
@Override
public void onDeviceDeleted(CachedBluetoothDevice cachedDevice) { }
@Override
public void onScanningStateChanged(boolean started) { }
@Override
public void onConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { }
@Override
public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice,
int bluetoothProfile) { }
@Override
public void onAudioModeChanged() { }
}
private final class BluetoothErrorListener implements BluetoothUtils.ErrorListener {

View File

@@ -238,11 +238,6 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
}
@Override
public void onScanningStateChanged(boolean started) {
// Don't care.
}
@Override
public void onDeviceAdded(CachedBluetoothDevice cachedDevice) {
cachedDevice.registerCallback(this);
@@ -277,12 +272,6 @@ public class BluetoothControllerImpl implements BluetoothController, BluetoothCa
mHandler.sendEmptyMessage(H.MSG_STATE_CHANGED);
}
@Override
public void onActiveDeviceChanged(CachedBluetoothDevice activeDevice, int bluetoothProfile) {}
@Override
public void onAudioModeChanged() {}
private ActuallyCachedState getCachedState(CachedBluetoothDevice device) {
ActuallyCachedState state = mCachedState.get(device);
if (state == null) {