diff --git a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h index 2e9637235a461b484c91b1992f9e5e426715b7d9..bcd973d0049ff898899112dbabeaba376ff95454 100644 --- a/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h +++ b/frameworks/enhance_adapter/include/sec_comp_enhance_adapter.h @@ -54,7 +54,7 @@ public: virtual int32_t CheckExtraInfo(const SecCompClickEvent& clickInfo) = 0; // send component info to enhance service for checking its validity - virtual int32_t CheckComponentInfoEnhnace(int32_t pid, std::shared_ptr& compInfo, + virtual int32_t CheckComponentInfoEnhance(int32_t pid, std::shared_ptr& compInfo, const nlohmann::json& jsonComponent) = 0; // get RemoteObject of enhance service to connect it @@ -71,6 +71,9 @@ public: // notify process registered virtual void AddSecurityComponentProcess(int32_t pid) = 0; + + virtual bool SerializeSessionInfoEnhance(MessageParcel& tmpReply, MessageParcel& reply) = 0; + virtual bool DeserializeSessionInfoEnhance(MessageParcel& data, MessageParcel& reply) = 0; }; // for client @@ -80,6 +83,10 @@ public: virtual bool EnhanceDataPreprocess(const uintptr_t caller, std::string& componentInfo) = 0; virtual bool EnhanceDataPreprocess(const uintptr_t caller, int32_t scId, std::string& componentInfo) = 0; + virtual bool EnhanceSerializeSessionInfo(const uintptr_t caller, + MessageParcel& tmpData, MessageParcel& data) = 0; + virtual bool EnhanceDeserializeSessionInfo(const uintptr_t caller, MessageParcel& data) = 0; + // regiter scid to enhance client virtual void RegisterScIdEnhance(const uintptr_t caller, int32_t scId) = 0; // unregiter scid to enhance client @@ -96,20 +103,24 @@ public: static int32_t CheckExtraInfo(const SecCompClickEvent& clickInfo); static int32_t EnableInputEnhance(); static int32_t DisableInputEnhance(); - static int32_t CheckComponentInfoEnhnace(int32_t pid, std::shared_ptr& compInfo, + static int32_t CheckComponentInfoEnhance(int32_t pid, std::shared_ptr& compInfo, const nlohmann::json& jsonComponent); static sptr GetEnhanceRemoteObject(); static void StartEnhanceService(); - static void ExistEnhanceService(); + static void ExitEnhanceService(); static void NotifyProcessDied(int32_t pid); static bool EnhanceDataPreprocess(std::string& componentInfo); static bool EnhanceDataPreprocess(int32_t scId, std::string& componentInfo); + static bool EnhanceSerializeSessionInfo(MessageParcel& tmpData, MessageParcel& data); + static bool EnhanceDeserializeSessionInfo(MessageParcel& data); static void RegisterScIdEnhance(int32_t scId); static void UnregisterScIdEnhance(int32_t scId); static void AddSecurityComponentProcess(int32_t pid); + static bool SerializeSessionInfoEnhance(MessageParcel& tmpReply, MessageParcel& reply); + static bool DeserializeSessionInfoEnhance(MessageParcel& data, MessageParcel& reply); static __attribute__((visibility("default"))) SecCompInputEnhanceInterface* inputHandler; static bool isEnhanceInputHandlerInit; diff --git a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp index 6dad7a1ced5cde1eb14565630412155f54a9b408..27ca8c20026e74a6718994ca22f9c517947335ab 100644 --- a/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp +++ b/frameworks/enhance_adapter/src/sec_comp_enhance_adapter.cpp @@ -15,8 +15,13 @@ #include "sec_comp_enhance_adapter.h" #include +#include + +#include "ipc_skeleton.h" +#include "parcel.h" #include "sec_comp_err.h" #include "sec_comp_log.h" +#include "securec.h" namespace OHOS { namespace Security { @@ -69,8 +74,24 @@ void SecCompEnhanceAdapter::InitEnhanceHandler(EnhanceInterfaceType type) default: break; } - if (dlopen(libPath.c_str(), RTLD_LAZY) == nullptr) { + + void* handler = dlopen(libPath.c_str(), RTLD_LAZY); + if (handler == nullptr) { SC_LOG_ERROR(LABEL, "init enhance lib %{public}s failed, error %{public}s", libPath.c_str(), dlerror()); + return; + } + if (type == SEC_COMP_ENHANCE_CLIENT_INTERFACE) { + SecCompClientEnhanceInterface* (*getClientInstance)(void) = + (SecCompClientEnhanceInterface* (*)(void))dlsym(handler, "GetClientInstance"); + if (getClientInstance == nullptr) { + SC_LOG_ERROR(LABEL, "GetClientInstance failed."); + return; + } + SecCompClientEnhanceInterface* instance = getClientInstance(); + if (instance != nullptr) { + SC_LOG_DEBUG(LABEL, "Dlopen client enhance successful."); + clientHandler = instance; + } } } @@ -144,6 +165,84 @@ bool SecCompEnhanceAdapter::EnhanceDataPreprocess(int32_t scId, std::string& com return true; } +static bool WriteMessageParcel(MessageParcel& tmpData, MessageParcel& data) +{ + size_t bufferLength = tmpData.GetDataSize(); + if (bufferLength < 0) { + SC_LOG_ERROR(LABEL, "TmpData is invalid."); + return false; + } + if (bufferLength == 0) { + SC_LOG_INFO(LABEL, "TmpData is empty."); + return true; + } + + char* buffer = reinterpret_cast(tmpData.GetData()); + if (buffer == nullptr) { + SC_LOG_ERROR(LABEL, "Get tmpData data failed."); + return false; + } + + if (!data.WriteBuffer(reinterpret_cast(buffer), bufferLength)) { + SC_LOG_ERROR(LABEL, "Write data failed."); + return false; + } + return true; +} + +bool SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(MessageParcel& tmpData, MessageParcel& data) +{ + if (!isEnhanceClientHandlerInit) { + InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE); + } + + uintptr_t enhanceCallerAddr = reinterpret_cast(__builtin_return_address(0)); + if (clientHandler != nullptr) { + return clientHandler->EnhanceSerializeSessionInfo(enhanceCallerAddr, tmpData, data); + } + + return WriteMessageParcel(tmpData, data); +} + +bool SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(MessageParcel& data) +{ + if (!isEnhanceClientHandlerInit) { + InitEnhanceHandler(SEC_COMP_ENHANCE_CLIENT_INTERFACE); + } + + uintptr_t enhanceCallerAddr = reinterpret_cast(__builtin_return_address(0)); + if (clientHandler != nullptr) { + return clientHandler->EnhanceDeserializeSessionInfo(enhanceCallerAddr, data); + } + + return true; +} + +bool SecCompEnhanceAdapter::SerializeSessionInfoEnhance(MessageParcel& tmpReply, MessageParcel& reply) +{ + if (!isEnhanceSrvHandlerInit) { + InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); + } + if (srvHandler != nullptr) { + return srvHandler->SerializeSessionInfoEnhance(tmpReply, reply); + } + + WriteMessageParcel(tmpReply, reply); + return true; +} + +bool SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(MessageParcel& data, MessageParcel& reply) +{ + if (!isEnhanceSrvHandlerInit) { + InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); + } + if (srvHandler != nullptr) { + return srvHandler->DeserializeSessionInfoEnhance(data, reply); + } + + return true; +} + void SecCompEnhanceAdapter::RegisterScIdEnhance(int32_t scId) { if (!isEnhanceClientHandlerInit) { @@ -200,7 +299,7 @@ void SecCompEnhanceAdapter::StartEnhanceService() } } -void SecCompEnhanceAdapter::ExistEnhanceService() +void SecCompEnhanceAdapter::ExitEnhanceService() { if (!isEnhanceSrvHandlerInit) { InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); @@ -220,14 +319,14 @@ void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid) } } -int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhnace(int32_t pid, +int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhance(int32_t pid, std::shared_ptr& compInfo, const nlohmann::json& jsonComponent) { if (!isEnhanceSrvHandlerInit) { InitEnhanceHandler(SEC_COMP_ENHANCE_SRV_INTERFACE); } if (srvHandler != nullptr) { - return srvHandler->CheckComponentInfoEnhnace(pid, compInfo, jsonComponent); + return srvHandler->CheckComponentInfoEnhance(pid, compInfo, jsonComponent); } return SC_OK; } diff --git a/frameworks/enhance_adapter/test/unittest/src/sec_comp_enhance_adapter_test.cpp b/frameworks/enhance_adapter/test/unittest/src/sec_comp_enhance_adapter_test.cpp index 73b957ebfecc55c883fb2c99d851b6aede5bf2c0..fde44e99bc36a4efcd585746e6cc23193647f197 100644 --- a/frameworks/enhance_adapter/test/unittest/src/sec_comp_enhance_adapter_test.cpp +++ b/frameworks/enhance_adapter/test/unittest/src/sec_comp_enhance_adapter_test.cpp @@ -87,7 +87,7 @@ HWTEST_F(SecCompEnhanceAdapterTest, EnhanceAdapter001, TestSize.Level1) SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; SecCompEnhanceAdapter::StartEnhanceService(); SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; - SecCompEnhanceAdapter::ExistEnhanceService(); + SecCompEnhanceAdapter::ExitEnhanceService(); SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; SecCompEnhanceAdapter::NotifyProcessDied(0); SecCompEnhanceAdapter::isEnhanceClientHandlerInit = false; @@ -97,7 +97,19 @@ HWTEST_F(SecCompEnhanceAdapterTest, EnhanceAdapter001, TestSize.Level1) SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; SecCompEnhanceAdapter::AddSecurityComponentProcess(0); SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; + + OHOS::MessageParcel tmpData; + OHOS::MessageParcel data; + OHOS::MessageParcel reply; + SecCompEnhanceAdapter::isEnhanceClientHandlerInit = false; + SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data); + SecCompEnhanceAdapter::isEnhanceClientHandlerInit = false; + SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(data); + SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; + SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpData, data); + SecCompEnhanceAdapter::isEnhanceSrvHandlerInit = false; + SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply); std::shared_ptr compInfo; const nlohmann::json jsonComponent; - ASSERT_EQ(SC_OK, SecCompEnhanceAdapter::CheckComponentInfoEnhnace(0, compInfo, jsonComponent)); + ASSERT_EQ(SC_OK, SecCompEnhanceAdapter::CheckComponentInfoEnhance(0, compInfo, jsonComponent)); } diff --git a/interfaces/inner_api/security_component/include/sec_comp_proxy.h b/interfaces/inner_api/security_component/include/sec_comp_proxy.h index f63496527e122afc07812dc82ff10d68142d67c6..5df62d5e99cd2a86db8375352d02da9e3d5cd64f 100644 --- a/interfaces/inner_api/security_component/include/sec_comp_proxy.h +++ b/interfaces/inner_api/security_component/include/sec_comp_proxy.h @@ -36,6 +36,7 @@ public: int32_t PreRegisterSecCompProcess() override; private: + int32_t SendReportClickEventRequest(MessageParcel& data); static inline BrokerDelegator delegator_; }; } // namespace SecurityComponent diff --git a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp index 6182d7a7e49474ff142c42d44425deaa108f1314..b0d5ae13d7b52a40c365400620ce7a9eb1c6f362 100644 --- a/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp +++ b/interfaces/inner_api/security_component/src/sec_comp_proxy.cpp @@ -15,6 +15,7 @@ #include "sec_comp_proxy.h" #include "sec_comp_click_event_parcel.h" +#include "sec_comp_enhance_adapter.h" #include "sec_comp_err.h" #include "sec_comp_log.h" @@ -34,18 +35,25 @@ SecCompProxy::~SecCompProxy() int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type, const std::string& componentInfo, int32_t& scId) { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Register write descriptor fail"); + SC_LOG_ERROR(LABEL, "Register write descriptor failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteUint32(type)) { - SC_LOG_ERROR(LABEL, "Register write Uint32 fail"); + if (!tmpData.WriteUint32(type)) { + SC_LOG_ERROR(LABEL, "Register write type failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Register write string fail"); + + if (!tmpData.WriteString(componentInfo)) { + SC_LOG_ERROR(LABEL, "Register write componentInfo failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Register serialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -53,24 +61,31 @@ int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type, MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Register remote service is null"); + SC_LOG_ERROR(LABEL, "Register remote service is null."); return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT), data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Register deserialize session info failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Register request fail, result: %{public}d", requestResult); + SC_LOG_ERROR(LABEL, "Register request failed, result: %{public}d.", requestResult); return requestResult; } + int32_t res; if (!reply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Register read result int32 fail"); + SC_LOG_ERROR(LABEL, "Register read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } if (!reply.ReadInt32(scId)) { - SC_LOG_ERROR(LABEL, "Register read scId int32 fail"); + SC_LOG_ERROR(LABEL, "Register read scId failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } return res; @@ -78,18 +93,24 @@ int32_t SecCompProxy::RegisterSecurityComponent(SecCompType type, int32_t SecCompProxy::UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Update write descriptor fail"); + SC_LOG_ERROR(LABEL, "Update write descriptor failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteInt32(scId)) { - SC_LOG_ERROR(LABEL, "Update write Int32 fail"); + if (!tmpData.WriteInt32(scId)) { + SC_LOG_ERROR(LABEL, "Update write scId failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Update write string fail"); + if (!tmpData.WriteString(componentInfo)) { + SC_LOG_ERROR(LABEL, "Update write componentInfo failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Update serialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -97,18 +118,25 @@ int32_t SecCompProxy::UpdateSecurityComponent(int32_t scId, const std::string& c MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Update remote update service is null"); + SC_LOG_ERROR(LABEL, "Update remote update service is null."); return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::UPDATE_SECURITY_COMPONENT), data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Update deserialize session info failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Update request fail, result: %{public}d", requestResult); + SC_LOG_ERROR(LABEL, "Update request failed, result: %{public}d.", requestResult); return requestResult; } + int32_t res; if (!reply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Update read result int32 fail"); + SC_LOG_ERROR(LABEL, "Update read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } return res; @@ -116,14 +144,20 @@ int32_t SecCompProxy::UpdateSecurityComponent(int32_t scId, const std::string& c int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId) { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Unregister write descriptor fail"); + SC_LOG_ERROR(LABEL, "Unregister write descriptor failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteInt32(scId)) { - SC_LOG_ERROR(LABEL, "Unregister write Int32 fail"); + if (!tmpData.WriteInt32(scId)) { + SC_LOG_ERROR(LABEL, "Unregister write scId failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Unregister serialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -131,19 +165,57 @@ int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId) MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Unregister remote service is null"); + SC_LOG_ERROR(LABEL, "Unregister remote service is null."); return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::UNREGISTER_SECURITY_COMPONENT), data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Unregister deserialize session info failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (requestResult != SC_OK) { + SC_LOG_ERROR(LABEL, "Unregister request failed, result: %{public}d.", requestResult); + return requestResult; + } + + int32_t res; + if (!reply.ReadInt32(res)) { + SC_LOG_ERROR(LABEL, "Unregister read res failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + return res; +} + +int32_t SecCompProxy::SendReportClickEventRequest(MessageParcel& data) +{ + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + sptr remote = Remote(); + if (remote == nullptr) { + SC_LOG_ERROR(LABEL, "Report remote service is null."); + return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; + } + int32_t requestResult = remote->SendRequest( + static_cast(SecurityComponentServiceInterfaceCode::REPORT_SECURITY_COMPONENT_CLICK_EVENT), + data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Report deserialize session info failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Unregister request fail, result: %{public}d", requestResult); + SC_LOG_ERROR(LABEL, "Report request failed, result: %{public}d.", requestResult); return requestResult; } + int32_t res; if (!reply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Unregister read int32 fail"); + SC_LOG_ERROR(LABEL, "Report read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } return res; @@ -152,70 +224,63 @@ int32_t SecCompProxy::UnregisterSecurityComponent(int32_t scId) int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, const SecCompClickEvent& clickInfo, sptr callerToken) { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Report write descriptor fail"); + SC_LOG_ERROR(LABEL, "Report write descriptor failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteInt32(scId)) { - SC_LOG_ERROR(LABEL, "Report write Uint32 fail"); + if (!tmpData.WriteInt32(scId)) { + SC_LOG_ERROR(LABEL, "Report write scId failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!data.WriteString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Report write string fail"); + if (!tmpData.WriteString(componentInfo)) { + SC_LOG_ERROR(LABEL, "Report write componentInfo failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } sptr parcel = new (std::nothrow) SecCompClickEventParcel(); if (parcel == nullptr) { - SC_LOG_ERROR(LABEL, "Report new click event parcel failed"); + SC_LOG_ERROR(LABEL, "Report new click event parcel failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } parcel->clickInfoParams_ = clickInfo; - if (!data.WriteParcelable(parcel)) { - SC_LOG_ERROR(LABEL, "Report write clickInfo fail"); + if (!tmpData.WriteParcelable(parcel)) { + SC_LOG_ERROR(LABEL, "Report write clickInfo failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } if ((callerToken != nullptr) && !data.WriteRemoteObject(callerToken)) { - SC_LOG_ERROR(LABEL, "Report write caller token fail"); + SC_LOG_ERROR(LABEL, "Report write caller token failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - MessageParcel reply; - MessageOption option(MessageOption::TF_SYNC); - sptr remote = Remote(); - if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Report remote service is null"); - return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; - } - int32_t requestResult = remote->SendRequest( - static_cast(SecurityComponentServiceInterfaceCode::REPORT_SECURITY_COMPONENT_CLICK_EVENT), - data, reply, option); - if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Report request fail, result: %{public}d", requestResult); - return requestResult; - } - int32_t res; - if (!reply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "Report read int32 fail"); + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Report serialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - return res; + + return SendReportClickEventRequest(data); } bool SecCompProxy::VerifySavePermission(AccessToken::AccessTokenID tokenId) { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Verify write descriptor fail"); + SC_LOG_ERROR(LABEL, "Verify write descriptor failed."); + return false; + } + + if (!tmpData.WriteUint32(tokenId)) { + SC_LOG_ERROR(LABEL, "Verify write tokenId failed."); return false; } - if (!data.WriteUint32(tokenId)) { - SC_LOG_ERROR(LABEL, "Verify write Uint32 fail"); + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Verify serialize session info failed."); return false; } @@ -223,19 +288,26 @@ bool SecCompProxy::VerifySavePermission(AccessToken::AccessTokenID tokenId) MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Verify remote service is null"); + SC_LOG_ERROR(LABEL, "Verify remote service is null."); return false; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::VERIFY_TEMP_SAVE_PERMISSION), data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Verify deserialize session info failed."); + return false; + } + if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Verify request fail, result: %{public}d", requestResult); + SC_LOG_ERROR(LABEL, "Verify request failed, result: %{public}d.", requestResult); return false; } + bool res; if (!reply.ReadBool(res)) { - SC_LOG_ERROR(LABEL, "Verify read bool fail"); + SC_LOG_ERROR(LABEL, "Verify read res failed."); return false; } return res; @@ -243,9 +315,15 @@ bool SecCompProxy::VerifySavePermission(AccessToken::AccessTokenID tokenId) sptr SecCompProxy::GetEnhanceRemoteObject() { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "Get enhance write descriptor fail"); + SC_LOG_ERROR(LABEL, "Get enhance write descriptor failed."); + return nullptr; + } + + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "Get enhance serialize session info failed."); return nullptr; } @@ -253,28 +331,41 @@ sptr SecCompProxy::GetEnhanceRemoteObject() MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "Get enhance remote service is null"); + SC_LOG_ERROR(LABEL, "Get enhance remote service is null."); return nullptr; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::GET_SECURITY_COMPONENT_ENHANCE_OBJECT), data, reply, option); - if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "Get enhance request fail, result: %{public}d", requestResult); - return nullptr; - } - sptr callback = reply.ReadRemoteObject(); - if (callback == nullptr) { - SC_LOG_ERROR(LABEL, "Get enhance read remote object fail"); - } + + sptr callback; + if (requestResult == SC_OK) { + callback = reply.ReadRemoteObject(); + if (callback == nullptr) { + SC_LOG_ERROR(LABEL, "Get enhance read callback failed."); + } + } else { + SC_LOG_ERROR(LABEL, "Get enhance request failed, result: %{public}d.", requestResult); + } + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "Get enhance deserialize session info failed."); + } + return callback; } int32_t SecCompProxy::PreRegisterSecCompProcess() { + MessageParcel tmpData; MessageParcel data; if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) { - SC_LOG_ERROR(LABEL, "PreRegister write descriptor fail"); + SC_LOG_ERROR(LABEL, "PreRegister write descriptor failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(tmpData, data)) { + SC_LOG_ERROR(LABEL, "PreRegister serialize session info failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -282,19 +373,26 @@ int32_t SecCompProxy::PreRegisterSecCompProcess() MessageOption option(MessageOption::TF_SYNC); sptr remote = Remote(); if (remote == nullptr) { - SC_LOG_ERROR(LABEL, "PreRegister remote service is null"); + SC_LOG_ERROR(LABEL, "PreRegister remote service is null."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } int32_t requestResult = remote->SendRequest( static_cast(SecurityComponentServiceInterfaceCode::PRE_REGISTER_PROCESS), data, reply, option); + + if (!SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(reply)) { + SC_LOG_ERROR(LABEL, "PreRegister deserialize session info failed."); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + if (requestResult != SC_OK) { - SC_LOG_ERROR(LABEL, "PreRegister request fail, result: %{public}d", requestResult); + SC_LOG_ERROR(LABEL, "PreRegister request failed, result: %{public}d.", requestResult); return requestResult; } + int32_t res; if (!reply.ReadInt32(res)) { - SC_LOG_ERROR(LABEL, "PreRegister read int32 fail"); + SC_LOG_ERROR(LABEL, "PreRegister read res failed."); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } return res; diff --git a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp index 4c82ffc13a6121d092f9fff5b9818f6fa2a19715..c2cb804603f2f9325be47fa235ba776e108f99a5 100644 --- a/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp +++ b/interfaces/inner_api/security_component/test/unittest/src/sec_comp_kit_test.cpp @@ -189,9 +189,9 @@ HWTEST_F(SecCompKitTest, RegisterWithoutCallback001, TestSize.Level1) int32_t scId; #ifdef SECURITY_COMPONENT_ENHANCE_ENABLE - ASSERT_EQ(SC_ENHANCE_ERROR_CALLBACK_NOT_EXIST, + ASSERT_EQ(SC_ENHANCE_ERROR_VALUE_INVALID, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); - ASSERT_EQ(-1, scId); + ASSERT_EQ(0, scId); #else ASSERT_EQ(SC_OK, SecCompKit::RegisterSecurityComponent(LOCATION_COMPONENT, locationInfo, scId)); diff --git a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp index 3a4a85151e745a76a299f1beb962068ff9f41fae..7e4d348554384a61b407a540cd7900283baa721f 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_manager.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_manager.cpp @@ -235,7 +235,7 @@ void SecCompManager::ExitSaProcess() isSaExit_ = true; SecCompEnhanceAdapter::DisableInputEnhance(); - SecCompEnhanceAdapter::ExistEnhanceService(); + SecCompEnhanceAdapter::ExitEnhanceService(); SC_LOG_INFO(LABEL, "All processes using security component died, start sa exit"); auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); @@ -338,7 +338,7 @@ int32_t SecCompManager::RegisterSecurityComponent(SecCompType type, } int32_t enhanceRes = - SecCompEnhanceAdapter::CheckComponentInfoEnhnace(caller.pid, component, jsonComponent); + SecCompEnhanceAdapter::CheckComponentInfoEnhance(caller.pid, component, jsonComponent); if (enhanceRes != SC_OK) { SendCheckInfoEnhanceSysEvent(INVALID_SC_ID, type, "REGISTER", enhanceRes); SC_LOG_ERROR(LABEL, "enhance check failed"); @@ -385,7 +385,7 @@ int32_t SecCompManager::UpdateSecurityComponent(int32_t scId, const nlohmann::js } int32_t enhanceRes = - SecCompEnhanceAdapter::CheckComponentInfoEnhnace(caller.pid, reportComponentInfo, jsonComponent); + SecCompEnhanceAdapter::CheckComponentInfoEnhance(caller.pid, reportComponentInfo, jsonComponent); if (enhanceRes != SC_OK) { SendCheckInfoEnhanceSysEvent(scId, sc->GetType(), "UPDATE", enhanceRes); SC_LOG_ERROR(LABEL, "enhance check failed"); @@ -430,7 +430,7 @@ int32_t SecCompManager::CheckClickSecurityComponentInfo(SecCompEntity* sc, int32 return SC_SERVICE_ERROR_COMPONENT_INFO_INVALID; } int32_t enhanceRes = - SecCompEnhanceAdapter::CheckComponentInfoEnhnace(caller.pid, reportComponentInfo, jsonComponent); + SecCompEnhanceAdapter::CheckComponentInfoEnhance(caller.pid, reportComponentInfo, jsonComponent); if (enhanceRes != SC_OK) { SendCheckInfoEnhanceSysEvent(scId, sc->GetType(), "CLICK", enhanceRes); SC_LOG_ERROR(LABEL, "enhance check failed"); diff --git a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp index 417e512199979f6403408d53c7ef0352b87e117e..9ce1b970c8626df4e36cc73318b185c731f4ff09 100644 --- a/services/security_component_service/sa/sa_main/sec_comp_stub.cpp +++ b/services/security_component_service/sa/sa_main/sec_comp_stub.cpp @@ -17,6 +17,7 @@ #include "accesstoken_kit.h" #include "ipc_skeleton.h" #include "sec_comp_click_event_parcel.h" +#include "sec_comp_enhance_adapter.h" #include "sec_comp_err.h" #include "sec_comp_log.h" @@ -35,7 +36,7 @@ int32_t SecCompStub::OnRemoteRequest( std::u16string descripter = SecCompStub::GetDescriptor(); std::u16string remoteDescripter = data.ReadInterfaceToken(); if (descripter != remoteDescripter) { - SC_LOG_ERROR(LABEL, "Deal remote request fail, descriptor is not matched"); + SC_LOG_ERROR(LABEL, "Deal remote request failed, descriptor is not matched"); return SC_SERVICE_ERROR_IPC_REQUEST_FAIL; } @@ -51,9 +52,13 @@ int32_t SecCompStub::OnRemoteRequest( int32_t SecCompStub::RegisterSecurityComponentInner(MessageParcel& data, MessageParcel& reply) { + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Register deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } uint32_t type; if (!data.ReadUint32(type)) { - SC_LOG_ERROR(LABEL, "Register read component type fail"); + SC_LOG_ERROR(LABEL, "Register read component type failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -64,19 +69,25 @@ int32_t SecCompStub::RegisterSecurityComponentInner(MessageParcel& data, Message std::string componentInfo; if (!data.ReadString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Register read component info fail"); + SC_LOG_ERROR(LABEL, "Register read component info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } int32_t scId = INVALID_SC_ID; int32_t res = this->RegisterSecurityComponent(static_cast(type), componentInfo, scId); - if (!reply.WriteInt32(res)) { - SC_LOG_ERROR(LABEL, "Register security component result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "Register security component result failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - if (!reply.WriteInt32(scId)) { - SC_LOG_ERROR(LABEL, "Register security component result fail"); + if (!tmpReply.WriteInt32(scId)) { + SC_LOG_ERROR(LABEL, "Register security component result failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Register serialize session info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -85,9 +96,13 @@ int32_t SecCompStub::RegisterSecurityComponentInner(MessageParcel& data, Message int32_t SecCompStub::UpdateSecurityComponentInner(MessageParcel& data, MessageParcel& reply) { + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Update deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } int32_t scId; if (!data.ReadInt32(scId)) { - SC_LOG_ERROR(LABEL, "Update read component id fail"); + SC_LOG_ERROR(LABEL, "Update read component id failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -98,13 +113,19 @@ int32_t SecCompStub::UpdateSecurityComponentInner(MessageParcel& data, MessagePa std::string componentInfo; if (!data.ReadString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Update read component info fail"); + SC_LOG_ERROR(LABEL, "Update read component info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } int32_t res = this->UpdateSecurityComponent(scId, componentInfo); - if (!reply.WriteInt32(res)) { - SC_LOG_ERROR(LABEL, "Update security component result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "Update security component result failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Update serialize session info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -113,9 +134,13 @@ int32_t SecCompStub::UpdateSecurityComponentInner(MessageParcel& data, MessagePa int32_t SecCompStub::UnregisterSecurityComponentInner(MessageParcel& data, MessageParcel& reply) { + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Unreigster deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } int32_t scId; if (!data.ReadInt32(scId)) { - SC_LOG_ERROR(LABEL, "Unreigster read component id fail"); + SC_LOG_ERROR(LABEL, "Unreigster read component id failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -125,18 +150,35 @@ int32_t SecCompStub::UnregisterSecurityComponentInner(MessageParcel& data, Messa } int32_t res = this->UnregisterSecurityComponent(scId); - if (!reply.WriteInt32(res)) { - SC_LOG_ERROR(LABEL, "Unregister security component result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "Unregister security component result failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Unreigster serialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + return SC_OK; } int32_t SecCompStub::ReportSecurityComponentClickEventInner(MessageParcel& data, MessageParcel& reply) { + sptr callerToken = data.ReadRemoteObject(); + if (callerToken == nullptr) { + SC_LOG_ERROR(LABEL, "callerToken is nullptr"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Report deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } int32_t scId; if (!data.ReadInt32(scId)) { - SC_LOG_ERROR(LABEL, "Report read component id fail"); + SC_LOG_ERROR(LABEL, "Report read component id failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -147,26 +189,28 @@ int32_t SecCompStub::ReportSecurityComponentClickEventInner(MessageParcel& data, std::string componentInfo; if (!data.ReadString(componentInfo)) { - SC_LOG_ERROR(LABEL, "Report read component info fail"); + SC_LOG_ERROR(LABEL, "Report read component info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } sptr clickInfoParcel = data.ReadParcelable(); if (clickInfoParcel == nullptr) { - SC_LOG_ERROR(LABEL, "Report read clickInfo info fail"); + SC_LOG_ERROR(LABEL, "Report read clickInfo info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } - sptr callerToken = data.ReadRemoteObject(); - if (callerToken == nullptr) { - SC_LOG_ERROR(LABEL, "callerToken is nullptr"); - return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; - } int32_t res = this->ReportSecurityComponentClickEvent(scId, componentInfo, clickInfoParcel->clickInfoParams_, callerToken); - if (!reply.WriteInt32(res)) { - SC_LOG_ERROR(LABEL, "Report security component result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "Report security component result failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Report serialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + return SC_OK; } @@ -176,9 +220,13 @@ int32_t SecCompStub::VerifySavePermissionInner(MessageParcel& data, MessageParce SC_LOG_ERROR(LABEL, "Not medialibrary called"); return SC_SERVICE_ERROR_CALLER_INVALID; } + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Verify deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } uint32_t tokenId; if (!data.ReadUint32(tokenId)) { - SC_LOG_ERROR(LABEL, "Verify read component id fail"); + SC_LOG_ERROR(LABEL, "Verify read component id failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } @@ -188,30 +236,59 @@ int32_t SecCompStub::VerifySavePermissionInner(MessageParcel& data, MessageParce } bool res = this->VerifySavePermission(tokenId); - if (!reply.WriteBool(res)) { - SC_LOG_ERROR(LABEL, "Verify temp save permission result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteBool(res)) { + SC_LOG_ERROR(LABEL, "Verify temp save permission result failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Verify serialize session info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + return SC_OK; } int32_t SecCompStub::GetEnhanceRemoteObjectInner(MessageParcel& data, MessageParcel& reply) { + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "Get remote obj deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } auto res = this->GetEnhanceRemoteObject(); + MessageParcel tmpReply; if (!reply.WriteRemoteObject(res)) { - SC_LOG_ERROR(LABEL, "Security component enhance remote object fail"); + SC_LOG_ERROR(LABEL, "Security component enhance remote object failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "Get remote obj serialize session info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + return SC_OK; } int32_t SecCompStub::PreRegisterSecCompProcessInner(MessageParcel& data, MessageParcel& reply) { + if (!SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(data, reply)) { + SC_LOG_ERROR(LABEL, "preRegister deserialize session info failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } int32_t res = this->PreRegisterSecCompProcess(); - if (!reply.WriteInt32(res)) { - SC_LOG_ERROR(LABEL, "preRegister write result fail"); + MessageParcel tmpReply; + if (!tmpReply.WriteInt32(res)) { + SC_LOG_ERROR(LABEL, "preRegister write result failed"); + return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; + } + + if (!SecCompEnhanceAdapter::SerializeSessionInfoEnhance(tmpReply, reply)) { + SC_LOG_ERROR(LABEL, "preRegister serialize session info failed"); return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL; } + return SC_OK; } diff --git a/services/security_component_service/sa/test/BUILD.gn b/services/security_component_service/sa/test/BUILD.gn index 27fbbeccb3abe446dd8562564f695566c930b3d1..e599b588ad9c1e8216cc43d58344138a74b0abea 100644 --- a/services/security_component_service/sa/test/BUILD.gn +++ b/services/security_component_service/sa/test/BUILD.gn @@ -127,6 +127,7 @@ ohos_unittest("sec_comp_service_mock_test") { "${sec_comp_root_dir}/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp", "unittest/src/first_use_dialog_test.cpp", "unittest/src/sec_comp_service_mock_test.cpp", + "unittest/src/sec_comp_stub_mock_test.cpp", "unittest/src/service_test_common.cpp", ] diff --git a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp index 594d42a8953650b57a2e6566d2eea4095b2626ff..4ef5141efc9815f78f051f918060bedf35db481d 100644 --- a/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp +++ b/services/security_component_service/sa/test/mock/src/sec_comp_enhance_adapter.cpp @@ -68,6 +68,60 @@ bool SecCompEnhanceAdapter::EnhanceDataPreprocess(int32_t scId, std::string& com return true; } +static bool WriteMessageParcel(MessageParcel& tmpData, MessageParcel& data) +{ + size_t bufferLength = tmpData.GetDataSize(); + if (bufferLength < 0) { + SC_LOG_ERROR(LABEL, "TmpData is invalid."); + return false; + } + if (bufferLength == 0) { + SC_LOG_INFO(LABEL, "TmpData is empty."); + return true; + } + + char* buffer = reinterpret_cast(tmpData.GetData()); + if (buffer == nullptr) { + SC_LOG_ERROR(LABEL, "Get tmpData data failed."); + } + + if (!data.WriteBuffer(reinterpret_cast(buffer), bufferLength)) { + SC_LOG_ERROR(LABEL, "Write data failed."); + return false; + } + return true; +} + +bool SecCompEnhanceAdapter::EnhanceSerializeSessionInfo(MessageParcel& tmpData, MessageParcel& data) +{ + if (!WriteMessageParcel(tmpData, data)) { + return false; + } + SC_LOG_DEBUG(LABEL, "EnhanceSerializeSessionInfo successful."); + return true; +} + +bool SecCompEnhanceAdapter::EnhanceDeserializeSessionInfo(MessageParcel& data) +{ + SC_LOG_DEBUG(LABEL, "EnhanceDeserializeSessionInfo successful."); + return true; +} + +bool SecCompEnhanceAdapter::SerializeSessionInfoEnhance(MessageParcel& tmpReply, MessageParcel& reply) +{ + if (!WriteMessageParcel(tmpReply, reply)) { + return false; + } + SC_LOG_DEBUG(LABEL, "SerializeSessionInfoEnhance successful."); + return true; +} + +bool SecCompEnhanceAdapter::DeserializeSessionInfoEnhance(MessageParcel& data, MessageParcel& reply) +{ + SC_LOG_DEBUG(LABEL, "DeserializeSessionInfoEnhance successful."); + return true; +} + void SecCompEnhanceAdapter::RegisterScIdEnhance(int32_t scId) { SC_LOG_DEBUG(LABEL, "RegisterScIdEnhance success"); @@ -83,9 +137,9 @@ void SecCompEnhanceAdapter::StartEnhanceService() SC_LOG_DEBUG(LABEL, "StartEnhanceService success"); } -void SecCompEnhanceAdapter::ExistEnhanceService() +void SecCompEnhanceAdapter::ExitEnhanceService() { - SC_LOG_DEBUG(LABEL, "ExistEnhanceService success"); + SC_LOG_DEBUG(LABEL, "ExitEnhanceService success"); } void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid) @@ -93,10 +147,10 @@ void SecCompEnhanceAdapter::NotifyProcessDied(int32_t pid) SC_LOG_DEBUG(LABEL, "NotifyProcessDied success"); } -int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhnace(int32_t pid, +int32_t SecCompEnhanceAdapter::CheckComponentInfoEnhance(int32_t pid, std::shared_ptr& compInfo, const nlohmann::json& jsonComponent) { - SC_LOG_DEBUG(LABEL, "CheckComponentInfoEnhnace success"); + SC_LOG_DEBUG(LABEL, "CheckComponentInfoEnhance success"); return SC_OK; } diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6491b6856d0f75d520a7ac424e70946d12fb4a20 --- /dev/null +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.cpp @@ -0,0 +1,251 @@ +/* + * Copyright (c) 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 + * + * 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 "sec_comp_stub_mock_test.h" + +#include "sec_comp_log.h" +#include "sec_comp_err.h" +#include "sec_comp_click_event_parcel.h" +#include "service_test_common.h" + +using namespace testing::ext; +using namespace OHOS; +using namespace OHOS::Security::SecurityComponent; + +namespace { +static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { + LOG_CORE, SECURITY_DOMAIN_SECURITY_COMPONENT, "SecCompStubMockTest"}; +} + +void SecCompStubMockTest::SetUpTestCase() +{} + +void SecCompStubMockTest::TearDownTestCase() +{} + +void SecCompStubMockTest::SetUp() +{ + SC_LOG_INFO(LABEL, "setup"); + if (stub_ != nullptr) { + return; + } + + stub_ = new (std::nothrow) SecCompStubMock(); + ASSERT_NE(nullptr, stub_); +} + +void SecCompStubMockTest::TearDown() +{ + stub_ = nullptr; +} + +/** + * @tc.name: OnRemoteRequestMock001 + * @tc.desc: Test on remote request + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, OnRemoteRequestMock001, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + + data.WriteInterfaceToken(u"wrong"); + ASSERT_EQ(SC_SERVICE_ERROR_IPC_REQUEST_FAIL, stub_->OnRemoteRequest(static_cast( + SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT), data, reply, option)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInterfaceToken(u"ohos.security.ISecCompService"); + ASSERT_EQ(305, stub_->OnRemoteRequest(1000, data, reply, option)); +} + +/** + * @tc.name: RegisterSecurityComponentInnerMock001 + * @tc.desc: Test register security component + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, RegisterSecurityComponentInnerMock001, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->RegisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteUint32(UNKNOWN_SC_TYPE); + ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->RegisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteUint32(MAX_SC_TYPE); + ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->RegisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteUint32(LOCATION_COMPONENT); + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->RegisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteUint32(LOCATION_COMPONENT); + data.WriteString(""); + ASSERT_EQ(SC_OK, stub_->RegisterSecurityComponentInner(data, reply)); +} + +/** + * @tc.name: UpdateSecurityComponentInnerMock001 + * @tc.desc: Test update security component + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, UpdateSecurityComponentInnerMock001, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UpdateSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInt32(-1); + ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->UpdateSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInt32(1); + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UpdateSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInt32(1); + data.WriteString(""); + ASSERT_EQ(SC_OK, stub_->UpdateSecurityComponentInner(data, reply)); +} + +/** + * @tc.name: UnregisterSecurityComponentInnerMock001 + * @tc.desc: Test unregister security component + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, UnregisterSecurityComponentInnerMock001, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UnregisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInt32(-1); + ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->UnregisterSecurityComponentInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + + data.WriteInt32(1); + ASSERT_EQ(SC_OK, stub_->UnregisterSecurityComponentInner(data, reply)); +} + +/** + * @tc.name: VerifySavePermissionInnerMock001 + * @tc.desc: Test VerifySavePermissionInner + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, VerifySavePermissionInnerMock001, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + setuid(0); + ASSERT_TRUE(stub_->IsMediaLibraryCalling()); + ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->VerifySavePermissionInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + data.WriteInt32(0); + ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->VerifySavePermissionInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + data.WriteInt32(1); + ASSERT_EQ(SC_OK, stub_->VerifySavePermissionInner(data, reply)); + ASSERT_NE(SC_OK, stub_->GetEnhanceRemoteObjectInner(data, reply)); +} + +/** + * @tc.name: MarshallingMock001 + * @tc.desc: Test SecCompClickEventParcel::Marshalling + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, MarshallingMock001, TestSize.Level1) +{ + sptr clickParcel = new (std::nothrow) SecCompClickEventParcel(); + Parcel out; + EXPECT_FALSE(clickParcel->Marshalling(out)); + clickParcel->clickInfoParams_.type = ClickEventType::UNKNOWN_EVENT_TYPE; + EXPECT_FALSE(clickParcel->Marshalling(out)); + + clickParcel->clickInfoParams_.extraInfo.dataSize = 1; + clickParcel->clickInfoParams_.type = ClickEventType::POINT_EVENT_TYPE; + EXPECT_FALSE(clickParcel->Marshalling(out)); + clickParcel->clickInfoParams_.type = ClickEventType::KEY_EVENT_TYPE; + EXPECT_FALSE(clickParcel->Marshalling(out)); + + uint8_t data[32] = {0}; + clickParcel->clickInfoParams_.extraInfo.dataSize = 32; + clickParcel->clickInfoParams_.extraInfo.data = data; + EXPECT_TRUE(clickParcel->Marshalling(out)); +} + +/** + * @tc.name: UnmarshallingMock001 + * @tc.desc: Test SecCompClickEventParcel::Unmarshalling + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(SecCompStubMockTest, UnmarshallingMock001, TestSize.Level1) +{ + sptr clickParcel = new (std::nothrow) SecCompClickEventParcel(); + Parcel in; + in.WriteInt32(1); + EXPECT_EQ(nullptr, clickParcel->Unmarshalling(in)); + in.WriteInt32(2); + EXPECT_EQ(nullptr, clickParcel->Unmarshalling(in)); + in.WriteInt32(0); + EXPECT_EQ(nullptr, clickParcel->Unmarshalling(in)); + + in.WriteInt32(2); + in.WriteUint64(1); + in.WriteInt32(1); + int dataSize = MAX_EXTRA_SIZE + 1; + in.WriteUint32(dataSize); + EXPECT_EQ(nullptr, clickParcel->Unmarshalling(in)); + + in.WriteInt32(2); + in.WriteUint64(1); + in.WriteInt32(1); + in.WriteUint32(1); + EXPECT_EQ(nullptr, clickParcel->Unmarshalling(in)); + + in.WriteInt32(2); + in.WriteUint64(1); + in.WriteInt32(1); + in.WriteUint32(32); + uint8_t data[32] = {0}; + in.WriteBuffer(data, 32); + EXPECT_NE(nullptr, clickParcel->Unmarshalling(in)); +} diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h new file mode 100644 index 0000000000000000000000000000000000000000..03a6862c5cc783b64ed846f78c9ccd4122f0547f --- /dev/null +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_mock_test.h @@ -0,0 +1,83 @@ +/* + * Copyright (c) 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 + * + * 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 SEC_COMP_STUB_MOCK_TEST_H +#define SEC_COMP_STUB_MOCK_TEST_H + +#include +#define private public +#include "sec_comp_stub.h" +#undef private + +namespace OHOS { +namespace Security { +namespace SecurityComponent { +// stub is abstract class +struct SecCompStubMock : public SecCompStub { +public: + int32_t RegisterSecurityComponent(SecCompType type, + const std::string& componentInfo, int32_t& scId) override + { + return 0; + }; + + int32_t UpdateSecurityComponent(int32_t scId, const std::string& componentInfo) override + { + return 0; + }; + + int32_t UnregisterSecurityComponent(int32_t scId) override + { + return 0; + }; + + int32_t ReportSecurityComponentClickEvent(int32_t scId, const std::string& componentInfo, + const SecCompClickEvent& clickInfo, sptr callerToken) override + { + return 0; + }; + + bool VerifySavePermission(AccessToken::AccessTokenID tokenId) override + { + return true; + }; + + sptr GetEnhanceRemoteObject() override + { + return nullptr; + }; + + int32_t PreRegisterSecCompProcess() override + { + return 0; + }; +}; + +class SecCompStubMockTest : public testing::Test { +public: + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); + + sptr stub_ = nullptr; +}; +} // namespace SecurityComponent +} // namespace Security +} // namespace OHOS +#endif // SEC_COMP_STUB_MOCK_TEST_H diff --git a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp index 87bb4af0c7cdfc1fd9e7ef196d74e2109625ee90..78425bb2a3a4e8fc24af99658b2fecf2ab89aace 100644 --- a/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp +++ b/services/security_component_service/sa/test/unittest/src/sec_comp_stub_test.cpp @@ -66,10 +66,8 @@ HWTEST_F(SecCompStubTest, OnRemoteRequest001, TestSize.Level1) data.WriteInterfaceToken(u"wrong"); ASSERT_EQ(SC_SERVICE_ERROR_IPC_REQUEST_FAIL, stub_->OnRemoteRequest(static_cast( SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT), data, reply, option)); - - data.WriteInterfaceToken(u"ohos.security.ISecCompService"); - ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->OnRemoteRequest(static_cast( - SecurityComponentServiceInterfaceCode::REGISTER_SECURITY_COMPONENT), data, reply, option)); + data.FlushBuffer(); + reply.FlushBuffer(); data.WriteInterfaceToken(u"ohos.security.ISecCompService"); ASSERT_EQ(305, stub_->OnRemoteRequest(1000, data, reply, option)); @@ -87,19 +85,6 @@ HWTEST_F(SecCompStubTest, RegisterSecurityComponentInner001, TestSize.Level1) MessageParcel reply; ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->RegisterSecurityComponentInner(data, reply)); - - data.WriteUint32(UNKNOWN_SC_TYPE); - ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->RegisterSecurityComponentInner(data, reply)); - - data.WriteUint32(MAX_SC_TYPE); - ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->RegisterSecurityComponentInner(data, reply)); - - data.WriteUint32(LOCATION_COMPONENT); - ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->RegisterSecurityComponentInner(data, reply)); - - data.WriteUint32(LOCATION_COMPONENT); - data.WriteString(""); - ASSERT_EQ(SC_OK, stub_->RegisterSecurityComponentInner(data, reply)); } /** @@ -114,16 +99,6 @@ HWTEST_F(SecCompStubTest, UpdateSecurityComponentInner001, TestSize.Level1) MessageParcel reply; ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UpdateSecurityComponentInner(data, reply)); - - data.WriteInt32(-1); - ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->UpdateSecurityComponentInner(data, reply)); - - data.WriteInt32(1); - ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UpdateSecurityComponentInner(data, reply)); - - data.WriteInt32(1); - data.WriteString(""); - ASSERT_EQ(SC_OK, stub_->UpdateSecurityComponentInner(data, reply)); } /** @@ -137,12 +112,6 @@ HWTEST_F(SecCompStubTest, UnregisterSecurityComponentInner001, TestSize.Level1) MessageParcel data; MessageParcel reply; ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->UnregisterSecurityComponentInner(data, reply)); - - data.WriteInt32(-1); - ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->UnregisterSecurityComponentInner(data, reply)); - - data.WriteInt32(1); - ASSERT_EQ(SC_OK, stub_->UnregisterSecurityComponentInner(data, reply)); } /** @@ -156,17 +125,30 @@ HWTEST_F(SecCompStubTest, ReportSecurityComponentClickEventInner001, TestSize.Le MessageParcel data; MessageParcel reply; ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->ReportSecurityComponentClickEventInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + auto token = std::make_shared(); + data.WriteRemoteObject(token->AsObject()); data.WriteInt32(-1); ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->ReportSecurityComponentClickEventInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + data.WriteRemoteObject(token->AsObject()); data.WriteInt32(1); ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->ReportSecurityComponentClickEventInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + data.WriteRemoteObject(token->AsObject()); data.WriteInt32(1); data.WriteString(""); ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->ReportSecurityComponentClickEventInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); + data.WriteRemoteObject(token->AsObject()); data.WriteInt32(1); data.WriteString(""); SecCompClickEvent clickInfo; @@ -174,8 +156,6 @@ HWTEST_F(SecCompStubTest, ReportSecurityComponentClickEventInner001, TestSize.Le sptr parcel = new (std::nothrow) SecCompClickEventParcel(); parcel->clickInfoParams_ = clickInfo; data.WriteParcelable(parcel); - auto token = std::make_shared(); - data.WriteRemoteObject(token->AsObject()); ASSERT_EQ(SC_OK, stub_->ReportSecurityComponentClickEventInner(data, reply)); } @@ -192,11 +172,10 @@ HWTEST_F(SecCompStubTest, VerifySavePermissionInner001, TestSize.Level1) setuid(0); ASSERT_TRUE(stub_->IsMediaLibraryCalling()); ASSERT_EQ(SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL, stub_->VerifySavePermissionInner(data, reply)); + data.FlushBuffer(); + reply.FlushBuffer(); data.WriteInt32(0); ASSERT_EQ(SC_SERVICE_ERROR_VALUE_INVALID, stub_->VerifySavePermissionInner(data, reply)); - data.WriteInt32(1); - ASSERT_EQ(SC_OK, stub_->VerifySavePermissionInner(data, reply)); - ASSERT_NE(SC_OK, stub_->GetEnhanceRemoteObjectInner(data, reply)); } /**