1 /* 2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_ACELITE_DFT_IMPL_H 17 #define OHOS_ACELITE_DFT_IMPL_H 18 19 #include "acelite_config.h" 20 21 #if ((OHOS_ACELITE_PRODUCT_WATCH == 1) || (FEATURE_CUSTOM_ENTRY_PAGE == 1)) 22 #include "memory_heap.h" 23 24 namespace OHOS { 25 namespace ACELite { 26 typedef void (*PageReplacedCallback)(const char *path, int state); 27 28 struct Param { 29 const char *routerPath = nullptr; 30 const char *routerParam = nullptr; 31 const char *path = nullptr; 32 }; 33 34 typedef void (*PageInfoFunc)(const Param param); 35 36 class DftImpl final : public MemoryHeap { 37 public: 38 static DftImpl *GetInstance(); 39 40 /** 41 * @fn DftImpl::RegisterPageReplaced() 42 * 43 * @brief Register page replace event 44 */ 45 void RegisterPageReplaced(PageReplacedCallback handler); 46 47 void RegisterPageChangedCallback(PageInfoFunc pageInfoFunc); 48 49 /** 50 * @fn DftImpl::CallbackPageReplaced() 51 * 52 * @brief Call the path handler if it's set 53 */ 54 void CallbackPageReplaced(int state, const char *param = nullptr); 55 56 private: DftImpl()57 DftImpl() : pageReplacedCallback_(nullptr), pageInfoFunc_(nullptr) {} 58 59 ~DftImpl() = default; 60 61 /** 62 * @fn DftImpl::GetPagePath() 63 * 64 * @brief Return current page path 65 */ 66 char *GetPagePath(); 67 68 PageReplacedCallback pageReplacedCallback_; 69 PageInfoFunc pageInfoFunc_; 70 }; 71 } // namespace ACELite 72 } // namespace OHOS 73 #endif // OHOS_ACELITE_PRODUCT_WATCH 74 #endif // OHOS_ACELITE_DFT_IMPL_H 75