1/* 2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15#include "profile_info.h" 16#include "signature_info.h" 17#include "securec.h" 18#include "signature_tools_log.h" 19 20namespace OHOS { 21namespace SignatureTools { 22 23ProfileInfo::ProfileInfo() 24{ 25 profileBlock = nullptr; 26} 27ProfileInfo::~ProfileInfo() 28{ 29 profileBlock.reset(nullptr); 30} 31ProfileInfo::ProfileInfo(const ProfileInfo& profileInfo) 32{ 33 *this = profileInfo; 34} 35ProfileInfo& ProfileInfo::operator=(const ProfileInfo& profileInfo) 36{ 37 if (this == &profileInfo) { 38 return *this; 39 } 40 this->versionCode = profileInfo.versionCode; 41 this->versionName = profileInfo.versionName; 42 this->uuid = profileInfo.uuid; 43 this->type = profileInfo.type; 44 this->distributionType = profileInfo.distributionType; 45 this->bundleInfo = profileInfo.bundleInfo; 46 this->acls = profileInfo.acls; 47 this->permissions = profileInfo.permissions; 48 this->debugInfo = profileInfo.debugInfo; 49 this->issuer = profileInfo.issuer; 50 this->appId = profileInfo.appId; 51 this->fingerprint = profileInfo.fingerprint; 52 this->appPrivilegeCapabilities = profileInfo.appPrivilegeCapabilities; 53 this->validity = profileInfo.validity; 54 this->metadatas = profileInfo.metadatas; 55 this->profileBlockLength = profileInfo.profileBlockLength; 56 (this->profileBlock).reset(nullptr); 57 if (profileInfo.profileBlockLength != 0 && profileInfo.profileBlock != nullptr) { 58 this->profileBlock = std::make_unique<unsigned char[]>(profileInfo.profileBlockLength); 59 unsigned char* profileBlockData = (this->profileBlock).get(); 60 unsigned char* originalProfile = profileInfo.profileBlock.get(); 61 if (profileBlockData == nullptr) { 62 return *this; 63 } 64 std::copy(originalProfile, originalProfile + profileInfo.profileBlockLength, profileBlockData); 65 } 66 this->appServiceCapabilities = profileInfo.appServiceCapabilities; 67 this->organization = profileInfo.organization; 68 return *this; 69} 70} // namespace SignatureTools 71} // namespace OHOS