From 6b155e32f2c1e723b3bf394bc458e945fc6909f0 Mon Sep 17 00:00:00 2001 From: libaoshan Date: Tue, 1 Jul 2025 15:22:51 +0800 Subject: [PATCH] server unsupport file command, unsupport remote connect. Signed-off-by: libaoshan --- BUILD.gn | 6 +++++- bundle.json | 3 ++- src/common/define.h | 3 +++ src/host/main.cpp | 34 ++++++++++++++++++++++++++++++++++ src/host/server_for_client.cpp | 13 ++++++++++++- 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index caba3b2f..c9144264 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -405,7 +405,11 @@ ohos_executable("hdc") { sources += [ "src/common/password.cpp" ] sources += [ "src/common/hdc_huks.cpp" ] defines += [ "HDC_SUPPORT_ENCRYPT_PRIVATE_KEY" ] - external_deps += [ "huks:libhukssdk" ] + external_deps += [ + "huks:libhukssdk", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + ] } deps = [ ":hdc_hash_gen" ] diff --git a/bundle.json b/bundle.json index e596389f..2b9bd7b6 100644 --- a/bundle.json +++ b/bundle.json @@ -43,7 +43,8 @@ "pin_auth", "rust_rust-openssl", "huks", - "rust_libc" + "rust_libc", + "bundle_framework" ], "third_party": [] }, diff --git a/src/common/define.h b/src/common/define.h index fd414e9a..16ce887f 100644 --- a/src/common/define.h +++ b/src/common/define.h @@ -238,5 +238,8 @@ constexpr uint64_t MAX_COMPRESS_LOG_FILE_SIZE = (50) * 1024 * 1024; // 50MB constexpr size_t MAX_SAVE_CMD_LOG_TO_FILE_CYCLE = 10; constexpr size_t MAX_SAVE_CMD_LOG_TO_FILE_COUNTS = 1500; constexpr size_t MAX_PROCESS_TIMEOUT = 120; // 120 seconds +#ifdef __OHOS__ +const string HISHELL_BUNDLE_NAME = "com.huawei.hmos.hishell"; +#endif } // namespace Hdc #endif // HDC_DEFINE_H diff --git a/src/host/main.cpp b/src/host/main.cpp index 817e2b40..984cfad0 100644 --- a/src/host/main.cpp +++ b/src/host/main.cpp @@ -293,6 +293,33 @@ bool ParseServerListenString(string &serverListenString, char *optarg) return true; } +#ifdef __OHOS__ +std::string GetBundleName() +{ + string bundleName; + OHOS::sptr systemAbilityManager = + OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (systemAbilityManager == nullptr) { + return bundleName; + } + OHOS::sptr remoteObject = + systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); + if (remoteObject == nullptr) { + return bundleName; + } + OHOS::sptr bundleManager = + OHOS::iface_cast(remoteObject); + if (bundleManager == nullptr) { + return bundleName; + } + + OHOS::AppExecFwk::BundleInfo bundleInfo; + bundleManager->GetBundleInfoForSelf(0, bundleInfo); + bundleName = bundleInfo.name; + return bundleName; +} +#endif + bool GetCommandlineOptions(int optArgc, const char *optArgv[]) { int ch = 0; @@ -356,6 +383,13 @@ bool GetCommandlineOptions(int optArgc, const char *optArgv[]) break; } case 's': { +#ifdef __OHOS__ + if (GetBundleName() != HISHELL_BUNDLE_NAME) { + Base::PrintMessage("Unsupport remote connect!!!"); + needExit = true; + return needExit; + } +#endif if (!Hdc::ParseServerListenString(g_serverListenString, optarg)) { needExit = true; return needExit; diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp index dd6167c3..cadcee4b 100644 --- a/src/host/server_for_client.cpp +++ b/src/host/server_for_client.cpp @@ -699,7 +699,18 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI } break; } - case CMD_FILE_INIT: + case CMD_FILE_INIT: { +#ifdef __OHOS__ + if (formatCommand->cmdFlag == CMD_FILE_INIT) { + HandleRemote(hChannel, formatCommand->parameters, RemoteType::REMOTE_FILE); + if (!hChannel->fromClient) { + EchoClient(hChannel, MSG_FAIL, "Unsupport command!!!"); + ret = false; + return ret; + } + } +#endif + } case CMD_FORWARD_INIT: case CMD_APP_INIT: case CMD_APP_UNINSTALL: -- Gitee