1 /*
2  * Copyright (c) 2021-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 
16 #include "profile.h"
17 
18 #include "string_ex.h"
19 
20 #include "hilog_tag_wrapper.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
Profile(const std::string & name)24 Profile::Profile(const std::string &name) : profileName_(name)
25 {}
26 
ReadFromParcel(Parcel & parcel)27 bool Profile::ReadFromParcel(Parcel &parcel)
28 {
29     profileName_ = Str16ToStr8(parcel.ReadString16());
30 
31     return true;
32 }
33 
Unmarshalling(Parcel & parcel)34 Profile *Profile::Unmarshalling(Parcel &parcel)
35 {
36     Profile *profile = new (std::nothrow) Profile();
37     if (profile && !profile->ReadFromParcel(parcel)) {
38         TAG_LOGW(AAFwkTag::APPMGR, "failed, because ReadFromParcel failed");
39         delete profile;
40         profile = nullptr;
41     }
42     return profile;
43 }
44 
Marshalling(Parcel & parcel) const45 bool Profile::Marshalling(Parcel &parcel) const
46 {
47     return (parcel.WriteString16(Str8ToStr16(profileName_)));
48 }
49 }  // namespace AppExecFwk
50 }  // namespace OHOS
51