mcu_hi3321_watch/tjd/ui/common/TjdUiLauncher.cpp
2025-05-26 20:15:20 +08:00

96 lines
3.0 KiB
C++

/*----------------------------------------------------------------------------
* Copyright (c) TJD Technologies Co., Ltd. 2024. All rights reserved.
*
* Description:
*
* Author: huangshuyi
*
* Create: 2024-4
*--------------------------------------------------------------------------*/
#include "TjdUiLauncher.h"
#include "NativeAbility.h"
#include "TjdUiAppCallModel.h"
#include "TjdUiAppMainModel.h"
#include "TjdUiAppPlayerModel.h"
#include "TjdUiMultiLanguageExt.h"
#include "TjdUiRegisterManager.h"
#include "TjdUiScreenManage.h"
#include "TjdUiSettingCenter.h"
#include "common/graphic_startup.h"
#include "dock/vibrator_manager.h"
#ifdef JS_ENABLE
#include "product_adapter.h"
#endif
extern "C"
{
#include "motor.h"
#include "sql_setting.h"
}
using namespace OHOS;
namespace TJD {
TjdUiLauncher::TjdUiLauncher() {}
TjdUiLauncher::~TjdUiLauncher() {}
TjdUiLauncher &TjdUiLauncher::GetInstance(void)
{
static TjdUiLauncher instance;
return instance;
}
static void TjdVibratorFunc(VibratorType vibratorType)
{
motor_param_t motorParam = {.cycle1_on = 50, .cycle1_off = 0, .cycle1_cnt = 1, .duty = 100};
switch (vibratorType) {
case VibratorType::VIBRATOR_TYPE_ONE:
motorParam.cycle1_cnt = 1;
break;
case VibratorType::VIBRATOR_TYPE_TWO:
motorParam.cycle1_cnt = 2;
break;
case VibratorType::VIBRATOR_TYPE_THREE:
motorParam.cycle1_cnt = 3;
break;
}
tjd_driver_motor_user_start(&motorParam);
}
void TjdUiLauncher::InitNativeLauncher()
{
#ifdef JS_ENABLE
OHOS::ACELite::ProductAdapter::SetScreenSize(HORIZONTAL_RESOLUTION, VERTICAL_RESOLUTION);
#endif
OHOS::VibratorManager::GetInstance()->RegisterVibratorFunc(TjdVibratorFunc);
GraphicStartUp::InitFontEngine(MEM_POOL_UI_FONT, MEM_POOL_UI_FONT_SIZE, TJD_VECTOR_FONT_DIR,
TJD_VECTOR_FONT_FILENAME);
WEARABLE_LOGI(WEARABLE_LOG_MODULE_LAUNCHER_FWK, "TJD NativeLauncher::InitNativeLauncher");
TjdUiMultiLanguageExt::RegisterLanguage();
TjdUiMultiLanguageExt::RegisterFont();
InitAllNativeSlices();
OHOS::NativeAbility::GetInstance().SetDefaultSliceId(TJD_APP_VIEW_OPEN_LOGO);
TjdUiScreenManage::SetScreenOnSystime();
TjdUiAppCallModel::InitCallService();
TjdUiMultiLanguageExt::SetCurrentLanguage(sql_setting_get_language());
TjdUiSettingCenter::GetInstance().Init();
TjdUiAppMainModel::GetInstance().Init();
TjdUiAppPlayerModel::GetInstance()->AudioInit();
TjdUiAppPlayerModel::GetInstance()->InitBluetoothPlayer();
power_display_gui_enable_aod(sql_setting_get_off_screen());
}
void TjdUiLauncher::InitAllNativeSlices(void)
{
OHOS::Graphic::Vector<NativeMap> &natives = TjdNativeRegisterManager::GetInstance().GetNatives();
for (uint16_t index = 0; index < natives.Size(); index++) {
if (static_cast<uint16_t>(natives[index].type) >= TJD_VIEW_MAX_INTER_APP) {
continue;
}
natives[index].native->InitSlice();
}
TjdNativeRegisterManager::GetInstance().InitAllNativesSlices();
}
} // namespace TJD