• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "form_lock_info.h"
16 #include "fms_log_wrapper.h"
17 #include "string_ex.h"
18 
19 namespace OHOS {
20 namespace AppExecFwk {
Marshalling(Parcel & parcel) const21 bool FormLockInfo::Marshalling(Parcel &parcel) const
22 {
23     if (!parcel.WriteString(bundleName)) {
24         HILOG_ERROR("marshall bundleName failed");
25         return false;
26     }
27 
28     if (!parcel.WriteInt32(userId)) {
29         HILOG_ERROR("marshall userId failed");
30         return false;
31     }
32 
33     if (!parcel.WriteBool(lock)) {
34         HILOG_ERROR("marshall lock failed");
35         return false;
36     }
37     return true;
38 }
39 
Unmarshalling(Parcel & parcel)40 FormLockInfo *FormLockInfo::Unmarshalling(Parcel &parcel)
41 {
42     FormLockInfo *lockInfo = new (std::nothrow) FormLockInfo();
43 
44     if (lockInfo == nullptr) {
45         HILOG_ERROR("new FormLockInfo failed.");
46         return nullptr;
47     }
48 
49     if (!parcel.ReadString(lockInfo->bundleName)) {
50         HILOG_ERROR("marshall bundleName failed.");
51         delete lockInfo;
52         lockInfo = nullptr;
53         return lockInfo;
54     }
55 
56     if (!parcel.ReadInt32(lockInfo->userId)) {
57         HILOG_ERROR("marshall userId failed.");
58         delete lockInfo;
59         lockInfo = nullptr;
60         return lockInfo;
61     }
62 
63     if (!parcel.ReadBool(lockInfo->lock)) {
64         HILOG_ERROR("marshall lock failed.");
65         delete lockInfo;
66         lockInfo = nullptr;
67         return lockInfo;
68     }
69     return lockInfo;
70 }
71 } // OHOS
72 } // AppExecFwk
73