Add null pointer checks when updating A2DP configuration values
Under expected circumstances, those null pointer checks are not needed: onCreate() is always called before onCreateView(), and the former creates the objects: mBluetoothSelectA2dpCodec, mBluetoothSelectA2dpSampleRate, mBluetoothSelectA2dpBitsPerSample, mBluetoothSelectA2dpChannelMode, mBluetoothSelectA2dpLdacPlaybackQuality . For some unknown reason, somehow the following chain of calls is executed before onCreate() : onCreateView() -> getActivity().registerReceiver(mBluetoothA2dpReceiver, ...) -> mBluetoothA2dpReceiver.onReceive(...) -> updateBluetoothA2dpConfigurationValues() Adding the null pointer checks until the issue is understood. Test: Code compilation Bug: 35204511 Change-Id: I7c1d81015e66b26544b7b26f36cbc75f11713496
This commit is contained in:
@@ -1871,7 +1871,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0 && mBluetoothSelectA2dpCodec != null) {
|
||||||
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_summaries);
|
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_summaries);
|
||||||
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
||||||
mBluetoothSelectA2dpCodec.setSummary(streaming);
|
mBluetoothSelectA2dpCodec.setSummary(streaming);
|
||||||
@@ -1898,7 +1898,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0 && mBluetoothSelectA2dpSampleRate != null) {
|
||||||
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
|
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_sample_rate_summaries);
|
||||||
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
||||||
mBluetoothSelectA2dpSampleRate.setSummary(streaming);
|
mBluetoothSelectA2dpSampleRate.setSummary(streaming);
|
||||||
@@ -1920,7 +1920,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0 && mBluetoothSelectA2dpBitsPerSample != null) {
|
||||||
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
|
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_bits_per_sample_summaries);
|
||||||
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
||||||
mBluetoothSelectA2dpBitsPerSample.setSummary(streaming);
|
mBluetoothSelectA2dpBitsPerSample.setSummary(streaming);
|
||||||
@@ -1939,7 +1939,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0 && mBluetoothSelectA2dpChannelMode != null) {
|
||||||
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
|
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_channel_mode_summaries);
|
||||||
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
||||||
mBluetoothSelectA2dpChannelMode.setSummary(streaming);
|
mBluetoothSelectA2dpChannelMode.setSummary(streaming);
|
||||||
@@ -1965,7 +1965,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
|||||||
index = -1;
|
index = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index >= 0) {
|
if (index >= 0 && mBluetoothSelectA2dpLdacPlaybackQuality != null) {
|
||||||
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
|
summaries = resources.getStringArray(R.array.bluetooth_a2dp_codec_ldac_playback_quality_summaries);
|
||||||
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
streaming = resources.getString(R.string.bluetooth_select_a2dp_codec_streaming_label, summaries[index]);
|
||||||
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(streaming);
|
mBluetoothSelectA2dpLdacPlaybackQuality.setSummary(streaming);
|
||||||
|
Reference in New Issue
Block a user