1#!/usr/bin/env python3
2#
3#   Copyright 2020 - The Android Open Source Project
4#
5#   Licensed under the Apache License, Version 2.0 (the "License");
6#   you may not use this file except in compliance with the License.
7#   You may obtain a copy of 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,
13#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14#   See the License for the specific language governing permissions and
15#   limitations under the License.
16
17from acts.controllers.fuchsia_lib.base_lib import BaseLib
18
19
20class FuchsiaInputReportLib(BaseLib):
21    def __init__(self, addr, tc, client_id):
22        self.address = addr
23        self.test_counter = tc
24        self.client_id = client_id
25
26    """Gets the fuchsia.input.report.DeviceDescriptor for a given device.
27
28    Args:
29      vendor_id: the uint32 vendor ID to match against available input devices, or None to match any
30        vendor ID.
31      product_id: the uint32 product ID to match against available input devices, or None to match
32        any product ID.
33      version: the uint32 version to match against available input devices, or None to match any
34        version.
35
36    Returns:
37      The DeviceDescriptor object, or an error message if an error was encountered.
38    """
39
40    def getDescriptor(self, vendor_id=None, product_id=None, version=None):
41        test_cmd = 'input_report_facade.GetDescriptor'
42        test_args = {
43            'vendor_id': vendor_id,
44            'product_id': product_id,
45            'version': version
46        }
47        test_id = self.build_id(self.test_counter)
48        self.test_counter += 1
49        return self.send_command(test_id, test_cmd, test_args)
50
51    """Gets the list of fuchsia.input.report.InputReports that were seen since the last call.
52
53    Args:
54      vendor_id: the uint32 vendor ID to match against available input devices, or None to match any
55        vendor ID.
56      product_id: the uint32 product ID to match against available input devices, or None to match
57        any product ID.
58      version: the uint32 version to match against available input devices, or None to match any
59        version.
60
61    Returns:
62      A list of InputReports, or an error message if an error was encountered.
63    """
64
65    def getReports(self, vendor_id=None, product_id=None, version=None):
66        test_cmd = 'input_report_facade.GetReports'
67        test_args = {
68            'vendor_id': vendor_id,
69            'product_id': product_id,
70            'version': version
71        }
72        test_id = self.build_id(self.test_counter)
73        self.test_counter += 1
74        return self.send_command(test_id, test_cmd, test_args)
75