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 17 #pragma once 18 19 #include "vhal_v2_0/VehicleObjectPool.h" 20 #include "vhal_v2_0/VehiclePropertyStore.h" 21 #include "vhal_v2_0/VehicleServer.h" 22 23 #include "vhal_v2_0/DefaultConfig.h" 24 #include "vhal_v2_0/GeneratorHub.h" 25 26 namespace android { 27 namespace hardware { 28 namespace automotive { 29 namespace vehicle { 30 namespace V2_0 { 31 32 namespace impl { 33 34 // This contains the server operation for VHAL running in emulator. 35 class DefaultVehicleHalServer : public IVehicleServer { 36 public: 37 DefaultVehicleHalServer(); 38 39 // Send all the property values to client. 40 void sendAllValuesToClient(); 41 42 // Methods from IVehicleServer 43 44 std::vector<VehiclePropConfig> onGetAllPropertyConfig() const override; 45 46 StatusCode onSetProperty(const VehiclePropValue& value, bool updateStatus) override; 47 48 // Set the Property Value Pool used in this server 49 void setValuePool(VehiclePropValuePool* valuePool); 50 51 protected: 52 using VehiclePropValuePtr = recyclable_ptr<VehiclePropValue>; 53 GeneratorHub* getGenerator(); 54 55 VehiclePropValuePool* getValuePool() const; 56 57 void onFakeValueGenerated(const VehiclePropValue& value); 58 59 StatusCode handleGenerateFakeDataRequest(const VehiclePropValue& request); 60 61 VehiclePropValuePtr createApPowerStateReq(VehicleApPowerStateReq req, int32_t param); 62 63 VehiclePropValuePtr createHwInputKeyProp(VehicleHwKeyInputAction action, int32_t keyCode, 64 int32_t targetDisplay); 65 66 void storePropInitialValue(const ConfigDeclaration& config); 67 68 protected: 69 GeneratorHub mGeneratorHub{ 70 [this](const VehiclePropValue& value) { return onFakeValueGenerated(value); }}; 71 72 VehiclePropValuePool* mValuePool{nullptr}; 73 VehiclePropertyStore mServerSidePropStore; 74 }; 75 76 } // namespace impl 77 78 } // namespace V2_0 79 } // namespace vehicle 80 } // namespace automotive 81 } // namespace hardware 82 } // namespace android 83