1 /* 2 * Copyright (C) 2015 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 17 package com.android.car.hal; 18 19 import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropConfig; 20 import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValue; 21 22 import java.io.PrintWriter; 23 import java.util.LinkedList; 24 import java.util.List; 25 26 /** 27 * Common interface for all HAL service like sensor HAL. 28 * Each HAL service is connected with XyzService supporting XyzManager, 29 * and will translate HAL data into car api specific format. 30 */ 31 public abstract class HalServiceBase { 32 /** For dispatching events. Kept here to avoid alloc every time */ 33 private final LinkedList<VehiclePropValue> mDispatchList = new LinkedList<VehiclePropValue>(); 34 getDispatchList()35 public List<VehiclePropValue> getDispatchList() { 36 return mDispatchList; 37 } 38 39 /** initialize */ init()40 public abstract void init(); 41 42 /** release and stop operation */ release()43 public abstract void release(); 44 45 /** 46 * return supported properties among all properties. 47 * @return null if no properties are supported 48 */ 49 /** 50 * Take supported properties from given allProperties and return List of supported properties. 51 * @param allProperties 52 * @return null if no properties are supported. 53 */ takeSupportedProperties( List<VehiclePropConfig> allProperties)54 public abstract List<VehiclePropConfig> takeSupportedProperties( 55 List<VehiclePropConfig> allProperties); 56 handleHalEvents(List<VehiclePropValue> values)57 public abstract void handleHalEvents(List<VehiclePropValue> values); 58 dump(PrintWriter writer)59 public abstract void dump(PrintWriter writer); 60 } 61