• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.tradefed.device.metric.target;
17 
18 import com.android.tradefed.config.Option;
19 import com.android.tradefed.config.OptionClass;
20 import com.android.tradefed.device.metric.BaseDeviceMetricCollector;
21 import com.android.tradefed.util.MultiMap;
22 
23 import java.util.ArrayList;
24 import java.util.List;
25 
26 /**
27  * Tradefed object to specify a device collector defined in:
28  *
29  * <p>platform_testing/libraries/device-collectors. This allows to specify these objects in the
30  * Tradefed xml like the host-side ones and to set their options.
31  */
32 @OptionClass(alias = "device-target-collector")
33 public final class DeviceSideCollectorSpecification {
34 
35     @Option(
36             name = "collectors-qualified-name",
37             description =
38                     "The fully qualified name of each device side collector that wants to be added "
39                             + "to the instrumentation. Example: --collectors-qualified-name "
40                             + "android.device.collectors.ScreenshotListener",
41             mandatory = true)
42     private List<String> mCollectorQualifiedName = new ArrayList<>();
43 
44     @Option(
45             name = "collector-options",
46             description =
47                     "Specify device side collector's options that will be given to the "
48                             + "instrumentation. Can be prepended with the alias to target a "
49                             + "specific collector. Example: --collector-options "
50                             + "screenshot-collector:screenshot-quality 75"
51                             + "or --collector-options screenshot-quality 75 (without the alias).")
52     private MultiMap<String, String> mInstrumentationArgs = new MultiMap<>();
53 
54     /**
55      * The filtering options are part of BaseMetricListener and shared by all device side
56      * collectors, so we put them on their own to make it clear. Shares its name with the base host
57      * side collectors in order to easily target both host and device side groups.
58      */
59     @Option(
60             name = BaseDeviceMetricCollector.TEST_CASE_INCLUDE_GROUP_OPTION,
61             description =
62                     "The 'include-filter-group' to run the collector only against some methods.")
63     private List<String> mIncludeGroupFilters = new ArrayList<>();
64 
65     @Option(
66             name = BaseDeviceMetricCollector.TEST_CASE_EXCLUDE_GROUP_OPTION,
67             description =
68                     "The 'exclude-filter-group' to run the collector only against some methods.")
69     private List<String> mExcludeGroupFilters = new ArrayList<>();
70 
71     /**
72      * Returns the {@link MultiMap} of device side collector options to be added to the
73      * instrumentation.
74      */
getCollectorOptions()75     public MultiMap<String, String> getCollectorOptions() {
76         return mInstrumentationArgs;
77     }
78 
79     /** Returns the {@link List} of collectors to be added to the instrumentation. */
getCollectorNames()80     public List<String> getCollectorNames() {
81         return mCollectorQualifiedName;
82     }
83 
84     /** Returns the {@link List} of groups to be included via --include-filter-group. */
getIncludeGroupFilters()85     public List<String> getIncludeGroupFilters() {
86         return mIncludeGroupFilters;
87     }
88 
89     /** Returns the {@link List} of groups to be excluded via --exclude-filter-group. */
getExcludeGroupFilters()90     public List<String> getExcludeGroupFilters() {
91         return mExcludeGroupFilters;
92     }
93 }
94