Merge "Use BluetoothUtils.isAdvancedDetailsHeader in Header controllers."
This commit is contained in:
@@ -126,7 +126,7 @@ public class AdvancedBluetoothDetailsHeaderController extends BasePreferenceCont
|
||||
if (mCachedDevice == null) {
|
||||
return CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
return Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice())
|
||||
return BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice())
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ public class BluetoothDetailsHeaderController extends BluetoothDetailsController
|
||||
boolean hasLeAudio = mCachedDevice.getConnectableProfiles()
|
||||
.stream()
|
||||
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);
|
||||
return !Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio;
|
||||
return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && !hasLeAudio;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -111,7 +111,7 @@ public class LeAudioBluetoothDetailsHeaderController extends BasePreferenceContr
|
||||
.stream()
|
||||
.anyMatch(profile -> profile.getProfileId() == BluetoothProfile.LE_AUDIO);
|
||||
|
||||
return !Utils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && hasLeAudio
|
||||
return !BluetoothUtils.isAdvancedDetailsHeader(mCachedDevice.getDevice()) && hasLeAudio
|
||||
? AVAILABLE : CONDITIONALLY_UNAVAILABLE;
|
||||
}
|
||||
|
||||
|
@@ -28,18 +28,14 @@ import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.SettingsUIDeviceConfig;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils;
|
||||
import com.android.settingslib.bluetooth.BluetoothUtils.ErrorListener;
|
||||
@@ -165,38 +161,6 @@ public final class Utils {
|
||||
Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Bluetooth device supports advanced details header
|
||||
*
|
||||
* @param bluetoothDevice the BluetoothDevice to get metadata
|
||||
* @return true if it supports advanced details header, false otherwise.
|
||||
*/
|
||||
public static boolean isAdvancedDetailsHeader(@NonNull BluetoothDevice bluetoothDevice) {
|
||||
final boolean advancedEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
|
||||
SettingsUIDeviceConfig.BT_ADVANCED_HEADER_ENABLED, true);
|
||||
if (!advancedEnabled) {
|
||||
Log.d(TAG, "isAdvancedDetailsHeader: advancedEnabled is false");
|
||||
return false;
|
||||
}
|
||||
// The metadata is for Android R
|
||||
final boolean untetheredHeadset = BluetoothUtils.getBooleanMetaData(bluetoothDevice,
|
||||
BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET);
|
||||
if (untetheredHeadset) {
|
||||
Log.d(TAG, "isAdvancedDetailsHeader: untetheredHeadset is true");
|
||||
return true;
|
||||
}
|
||||
// The metadata is for Android S
|
||||
final String deviceType = BluetoothUtils.getStringMetaData(bluetoothDevice,
|
||||
BluetoothDevice.METADATA_DEVICE_TYPE);
|
||||
if (TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_UNTETHERED_HEADSET)
|
||||
|| TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_WATCH)
|
||||
|| TextUtils.equals(deviceType, BluetoothDevice.DEVICE_TYPE_DEFAULT)) {
|
||||
Log.d(TAG, "isAdvancedDetailsHeader: deviceType is " + deviceType);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Bluetooth Package name
|
||||
*/
|
||||
|
Reference in New Issue
Block a user