keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 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 | |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 19 | import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropConfig; |
| 20 | import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValue; |
| 21 | |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 22 | import java.io.PrintWriter; |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 23 | import java.util.LinkedList; |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 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 { |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 32 | /** For dispatching events. Kept here to avoid alloc every time */ |
| 33 | private final LinkedList<VehiclePropValue> mDispatchList = new LinkedList<VehiclePropValue>(); |
| 34 | |
| 35 | public List<VehiclePropValue> getDispatchList() { |
| 36 | return mDispatchList; |
| 37 | } |
| 38 | |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 39 | /** initialize */ |
| 40 | public abstract void init(); |
| 41 | |
| 42 | /** release and stop operation */ |
| 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 | */ |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 54 | public abstract List<VehiclePropConfig> takeSupportedProperties( |
| 55 | List<VehiclePropConfig> allProperties); |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 56 | |
keunyoung | fe30ba0 | 2015-09-17 17:56:35 -0700 | [diff] [blame] | 57 | public abstract void handleHalEvents(List<VehiclePropValue> values); |
keunyoung | cc449f7 | 2015-08-12 10:46:27 -0700 | [diff] [blame] | 58 | |
| 59 | public abstract void dump(PrintWriter writer); |
| 60 | } |