diff --git a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java index ec131d46edd..99ebd7b0bbd 100644 --- a/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/AvailableMediaBluetoothDeviceUpdater.java @@ -32,7 +32,7 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater implements Preference.OnPreferenceClickListener { private static final String TAG = "AvailableMediaBluetoothDeviceUpdater"; - private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean DBG = Log.isLoggable(BluetoothDeviceUpdater.TAG, Log.DEBUG); private static final String PREF_KEY = "available_media_bt"; @@ -111,4 +111,15 @@ public class AvailableMediaBluetoothDeviceUpdater extends BluetoothDeviceUpdater protected String getPreferenceKey() { return PREF_KEY; } + + @Override + protected String getLogTag() { + return TAG; + } + + @Override + protected void update(CachedBluetoothDevice cachedBluetoothDevice) { + super.update(cachedBluetoothDevice); + Log.d(TAG, "Map : " + mPreferenceMap); + } } diff --git a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java index 563c010d692..f69cf580d51 100644 --- a/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java +++ b/src/com/android/settings/bluetooth/BluetoothDetailsProfilesController.java @@ -267,8 +267,6 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll for (LocalBluetoothProfile profile : tmpResult) { if (mProfileDeviceMap.containsKey(profile.toString())) { mProfileDeviceMap.get(profile.toString()).add(cachedItem); - Log.d(TAG, "getProfiles: " + profile.toString() + " add device " - + cachedItem.getDevice().getAnonymizedAddress()); } else { List tmpCachedDeviceList = new ArrayList(); @@ -303,7 +301,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll result.remove(mManager.getProfileManager().getA2dpProfile()); result.remove(mManager.getProfileManager().getHeadsetProfile()); } - Log.d(TAG, "getProfiles:result:" + result); + Log.d(TAG, "getProfiles:Map:" + mProfileDeviceMap); return result; } @@ -336,7 +334,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) { Log.d(TAG, - "User disable LE device: " + leAudioDevice.getDevice().getAnonymizedAddress()); + "device:" + leAudioDevice.getDevice().getAnonymizedAddress() + + "disable LE profile"); profile.setEnabled(leAudioDevice.getDevice(), false); if (vcp != null) { vcp.setEnabled(leAudioDevice.getDevice(), false); @@ -374,7 +373,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll LocalBluetoothProfile csip = mProfileManager.getCsipSetCoordinatorProfile(); for (CachedBluetoothDevice leAudioDevice : mProfileDeviceMap.get(profile.toString())) { Log.d(TAG, - "User enable LE device: " + leAudioDevice.getDevice().getAnonymizedAddress()); + "device:" + leAudioDevice.getDevice().getAnonymizedAddress() + + "enable LE profile"); profile.setEnabled(leAudioDevice.getDevice(), true); if (vcp != null) { vcp.setEnabled(leAudioDevice.getDevice(), true); @@ -390,9 +390,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll Log.d(TAG, "Disable " + profile.toString() + " before user enables LE"); for (CachedBluetoothDevice profileDevice : mProfileDeviceMap.get(profile.toString())) { if (profile.isEnabled(profileDevice.getDevice())) { + Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":" + + profile.toString() + " set disable"); profile.setEnabled(profileDevice.getDevice(), false); } else { - Log.d(TAG, "The " + profile.toString() + " profile is disabled. Do nothing."); + Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":" + + profile.toString() + " profile is disabled. Do nothing."); } } } @@ -403,9 +406,12 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll Log.d(TAG, "enable " + profile.toString() + "after user disables LE"); for (CachedBluetoothDevice profileDevice : mProfileDeviceMap.get(profile.toString())) { if (!profile.isEnabled(profileDevice.getDevice())) { + Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":" + + profile.toString() + " set enable"); profile.setEnabled(profileDevice.getDevice(), true); } else { - Log.d(TAG, "The " + profile.toString() + " profile is enabled. Do nothing."); + Log.d(TAG, "The " + profileDevice.getDevice().getAnonymizedAddress() + ":" + + profile.toString() + " profile is enabled. Do nothing."); } } } diff --git a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java index 25e5fbb9928..17c5f36d5c6 100644 --- a/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/BluetoothDeviceUpdater.java @@ -58,7 +58,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, protected LocalBluetoothManager mLocalManager; protected int mMetricsCategory; - private static final String TAG = "BluetoothDeviceUpdater"; + protected static final String TAG = "BluetoothDeviceUpdater"; private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); @VisibleForTesting @@ -88,7 +88,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, */ public void registerCallback() { if (mLocalManager == null) { - Log.e(TAG, "registerCallback() Bluetooth is not supported on this device"); + Log.e(getLogTag(), "registerCallback() Bluetooth is not supported on this device"); return; } mLocalManager.setForegroundActivity(mContext); @@ -102,7 +102,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, */ public void unregisterCallback() { if (mLocalManager == null) { - Log.e(TAG, "unregisterCallback() Bluetooth is not supported on this device"); + Log.e(getLogTag(), "unregisterCallback() Bluetooth is not supported on this device"); return; } mLocalManager.setForegroundActivity(null); @@ -115,7 +115,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, */ public void forceUpdate() { if (mLocalManager == null) { - Log.e(TAG, "forceUpdate() Bluetooth is not supported on this device"); + Log.e(getLogTag(), "forceUpdate() Bluetooth is not supported on this device"); return; } if (BluetoothAdapter.getDefaultAdapter().isEnabled()) { @@ -131,7 +131,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, public void removeAllDevicesFromPreference() { if (mLocalManager == null) { - Log.e(TAG, "removeAllDevicesFromPreference() BT is not supported on this device"); + Log.e(getLogTag(), + "removeAllDevicesFromPreference() BT is not supported on this device"); return; } final Collection cachedDevices = @@ -172,7 +173,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, public void onProfileConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state, int bluetoothProfile) { if (DBG) { - Log.d(TAG, "onProfileConnectionStateChanged() device: " + cachedDevice.getName() + Log.d(getLogTag(), "onProfileConnectionStateChanged() device: " + cachedDevice.getName() + ", state: " + state + ", bluetoothProfile: " + bluetoothProfile); } update(cachedDevice); @@ -181,7 +182,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, @Override public void onAclConnectionStateChanged(CachedBluetoothDevice cachedDevice, int state) { if (DBG) { - Log.d(TAG, "onAclConnectionStateChanged() device: " + cachedDevice.getName() + Log.d(getLogTag(), "onAclConnectionStateChanged() device: " + cachedDevice.getName() + ", state: " + state); } update(cachedDevice); @@ -312,8 +313,8 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, } final BluetoothDevice device = cachedDevice.getDevice(); if (DBG) { - Log.d(TAG, "isDeviceConnected() device name : " + cachedDevice.getName() + - ", is connected : " + device.isConnected() + " , is profile connected : " + Log.d(getLogTag(), "isDeviceConnected() device name : " + cachedDevice.getName() + + ", is connected : " + device.isConnected() + " , is profile connected : " + cachedDevice.isConnected()); } return device.getBondState() == BluetoothDevice.BOND_BONDED && device.isConnected(); @@ -331,4 +332,7 @@ public abstract class BluetoothDeviceUpdater implements BluetoothCallback, protected boolean isDeviceInCachedDevicesList(CachedBluetoothDevice cachedDevice){ return mLocalManager.getCachedDeviceManager().getCachedDevicesCopy().contains(cachedDevice); } + protected String getLogTag() { + return TAG; + } } diff --git a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java index 7bb26968d93..489c0953fdd 100644 --- a/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/ConnectedBluetoothDeviceUpdater.java @@ -32,7 +32,7 @@ import com.android.settingslib.bluetooth.CachedBluetoothDevice; public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { private static final String TAG = "ConnBluetoothDeviceUpdater"; - private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean DBG = Log.isLoggable(BluetoothDeviceUpdater.TAG, Log.DEBUG); private static final String PREF_KEY = "connected_bt"; @@ -118,4 +118,15 @@ public class ConnectedBluetoothDeviceUpdater extends BluetoothDeviceUpdater { protected String getPreferenceKey() { return PREF_KEY; } + + @Override + protected String getLogTag() { + return TAG; + } + + @Override + protected void update(CachedBluetoothDevice cachedBluetoothDevice) { + super.update(cachedBluetoothDevice); + Log.d(TAG, "Map : " + mPreferenceMap); + } } diff --git a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java index 9e4d12f586e..7bf9fdbce23 100644 --- a/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java +++ b/src/com/android/settings/bluetooth/LeAudioBluetoothDetailsHeaderController.java @@ -91,6 +91,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr @VisibleForTesting LayoutPreference mLayoutPreference; private CachedBluetoothDevice mCachedDevice; + private List mLeAudioDevices; @VisibleForTesting Handler mHandler = new Handler(Looper.getMainLooper()); @VisibleForTesting @@ -128,7 +129,13 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr return; } mIsRegisterCallback = true; - mCachedDevice.registerCallback(this); + if (mLeAudioDevices != null && !mLeAudioDevices.isEmpty()) { + for (CachedBluetoothDevice item : mLeAudioDevices) { + item.registerCallback(this); + } + } else { + mCachedDevice.registerCallback(this); + } refresh(); } @@ -137,7 +144,13 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr if (!mIsRegisterCallback) { return; } - mCachedDevice.unregisterCallback(this); + if (mLeAudioDevices != null && !mLeAudioDevices.isEmpty()) { + for (CachedBluetoothDevice item : mLeAudioDevices) { + item.unregisterCallback(this); + } + } else { + mCachedDevice.unregisterCallback(this); + } mIsRegisterCallback = false; } @@ -149,6 +162,8 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr LocalBluetoothManager bluetoothManager) { mCachedDevice = cachedBluetoothDevice; mProfileManager = bluetoothManager.getProfileManager(); + mLeAudioDevices = getAllOfLeAudioDevices(); + } @VisibleForTesting @@ -230,15 +245,15 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr leAudioDevices.add(member); } } + Log.d(TAG, "mLeAudioDevices is " + mLeAudioDevices); return leAudioDevices; } private void updateBatteryLayout() { // Init the battery layouts. hideAllOfBatteryLayouts(); - final List leAudioDevices = getAllOfLeAudioDevices(); LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile(); - if (leAudioDevices == null || leAudioDevices.isEmpty()) { + if (mLeAudioDevices == null || mLeAudioDevices.isEmpty()) { Log.e(TAG, "There is no LeAudioProfile."); return; } @@ -252,7 +267,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr return; } - for (CachedBluetoothDevice cachedDevice : leAudioDevices) { + for (CachedBluetoothDevice cachedDevice : mLeAudioDevices) { int deviceId = leAudioProfile.getAudioLocation(cachedDevice.getDevice()); Log.d(TAG, "LeAudioDevices:" + cachedDevice.getDevice().getAnonymizedAddress() + ", deviceId:" + deviceId); diff --git a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java index a4a94511ffc..43bc4f38d26 100644 --- a/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java +++ b/src/com/android/settings/bluetooth/SavedBluetoothDeviceUpdater.java @@ -38,7 +38,7 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater implements Preference.OnPreferenceClickListener { private static final String TAG = "SavedBluetoothDeviceUpdater"; - private static final boolean DBG = Log.isLoggable(TAG, Log.DEBUG); + private static final boolean DBG = Log.isLoggable(BluetoothDeviceUpdater.TAG, Log.DEBUG); private static final String PREF_KEY = "saved_bt"; @@ -94,6 +94,7 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater } else { removePreference(cachedDevice); } + Log.d(TAG, "Map : " + mPreferenceMap); } @Override @@ -127,4 +128,9 @@ public class SavedBluetoothDeviceUpdater extends BluetoothDeviceUpdater protected String getPreferenceKey() { return PREF_KEY; } + + @Override + protected String getLogTag() { + return TAG; + } }