Merge "Add a "Use high quality audio" option to Bluetooth A2DP device settings" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c439202da9
@@ -23,6 +23,7 @@ import android.bluetooth.BluetoothProfile;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
@@ -37,6 +38,7 @@ import android.widget.TextView;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
||||
import com.android.settingslib.bluetooth.A2dpProfile;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
|
||||
import com.android.settingslib.bluetooth.CachedBluetoothDeviceManager;
|
||||
import com.android.settingslib.bluetooth.LocalBluetoothManager;
|
||||
@@ -55,6 +57,8 @@ public final class DeviceProfilesSettings extends InstrumentedDialogFragment imp
|
||||
private static final String KEY_PROFILE_CONTAINER = "profile_container";
|
||||
private static final String KEY_UNPAIR = "unpair";
|
||||
private static final String KEY_PBAP_SERVER = "PBAP Server";
|
||||
@VisibleForTesting
|
||||
static final String HIGH_QUALITY_AUDIO_PREF_TAG = "A2dpProfileHighQualityAudio";
|
||||
|
||||
private CachedBluetoothDevice mCachedDevice;
|
||||
private LocalBluetoothManager mManager;
|
||||
@@ -169,6 +173,21 @@ public final class DeviceProfilesSettings extends InstrumentedDialogFragment imp
|
||||
for (LocalBluetoothProfile profile : mCachedDevice.getConnectableProfiles()) {
|
||||
CheckBox pref = createProfilePreference(profile);
|
||||
mProfileContainer.addView(pref);
|
||||
|
||||
if (profile instanceof A2dpProfile) {
|
||||
BluetoothDevice device = mCachedDevice.getDevice();
|
||||
A2dpProfile a2dpProfile = (A2dpProfile) profile;
|
||||
if (a2dpProfile.supportsHighQualityAudio(device)) {
|
||||
CheckBox highQualityPref = new CheckBox(getActivity());
|
||||
highQualityPref.setTag(HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
highQualityPref.setOnClickListener(v -> {
|
||||
a2dpProfile.setHighQualityAudioEnabled(device, highQualityPref.isChecked());
|
||||
});
|
||||
highQualityPref.setVisibility(View.GONE);
|
||||
mProfileContainer.addView(highQualityPref);
|
||||
}
|
||||
refreshProfilePreference(pref, profile);
|
||||
}
|
||||
}
|
||||
|
||||
final int pbapPermission = mCachedDevice.getPhonebookPermissionChoice();
|
||||
@@ -356,6 +375,22 @@ public final class DeviceProfilesSettings extends InstrumentedDialogFragment imp
|
||||
} else {
|
||||
profilePref.setChecked(profile.isPreferred(device));
|
||||
}
|
||||
if (profile instanceof A2dpProfile) {
|
||||
A2dpProfile a2dpProfile = (A2dpProfile) profile;
|
||||
View v = mProfileContainer.findViewWithTag(HIGH_QUALITY_AUDIO_PREF_TAG);
|
||||
if (v instanceof CheckBox) {
|
||||
CheckBox highQualityPref = (CheckBox) v;
|
||||
highQualityPref.setText(a2dpProfile.getHighQualityAudioOptionLabel(device));
|
||||
highQualityPref.setChecked(a2dpProfile.isHighQualityAudioEnabled(device));
|
||||
|
||||
if (a2dpProfile.isPreferred(device)) {
|
||||
v.setVisibility(View.VISIBLE);
|
||||
v.setEnabled(!mCachedDevice.isBusy());
|
||||
} else {
|
||||
v.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LocalBluetoothProfile getProfileOf(View v) {
|
||||
|
Reference in New Issue
Block a user