1# /usr/bin/env python3
2#
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17import base64
18import os
19import time
20
21from acts.metrics.core import ProtoMetric
22from acts.metrics.logger import MetricLogger
23from acts.test_utils.tel.loggers.protos.telephony_metric_pb2 import TelephonyVoiceTestResult
24
25# Initializes the path to the protobuf
26PROTO_PATH = os.path.join(os.path.dirname(__file__),
27                          'protos',
28                          'telephony_metric.proto')
29
30
31class TelephonyMetricLogger(MetricLogger):
32    """A logger for gathering Telephony test metrics
33
34    Attributes:
35        proto: Module used to store Telephony metrics in a proto
36    """
37
38    def __init__(self, event):
39        super().__init__(event=event)
40        self.proto = TelephonyVoiceTestResult()
41
42    def set_result(self, result_type):
43        self.proto.result = result_type
44
45    def end(self, event):
46        metric = ProtoMetric(name='telephony_voice_test_result',
47                             data=self.proto)
48        return self.publisher.publish(metric)
49
50