getMeasurement method

  1. @override
Future<Measurement> getMeasurement()
override

Subclasses should implement this method to collect a Measurement.

Can return null if no data is available. Can return an Error measurement if an error occurs.

Implementation

@override
Future<Measurement> getMeasurement() async {
  final m = (samplingConfiguration as HistoricSamplingConfiguration);
  int from = (m.lastTime != null)
      ? m.lastTime!.millisecondsSinceEpoch
      : DateTime.now().subtract(m.past).millisecondsSinceEpoch;
  int now = DateTime.now().millisecondsSinceEpoch;
  Iterable<CallLogEntry> entries =
      await CallLog.query(dateFrom: from, dateTo: now);
  return Measurement.fromData(PhoneLog(
    m.lastTime!,
    DateTime.now(),
    entries.map((call) => PhoneCall.fromCallLogEntry(call)).toList(),
  ));
}