1 /*
2 * Copyright (c) 2025 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 "manage_auto_start_app_info.h"
17 #include "parcel_macro.h"
18 #include "edm_log.h"
19
20 namespace OHOS {
21 namespace EDM {
22 const std::string SEPARATOR = "/";
Marshalling(MessageParcel & parcel) const23 bool ManageAutoStartAppInfo::Marshalling(MessageParcel &parcel) const
24 {
25 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, bundleName_);
26 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(String, parcel, abilityName_);
27 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, disallowModify_);
28 return true;
29 }
30
Unmarshalling(MessageParcel & parcel,ManageAutoStartAppInfo & appInfo)31 bool ManageAutoStartAppInfo::Unmarshalling(MessageParcel &parcel, ManageAutoStartAppInfo &appInfo)
32 {
33 std::string bundleName = parcel.ReadString();
34 std::string abilityName = parcel.ReadString();
35 bool disallowModify = parcel.ReadBool();
36 appInfo.SetBundleName(bundleName);
37 appInfo.SetAbilityName(abilityName);
38 appInfo.SetDisallowModify(disallowModify);
39 return true;
40 }
41
SetUniqueKey(const std::string & uniqueKey)42 bool ManageAutoStartAppInfo::SetUniqueKey(const std::string &uniqueKey)
43 {
44 size_t index = uniqueKey.find(SEPARATOR);
45 if (index != uniqueKey.npos) {
46 bundleName_ = uniqueKey.substr(0, index);
47 abilityName_ = uniqueKey.substr(index + 1);
48 } else {
49 EDMLOGE("ManageAutoStartAppInfo SetUniqueKey parse auto start app want failed");
50 return false;
51 }
52 return true;
53 }
54
SetBundleName(const std::string & bundleName)55 void ManageAutoStartAppInfo::SetBundleName(const std::string &bundleName)
56 {
57 bundleName_ = bundleName;
58 }
59
SetAbilityName(const std::string & abilityName)60 void ManageAutoStartAppInfo::SetAbilityName(const std::string &abilityName)
61 {
62 abilityName_ = abilityName;
63 }
64
SetDisallowModify(bool disallowModify)65 void ManageAutoStartAppInfo::SetDisallowModify(bool disallowModify)
66 {
67 disallowModify_ = disallowModify;
68 }
69
GetBundleName() const70 std::string ManageAutoStartAppInfo::GetBundleName() const
71 {
72 return bundleName_;
73 }
74
GetAbilityName() const75 std::string ManageAutoStartAppInfo::GetAbilityName() const
76 {
77 return abilityName_;
78 }
79
GetDisallowModify() const80 bool ManageAutoStartAppInfo::GetDisallowModify() const
81 {
82 return disallowModify_;
83 }
84 } // namespace EDM
85 } // namespace OHOS