mirror of
https://gitee.com/openharmony/distributedhardware_distributed_hardware_fwk
synced 2024-11-23 07:40:26 +00:00
modify
Signed-off-by: chen0088 <chenmenghuan6@huawei.com>
This commit is contained in:
parent
807ec9b1bc
commit
c8e6bbc864
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023-2024 Huawei Device Co., Ltd.
|
||||
* 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
|
||||
@ -22,11 +22,20 @@
|
||||
#include "napi/native_node_api.h"
|
||||
#include "cJSON.h"
|
||||
|
||||
constexpr int32_t ALL = 0;
|
||||
constexpr int32_t CAMERA = 1;
|
||||
constexpr int32_t SCREEN = 8;
|
||||
constexpr int32_t MODEM_MIC = 256;
|
||||
constexpr int32_t MODEM_SPEAKER = 512;
|
||||
constexpr int32_t MIC = 1024;
|
||||
constexpr int32_t SPEAKER = 2048;
|
||||
|
||||
class DistributedHardwareManager {
|
||||
public:
|
||||
explicit DistributedHardwareManager(napi_env env, napi_value thisVar);
|
||||
~DistributedHardwareManager();
|
||||
static napi_value Init(napi_env env, napi_value exports);
|
||||
static void InitDistributedHardwareType(napi_env env, napi_value exports);
|
||||
static napi_value PauseDistributedHardware(napi_env env, napi_callback_info info);
|
||||
static napi_value ResumeDistributedHardware(napi_env env, napi_callback_info info);
|
||||
static napi_value StopDistributedHardware(napi_env env, napi_callback_info info);
|
||||
|
@ -291,6 +291,38 @@ napi_value DistributedHardwareManager::Init(napi_env env, napi_value exports)
|
||||
return exports;
|
||||
}
|
||||
|
||||
void DistributedHardwareManager::InitDistributedHardwareType(napi_env env, napi_value exports)
|
||||
{
|
||||
char propertyName[] = "DistributedHardwareType";
|
||||
napi_value all = nullptr;
|
||||
napi_value camera = nullptr;
|
||||
napi_value screen = nullptr;
|
||||
napi_value modemMic = nullptr;
|
||||
napi_value modemSpk = nullptr;
|
||||
napi_value mic = nullptr;
|
||||
napi_value speaker = nullptr;
|
||||
napi_create_int32(env, ALL, &all);
|
||||
napi_create_int32(env, CAMERA, &camera);
|
||||
napi_create_int32(env, SCREEN, &screen);
|
||||
napi_create_int32(env, MODEM_MIC, &modemMic);
|
||||
napi_create_int32(env, MODEM_SPEAKER, &modemSpk);
|
||||
napi_create_int32(env, MIC, &mic);
|
||||
napi_create_int32(env, SPEAKER, &speaker);
|
||||
napi_property_descriptor desc[] = {
|
||||
DECLARE_NAPI_STATIC_PROPERTY("ALL", all),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("CAMERA", camera),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("SCREEN", screen),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("MODEM_MIC", modemMic),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("MODEM_SPEAKER", modemSpk),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("MIC", mic),
|
||||
DECLARE_NAPI_STATIC_PROPERTY("SPEAKER", speaker)
|
||||
};
|
||||
napi_value obj = nullptr;
|
||||
napi_create_object(env, &obj);
|
||||
napi_define_properties(env, obj, sizeof(desc) / sizeof(desc[0]), desc);
|
||||
napi_set_named_property(env, exports, propertyName, obj);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function registering all props and functions of ohos.distributedhardware
|
||||
*/
|
||||
@ -298,6 +330,7 @@ static napi_value Export(napi_env env, napi_value exports)
|
||||
{
|
||||
DHLOGI("Export is called!");
|
||||
DistributedHardwareManager::Init(env, exports);
|
||||
DistributedHardwareManager::InitDistributedHardwareType(env, exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user