Hide the Contact sharing toggle for LE audio mode
1. Add the device config key 2. Hide the Contact sharing toggle for LE audio mode Bug: 228415214 Test: manual test and take the screenshots at bug. Change-Id: I07674d0edbcd642814ed61ccd13cb4e1e42caec3
This commit is contained in:
@@ -20,6 +20,7 @@ import android.bluetooth.BluetoothCsipSetCoordinator;
|
|||||||
import android.bluetooth.BluetoothDevice;
|
import android.bluetooth.BluetoothDevice;
|
||||||
import android.bluetooth.BluetoothProfile;
|
import android.bluetooth.BluetoothProfile;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
@@ -31,6 +32,7 @@ import androidx.preference.PreferenceScreen;
|
|||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.core.SettingsUIDeviceConfig;
|
||||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||||
import com.android.settingslib.bluetooth.LeAudioProfile;
|
import com.android.settingslib.bluetooth.LeAudioProfile;
|
||||||
@@ -70,6 +72,7 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
private List<CachedBluetoothDevice> mAllOfCachedDevices;
|
private List<CachedBluetoothDevice> mAllOfCachedDevices;
|
||||||
private Map<String, List<CachedBluetoothDevice>> mProfileDeviceMap =
|
private Map<String, List<CachedBluetoothDevice>> mProfileDeviceMap =
|
||||||
new HashMap<String, List<CachedBluetoothDevice>>();
|
new HashMap<String, List<CachedBluetoothDevice>>();
|
||||||
|
private boolean mIsLeContactSharingEnabled = false;
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
PreferenceCategory mProfilesContainer;
|
PreferenceCategory mProfilesContainer;
|
||||||
@@ -88,6 +91,8 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
protected void init(PreferenceScreen screen) {
|
protected void init(PreferenceScreen screen) {
|
||||||
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
|
mProfilesContainer = (PreferenceCategory)screen.findPreference(getPreferenceKey());
|
||||||
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
mProfilesContainer.setLayoutResource(R.layout.preference_bluetooth_profile_category);
|
||||||
|
mIsLeContactSharingEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||||
|
SettingsUIDeviceConfig.BT_LE_AUDIO_CONTACT_SHARING_ENABLED, false);
|
||||||
// Call refresh here even though it will get called later in onResume, to avoid the
|
// Call refresh here even though it will get called later in onResume, to avoid the
|
||||||
// list of switches appearing to "pop" into the page.
|
// list of switches appearing to "pop" into the page.
|
||||||
refresh();
|
refresh();
|
||||||
@@ -119,21 +124,11 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
private void refreshProfilePreference(SwitchPreference profilePref,
|
private void refreshProfilePreference(SwitchPreference profilePref,
|
||||||
LocalBluetoothProfile profile) {
|
LocalBluetoothProfile profile) {
|
||||||
BluetoothDevice device = mCachedDevice.getDevice();
|
BluetoothDevice device = mCachedDevice.getDevice();
|
||||||
boolean isLeAudioEnabled = false;
|
boolean isLeAudioEnabled = isLeAudioEnabled();
|
||||||
if (profile instanceof A2dpProfile || HEADSET_CLIENT.equals(profile.toString())) {
|
if (profile instanceof A2dpProfile || HEADSET_CLIENT.equals(profile.toString())) {
|
||||||
LocalBluetoothProfile leAudio = mProfileManager.getLeAudioProfile();
|
|
||||||
if (leAudio != null) {
|
|
||||||
List<CachedBluetoothDevice> leAudioDeviceList = mProfileDeviceMap.get(
|
|
||||||
leAudio.toString());
|
|
||||||
if (leAudioDeviceList != null
|
|
||||||
&& leAudioDeviceList.stream()
|
|
||||||
.anyMatch(item -> leAudio.isEnabled(item.getDevice()))) {
|
|
||||||
isLeAudioEnabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isLeAudioEnabled) {
|
if (isLeAudioEnabled) {
|
||||||
// If the LeAudio profile is enabled on the LeAudio devices, then the
|
// If the LeAudio profile is enabled on the LeAudio devices, then the
|
||||||
// SwitchPreferences of A2dp profile and Hfp profile are graied out.
|
// SwitchPreferences of A2dp profile and Hfp profile are grayed out.
|
||||||
profilePref.setEnabled(false);
|
profilePref.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
List<CachedBluetoothDevice> deviceList = mProfileDeviceMap.get(
|
List<CachedBluetoothDevice> deviceList = mProfileDeviceMap.get(
|
||||||
@@ -145,12 +140,9 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
} else if (profile instanceof LeAudioProfile) {
|
} else if (profile instanceof LeAudioProfile) {
|
||||||
List<CachedBluetoothDevice> leAudioDeviceList = mProfileDeviceMap.get(
|
List<CachedBluetoothDevice> leAudioDeviceList = mProfileDeviceMap.get(
|
||||||
profile.toString());
|
profile.toString());
|
||||||
boolean isLeAudioProfileEnable =
|
|
||||||
leAudioDeviceList != null && leAudioDeviceList.stream().anyMatch(
|
|
||||||
item -> profile.isEnabled(item.getDevice()));
|
|
||||||
boolean isBusy = leAudioDeviceList != null
|
boolean isBusy = leAudioDeviceList != null
|
||||||
&& leAudioDeviceList.stream().anyMatch(item -> item.isBusy());
|
&& leAudioDeviceList.stream().anyMatch(item -> item.isBusy());
|
||||||
if (isLeAudioProfileEnable && !isBusy) {
|
if (isLeAudioEnabled && !isBusy) {
|
||||||
LocalBluetoothProfile a2dp = mProfileManager.getA2dpProfile();
|
LocalBluetoothProfile a2dp = mProfileManager.getA2dpProfile();
|
||||||
LocalBluetoothProfile hfp = mProfileManager.getHfpClientProfile();
|
LocalBluetoothProfile hfp = mProfileManager.getHfpClientProfile();
|
||||||
// If the LeAudio profile is enabled on the LeAudio devices, then the
|
// If the LeAudio profile is enabled on the LeAudio devices, then the
|
||||||
@@ -169,6 +161,10 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
profilePref.setEnabled(!isBusy);
|
profilePref.setEnabled(!isBusy);
|
||||||
|
} else if (profile instanceof PbapServerProfile
|
||||||
|
&& isLeAudioEnabled
|
||||||
|
&& !mIsLeContactSharingEnabled) {
|
||||||
|
profilePref.setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
profilePref.setEnabled(!mCachedDevice.isBusy());
|
profilePref.setEnabled(!mCachedDevice.isBusy());
|
||||||
}
|
}
|
||||||
@@ -203,6 +199,20 @@ public class BluetoothDetailsProfilesController extends BluetoothDetailsControll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLeAudioEnabled(){
|
||||||
|
LocalBluetoothProfile leAudio = mProfileManager.getLeAudioProfile();
|
||||||
|
if (leAudio != null) {
|
||||||
|
List<CachedBluetoothDevice> leAudioDeviceList = mProfileDeviceMap.get(
|
||||||
|
leAudio.toString());
|
||||||
|
if (leAudioDeviceList != null
|
||||||
|
&& leAudioDeviceList.stream()
|
||||||
|
.anyMatch(item -> leAudio.isEnabled(item.getDevice()))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to enable a profile for a device.
|
* Helper method to enable a profile for a device.
|
||||||
*/
|
*/
|
||||||
|
@@ -33,7 +33,11 @@ public class SettingsUIDeviceConfig {
|
|||||||
* {@code true} if near by device suggestion is enabled in connected device page
|
* {@code true} if near by device suggestion is enabled in connected device page
|
||||||
*/
|
*/
|
||||||
public static final String BT_NEAR_BY_SUGGESTION_ENABLED = "bt_near_by_suggestion_enabled";
|
public static final String BT_NEAR_BY_SUGGESTION_ENABLED = "bt_near_by_suggestion_enabled";
|
||||||
|
/**
|
||||||
|
* {@code true} if le audio contact sharing is enabled in BT device detail page
|
||||||
|
*/
|
||||||
|
public static final String BT_LE_AUDIO_CONTACT_SHARING_ENABLED =
|
||||||
|
"bt_le_audio_contact_sharing_enabled";
|
||||||
/**
|
/**
|
||||||
* {@code true} whether or not event_log for generic actions is enabled. Default is true.
|
* {@code true} whether or not event_log for generic actions is enabled. Default is true.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user