1 /* 2 * Copyright (C) 2021 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.car.hal; 17 18 import android.hardware.automotive.vehicle.VehiclePropConfig; 19 import android.hardware.automotive.vehicle.VehiclePropertyAccess; 20 import android.hardware.automotive.vehicle.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 HalPropConfig newConfig(int prop) { 31 VehiclePropConfig config = new VehiclePropConfig(); 32 config.prop = prop; 33 config.configString = new String(); 34 config.configArray = new int[0]; 35 return new AidlHalPropConfig(config); 36 } 37 38 /** 39 * Creates a config for the given property that passes the 40 * {@link com.android.car.hal.VehicleHal.VehicleHal#isPropertySubscribable(VehiclePropConfig)} 41 * criteria. 42 */ newSubscribableConfig(int prop)43 public static HalPropConfig newSubscribableConfig(int prop) { 44 VehiclePropConfig config = new VehiclePropConfig(); 45 config.prop = prop; 46 config.configString = new String(); 47 config.configArray = new int[0]; 48 config.access = VehiclePropertyAccess.READ_WRITE; 49 config.changeMode = VehiclePropertyChangeMode.ON_CHANGE; 50 return new AidlHalPropConfig(config); 51 } 52 VehicleHalTestingHelper()53 private VehicleHalTestingHelper() { 54 throw new UnsupportedOperationException("contains only static methods"); 55 } 56 } 57