• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 android.car.test.util;
17 
18 import android.hardware.automotive.vehicle.V2_0.VehiclePropConfig;
19 import android.hardware.automotive.vehicle.V2_0.VehiclePropertyAccess;
20 import android.hardware.automotive.vehicle.V2_0.VehiclePropertyChangeMode;
21 
22 /**
23  * Provides utilities for Vehicle HAL related tasks.
24  */
25 public final class VehicleHalTestingHelper {
26 
27     /**
28      * Creates an empty config for the given property.
29      */
newConfig(int prop)30     public static VehiclePropConfig newConfig(int prop) {
31         VehiclePropConfig config = new VehiclePropConfig();
32         config.prop = prop;
33         return config;
34     }
35 
36     /**
37      * Creates a config for the given property that passes the
38      * {@link com.android.car.hal.VehicleHal.VehicleHal#isPropertySubscribable(VehiclePropConfig)}
39      * criteria.
40      */
newSubscribableConfig(int prop)41     public static VehiclePropConfig newSubscribableConfig(int prop) {
42         VehiclePropConfig config = newConfig(prop);
43         config.access = VehiclePropertyAccess.READ_WRITE;
44         config.changeMode = VehiclePropertyChangeMode.ON_CHANGE;
45         return config;
46     }
47 
VehicleHalTestingHelper()48     private VehicleHalTestingHelper() {
49         throw new UnsupportedOperationException("contains only static methods");
50     }
51 }
52