diff --git a/README_zh.md b/README_zh.md
index 3df3bd0f8b5d91595accc82e8fcf02cf99dd2bed..03fae84318a5f854ac6c5a24885264683cf9af1e 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -1,6 +1,6 @@
# HDC-OpenHarmony设备连接器
-- [HDC-OpenHarmony设备连接器](#hdc-OpenHarmony设备连接器)
+- [HDC-OpenHarmony设备连接器](#hdc-openharmony设备连接器)
- [简介](#简介)
- [架构](#架构)
- [目录](#目录)
@@ -69,7 +69,7 @@ linux版本建议ubuntu 16.04以上 64位,其他相近版本也可;libc++.so
在Linux下在非root权限下使用hdc会出现无法找到设备的情况,此问题原因为用户USB操作权限问题,解决方法如下:
1. 开启非root用户USB设备操作权限
- 该操作方法简单易行但是可能存在潜在安全问题,请根据使用场景自行评估
+ 该操作方法简单易行,但是可能存在潜在安全问题,请根据使用场景自行评估
```
sudo chmod -R 777 /dev/bus/usb/
```
@@ -131,7 +131,7 @@ hdc当前常用命令如下,未尽命令使用hdc -h或者hdc --help查看:
target mount
|
-以读写模式挂载/system等分区
+ | 以读写模式挂载/vendor、/data等分区,因为安全性问题,需要挂在根目录或者/system分区请单独使用'hdc_std shell mount -o rw,remount /'等命令
举例: hdc target mount
|
diff --git a/src/common/base.cpp b/src/common/base.cpp
index a8c772a3aa90ee2ae5d81a60d7f0b240d35a3e96..c81fcc757999a8b81903865c135a45378d9fb2a4 100644
--- a/src/common/base.cpp
+++ b/src/common/base.cpp
@@ -689,7 +689,8 @@ namespace Base {
WRITE_LOG(LOG_FATAL, "Tmppath failed");
return ERR_API_FAIL;
}
- if (snprintf_s(bufPath, sizeof(bufPath), sizeof(bufPath) - 1, "%s/.%s.pid", buf, procname) < 0) {
+ if (snprintf_s(bufPath, sizeof(bufPath), sizeof(bufPath) - 1, "%s%c.%s.pid", buf, Base::GetPathSep(), procname)
+ < 0) {
return ERR_BUF_OVERFLOW;
}
int pid = static_cast(getpid());
diff --git a/src/common/file.cpp b/src/common/file.cpp
index 8bb9ead1203936ca94feede9c0c2be9bce5710df..4e3cd9059c6eac7a9cab950a127dd0d8aefe4424 100644
--- a/src/common/file.cpp
+++ b/src/common/file.cpp
@@ -34,9 +34,6 @@ void HdcFile::StopTask()
singalStop = true;
};
-// Send supported below styles
-// send|recv path/filename path/filename
-// send|recv filename path
bool HdcFile::BeginTransfer(CtxFile *context, const string &command)
{
int argc = 0;
@@ -82,11 +79,15 @@ bool HdcFile::SetMasterParameters(CtxFile *context, const char *command, int arg
context->transferConfig.updateIfNew = true;
++srcArgvIndex;
} else if (argv[i] == CMD_OPTION_TSTMP) {
+ // The time zone difference may cause the display time on the PC and the
+ // device to differ by several hours
+ //
+ // ls -al --full-time
context->transferConfig.holdTimestamp = true;
++srcArgvIndex;
} else if (argv[i] == CMD_OPTION_CLIENTCWD) {
context->transferConfig.clientCwd = argv[i + 1];
- srcArgvIndex += CMD_ARG1_COUNT; // skip 2args
+ srcArgvIndex += CMD_ARG1_COUNT; // skip 2args
} else if (argv[i][0] == '-') {
LogMsg(MSG_FAIL, "Unknow file option: %s", argv[i]);
return false;
diff --git a/src/daemon/daemon_app.cpp b/src/daemon/daemon_app.cpp
index 2f8edf24417f49eadc8774d97d77459175dbc0e1..4f04dc93eabd5712d724b7b876309bc2b055203b 100644
--- a/src/daemon/daemon_app.cpp
+++ b/src/daemon/daemon_app.cpp
@@ -65,7 +65,7 @@ bool HdcDaemonApp::CommandDispatch(const uint16_t command, uint8_t *payload, con
size_t size = 256;
uv_os_tmpdir(tmpPath, &size);
dstPath = tmpPath;
- dstPath += PREF_SEPARATOR;
+ dstPath += Base::GetPathSep();
#endif
dstPath += ctxNow.transferConfig.optionalName;
ctxNow.localPath = dstPath;
diff --git a/src/host/client.cpp b/src/host/client.cpp
index e1f7944933e92b2a16b3951040b3d9392fd1462d..5c8994097545607d7f64cf1aa16b94adf3cec7f3 100644
--- a/src/host/client.cpp
+++ b/src/host/client.cpp
@@ -46,7 +46,7 @@ uint32_t HdcClient::GetLastPID()
WRITE_LOG(LOG_FATAL, "Tmppath failed");
return 0;
}
- string path = Base::StringFormat("%s/.%s.pid", bufPath, SERVER_NAME.c_str());
+ string path = Base::StringFormat("%s%c.%s.pid", bufPath, Base::GetPathSep(), SERVER_NAME.c_str());
Base::ReadBinFile(path.c_str(), (void **)&pidBuf, BUF_SIZE_TINY);
int pid = atoi(pidBuf); // pid maybe 0
return pid;
@@ -322,7 +322,7 @@ int HdcClient::PreHandshake(HChannel hChannel, const uint8_t *buf)
#ifdef HDC_CHANNEL_KEEP_ALIVE
// Evaluation method, non long-term support
Send(hChannel->channelId, reinterpret_cast(CMDSTR_INNER_ENABLE_KEEPALIVE.c_str()),
- CMDSTR_INNER_ENABLE_KEEPALIVE.size());
+ CMDSTR_INNER_ENABLE_KEEPALIVE.size());
#endif
return RET_SUCCESS;
}
diff --git a/src/host/server.cpp b/src/host/server.cpp
index fef638b72856da1f029a177e42d07788493ab8aa..a278c6a19af7d201ae8d1df11ffe7782d0acf5ae 100644
--- a/src/host/server.cpp
+++ b/src/host/server.cpp
@@ -471,12 +471,9 @@ bool HdcServer::FetchCommand(HSession hSession, const uint32_t channelId, const
case CMD_KERNEL_CHANNEL_CLOSE: {
WRITE_LOG(LOG_DEBUG, "CMD_KERNEL_CHANNEL_CLOSE channelid:%d", channelId);
ClearOwnTasks(hSession, channelId);
- auto funcChannleClose = [](uv_handle_t *handle) -> void {
- HChannel hChannel = (HChannel)handle->data;
- HdcServerForClient *sfc = static_cast(hChannel->clsChannel);
- sfc->FreeChannel(hChannel->channelId);
- };
- Base::TryCloseHandle((uv_handle_t *)&hChannel->hChildWorkTCP, funcChannleClose);
+ // Forcibly closing the tcp handle here may result in incomplete data reception on the client side
+ HdcServerForClient *sfc = static_cast(hChannel->clsChannel);
+ sfc->FreeChannel(hChannel->channelId);
if (*payload) {
--(*payload);
Send(hSession->sessionId, channelId, CMD_KERNEL_CHANNEL_CLOSE, payload, 1);
diff --git a/src/host/server_for_client.cpp b/src/host/server_for_client.cpp
index 1d1b09ed9d6c292667ff1fe1d083173773c443cf..18abf088c5b23164ec89de1b5b2ff2b35e0d6699 100644
--- a/src/host/server_for_client.cpp
+++ b/src/host/server_for_client.cpp
@@ -426,18 +426,16 @@ bool HdcServerForClient::TaskCommand(HChannel hChannel, void *formatCommandInput
cmdFlag = "sideload ";
sizeCmdFlag = 9;
}
+ uint8_t *payload = reinterpret_cast(const_cast(formatCommand->parameters.c_str())) + sizeCmdFlag;
if (!strncmp(formatCommand->parameters.c_str(), cmdFlag.c_str(), sizeCmdFlag)) { // local do
HSession hSession = FindAliveSession(hChannel->targetSessionId);
if (!hSession) {
return false;
}
- ptrServer->DispatchTaskData(hSession, hChannel->channelId, formatCommand->cmdFlag,
- reinterpret_cast(const_cast(formatCommand->parameters.c_str())) + sizeCmdFlag,
- sizeSend - sizeCmdFlag);
+ ptrServer->DispatchTaskData(hSession, hChannel->channelId, formatCommand->cmdFlag, payload,
+ sizeSend - sizeCmdFlag);
} else { // Send to Daemon-side to do
- SendToDaemon(hChannel, formatCommand->cmdFlag,
- reinterpret_cast(const_cast(formatCommand->parameters.c_str())) + sizeCmdFlag,
- sizeSend - sizeCmdFlag);
+ SendToDaemon(hChannel, formatCommand->cmdFlag, payload, sizeSend - sizeCmdFlag);
}
return true;
}
@@ -461,7 +459,8 @@ bool HdcServerForClient::DoCommandRemote(HChannel hChannel, void *formatCommandI
case CMD_UNITY_ROOTRUN:
case CMD_UNITY_JPID: {
if (!SendToDaemon(hChannel, formatCommand->cmdFlag,
- reinterpret_cast(const_cast(formatCommand->parameters.c_str())), sizeSend)) {
+ reinterpret_cast(const_cast(formatCommand->parameters.c_str())),
+ sizeSend)) {
break;
}
ret = true;
diff --git a/src/host/translate.cpp b/src/host/translate.cpp
index 6a24b873cc6e8921c328a6c8315f4fb1b7cfdf53..b335f74aba0038c9eeec3716f82febff1ec87857 100644
--- a/src/host/translate.cpp
+++ b/src/host/translate.cpp
@@ -212,12 +212,12 @@ namespace TranslateCommand {
} else if (!strcmp(input.c_str(), CMDSTR_SHELL.c_str())) {
outCmd->cmdFlag = CMD_SHELL_INIT;
} else if (!strncmp(input.c_str(), CMDSTR_FILE_SEND.c_str(), CMDSTR_FILE_SEND.size())
- || !strncmp(input.c_str(), CMDSTR_FILE_RECV.c_str(), CMDSTR_FILE_RECV.size())) {
+ || !strncmp(input.c_str(), CMDSTR_FILE_RECV.c_str(), CMDSTR_FILE_RECV.size())) {
outCmd->cmdFlag = CMD_FILE_INIT;
outCmd->parameters = input.c_str() + 5; // 5: CMDSTR_FORWARD_FPORT CMDSTR_FORWARD_RPORT size
} else if (!strncmp(input.c_str(), string(CMDSTR_FORWARD_FPORT + " ").c_str(), CMDSTR_FORWARD_FPORT.size() + 1)
- || !strncmp(input.c_str(), string(CMDSTR_FORWARD_RPORT + " ").c_str(),
- CMDSTR_FORWARD_RPORT.size() + 1)) {
+ || !strncmp(input.c_str(), string(CMDSTR_FORWARD_RPORT + " ").c_str(),
+ CMDSTR_FORWARD_RPORT.size() + 1)) {
stringError = ForwardPort(input.c_str(), outCmd);
} else if (!strcmp(input.c_str(), CMDSTR_KILL_SERVER.c_str())) {
outCmd->cmdFlag = CMD_KERNEL_SERVER_KILL;