mirror of
https://github.com/openharmony/distributedhardware_distributed_input.git
synced 2026-07-20 01:53:34 -04:00
Description: use real networkid
Match-id-13613ce07b501054f2ed0be56232992902573a4f
This commit is contained in:
+2
-1
@@ -59,7 +59,8 @@
|
||||
"//foundation/distributedhardware/distributed_input/sourcehandler:libdinput_source_handler",
|
||||
"//foundation/distributedhardware/distributed_input/sinkhandler:libdinput_sink_handler",
|
||||
"//foundation/distributedhardware/distributed_input/inputdevicehandler:libdinput_handler",
|
||||
"//foundation/distributedhardware/distributed_input/dfx_utils:libdinput_dfx_utils"
|
||||
"//foundation/distributedhardware/distributed_input/dfx_utils:libdinput_dfx_utils",
|
||||
"//foundation/distributedhardware/distributed_input/utils:libdinput_utils"
|
||||
],
|
||||
"inner_kits":[
|
||||
{
|
||||
|
||||
@@ -133,8 +133,6 @@ namespace DistributedInput {
|
||||
/* The input device is external (not built-in). */
|
||||
constexpr uint32_t INPUT_DEVICE_CLASS_EXTERNAL = 0x80000000;
|
||||
|
||||
const std::string LOCAL_DEV_ID = "localNodeDevice";
|
||||
|
||||
enum class EHandlerMsgType {
|
||||
DINPUT_SINK_EVENT_HANDLER_MSG = 1,
|
||||
DINPUT_SOURCE_EVENT_HANDLER_MSG = 2
|
||||
|
||||
@@ -42,6 +42,7 @@ ohos_unittest("distributed_input_white_list_test") {
|
||||
"${service_common}/include",
|
||||
"//third_party/json/include",
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -68,6 +69,7 @@ ohos_unittest("distributed_input_white_list_test") {
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "distributed_hardware_log.h"
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
@@ -101,7 +102,13 @@ int32_t WhiteListUtil::Init()
|
||||
}
|
||||
|
||||
inFile.close();
|
||||
SyncWhiteList(LOCAL_DEV_ID, vecWhiteList);
|
||||
|
||||
std::string localNetworkId = GetLocalDeviceInfo().networkId;
|
||||
if (!localNetworkId.empty()) {
|
||||
SyncWhiteList(localNetworkId, vecWhiteList);
|
||||
} else {
|
||||
DHLOGE("query local network id from softbus failed");
|
||||
}
|
||||
|
||||
DHLOGI("Local WhiteListUtil init success");
|
||||
return DH_SUCCESS;
|
||||
|
||||
@@ -29,8 +29,6 @@ namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
class IDistributedSinkInput : public IRemoteBroker {
|
||||
public:
|
||||
static const int32_t SA_ID_DISTRIBUTED_INPUT_SINK_SERVICE = 4810;
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IDistributedSinkInput");
|
||||
|
||||
virtual int32_t Init() = 0;
|
||||
|
||||
@@ -37,8 +37,6 @@ namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
class IDistributedSourceInput : public IRemoteBroker {
|
||||
public:
|
||||
static const int32_t SA_ID_DISTRIBUTED_INPUT_SOURCE_SERVICE = 4809;
|
||||
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.DistributedHardware.DistributedInput.IDistributedSourceInput");
|
||||
|
||||
virtual int32_t Init() = 0;
|
||||
|
||||
@@ -28,6 +28,7 @@ ohos_shared_library("libdinput_sdk") {
|
||||
"${fwk_common_path}/utils/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${fwk_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"//third_party/json/include",
|
||||
]
|
||||
sources = [
|
||||
@@ -62,6 +63,7 @@ ohos_shared_library("libdinput_sdk") {
|
||||
deps = [
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils"
|
||||
]
|
||||
|
||||
defines = [
|
||||
|
||||
@@ -41,6 +41,7 @@ ohos_unittest("distributed_input_inner_test") {
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${fwk_utils_path}/include",
|
||||
"//third_party/json/include",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -63,9 +64,7 @@ ohos_unittest("distributed_input_inner_test") {
|
||||
"${ipc_path}/src/del_white_list_infos_call_back_proxy.cpp",
|
||||
"${ipc_path}/src/del_white_list_infos_call_back_stub.cpp",
|
||||
"${ipc_path}/src/distributed_input_source_proxy.cpp",
|
||||
|
||||
"//foundation/distributedhardware/distributed_input/interfaces/inner_kits/test/unittest/mock/mock_distributed_input_client.cpp",
|
||||
|
||||
"distributed_input_inner_test.cpp",
|
||||
]
|
||||
|
||||
@@ -87,6 +86,7 @@ ohos_unittest("distributed_input_inner_test") {
|
||||
"//base/notification/eventhandler/frameworks/eventhandler:libeventhandler",
|
||||
"//utils/native/base:utils",
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "distributed_input_inner_test.h"
|
||||
|
||||
#include "system_ability_definition.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::DistributedHardware::DistributedInput;
|
||||
using namespace std;
|
||||
@@ -82,7 +84,7 @@ int DistributedInputInnerTest::CheckSourceProxy() const
|
||||
}
|
||||
|
||||
OHOS::sptr<OHOS::IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
|
||||
IDistributedSourceInput::SA_ID_DISTRIBUTED_INPUT_SOURCE_SERVICE);
|
||||
DISTRIBUTED_HARDWARE_INPUT_SOURCE_SA_ID);
|
||||
if (!remoteObject) {
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -106,7 +108,7 @@ int DistributedInputInnerTest::CheckSinkProxy() const
|
||||
}
|
||||
|
||||
OHOS::sptr<OHOS::IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(
|
||||
IDistributedSinkInput::SA_ID_DISTRIBUTED_INPUT_SINK_SERVICE);
|
||||
DISTRIBUTED_HARDWARE_INPUT_SINK_SA_ID);
|
||||
if (!remoteObject) {
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ int32_t DistributedInputClient::ReleaseSink()
|
||||
serverType = DInputServerType::NULL_SERVER_TYPE;
|
||||
inputTypes_ = DInputDeviceType::NONE;
|
||||
sinkTypeCallback = nullptr;
|
||||
WhiteListUtil::GetInstance().ClearWhiteList(LOCAL_DEV_ID);
|
||||
WhiteListUtil::GetInstance().ClearWhiteList();
|
||||
return DinputSAManager::GetInstance().dInputSinkProxy_->Release();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ ohos_shared_library("libdinput_sink") {
|
||||
"${services_sink_path}/inputcollector/include",
|
||||
"//third_party/json/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -59,6 +60,7 @@ ohos_shared_library("libdinput_sink") {
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/transport:libdinput_sink_trans",
|
||||
"//foundation/distributedhardware/distributed_input/services/sink/inputcollector:libdinput_collector",
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "distributed_input_sink_transport.h"
|
||||
|
||||
#include "dinput_errcode.h"
|
||||
#include "dinput_utils_tool.h"
|
||||
#include "hidumper.h"
|
||||
#include "white_list_util.h"
|
||||
|
||||
@@ -80,7 +81,12 @@ void DistributedInputSinkManager::DInputSinkListener::onPrepareRemoteInput(
|
||||
|
||||
// send prepare result and if result ok, send white list
|
||||
TYPE_WHITE_LIST_VEC vecFilter;
|
||||
WhiteListUtil::GetInstance().GetWhiteList(LOCAL_DEV_ID, vecFilter);
|
||||
std::string localNetworkId = GetLocalDeviceInfo().networkId;
|
||||
if (!localNetworkId.empty()) {
|
||||
WhiteListUtil::GetInstance().GetWhiteList(localNetworkId, vecFilter);
|
||||
} else {
|
||||
DHLOGE("query local network id from softbus failed");
|
||||
}
|
||||
if (vecFilter.empty() || vecFilter[0].empty() || vecFilter[0][0].empty()) {
|
||||
DHLOGE("onPrepareRemoteInput called, white list is null.");
|
||||
jsonStr[DINPUT_SOFTBUS_KEY_RESP_VALUE] = true;
|
||||
|
||||
@@ -45,6 +45,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"//foundation/communication/dsoftbus/interfaces/kits/transport",
|
||||
"${services_sink_path}/inputcollector/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@@ -82,6 +83,7 @@ ohos_unittest("distributed_input_sinkmanager_test") {
|
||||
"//foundation/communication/dsoftbus/sdk:softbus_client",
|
||||
"//third_party/openssl:libcrypto_static",
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -33,6 +33,7 @@ ohos_shared_library("libdinput_source") {
|
||||
"${services_source_path}/inputinject/include",
|
||||
"${services_source_path}/transport/include",
|
||||
"${dfx_utils_path}/include",
|
||||
"${utils_path}/include",
|
||||
"//third_party/json/include",
|
||||
"//base/hiviewdfx/hitrace/interfaces/native/innerkits/include/hitrace_meter",
|
||||
]
|
||||
@@ -79,6 +80,7 @@ ohos_shared_library("libdinput_source") {
|
||||
"//foundation/distributedhardware/distributed_input/services/source/transport:libdinput_source_trans",
|
||||
"//foundation/distributedhardware/distributed_input/services/source/inputinject:libdinput_inject",
|
||||
"${dfx_utils_path}:libdinput_dfx_utils",
|
||||
"${utils_path}:libdinput_utils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
# Copyright (c) 2022 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
|
||||
#
|
||||
# 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.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import(
|
||||
"//foundation/distributedhardware/distributed_input/distributedinput.gni")
|
||||
|
||||
ohos_shared_library("libdinput_utils") {
|
||||
include_dirs = [
|
||||
"${fwk_common_path}/log/include",
|
||||
"${fwk_utils_path}/include",
|
||||
"${fwk_utils_path}/include/log",
|
||||
"${utils_path}/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"src/dinput_utils_tool.cpp",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"HI_LOG_ENABLE",
|
||||
"DH_LOG_TAG=\"dinpututils\"",
|
||||
"LOG_DOMAIN=0xD004100",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${fwk_utils_path}:distributedhardwareutils",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"dsoftbus:softbus_client",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
subsystem_name = "distributedhardware"
|
||||
|
||||
part_name = "distributed_input"
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_DISTRIBUTED_INPUT_UTILS_TOOL_H
|
||||
#define OHOS_DISTRIBUTED_INPUT_UTILS_TOOL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include "distributed_hardware_log.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
struct DevInfo {
|
||||
std::string networkId;
|
||||
std::string deviceName;
|
||||
uint16_t deviceType;
|
||||
};
|
||||
|
||||
DevInfo GetLocalDeviceInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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
|
||||
*
|
||||
* 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 "dinput_utils_tool.h"
|
||||
|
||||
#include "softbus_bus_center.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
namespace DistributedInput {
|
||||
namespace {
|
||||
const std::string DINPUT_PKG_NAME = "ohos.dhardware.dinput";
|
||||
}
|
||||
|
||||
DevInfo GetLocalDeviceInfo()
|
||||
{
|
||||
DevInfo devInfo { "", "", 0 };
|
||||
auto info = std::make_unique<NodeBasicInfo>();
|
||||
auto ret = GetLocalNodeDeviceInfo(DINPUT_PKG_NAME.c_str(), info.get());
|
||||
if (ret != 0) {
|
||||
DHLOGE("GetLocalNodeDeviceInfo failed, errCode = %d", ret);
|
||||
return devInfo;
|
||||
}
|
||||
|
||||
devInfo.networkId = info->networkId;
|
||||
devInfo.deviceName = info->deviceName;
|
||||
devInfo.deviceType = info->deviceTypeId;
|
||||
|
||||
return devInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user