@Test public void testNonZeroLogging() { CameraMetrics metrics1 = new CameraMetrics(); metrics1.cameraOpenTimeMs = 0; metrics1.cameraPreviewTimeMs = 200; ReporterEvent event = new ReporterEvent(); mCameraMetricsReporter.reportTo(metrics1, event); assertThat(event.eventMap.get(mCameraMetricsReporter.CAMERA_OPEN_TIME_MS)).isNull(); assertThat(event.eventMap.get(mCameraMetricsReporter.CAMERA_PREVIEW_TIME_MS)).isEqualTo(200L); CameraMetrics metrics2 = new CameraMetrics(); metrics2.cameraOpenTimeMs = 200; metrics2.cameraPreviewTimeMs = 400; mCameraMetricsReporter.reportTo(metrics2, event); assertThat(event.eventMap.get(mCameraMetricsReporter.CAMERA_OPEN_TIME_MS)).isEqualTo(200L); assertThat(event.eventMap.get(mCameraMetricsReporter.CAMERA_PREVIEW_TIME_MS)).isEqualTo(400L); }
@Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.add(CAMERA_PREVIEW_TIME_MS, metrics.cameraPreviewTimeMs); } }
CameraMetricsReporter implements SystemMetricsReporter<CameraMetrics> { @Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.add(CAMERA_PREVIEW_TIME_MS, metrics.cameraPreviewTimeMs); } } }
CameraMetricsReporter implements SystemMetricsReporter<CameraMetrics> { @Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.add(CAMERA_PREVIEW_TIME_MS, metrics.cameraPreviewTimeMs); } }  }
CameraMetricsReporter implements SystemMetricsReporter<CameraMetrics> { @Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.add(CAMERA_PREVIEW_TIME_MS, metrics.cameraPreviewTimeMs); } }  @Override void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event); }
CameraMetricsReporter implements SystemMetricsReporter<CameraMetrics> { @Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.add(CAMERA_PREVIEW_TIME_MS, metrics.cameraPreviewTimeMs); } }  @Override void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event); static final String CAMERA_OPEN_TIME_MS; static final String CAMERA_PREVIEW_TIME_MS; }