Fix NPE in UltraSoundSpeaker test.
The function LineAndPointFormatter#configure will use invoke function to get the object/variable
which defined in xml resource. aosp/758566 defined new object pointLabelFormatter on
R.xml.ultrasound_line_formatter_trials, it's the reason to get NPE here.
Bug: 110259506
Test: local build & run CtsVerifier.
Change-Id: I7f401a19c03bd2911e47631c68e87187aca74547
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
index 87618b1..01802a4 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/audio/HifiUltrasoundSpeakerTestActivity.java
@@ -280,9 +280,9 @@
Arrays.asList(powerWrap),
"");
LineAndPointFormatter seriesFormat = new LineAndPointFormatter();
+ seriesFormat.setPointLabelFormatter(new PointLabelFormatter());
seriesFormat.configure(getApplicationContext(),
R.xml.ultrasound_line_formatter_trials);
- seriesFormat.setPointLabelFormatter(new PointLabelFormatter());
plot.addSeries(series, seriesFormat);
}
@@ -297,9 +297,9 @@
Arrays.asList(noiseDBWrap),
"background noise");
LineAndPointFormatter noiseSeriesFormat = new LineAndPointFormatter();
+ noiseSeriesFormat.setPointLabelFormatter(new PointLabelFormatter());
noiseSeriesFormat.configure(getApplicationContext(),
R.xml.ultrasound_line_formatter_noise);
- noiseSeriesFormat.setPointLabelFormatter(new PointLabelFormatter());
plot.addSeries(noiseSeries, noiseSeriesFormat);
double[] dB = wavAnalyzerTask.getDB();
@@ -313,9 +313,9 @@
Arrays.asList(dBWrap),
"median");
LineAndPointFormatter seriesFormat = new LineAndPointFormatter();
+ seriesFormat.setPointLabelFormatter(new PointLabelFormatter());
seriesFormat.configure(getApplicationContext(),
R.xml.ultrasound_line_formatter_median);
- seriesFormat.setPointLabelFormatter(new PointLabelFormatter());
plot.addSeries(series, seriesFormat);
Double[] passX = new Double[] {Common.MIN_FREQUENCY_HZ, Common.MAX_FREQUENCY_HZ};
@@ -323,9 +323,9 @@
XYSeries passSeries = new SimpleXYSeries(
Arrays.asList(passX), Arrays.asList(passY), "passing");
LineAndPointFormatter passSeriesFormat = new LineAndPointFormatter();
+ passSeriesFormat.setPointLabelFormatter(new PointLabelFormatter());
passSeriesFormat.configure(getApplicationContext(),
R.xml.ultrasound_line_formatter_pass);
- passSeriesFormat.setPointLabelFormatter(new PointLabelFormatter());
plot.addSeries(passSeries, passSeriesFormat);
}
}