1 /* 2 * Copyright 2022 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 #pragma once 17 18 #include "IEvsServiceFactory.h" 19 #include "LinkUnlinkToDeathBase.h" 20 #include "MockEvsHal.h" 21 22 #include <aidl/android/hardware/automotive/evs/IEvsEnumerator.h> 23 24 namespace android::automotive::evs { 25 26 class MockEvsServiceFactory final : public IEvsServiceFactory { 27 public: 28 ~MockEvsServiceFactory() = default; 29 30 bool init() override; getService()31 aidl::android::hardware::automotive::evs::IEvsEnumerator* getService() override { 32 return mService.get(); 33 } clear()34 void clear() override { mService.reset(); } 35 36 private: 37 std::unique_ptr<aidl::android::automotive::evs::implementation::MockEvsHal> mMockEvs; 38 std::shared_ptr<aidl::android::hardware::automotive::evs::IEvsEnumerator> mService; 39 }; 40 41 class MockLinkUnlinkToDeath final : public LinkUnlinkToDeathBase { 42 public: 43 binder_status_t linkToDeath(AIBinder* binder, AIBinder_DeathRecipient* recipient, 44 void* cookie) override; 45 binder_status_t unlinkToDeath(AIBinder* binder) override; 46 getCookie()47 void* getCookie() override { return mCookie; } 48 }; 49 50 } // namespace android::automotive::evs 51