!309 feat: add remote judgment

Merge pull request !309 from zhuofan/master
This commit is contained in:
openharmony_ci 2024-09-23 12:00:39 +00:00 committed by Gitee
commit 00dac715fb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 2 deletions

View File

@ -48,6 +48,12 @@ int32_t DeviceSecurityLevelProxy::RequestDeviceSecurityLevel(const DeviceIdentif
MessageParcel reply;
auto length = identify.length;
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
HILOG_ERROR(LOG_CORE, "Remote is nullptr");
return ERR_INVALID_PARA;
}
if (length == 0 || length > DEVICE_ID_MAX_LEN) {
HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevel invalid para len.");
return ERR_INVALID_LEN_PARA;
@ -72,7 +78,7 @@ int32_t DeviceSecurityLevelProxy::RequestDeviceSecurityLevel(const DeviceIdentif
data.WriteUint32(cookie);
MessageOption ipcOption = {MessageOption::TF_SYNC};
auto result = Remote()->SendRequest(CMD_GET_DEVICE_SECURITY_LEVEL, data, reply, ipcOption);
auto result = remote->SendRequest(CMD_GET_DEVICE_SECURITY_LEVEL, data, reply, ipcOption);
if (result != ERR_NONE) {
HILOG_ERROR(LOG_CORE, "RequestDeviceSecurityLevelSendRequest send failed, ret is %{public}d", result);
return result;

View File

@ -20,6 +20,7 @@
#include "message_parcel.h"
#include "device_security_defines.h"
#include "utils_log.h"
namespace OHOS {
namespace Security {
@ -34,6 +35,11 @@ int32_t DslmCallbackProxy::ResponseDeviceSecurityLevel(uint32_t cookie, const Re
MessageParcel data;
MessageParcel reply;
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
SECURITY_LOG_ERROR("Remote is nullptr");
return ERR_INVALID_PARA;
}
if (!data.WriteInterfaceToken(GetDescriptor())) {
return ERR_INVALID_PARA;
}
@ -48,7 +54,7 @@ int32_t DslmCallbackProxy::ResponseDeviceSecurityLevel(uint32_t cookie, const Re
}
MessageOption ipcOption = {MessageOption::TF_ASYNC};
return Remote()->SendRequest(CMD_SET_DEVICE_SECURITY_LEVEL, data, reply, ipcOption);
return remote->SendRequest(CMD_SET_DEVICE_SECURITY_LEVEL, data, reply, ipcOption);
}
} // namespace DeviceSecurityLevel
} // namespace Security