diff --git a/.github/workflows/gnome_unit_test.yml b/.github/workflows/gnome_unit_test.yml new file mode 100644 index 00000000..5c4e3209 --- /dev/null +++ b/.github/workflows/gnome_unit_test.yml @@ -0,0 +1,161 @@ +name: gnome_unit_test + +on: + push: + branches: [ main, develop, 'release/**'] + pull_request: + branches: [ main, develop, 'release/**'] + +env: + BUILD_TYPE: Debug + THUNDER_REF: "R4.4.1" + THUNDER_TOOLS_REF: "R4.4.1" + INTERFACES_REF: "R4.4.1" + +jobs: + l1-tests: + name: Build and run unit tests + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [ gcc, clang ] + coverage: [ with-coverage, without-coverage ] + exclude: + - compiler: clang + coverage: with-coverage + - compiler: clang + coverage: without-coverage + - compiler: gcc + coverage: without-coverage + + steps: + - name: Configure cache + if: ${{ !env.ACT }} + id: cache + uses: actions/cache@v3 + with: + path: | + build/Thunder + build/ThunderInterfaces + build/ThunderTools + install + !install/etc/WPEFramework/plugins + !install/usr/lib/wpeframework/plugins + key: ${{ runner.os }}-${{ env.THUNDER_REF }}-${{ env.INTERFACES_REF }}-3 + + - name: Install packages + run: > + sudo apt update + && + sudo apt install -y libnm0 git pkg-config ninja-build libssl-dev libglib2.0-dev libnm-dev libcurl4-openssl-dev + + - name: Configure Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - run: pip install jsonref + + - name: Configure CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.16.x' + + - name: Checkout ThunderTools + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/ThunderTools + path: ThunderTools + ref: ${{env.THUNDER_TOOLS_REF}} + + - name: Checkout Thunder + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/Thunder + path: Thunder + ref: ${{env.THUNDER_REF}} + + - name: Checkout ThunderInterfaces + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/ThunderInterfaces + path: ThunderInterfaces + ref: ${{env.INTERFACES_REF}} + + - name: Checkout networkmanager + uses: actions/checkout@v3 + with: + path: networkmanager + + - name: Build ThunderTools + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/ThunderTools" + -B build/ThunderTools + -DEXCEPTIONS_ENABLE=ON + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + && + cmake --build build/ThunderTools -j8 + && + cmake --install build/ThunderTools + + - name: Build Thunder + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/Thunder" + -B build/Thunder + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DBUILD_TYPE=${{env.BUILD_TYPE}} + -DBINDING=127.0.0.1 + -DPORT=55555 + -DEXCEPTIONS_ENABLE=ON + && + cmake --build build/Thunder -j8 + && + cmake --install build/Thunder + + - name: Build ThunderInterfaces + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/ThunderInterfaces" + -B build/ThunderInterfaces + -DEXCEPTIONS_ENABLE=ON + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + && + cmake --build build/ThunderInterfaces -j8 + && + cmake --install build/ThunderInterfaces + + - name: Build networkmanager with Gnome Proxy + run: > + cmake + -S "${{github.workspace}}/networkmanager" + -B build/GnomeNetworkmanager + -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DCMAKE_CXX_FLAGS=" + -fprofile-arcs + -ftest-coverage + -DEXCEPTIONS_ENABLE=ON + -I ${{github.workspace}}/networkmanagerTests/headers + -I ${{github.workspace}}/networkmanager/Tests/headers/rdk/iarmbus + -I ${{github.workspace}}/networkmanager/Tests/headers/network" + -DCMAKE_DISABLE_FIND_PACKAGE_IARMBus=ON + -DENABLE_GNOME_NETWORKMANAGER=ON + -DENABLE_NETWORKMANAGER_UNIT_TEST=OFF + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + && + cmake --build build/GnomeNetworkmanager -j16 + && + cmake --install build/GnomeNetworkmanager + diff --git a/.github/workflows/rdk_unit_test.yml b/.github/workflows/rdk_unit_test.yml new file mode 100644 index 00000000..1155fd9e --- /dev/null +++ b/.github/workflows/rdk_unit_test.yml @@ -0,0 +1,174 @@ +name: rdk_unit_test + +on: + push: + branches: [ main, develop, 'release/**'] + pull_request: + branches: [ main, develop, 'release/**'] + +env: + BUILD_TYPE: Debug + THUNDER_REF: "R4.4.1" + THUNDER_TOOLS_REF: "R4.4.1" + INTERFACES_REF: "R4.4.1" + +jobs: + l1-tests: + name: Build and run unit tests + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [ gcc, clang ] + coverage: [ with-coverage, without-coverage ] + exclude: + - compiler: clang + coverage: with-coverage + - compiler: clang + coverage: without-coverage + - compiler: gcc + coverage: without-coverage + + steps: + - name: Set up cache + if: ${{ !env.ACT }} + id: cache + uses: actions/cache@v3 + with: + path: | + build/Thunder + build/ThunderInterfaces + build/ThunderTools + install + !install/etc/WPEFramework/plugins + !install/usr/lib/wpeframework/plugins + key: ${{ runner.os }}-${{ env.THUNDER_REF }}-${{ env.INTERFACES_REF }}-3 + + - name: Install packages + run: > + sudo apt update + && + sudo apt install -y libnm0 git pkg-config ninja-build libssl-dev libglib2.0-dev libnm-dev libcurl4-openssl-dev + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + - run: pip install jsonref + + - name: Set up CMake + uses: jwlawson/actions-setup-cmake@v1.13 + with: + cmake-version: '3.16.x' + + - name: Checkout ThunderTools + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/ThunderTools + path: ThunderTools + ref: ${{env.THUNDER_TOOLS_REF}} + + - name: Checkout Thunder + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/Thunder + path: Thunder + ref: ${{env.THUNDER_REF}} + + - name: Checkout ThunderInterfaces + if: steps.cache.outputs.cache-hit != 'true' + uses: actions/checkout@v3 + with: + repository: rdkcentral/ThunderInterfaces + path: ThunderInterfaces + ref: ${{env.INTERFACES_REF}} + + - name: Checkout networkmanager + uses: actions/checkout@v3 + with: + path: networkmanager + + - name: Build ThunderTools + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/ThunderTools" + -B build/ThunderTools + -DEXCEPTIONS_ENABLE=ON + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DGENERIC_CMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + && + cmake --build build/ThunderTools -j8 + && + cmake --install build/ThunderTools + + - name: Build Thunder + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/Thunder" + -B build/Thunder + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DBUILD_TYPE=${{env.BUILD_TYPE}} + -DBINDING=127.0.0.1 + -DPORT=55555 + -DEXCEPTIONS_ENABLE=ON + && + cmake --build build/Thunder -j8 + && + cmake --install build/Thunder + + - name: Build ThunderInterfaces + if: steps.cache.outputs.cache-hit != 'true' + run: > + cmake + -S "${{github.workspace}}/ThunderInterfaces" + -B build/ThunderInterfaces + -DEXCEPTIONS_ENABLE=ON + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + && + cmake --build build/ThunderInterfaces -j8 + && + cmake --install build/ThunderInterfaces + + - name: Generate external headers + run: > + touch install/usr/lib/libIARMBus.so && mkdir -p install/usr/include/rdk/iarmbus && touch install/usr/include/rdk/iarmbus/libIARM.h + && + cd "${{github.workspace}}/networkmanager/Tests/" + && + mkdir -p + headers + headers/rdk/iarmbus + headers/network + && + cd headers + && + touch + rdk/iarmbus/libIARM.h + rdk/iarmbus/libIBus.h + - name: Build networkmanager with RDK Proxy + run: > + cmake + -S "${{github.workspace}}/networkmanager" + -B build/RDKNetworkmanager + -DCMAKE_TOOLCHAIN_FILE="${{ env.TOOLCHAIN_FILE }}" + -DCMAKE_INSTALL_PREFIX="${{github.workspace}}/install/usr" + -DCMAKE_MODULE_PATH="${{github.workspace}}/install/tools/cmake" + -DCMAKE_CXX_FLAGS=" + -fprofile-arcs + -ftest-coverage + -DEXCEPTIONS_ENABLE=ON + -I ${{github.workspace}}/networkmanager/Tests/headers + -I ${{github.workspace}}/networkmanager/Tests/headers/rdk/iarmbus" + -DENABLE_NETWORKMANAGER_UNIT_TEST=ON + -DENABLE_GNOME_NETWORKMANAGER=OFF + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + && + cmake --build build/RDKNetworkmanager -j16 + && + cmake --install build/RDKNetworkmanager + diff --git a/Tests/.clang-format b/Tests/.clang-format new file mode 100644 index 00000000..423360be --- /dev/null +++ b/Tests/.clang-format @@ -0,0 +1,108 @@ +--- +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Right +AlignOperands: false +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^"config\.h"' + Priority: -1 + # The main header for a source file automatically gets category 0 + - Regex: '.*' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 +IncludeIsMainRegex: '(Test)?$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Never +... diff --git a/Tests/mocks/CMakeLists.txt b/Tests/mocks/CMakeLists.txt new file mode 100644 index 00000000..310b5075 --- /dev/null +++ b/Tests/mocks/CMakeLists.txt @@ -0,0 +1,46 @@ +#if not stated otherwise in this file or this component's LICENSE file the +# following copyright and licenses apply: +# +# Copyright 2023 Synamedia +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +cmake_minimum_required(VERSION 3.8) +set(MODULE_NAME TestMocklib) + +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/e39786088138f2749d64e9e90e0f9902daa77c40.zip +) +FetchContent_MakeAvailable(googletest) + + +add_library(${MODULE_NAME} SHARED + Rfc.cpp + Iarm.cpp + Wraps.cpp + RBus.cpp + Telemetry.cpp + devicesettings.cpp + Udev.cpp +) +target_link_libraries(${MODULE_NAME} PRIVATE gmock_main) + +set_target_properties(${MODULE_NAME} PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED YES) + + +install(TARGETS ${MODULE_NAME} + DESTINATION lib) diff --git a/Tests/mocks/Iarm.cpp b/Tests/mocks/Iarm.cpp new file mode 100644 index 00000000..63afa6f6 --- /dev/null +++ b/Tests/mocks/Iarm.cpp @@ -0,0 +1,104 @@ +/** +* If not stated otherwise in this file or this component's LICENSE +* file the following copyright and licenses apply: +* +* Copyright 2023 Synamedia +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +**/ + +#include "Iarm.h" +#include + +IarmBusImpl* IarmBus::impl = nullptr; + +IarmBus::IarmBus() {} + +void IarmBus::setImpl(IarmBusImpl* newImpl) +{ + // Handles both resetting 'impl' to nullptr and assigning a new value to 'impl' + EXPECT_TRUE ((nullptr == impl) || (nullptr == newImpl)); + impl = newImpl; +} + +IARM_Result_t IarmBus::IARM_Bus_Init(const char* name) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_Init(name); +} + +IARM_Result_t IarmBus::IARM_Bus_Connect() +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_Connect(); +} + +IARM_Result_t IarmBus::IARM_Bus_IsConnected(const char* memberName, int* isRegistered) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_IsConnected(memberName, isRegistered); +} + +IARM_Result_t IarmBus::IARM_Bus_RegisterEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_RegisterEventHandler(ownerName, eventId, handler); +} + +IARM_Result_t IarmBus::IARM_Bus_UnRegisterEventHandler(const char* ownerName, IARM_EventId_t eventId) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_UnRegisterEventHandler(ownerName, eventId); +} + +IARM_Result_t IarmBus::IARM_Bus_RemoveEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_RemoveEventHandler(ownerName, eventId, handler); +} + +IARM_Result_t IarmBus::IARM_Bus_Call(const char* ownerName, const char* methodName, void* arg, size_t argLen) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_Call(ownerName, methodName, arg, argLen); +} + +IARM_Result_t IarmBus::IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_BroadcastEvent(ownerName, eventId, arg, argLen); +} + + +IARM_Result_t IarmBus::IARM_Bus_RegisterCall(const char* methodName, IARM_BusCall_t handler) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_RegisterCall(methodName, handler); +} + +IARM_Result_t IarmBus::IARM_Bus_Call_with_IPCTimeout(const char *ownerName, const char *methodName, void *arg, size_t argLen, int timeout) +{ + EXPECT_NE(impl, nullptr); + return impl->IARM_Bus_Call_with_IPCTimeout(ownerName, methodName, arg, argLen, timeout); +} + +IARM_Result_t (*IARM_Bus_Init)(const char*) = &IarmBus::IARM_Bus_Init; +IARM_Result_t (*IARM_Bus_Connect)() = &IarmBus::IARM_Bus_Connect; +IARM_Result_t (*IARM_Bus_IsConnected)(const char*,int*) = &IarmBus::IARM_Bus_IsConnected; +IARM_Result_t (*IARM_Bus_RegisterEventHandler)(const char*,IARM_EventId_t,IARM_EventHandler_t) = &IarmBus::IARM_Bus_RegisterEventHandler; +IARM_Result_t (*IARM_Bus_UnRegisterEventHandler)(const char*,IARM_EventId_t) = &IarmBus::IARM_Bus_UnRegisterEventHandler; +IARM_Result_t (*IARM_Bus_RemoveEventHandler)(const char*,IARM_EventId_t,IARM_EventHandler_t) = &IarmBus::IARM_Bus_RemoveEventHandler; +IARM_Result_t (*IARM_Bus_Call)(const char*,const char*,void*,size_t) = &IarmBus::IARM_Bus_Call; +IARM_Result_t (*IARM_Bus_BroadcastEvent)(const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen) = &IarmBus::IARM_Bus_BroadcastEvent; +IARM_Result_t (*IARM_Bus_RegisterCall)(const char*,IARM_BusCall_t) = &IarmBus::IARM_Bus_RegisterCall; +IARM_Result_t (*IARM_Bus_Call_with_IPCTimeout)(const char*,const char*,void*,size_t,int) = &IarmBus::IARM_Bus_Call_with_IPCTimeout; diff --git a/Tests/mocks/Iarm.h b/Tests/mocks/Iarm.h new file mode 100644 index 00000000..417a2bb4 --- /dev/null +++ b/Tests/mocks/Iarm.h @@ -0,0 +1,754 @@ +#pragma once + +#include + +typedef int IARM_EventId_t; + +typedef enum _IARM_Result_t { + IARM_RESULT_SUCCESS, + IARM_RESULT_INVALID_PARAM, + IARM_RESULT_INVALID_STATE, + IARM_RESULT_IPCCORE_FAIL, + IARM_RESULT_OOM, +} IARM_Result_t; + +#define IARM_BUS_DAEMON_NAME "Daemon" + +typedef IARM_Result_t (*IARM_BusCall_t)(void* arg); +typedef void (*IARM_EventHandler_t)(const char* owner, IARM_EventId_t eventId, void* data, size_t len); + +class IarmBusImpl { +public: + virtual ~IarmBusImpl() = default; + + virtual IARM_Result_t IARM_Bus_Init(const char* name) = 0; + virtual IARM_Result_t IARM_Bus_Connect() = 0; + virtual IARM_Result_t IARM_Bus_IsConnected(const char* memberName, int* isRegistered) = 0; + virtual IARM_Result_t IARM_Bus_RegisterEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) = 0; + virtual IARM_Result_t IARM_Bus_UnRegisterEventHandler(const char* ownerName, IARM_EventId_t eventId) = 0; + virtual IARM_Result_t IARM_Bus_RemoveEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler) = 0; + virtual IARM_Result_t IARM_Bus_Call(const char* ownerName, const char* methodName, void* arg, size_t argLen) = 0; + virtual IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen) = 0; + virtual IARM_Result_t IARM_Bus_RegisterCall(const char* methodName, IARM_BusCall_t handler) = 0; + virtual IARM_Result_t IARM_Bus_Call_with_IPCTimeout(const char *ownerName, const char *methodName, void *arg, size_t argLen, int timeout) = 0; +}; + +class IarmBus { +protected: + static IarmBusImpl* impl; +public: + IarmBus(); + IarmBus(const IarmBus &obj) = delete; // deleted copy constructor so that copy of the instance cannot be created. + static void setImpl(IarmBusImpl* newImpl); + static IARM_Result_t IARM_Bus_Init(const char* name); + static IARM_Result_t IARM_Bus_Connect(); + static IARM_Result_t IARM_Bus_IsConnected(const char* memberName, int* isRegistered); + static IARM_Result_t IARM_Bus_RegisterEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler); + static IARM_Result_t IARM_Bus_UnRegisterEventHandler(const char* ownerName, IARM_EventId_t eventId); + static IARM_Result_t IARM_Bus_RemoveEventHandler(const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler); + static IARM_Result_t IARM_Bus_Call(const char* ownerName, const char* methodName, void* arg, size_t argLen); + static IARM_Result_t IARM_Bus_BroadcastEvent(const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen) ; + + static IARM_Result_t IARM_Bus_RegisterCall(const char* methodName, IARM_BusCall_t handler); + static IARM_Result_t IARM_Bus_Call_with_IPCTimeout(const char *ownerName, const char *methodName, void *arg, size_t argLen, int timeout); +}; + +extern IARM_Result_t (*IARM_Bus_Init)(const char*); +extern IARM_Result_t (*IARM_Bus_Connect)(); +extern IARM_Result_t (*IARM_Bus_IsConnected)(const char*,int*); +extern IARM_Result_t (*IARM_Bus_RegisterEventHandler)(const char*,IARM_EventId_t,IARM_EventHandler_t); +extern IARM_Result_t (*IARM_Bus_UnRegisterEventHandler)(const char*,IARM_EventId_t); +extern IARM_Result_t (*IARM_Bus_RemoveEventHandler)(const char*,IARM_EventId_t,IARM_EventHandler_t); +extern IARM_Result_t (*IARM_Bus_Call)(const char*,const char*,void*,size_t); +extern IARM_Result_t (*IARM_Bus_BroadcastEvent)(const char *,IARM_EventId_t,void *,size_t); +extern IARM_Result_t (*IARM_Bus_RegisterCall)(const char*,IARM_BusCall_t); +extern IARM_Result_t (*IARM_Bus_Call_with_IPCTimeout)(const char*,const char*,void*,size_t,int); + +#define IARM_BUS_COMMON_API_SysModeChange "SysModeChange" + +typedef enum _IARM_Bus_Daemon_PowerState_t { + IARM_BUS_PWRMGR_POWERSTATE_OFF, + IARM_BUS_PWRMGR_POWERSTATE_STANDBY, + IARM_BUS_PWRMGR_POWERSTATE_ON, + IARM_BUS_PWRMGR_POWERSTATE_STANDBY_LIGHT_SLEEP, + IARM_BUS_PWRMGR_POWERSTATE_STANDBY_DEEP_SLEEP +} IARM_Bus_PowerState_t; + +typedef IARM_Bus_PowerState_t IARM_Bus_PWRMgr_PowerState_t; + +typedef enum _IARM_Bus_Daemon_SysMode_t { + IARM_BUS_SYS_MODE_NORMAL, + IARM_BUS_SYS_MODE_EAS, + IARM_BUS_SYS_MODE_WAREHOUSE +} IARM_Bus_Daemon_SysMode_t; + +#define IARMBUS_AUDIOCAPTUREMGR_NAME "audiocapturemgr" +#define IARMBUS_AUDIOCAPTUREMGR_REQUEST_SAMPLE "requestSample" + +#define IARMBUS_AUDIOCAPTUREMGR_OPEN "open" +#define IARMBUS_AUDIOCAPTUREMGR_CLOSE "close" +#define IARMBUS_AUDIOCAPTUREMGR_START "start" +#define IARMBUS_AUDIOCAPTUREMGR_STOP "stop" +#define IARMBUS_AUDIOCAPTUREMGR_GET_DEFAULT_AUDIO_PROPS "getDefaultAudioProperties" +#define IARMBUS_AUDIOCAPTUREMGR_GET_AUDIO_PROPS "getAudioProperties" +#define IARMBUS_AUDIOCAPTUREMGR_GET_OUTPUT_PROPS "getOutputProperties" +#define IARMBUS_AUDIOCAPTUREMGR_SET_AUDIO_PROPERTIES "setAudioProperties" +#define IARMBUS_AUDIOCAPTUREMGR_SET_OUTPUT_PROPERTIES "setOutputProperties" + +#define AUDIOCAPTUREMGR_FILENAME_PREFIX "audio_sample" +#define AUDIOCAPTUREMGR_FILE_PATH "/opt/" + +#define DATA_CAPTURE_IARM_EVENT_AUDIO_CLIP_READY 100 + +#define ACM_RESULT_GENERAL_FAILURE 0 +#define ACM_RESULT_PRECAPTURE_NOT_SUPPORTED 1 +#define ACM_RESULT_STREAM_UNAVAILABLE 2 +#define ACM_RESULT_DURATION_OUT_OF_BOUNDS 3 +#define BUFFERED_FILE_OUTPUT "" + +enum Format { + acmFormate16BitStereo, + acmFormate16BitMonoLeft, + acmFormate16BitMonoRight, + acmFormate16BitMono, + acmFormate24BitStereo, + acmFormate24Bit5_1 +}; + +enum Sampling_frequency { + acmFreqe48000, + acmFreqe44100, + acmFreqe32000, + acmFreqe24000, + acmFreqe16000 +}; + +namespace audiocapturemgr { +using session_id_t = int; + +struct audio_properties_ifce_t { + Format format; + Sampling_frequency sampling_frequency; +}; +} + +struct iarmbus_notification_payload_t { + char dataLocator[64]; +}; + +struct iarmbus_acm_arg_t { + struct iarmbus_open_args { + int source; + std::string output_type; + }; + + struct iarmbus_request_payload_t { + float duration; + bool is_precapture; + }; + + struct output_t { + unsigned int buffer_duration; + unsigned int max_buffer_duration; + }; + + struct arg_output_props_t { + output_t output; + }; + + struct Details { + iarmbus_open_args arg_open; + audiocapturemgr::audio_properties_ifce_t arg_audio_properties; + iarmbus_request_payload_t arg_sample_request; + arg_output_props_t arg_output_props; + }; + + int session_id; + int result; + Details details; +}; + +#define IARM_BUS_CECMGR_NAME "CECMgr" +#define IARM_BUS_CECMGR_MAX_DATA_LENGTH 62 +#define IARM_BUS_CECMGR_API_Send "Send" + +typedef struct _IARM_Bus_CECMgr_Send_Param_t { + uint8_t length; + uint8_t data[IARM_BUS_CECMGR_MAX_DATA_LENGTH + 1]; + uint8_t retVal; +} IARM_Bus_CECMgr_Send_Param_t; + +#define IARM_BUS_DEEPSLEEPMGR_NAME "DEEPSLEEPMgr" + +#define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupReason "GetLastWakeupReason" +#define IARM_BUS_DEEPSLEEPMGR_API_GetLastWakeupKeyCode "GetLastWakeupKeycode" + +typedef enum _DeepSleep_WakeupReason_t { + DEEPSLEEP_WAKEUPREASON_IR = 0, + DEEPSLEEP_WAKEUPREASON_RCU_BT, + DEEPSLEEP_WAKEUPREASON_RCU_RF4CE, + DEEPSLEEP_WAKEUPREASON_GPIO, + DEEPSLEEP_WAKEUPREASON_LAN, + DEEPSLEEP_WAKEUPREASON_WLAN, + DEEPSLEEP_WAKEUPREASON_TIMER, + DEEPSLEEP_WAKEUPREASON_FRONT_PANEL, + DEEPSLEEP_WAKEUPREASON_WATCHDOG, + DEEPSLEEP_WAKEUPREASON_SOFTWARE_RESET, + DEEPSLEEP_WAKEUPREASON_THERMAL_RESET, + DEEPSLEEP_WAKEUPREASON_WARM_RESET, + DEEPSLEEP_WAKEUPREASON_COLDBOOT, + DEEPSLEEP_WAKEUPREASON_STR_AUTH_FAILURE, + DEEPSLEEP_WAKEUPREASON_CEC, + DEEPSLEEP_WAKEUPREASON_PRESENCE, + DEEPSLEEP_WAKEUPREASON_VOICE, + DEEPSLEEP_WAKEUPREASON_UNKNOWN +} DeepSleep_WakeupReason_t; + +typedef struct _DeepSleepMgr_WakeupKeyCode_Param_t { + unsigned int keyCode; +} DeepSleepMgr_WakeupKeyCode_Param_t; + +#define IARM_BUS_MFRLIB_NAME "MFRLib" +#define IARM_BUS_MFRLIB_API_SetBootLoaderPattern "mfrSetBootloaderPattern" +#define IARM_BUS_MFRLIB_API_SetBlSplashScreen "mfrSetBlSplashScreen" +#define IARM_BUS_MFRLIB_API_GetSerializedData "mfrGetManufacturerData" + +typedef enum _mfrSerializedType_t { + mfrSERIALIZED_TYPE_MANUFACTURER = 0, + mfrSERIALIZED_TYPE_MANUFACTUREROUI, + mfrSERIALIZED_TYPE_MODELNAME, + mfrSERIALIZED_TYPE_DESCRIPTION, + mfrSERIALIZED_TYPE_PRODUCTCLASS, + mfrSERIALIZED_TYPE_SERIALNUMBER, + mfrSERIALIZED_TYPE_HARDWAREVERSION, + mfrSERIALIZED_TYPE_SOFTWAREVERSION, + mfrSERIALIZED_TYPE_PROVISIONINGCODE, + mfrSERIALIZED_TYPE_FIRSTUSEDATE, + mfrSERIALIZED_TYPE_DEVICEMAC, + mfrSERIALIZED_TYPE_MOCAMAC, + mfrSERIALIZED_TYPE_HDMIHDCP, + mfrSERIALIZED_TYPE_PDRIVERSION, + mfrSERIALIZED_TYPE_WIFIMAC, + mfrSERIALIZED_TYPE_BLUETOOTHMAC, + mfrSERIALIZED_TYPE_WPSPIN, + mfrSERIALIZED_TYPE_MANUFACTURING_SERIALNUMBER, + mfrSERIALIZED_TYPE_ETHERNETMAC, + mfrSERIALIZED_TYPE_ESTBMAC, + mfrSERIALIZED_TYPE_RF4CEMAC, + mfrSERIALIZED_TYPE_PROVISIONED_MODELNAME, + mfrSERIALIZED_TYPE_PMI, + mfrSERIALIZED_TYPE_HWID, + mfrSERIALIZED_TYPE_MODELNUMBER, + /* boot data */ + mfrSERIALIZED_TYPE_SOC_ID, + mfrSERIALIZED_TYPE_IMAGENAME, + mfrSERIALIZED_TYPE_IMAGETYPE, + mfrSERIALIZED_TYPE_BLVERSION, + /* provisional data */ + mfrSERIALIZED_TYPE_REGION, + /* other data */ + mfrSERIALIZED_TYPE_BDRIVERSION, + /* led data */ + mfrSERIALIZED_TYPE_LED_WHITE_LEVEL, + mfrSERIALIZED_TYPE_LED_PATTERN, + mfrSERIALIZED_TYPE_MAX, +#ifdef PANEL_SERIALIZATION_TYPES + mfrSERIALIZED_TYPE_COREBOARD_SERIALNUMBER=0x51, + mfrSERIALIZED_TYPE_FACTORYBOOT, + mfrSERIALIZED_TYPE_COUNTRYCODE, + mfrSERIALIZED_TYPE_LANGUAGECODE, + mfrSERIALIZED_TYPE_MANUFACTURERDATA, + mfrSERIALIZED_TYPE_CPD_SIZE, + mfrSERIALIZED_TYPE_PANEL_ID, + mfrSERIALIZED_TYPE_PANEL_TYPE, + mfrSERIALIZED_TYPE_PANEL_HDMI_WB_DATA_NORMAL, + mfrSERIALIZED_TYPE_PANEL_HDMI_WB_DATA_COLD, + mfrSERIALIZED_TYPE_PANEL_HDMI_WB_DATA_WARM, + mfrSERIALIZED_TYPE_PANEL_HDMI_WB_DATA_USER, + mfrSERIALIZED_TYPE_PANEL_TV_WB_DATA_NORMAL, + mfrSERIALIZED_TYPE_PANEL_TV_WB_DATA_COLD, + mfrSERIALIZED_TYPE_PANEL_TV_WB_DATA_WARM, + mfrSERIALIZED_TYPE_PANEL_TV_WB_DATA_USER, + mfrSERIALIZED_TYPE_PANEL_AV_WB_DATA_NORMAL, + mfrSERIALIZED_TYPE_PANEL_AV_WB_DATA_COLD, + mfrSERIALIZED_TYPE_PANEL_AV_WB_DATA_WARM, + mfrSERIALIZED_TYPE_PANEL_AV_WB_DATA_USER, + mfrSERIALIZED_TYPE_PANEL_DTB_VERSION, + mfrSERIALIZED_TYPE_PANEL_DTB_DATA_SIZE, + mfrSERIALIZED_TYPE_PANEL_DTB_DATA, + /* panel data*/ + mfrSERIALIZED_TYPE_PANEL_DATA_FUNCTION_STATUS, + mfrSERIALIZED_TYPE_PANEL_DATA_AGEING_TIME, + mfrSERIALIZED_TYPE_PANEL_DATA_POWER_ON_TIME, + mfrSERIALIZED_TYPE_PANEL_DATA_BACKLIGHT_TIME, + mfrSERIALIZED_TYPE_PANEL_DATA_VALID, + mfrSERIALIZED_TYPE_PANEL_DATA_TPV_APP_VERSION, + mfrSERIALIZED_TYPE_PANEL_ALS_CALIBRATION_INDEX0, + mfrSERIALIZED_TYPE_PANEL_ALS_CALIBRATION_INDEX1, + mfrSERIALIZED_TYPE_MAX_PANEL, +#endif +} mfrSerializedType_t; + +typedef enum _mfrBlPattern_t { + mfrBL_PATTERN_NORMAL = 0, + mfrBL_PATTERN_SILENT, + mfrBL_PATTERN_SILENT_LED_ON +} mfrBlPattern_t; + +typedef struct _IARM_Bus_MFRLib_SetBLPattern_Param_t { + mfrBlPattern_t pattern; +} IARM_Bus_MFRLib_SetBLPattern_Param_t; + +typedef struct _IARM_Bus_MFRLib_GetSerializedData_Param_t { + mfrSerializedType_t type; + char buffer[1280]; + int bufLen; +} IARM_Bus_MFRLib_GetSerializedData_Param_t; + +#define PWRMGR_MAX_REBOOT_REASON_LENGTH 100 + +#define MAX_PWR_STATE_BEF_REBOOR_STR_LEN (32) +#define IARM_BUS_PWRMGR_API_GetPowerStateBeforeReboot "GetPowerStateBeforeReboot" +#define IARM_BUS_PWRMGR_API_SetStandbyVideoState "SetStandbyVideoState" +#define IARM_BUS_PWRMGR_API_GetStandbyVideoState "GetStandbyVideoState" +#define IARM_BUS_PWRMGR_API_SetNetworkStandbyMode "SetNetworkStandbyMode" +#define IARM_BUS_PWRMGR_API_GetNetworkStandbyMode "GetNetworkStandbyMode" +#define IARM_BUS_PWRMGR_API_Reboot "performReboot" +#define IARM_BUS_PWRMGR_API_WareHouseClear "WarehouseClear" /*!< */ +#define IARM_BUS_PWRMGR_API_ColdFactoryReset "ColdFactoryReset" /*!< Reset the box to cold factory state*/ +#define IARM_BUS_PWRMGR_API_FactoryReset "FactoryReset" /*!< Reset the box to factory state*/ +#define IARM_BUS_PWRMGR_API_UserFactoryReset "UserFactoryReset" /*!< Reset the box to user factory state*/ +#define IARM_BUS_PWRMGR_API_WareHouseReset "WareHouseReset" /*!< Reset the box to warehouse state*/ + +typedef struct _IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t { + bool bStandbyMode; +} IARM_Bus_PWRMgr_NetworkStandbyMode_Param_t; + +typedef struct _IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t { + char powerStateBeforeReboot[MAX_PWR_STATE_BEF_REBOOR_STR_LEN]; +} IARM_Bus_PWRMgr_GetPowerStateBeforeReboot_Param_t; + +typedef struct _IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t { + unsigned int timeout; +} IARM_Bus_PWRMgr_SetDeepSleepTimeOut_Param_t; + +typedef enum _IARM_Bus_PWRMgr_ThermalState_t { + IARM_BUS_PWRMGR_TEMPERATURE_NORMAL = 0, + IARM_BUS_PWRMGR_TEMPERATURE_HIGH, + IARM_BUS_PWRMGR_TEMPERATURE_CRITICAL +} IARM_Bus_PWRMgr_ThermalState_t; + +typedef enum _WakeupSrcType_t { + WAKEUPSRC_VOICE = 0, + WAKEUPSRC_PRESENCE_DETECTION, + WAKEUPSRC_BLUETOOTH, + WAKEUPSRC_WIFI, + WAKEUPSRC_IR, + WAKEUPSRC_POWER_KEY, + WAKEUPSRC_TIMER, + WAKEUPSRC_CEC, + WAKEUPSRC_LAN, + WAKEUPSRC_MAX +} WakeupSrcType_t; + +typedef struct _PWRMgr_EventData_t { + union { + struct _MODE_DATA { + IARM_Bus_PWRMgr_PowerState_t curState; + IARM_Bus_PWRMgr_PowerState_t newState; + uint32_t deep_sleep_timeout; + bool nwStandbyMode; + } state; + struct _THERM_DATA { + IARM_Bus_PWRMgr_ThermalState_t curLevel; + IARM_Bus_PWRMgr_ThermalState_t newLevel; + float curTemperature; + } therm; + bool bNetworkStandbyMode; + int32_t reset_sequence_progress; + } data; +} IARM_Bus_PWRMgr_EventData_t; + +typedef struct _IARM_Bus_PWRMgr_GetThermalState_Param_t { + IARM_Bus_PWRMgr_ThermalState_t curLevel; + float curTemperature; +} IARM_Bus_PWRMgr_GetThermalState_Param_t; + +typedef struct _IARM_Bus_PWRMgr_GetTempThresholds_Param_t { + float tempHigh; + float tempCritical; +} IARM_Bus_PWRMgr_GetTempThresholds_Param_t; + +typedef struct _IARM_Bus_PWRMgr_SetTempThresholds_Param_t { + float tempHigh; + float tempCritical; +} IARM_Bus_PWRMgr_SetTempThresholds_Param_t; + +typedef struct _IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t { + int graceInterval; +} IARM_Bus_PWRMgr_GetOvertempGraceInterval_Param_t; + +typedef struct _IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t { + int graceInterval; +} IARM_Bus_PWRMgr_SetOvertempGraceInterval_Param_t; + +typedef struct _IARM_Bus_CommonAPI_SysModeChange_Param_t { + IARM_Bus_Daemon_SysMode_t oldMode; + IARM_Bus_Daemon_SysMode_t newMode; +} IARM_Bus_CommonAPI_SysModeChange_Param_t; + +typedef enum _PWRMgr_EventId_t { + IARM_BUS_PWRMGR_EVENT_MODECHANGED = 0, + IARM_BUS_PWRMGR_EVENT_DEEPSLEEP_TIMEOUT, + IARM_BUS_PWRMGR_EVENT_RESET_SEQUENCE, + IARM_BUS_PWRMGR_EVENT_REBOOTING, + IARM_BUS_PWRMGR_EVENT_THERMAL_MODECHANGED, + IARM_BUS_PWRMGR_EVENT_WAREHOUSEOPS_STATUSCHANGED, + IARM_BUS_PWRMGR_EVENT_NETWORK_STANDBYMODECHANGED, + IARM_BUS_PWRMGR_EVENT_MAX, +} IARM_Bus_PWRMgr_EventId_t; + +typedef struct _IARM_Bus_PWRMgr_RebootParam_t { + char reboot_reason_custom[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char reboot_reason_other[PWRMGR_MAX_REBOOT_REASON_LENGTH]; + char requestor[PWRMGR_MAX_REBOOT_REASON_LENGTH]; +} IARM_Bus_PWRMgr_RebootParam_t; + +#define IARM_BUS_PWRMGR_NAME "PWRMgr" +#define IARM_BUS_PWRMGR_API_SetPowerState "SetPowerState" +#define IARM_BUS_PWRMGR_API_GetPowerState "GetPowerState" + +typedef struct _IARM_Bus_PWRMgr_SetPowerState_Param_t { + IARM_Bus_PWRMgr_PowerState_t newState; + int keyCode; +} IARM_Bus_PWRMgr_SetPowerState_Param_t; + +typedef struct _IARM_Bus_PWRMgr_GetPowerState_Param_t { + IARM_Bus_PWRMgr_PowerState_t curState; +} IARM_Bus_PWRMgr_GetPowerState_Param_t; + +#define IARM_BUS_PWRMGR_API_GetThermalState "GetThermalState" +#define IARM_BUS_PWRMGR_API_GetTemperatureThresholds "GetTemperatureThresholds" +#define IARM_BUS_PWRMGR_API_SetTemperatureThresholds "SetTemperatureThresholds" +#define IARM_BUS_PWRMGR_API_GetOvertempGraceInterval "GetOvertempGraceInterval" +#define IARM_BUS_PWRMGR_API_SetOvertempGraceInterval "SetOvertempGraceInterval" + +/** + * @brief Structure which holds the wakeup source type and the value to be set and the power state. + */ +typedef struct _IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t{ + uint32_t pwrMode; + uint32_t srcType; + uint32_t config; +} IARM_Bus_PWRMgr_WakeupSrcConfig_Param_t; +/** + * @brief Structure which holds the ware house reset time. + */ +typedef struct _IARM_Bus_PWRMgr_WareHouseReset_Param_t { + bool suppressReboot; /*!< STB should not be rebooted */ +} IARM_Bus_PWRMgr_WareHouseReset_Param_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOpsStatus_t{ + IARM_BUS_PWRMGR_WAREHOUSE_COMPLETED = 0, /* warehouse operation completed sucessfully */ + IARM_BUS_PWRMGR_WAREHOUSE_INPROGRESS, /* warehouse operation in progress*/ + IARM_BUS_PWRMGR_WAREHOUSE_FAILED, /* warehouse operation failed.*/ +} IARM_Bus_PWRMgr_WareHouseOpsStatus_t; + +/** + * @brief Enumerator which represents the possible warehouse ops + */ +typedef enum _IARM_Bus_PWRMgr_WareHouseOps_t{ + IARM_BUS_PWRMGR_WAREHOUSE_RESET = 0, /* warehouse reset */ + IARM_BUS_PWRMGR_WAREHOUSE_CLEAR, /* warehouse clear*/ +} IARM_Bus_PWRMgr_WareHouseOps_t; + +/** + * @brief Structure which holds warehouse opn status value. + */ +typedef struct _IARM_BUS_PWRMgr_WareHouseOpn_EventData_t { + IARM_Bus_PWRMgr_WareHouseOps_t wareHouseOpn; /*!< WareHouse operation*/ + IARM_Bus_PWRMgr_WareHouseOpsStatus_t status; /*!< WareHouse operation status*/ +} IARM_BUS_PWRMgr_WareHouseOpn_EventData_t; + +#define IARM_BUS_PWRMGR_API_SetWakeupSrcConfig "setWakeupSrcConfig" +#define IARM_BUS_PWRMGR_API_GetWakeupSrcConfig "getWakeupSrcConfig" /*!< gets wakup configuration*/ + +#define IARM_BUS_SYSMGR_NAME "SYSMgr" +#define IARM_BUS_SYSMGR_API_GetSystemStates "GetSystemStates" + +/** + * @brief Structure which holds RFC device management update information. + */ +typedef struct _IARM_BUS_SYSMGR_DeviceMgtUpdateInfo_Param_t +{ + char source[10]; /*!< Device Management Update source. Ex: rfc */ + char type[10]; /*!< Device Management Update type. Ex: initial */ + bool status; /*!< Device Management Update status. true/false */ +} IARM_BUS_SYSMGR_DeviceMgtUpdateInfo_Param_t; + +typedef enum _SYSMgr_EventId_t { + IARM_BUS_SYSMGR_EVENT_SYSTEMSTATE, + IARM_BUS_SYSMGR_EVENT_XUPNP_DATA_REQUEST, /*!< Xupnp data request frm Receiver to UPNP*/ + IARM_BUS_SYSMGR_EVENT_XUPNP_DATA_UPDATE, /*!< Xupnp data frm UPNP to Receiver*/ + IARM_BUS_SYSMGR_EVENT_IMAGE_DNLD, /*Image download status to Receiver */ + IARM_BUS_SYSMGR_EVENT_CARD_FWDNLD, /*!< CARD FW download event to Receiver - Valid on Cisco CA*/ + IARM_BUS_SYSMGR_EVENT_HDCP_PROFILE_UPDATE, /*!< HDCP Profile Update */ + IARM_BUS_SYSMGR_EVENT_INTRUSION, /*!< Intrusion Detection */ + IARM_BUS_SYSMGR_EVENT_EISS_FILTER_STATUS, /*!< EISS Filter status event */ + IARM_BUS_SYSMGR_EVENT_EISS_APP_ID_UPDATE, /*!< EISS App ID update */ + IARM_BUS_SYSMGR_EVENT_KEYCODE_LOGGING_CHANGED, /*!< Key Code logging status update */ + IARM_BUS_SYSMGR_EVENT_USB_MOUNT_CHANGED, /*!< Fires when USB mounts change */ + IARM_BUS_SYSMGR_EVENT_APP_RELEASE_FOCUS, /*!< Application fires event to release focus*/ + IARM_BUS_SYSMGR_EVENT_DEVICE_UPDATE_RECEIVED, /*!< Received Device Management update information */ + IARM_BUS_SYSMGR_EVENT_MAX /*!< Max Event Id */ +} IARM_Bus_SYSMgr_EventId_t; + +typedef struct _IARM_BUS_SYSMGR_KEYCodeLoggingInfo_Param_t { + int logStatus; /*!< HDCP Profile Data */ +} IARM_BUS_SYSMGR_KEYCodeLoggingInfo_Param_t; + +#define IARM_BUS_SYSMGR_API_GetKeyCodeLoggingPref "GetKeyCodeLoggingPref" +#define IARM_BUS_SYSMGR_API_SetKeyCodeLoggingPref "SetKeyCodeLoggingPref" + +typedef enum _SYSMgr_SystemState_t { + IARM_BUS_SYSMGR_SYSSTATE_CHANNELMAP, //0 + IARM_BUS_SYSMGR_SYSSTATE_DISCONNECTMGR, //1 + IARM_BUS_SYSMGR_SYSSTATE_TUNEREADY, //2 + IARM_BUS_SYSMGR_SYSSTATE_EXIT_OK, //3 + IARM_BUS_SYSMGR_SYSSTATE_CMAC, //4 + IARM_BUS_SYSMGR_SYSSTATE_MOTO_ENTITLEMENT, //5 + IARM_BUS_SYSMGR_SYSSTATE_MOTO_HRV_RX, //6 + IARM_BUS_SYSMGR_SYSSTATE_CARD_CISCO_STATUS, //7 + IARM_BUS_SYSMGR_SYSSTATE_VIDEO_PRESENTING, //8 + IARM_BUS_SYSMGR_SYSSTATE_HDMI_OUT, //9 + IARM_BUS_SYSMGR_SYSSTATE_HDCP_ENABLED, //10 + IARM_BUS_SYSMGR_SYSSTATE_HDMI_EDID_READ, //11 + IARM_BUS_SYSMGR_SYSSTATE_FIRMWARE_DWNLD, //12 + IARM_BUS_SYSMGR_SYSSTATE_TIME_SOURCE, //13 + IARM_BUS_SYSMGR_SYSSTATE_TIME_ZONE, //14 + IARM_BUS_SYSMGR_SYSSTATE_CA_SYSTEM, //15 + IARM_BUS_SYSMGR_SYSSTATE_ESTB_IP, //16 + IARM_BUS_SYSMGR_SYSSTATE_ECM_IP, //17 + IARM_BUS_SYSMGR_SYSSTATE_LAN_IP, //18 + IARM_BUS_SYSMGR_SYSSTATE_MOCA, //19 + IARM_BUS_SYSMGR_SYSSTATE_DOCSIS, //20 + IARM_BUS_SYSMGR_SYSSTATE_DSG_BROADCAST_CHANNEL, //21 + IARM_BUS_SYSMGR_SYSSTATE_DSG_CA_TUNNEL, //22 + IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD, //23 + IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD_DWNLD, //24 + IARM_BUS_SYSMGR_SYSSTATE_CVR_SUBSYSTEM, //25 + IARM_BUS_SYSMGR_SYSSTATE_DOWNLOAD, //26 + IARM_BUS_SYSMGR_SYSSTATE_VOD_AD, //27 + IARM_BUS_SYSMGR_SYSSTATE_DAC_INIT_TIMESTAMP, //28 + IARM_BUS_SYSMGR_SYSSTATE_CABLE_CARD_SERIAL_NO, //29 + IARM_BUS_SYSMGR_SYSSTATE_ECM_MAC, //30 + IARM_BUS_SYSMGR_SYSSTATE_DAC_ID, //31 + IARM_BUS_SYSMGR_SYSSTATE_PLANT_ID, //32 + IARM_BUS_SYSMGR_SYSSTATE_STB_SERIAL_NO, //33 + IARM_BUS_SYSMGR_SYSSTATE_BOOTUP, //34 + IARM_BUS_SYSMGR_SYSSTATE_GATEWAY_CONNECTION, //35 + IARM_BUS_SYSMGR_SYSSTATE_DST_OFFSET, //36 + IARM_BUS_SYSMGR_SYSSTATE_RF_CONNECTED, //37 + IARM_BUS_SYSMGR_SYSSTATE_PARTNERID_CHANGE, //38 + IARM_BUS_SYSMGR_SYSSTATE_IP_MODE, //39 + IARM_BUS_SYSMGR_SYSSTATE_LP_CONNECTION_RESET, //40 + IARM_BUS_SYSMGR_SYSSTATE_RWS_CONNECTION_RESET, //41 + IARM_BUS_SYSMGR_SYSSTATE_QAM_READY, //42 + IARM_BUS_SYSMGR_SYSSTATE_FIRMWARE_UPDATE_STATE, //43, Added as part of RDK-19978, As the IARM + IARM_BUS_SYSMGR_SYSSTATE_USB_DETECTED, //44 + IARM_BUS_SYSMGR_SYSSTATE_LOG_UPLOAD, //45 + IARM_BUS_SYSMGR_SYSSTATE_RED_RECOV_UPDATE_STATE, //46 +} IARM_Bus_SYSMgr_SystemState_t; + +typedef enum _SYSMgr_FirmwareUpdateState_t { + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_UNINITIALIZED = 0, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_REQUESTING = 1, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_DOWNLOADING = 2, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_FAILED = 3, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_DOWNLOAD_COMPLETE = 4, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_VALIDATION_COMPLETE = 5, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_PREPARING_TO_REBOOT = 6, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_ONHOLD_FOR_OPTOUT = 7, /* On Hold for opt-out */ + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_CRITICAL_REBOOT = 8, + IARM_BUS_SYSMGR_FIRMWARE_UPDATE_STATE_NO_UPGRADE_REQUIRED = 9 +} IARM_Bus_SYSMGR_FirmwareUpdateState_t; + +typedef enum _SYSMgr_RecoveryState_t { + IARM_BUS_SYSMGR_RECOVERY_STATE_COMPLETED = 0, + IARM_BUS_SYSMGR_RECOVERY_STATE_STARTED = 1, + IARM_BUS_SYSMGR_RECOVERY_STATE_DOWNLOADED = 2, + IARM_BUS_SYSMGR_RECOVERY_STATE_PROGRAMMED = 3, +} IARM_Bus_SYSMGR_RecoveryState_t; + +typedef enum _SYSMgr_LogUpload_t +{ + IARM_BUS_SYSMGR_LOG_UPLOAD_SUCCESS = 0, + IARM_BUS_SYSMGR_LOG_UPLOAD_FAILED = 1, + IARM_BUS_SYSMGR_LOG_UPLOAD_ABORTED = 2, +} IARM_Bus_SYSMGR_SYSMgr_LogUpload_t; + +typedef struct _IARM_BUS_SYSMgr_EventData_t { + union { + struct _CARD_FWDNLD_DATA { + char eventType; + char status; + } cardFWDNLD; + struct _IMAGE_FWDNLD_DATA { + char status; + } imageFWDNLD; + struct _XUPNP_DATA { + unsigned long deviceInfoLength; + } xupnpData; + struct _HDCP_PROFILE { + unsigned int hdcpProfile; + } hdcpProfileData; + struct _SystemStates { + IARM_Bus_SYSMgr_SystemState_t stateId; + int state; + int error; + char payload[128]; + } systemStates; + struct _EISS_STATUS { + int filterStatus; + } eissEventData; + struct _EISS_APP_ID { + unsigned char idList[4][6]; + int count; + } eissAppIDList; + struct _KEY_CODE_LOG { + int logStatus; + } keyCodeLogData; + struct _USB_MOUNT { + int mounted; + char device[128]; + char dir[256]; + } usbMountData; + + } data; +} IARM_Bus_SYSMgr_EventData_t; + +typedef struct _propertyValue { + int state; + int error; + char payload[128]; +} state_property; + +typedef struct _IARM_Bus_SYSMgr_GetSystemStates_Param_t { + state_property channel_map; + state_property disconnect_mgr_state; + state_property TuneReadyStatus; + state_property exit_ok_key_sequence; + state_property cmac; + state_property card_moto_entitlements; + state_property card_moto_hrv_rx; + state_property dac_init_timestamp; + state_property card_cisco_status; + state_property video_presenting; + state_property hdmi_out; + state_property hdcp_enabled; + state_property hdmi_edid_read; + state_property firmware_download; + state_property time_source; + state_property time_zone_available; + state_property ca_system; + state_property estb_ip; + state_property ecm_ip; + state_property lan_ip; + state_property moca; + state_property docsis; + state_property dsg_broadcast_tunnel; + state_property dsg_ca_tunnel; + state_property cable_card; + state_property cable_card_download; + state_property cvr_subsystem; + state_property download; + state_property vod_ad; + state_property card_serial_no; + state_property ecm_mac; + state_property dac_id; + state_property plant_id; + state_property stb_serial_no; + state_property bootup; + state_property dst_offset; + state_property rf_connected; + state_property ip_mode; + state_property qam_ready_status; + state_property firmware_update_state; + state_property red_recov_state; +} IARM_Bus_SYSMgr_GetSystemStates_Param_t; + +#define IARM_BUS_DSMGR_NAME "DSMgr" + +/*! Events published from DS Mananger */ +typedef enum _DSMgr_EventId_t { + IARM_BUS_DSMGR_EVENT_RES_PRECHANGE = 0, /*!< Resolution Pre Change Event */ + IARM_BUS_DSMGR_EVENT_RES_POSTCHANGE, /*!< Resolution Post Change Event */ + IARM_BUS_DSMGR_EVENT_ZOOM_SETTINGS, /*!< Zoom Settings Events */ + IARM_BUS_DSMGR_EVENT_HDMI_HOTPLUG, /*!< HDMI HPD DETECT Change Event */ + IARM_BUS_DSMGR_EVENT_AUDIO_MODE, /*!< HDMI HPD DETECT Change Event */ + IARM_BUS_DSMGR_EVENT_HDCP_STATUS, /*!< HDMI HDCP status */ + IARM_BUS_DSMGR_EVENT_RX_SENSE, /*!< HDMI Rx Sense status */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_HOTPLUG, /*!< HDMI IN HPD change event */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_SIGNAL_STATUS, /*!< HDMI IN signal status change event */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_STATUS, /*!< HDMI IN status change event */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_AV_LATENCY, /*!< HDMI IN AV Latency Event */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_VIDEO_MODE_UPDATE, /*!< HDMI IN video mode update event */ + IARM_BUS_DSMGR_EVENT_HDMI_IN_ALLM_STATUS, /*!< HDMI IN ALLM mode update event */ + IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_HOTPLUG, /*!< COMPOSITE IN HPD change event */ + IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_SIGNAL_STATUS, /*!< COMPOSITE IN signal status change event */ + IARM_BUS_DSMGR_EVENT_COMPOSITE_IN_STATUS, /*!< COMPOSITE IN status change event */ + IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE, /*!< Clock Time Format Change Event*/ + IARM_BUS_DSMGR_EVENT_AUDIO_LEVEL_CHANGED, /*!< Audio Level Change Event*/ + IARM_BUS_DSMGR_EVENT_AUDIO_OUT_HOTPLUG, /*!< AUDIO OUT HPD change event */ + IARM_BUS_DSMGR_EVENT_AUDIO_FORMAT_UPDATE, /*!< Audio Format change event */ + IARM_BUS_DSMGR_EVENT_AUDIO_PRIMARY_LANGUAGE_CHANGED, /*!< Audio Primary Language change event */ + IARM_BUS_DSMGR_EVENT_AUDIO_SECONDARY_LANGUAGE_CHANGED, /*!< Audio Secondary Language change event */ + IARM_BUS_DSMGR_EVENT_AUDIO_FADER_CONTROL_CHANGED, /*!< Audio Fader Control change event */ + IARM_BUS_DSMGR_EVENT_AUDIO_ASSOCIATED_AUDIO_MIXING_CHANGED, /*!< Audio Associated Audio Mixing change event */ + IARM_BUS_DSMGR_EVENT_VIDEO_FORMAT_UPDATE, /*!< Video Format change event */ + IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_PRECHANGE, /*!< Frame rate pre change */ + IARM_BUS_DSMGR_EVENT_DISPLAY_FRAMRATE_POSTCHANGE, /*!< Frame rate post change */ + IARM_BUS_DSMGR_EVENT_AUDIO_PORT_STATE, /*!< Audio Port Init State */ + IARM_BUS_DSMGR_EVENT_SLEEP_MODE_CHANGED, /*!< Sleep Mode Change Event*/ + IARM_BUS_DSMGR_EVENT_HDMI_IN_AVI_CONTENT_TYPE, /*Register(__VA_ARGS__) + + + +#define IARM_BUS_SYSMGR_API_RunScript "RunScript" +/*! Parameter for RunScript call*/ +typedef struct _IARM_Bus_SYSMgr_RunScript_t{ + char script_path [256]; //[in] Null terminated path name of the script. + int return_value; //[out] Returns the ret value of system. +} IARM_Bus_SYSMgr_RunScript_t; + +typedef enum _CECMgr_EventId_t { + IARM_BUS_CECMGR_EVENT_SEND, + IARM_BUS_CECMGR_EVENT_RECV, + IARM_BUS_CECMGR_EVENT_ENABLE, + IARM_BUS_CECMGR_EVENT_DAEMON_INITIALIZED, + IARM_BUS_CECMGR_EVENT_MAX, + IARM_BUS_CECMGR_EVENT_STATUS_UPDATED +} IARM_Bus_CECMgr_EventId_t; + +typedef struct _IARM_Bus_CECMgr_Status_Updated_Param_t +{ + int logicalAddress; +}IARM_Bus_CECMgr_Status_Updated_Param_t; + +typedef struct _IARM_Bus_MFRLib_SetBLSplashScreen_Param{ + char path[255]; +} IARM_Bus_MFRLib_SetBLSplashScreen_Param_t; + +#define IARM_BUS_CECMGR_API_isAvailable "isAvailable" +#define IARM_BUS_DSMGR_API_dsHdmiInGetNumberOfInputs "dsHdmiInGetNumberOfInputs" +#define IARM_BUS_DSMGR_API_dsHdmiInGetStatus "dsHdmiInGetStatus" +#define IARM_BUS_DSMGR_API_dsGetHDMIARCPortId "dsGetHDMIARCPortId" diff --git a/Tests/mocks/IarmBusMock.h b/Tests/mocks/IarmBusMock.h new file mode 100644 index 00000000..61d1c513 --- /dev/null +++ b/Tests/mocks/IarmBusMock.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +#include "libIBus.h" + +class IarmBusImplMock : public IarmBusImpl { +public: + IarmBusImplMock() + : IarmBusImpl() + { + // Defaults: + ON_CALL(*this, IARM_Bus_IsConnected(::testing::_, ::testing::_)) + .WillByDefault(::testing::Invoke( + [](const char*, int* isRegistered) { + *isRegistered = 1; + return IARM_RESULT_SUCCESS; + })); + ON_CALL(*this, IARM_Bus_Init(::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_Connect()) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_RegisterEventHandler(::testing::_, ::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_UnRegisterEventHandler(::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_Call(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_BroadcastEvent(::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_RegisterCall(::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + ON_CALL(*this, IARM_Bus_Call_with_IPCTimeout(::testing::_, ::testing::_, ::testing::_, ::testing::_, ::testing::_)) + .WillByDefault(::testing::Return(IARM_RESULT_SUCCESS)); + } + virtual ~IarmBusImplMock() = default; + + MOCK_METHOD(IARM_Result_t, IARM_Bus_Init, (const char* name), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_Connect, (), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_IsConnected, (const char* memberName, int* isRegistered), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_RegisterEventHandler, (const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_UnRegisterEventHandler, (const char* ownerName, IARM_EventId_t eventId), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_RemoveEventHandler, (const char* ownerName, IARM_EventId_t eventId, IARM_EventHandler_t handler), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_Call, (const char* ownerName, const char* methodName, void* arg, size_t argLen), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_RegisterCall, (const char* methodName, IARM_BusCall_t handler), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_BroadcastEvent, (const char *ownerName, IARM_EventId_t eventId, void *arg, size_t argLen), (override)); + MOCK_METHOD(IARM_Result_t, IARM_Bus_Call_with_IPCTimeout, (const char *ownerName, const char *methodName, void *arg, size_t argLen, int timeout), (override)); +};