1 /* 2 * Copyright (c) 2023 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 16 #include "ability_record_state_data.h" 17 18 #include "adapter.h" 19 #include "utils.h" 20 21 namespace OHOS { 22 namespace AbilitySlite { AbilityRecordStateData(const char * appName,AbilityRecordState state)23AbilityRecordStateData::AbilityRecordStateData(const char *appName, AbilityRecordState state) 24 { 25 SetAppName(appName); 26 state_ = state; 27 } 28 AbilityRecordStateData(const AbilityRecordStateData & stateData)29AbilityRecordStateData::AbilityRecordStateData(const AbilityRecordStateData &stateData) 30 : AbilityRecordStateData(stateData.GetAppName(), stateData.GetState()) 31 { 32 } 33 operator =(const AbilityRecordStateData & stateData)34AbilityRecordStateData &AbilityRecordStateData::operator=(const AbilityRecordStateData &stateData) 35 { 36 if (this != &stateData) { 37 SetAppName(stateData.GetAppName()); 38 state_ = stateData.GetState(); 39 } 40 return *this; 41 } 42 ~AbilityRecordStateData()43AbilityRecordStateData::~AbilityRecordStateData() 44 { 45 AdapterFree(appName_); 46 } 47 SetAppName(const char * name)48void AbilityRecordStateData::SetAppName(const char *name) 49 { 50 AdapterFree(appName_); 51 appName_ = Utils::Strdup(name); 52 } 53 } // namespace AbilitySlite 54 } // namespace OHOS 55