From 4f164ffdd35869f95e26f24656d04b37af34d9a0 Mon Sep 17 00:00:00 2001 From: hughchen Date: Thu, 2 Aug 2018 16:28:24 +0800 Subject: [PATCH] Set each function as default in BluetoothCallback 1. Set each function as default in BluetoothCallback. 2. Remove the function that not used. Bug: 111811266 Test: Build pass Change-Id: Ib0ad7b4d3290238dc472f3ace9e3b3d0ba17469d --- .../settingslib/bluetooth/BluetoothCallback.java | 16 ++++++++-------- .../android/systemui/keyboard/KeyboardUI.java | 15 --------------- .../policy/BluetoothControllerImpl.java | 11 ----------- 3 files changed, 8 insertions(+), 34 deletions(-) diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothCallback.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothCallback.java index eba6f94de12a0..a91c45dd59af9 100644 --- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothCallback.java +++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/BluetoothCallback.java @@ -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. diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java index 81d700ca3d025..682efb657d9e5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java +++ b/packages/SystemUI/src/com/android/systemui/keyboard/KeyboardUI.java @@ -599,21 +599,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 { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java index 8df51dbf5e68a..1085b06c0f04d 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/BluetoothControllerImpl.java @@ -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) {