AVRCP version interop pereference (2/3)

Add a mechanism to allow the user to select the AVRCP version broadcasted
through SDP in the developer options. This helps solve some interoperability
issues such as with Honda Carkits where broadcasting AVRCP version 1.6 causes
media metadata to fail.

Bug: 35956792
Test: Select AVRCP version through developer option
Merged-In: I7d4b1bd23342d1a96ffdf08bb7d6d3c5e5fedca6
Change-Id: I7d4b1bd23342d1a96ffdf08bb7d6d3c5e5fedca6
This commit is contained in:
Ajay Panicker
2017-03-20 11:34:54 -07:00
parent 4e32e87e57
commit e50b0d490a
2 changed files with 32 additions and 0 deletions

View File

@@ -201,6 +201,13 @@
android:title="@string/bluetooth_disable_absolute_volume" android:title="@string/bluetooth_disable_absolute_volume"
android:summary="@string/bluetooth_disable_absolute_volume_summary"/> android:summary="@string/bluetooth_disable_absolute_volume_summary"/>
<ListPreference
android:key="bluetooth_select_avrcp_version"
android:title="@string/bluetooth_select_avrcp_version_string"
android:dialogTitle="@string/bluetooth_select_avrcp_version_dialog_title"
android:entries="@array/bluetooth_avrcp_versions"
android:entryValues="@array/bluetooth_avrcp_version_values" />
<ListPreference <ListPreference
android:key="bluetooth_select_a2dp_codec" android:key="bluetooth_select_a2dp_codec"
android:title="@string/bluetooth_select_a2dp_codec_type" android:title="@string/bluetooth_select_a2dp_codec_type"

View File

@@ -199,7 +199,10 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
"bluetooth_disable_absolute_volume"; "bluetooth_disable_absolute_volume";
private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY = private static final String BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_PROPERTY =
"persist.bluetooth.disableabsvol"; "persist.bluetooth.disableabsvol";
private static final String BLUETOOTH_AVRCP_VERSION_PROPERTY =
"persist.bluetooth.avrcpversion";
private static final String BLUETOOTH_SELECT_AVRCP_VERSION_KEY = "bluetooth_select_avrcp_version";
private static final String BLUETOOTH_SELECT_A2DP_CODEC_KEY = "bluetooth_select_a2dp_codec"; private static final String BLUETOOTH_SELECT_A2DP_CODEC_KEY = "bluetooth_select_a2dp_codec";
private static final String BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY = "bluetooth_select_a2dp_sample_rate"; private static final String BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY = "bluetooth_select_a2dp_sample_rate";
private static final String BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY = "bluetooth_select_a2dp_bits_per_sample"; private static final String BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY = "bluetooth_select_a2dp_bits_per_sample";
@@ -280,6 +283,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
private BluetoothA2dp mBluetoothA2dp; private BluetoothA2dp mBluetoothA2dp;
private final Object mBluetoothA2dpLock = new Object(); private final Object mBluetoothA2dpLock = new Object();
private ListPreference mBluetoothSelectAvrcpVersion;
private ListPreference mBluetoothSelectA2dpCodec; private ListPreference mBluetoothSelectA2dpCodec;
private ListPreference mBluetoothSelectA2dpSampleRate; private ListPreference mBluetoothSelectA2dpSampleRate;
private ListPreference mBluetoothSelectA2dpBitsPerSample; private ListPreference mBluetoothSelectA2dpBitsPerSample;
@@ -474,6 +478,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY); mWebViewMultiprocess = findAndInitSwitchPref(WEBVIEW_MULTIPROCESS_KEY);
mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY); mBluetoothDisableAbsVolume = findAndInitSwitchPref(BLUETOOTH_DISABLE_ABSOLUTE_VOLUME_KEY);
mBluetoothSelectAvrcpVersion = addListPreference(BLUETOOTH_SELECT_AVRCP_VERSION_KEY);
mBluetoothSelectA2dpCodec = addListPreference(BLUETOOTH_SELECT_A2DP_CODEC_KEY); mBluetoothSelectA2dpCodec = addListPreference(BLUETOOTH_SELECT_A2DP_CODEC_KEY);
mBluetoothSelectA2dpSampleRate = addListPreference(BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY); mBluetoothSelectA2dpSampleRate = addListPreference(BLUETOOTH_SELECT_A2DP_SAMPLE_RATE_KEY);
mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY); mBluetoothSelectA2dpBitsPerSample = addListPreference(BLUETOOTH_SELECT_A2DP_BITS_PER_SAMPLE_KEY);
@@ -1781,6 +1786,14 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
String[] summaries; String[] summaries;
int index; int index;
// Init the AVRCP Version - Default
values = getResources().getStringArray(R.array.bluetooth_avrcp_version_values);
summaries = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
String value = SystemProperties.get(BLUETOOTH_AVRCP_VERSION_PROPERTY);
index = mBluetoothSelectAvrcpVersion.findIndexOfValue(value);
mBluetoothSelectAvrcpVersion.setValue(values[index]);
mBluetoothSelectAvrcpVersion.setSummary(summaries[index]);
// Init the Codec Type - Default // Init the Codec Type - Default
values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values); values = getResources().getStringArray(R.array.bluetooth_a2dp_codec_values);
summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries); summaries = getResources().getStringArray(R.array.bluetooth_a2dp_codec_summaries);
@@ -1817,6 +1830,15 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]); mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(summaries[index]);
} }
private void writeBluetoothAvrcpVersion(Object newValue) {
SystemProperties.set(BLUETOOTH_AVRCP_VERSION_PROPERTY, newValue.toString());
int index = mBluetoothSelectAvrcpVersion.findIndexOfValue(newValue.toString());
if (index >= 0) {
String[] titles = getResources().getStringArray(R.array.bluetooth_avrcp_versions);
mBluetoothSelectAvrcpVersion.setSummary(titles[index]);
}
}
private void updateBluetoothA2dpConfigurationValues() { private void updateBluetoothA2dpConfigurationValues() {
int index; int index;
String[] summaries; String[] summaries;
@@ -2544,6 +2566,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
toast.show(); toast.show();
} }
return false; return false;
} else if (preference == mBluetoothSelectAvrcpVersion) {
writeBluetoothAvrcpVersion(newValue);
return true;
} else if ((preference == mBluetoothSelectA2dpCodec) || } else if ((preference == mBluetoothSelectA2dpCodec) ||
(preference == mBluetoothSelectA2dpSampleRate) || (preference == mBluetoothSelectA2dpSampleRate) ||
(preference == mBluetoothSelectA2dpBitsPerSample) || (preference == mBluetoothSelectA2dpBitsPerSample) ||