!178 remove serialize and deserialize for VerifySavePermission

Merge pull request !178 from baoyang/VSP
This commit is contained in:
openharmony_ci
2024-08-20 05:16:22 +00:00
committed by Gitee
2 changed files with 4 additions and 30 deletions
@@ -283,25 +283,17 @@ int32_t SecCompProxy::ReportSecurityComponentClickEvent(int32_t scId,
bool SecCompProxy::VerifySavePermission(AccessToken::AccessTokenID tokenId)
{
std::lock_guard<std::mutex> lock(useIPCMutex_);
MessageParcel rawData;
MessageParcel data;
if (!data.WriteInterfaceToken(SecCompProxy::GetDescriptor())) {
SC_LOG_ERROR(LABEL, "Verify write descriptor failed.");
return false;
}
if (!rawData.WriteUint32(tokenId)) {
if (!data.WriteUint32(tokenId)) {
SC_LOG_ERROR(LABEL, "Verify write tokenId failed.");
return false;
}
if (!SecCompEnhanceAdapter::EnhanceClientSerialize(rawData, data)) {
SC_LOG_ERROR(LABEL, "Verify serialize session info failed.");
return false;
}
MessageParcel reply;
MessageParcel deserializedReply;
MessageOption option(MessageOption::TF_SYNC);
sptr<IRemoteObject> remote = Remote();
if (remote == nullptr) {
@@ -311,19 +303,12 @@ bool SecCompProxy::VerifySavePermission(AccessToken::AccessTokenID tokenId)
int32_t requestResult = remote->SendRequest(
static_cast<uint32_t>(SecurityComponentServiceInterfaceCode::VERIFY_TEMP_SAVE_PERMISSION),
data, reply, option);
if (!SecCompEnhanceAdapter::EnhanceClientDeserialize(reply, deserializedReply)) {
SC_LOG_ERROR(LABEL, "Verify deserialize session info failed.");
return false;
}
if (requestResult != SC_OK) {
SC_LOG_ERROR(LABEL, "Verify request failed, result: %{public}d.", requestResult);
return false;
}
bool res;
if (!deserializedReply.ReadBool(res)) {
if (!reply.ReadBool(res)) {
SC_LOG_ERROR(LABEL, "Verify read res failed.");
return false;
}
@@ -232,13 +232,8 @@ int32_t SecCompStub::VerifySavePermissionInner(MessageParcel& data, MessageParce
SC_LOG_ERROR(LABEL, "Not medialibrary called");
return SC_SERVICE_ERROR_CALLER_INVALID;
}
MessageParcel deserializedData;
if (!SecCompEnhanceAdapter::EnhanceSrvDeserialize(data, deserializedData, reply)) {
SC_LOG_ERROR(LABEL, "Verify deserialize session info failed");
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
}
uint32_t tokenId;
if (!deserializedData.ReadUint32(tokenId)) {
if (!data.ReadUint32(tokenId)) {
SC_LOG_ERROR(LABEL, "Verify read component id failed");
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
}
@@ -249,17 +244,11 @@ int32_t SecCompStub::VerifySavePermissionInner(MessageParcel& data, MessageParce
}
bool res = this->VerifySavePermission(tokenId);
MessageParcel rawReply;
if (!rawReply.WriteBool(res)) {
if (!reply.WriteBool(res)) {
SC_LOG_ERROR(LABEL, "Verify temp save permission result failed");
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
}
if (!SecCompEnhanceAdapter::EnhanceSrvSerialize(rawReply, reply)) {
SC_LOG_ERROR(LABEL, "Verify serialize session info failed");
return SC_SERVICE_ERROR_PARCEL_OPERATE_FAIL;
}
return SC_OK;
}