1 /*
2 * Copyright (c) 2021 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 "install_param.h"
17
18 #include "nlohmann/json.hpp"
19 #include "string_ex.h"
20
21 #include "app_log_wrapper.h"
22 #include "parcel_macro.h"
23
24 namespace OHOS {
25 namespace AppExecFwk {
26
ReadFromParcel(Parcel & parcel)27 bool InstallParam::ReadFromParcel(Parcel &parcel)
28 {
29 int32_t flagData;
30 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, flagData);
31 installFlag = static_cast<InstallFlag>(flagData);
32
33 int32_t locationData;
34 READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, locationData);
35 installLocation = static_cast<InstallLocation>(locationData);
36
37 userId = parcel.ReadInt32();
38 isKeepData = parcel.ReadBool();
39 noCheckSignature = parcel.ReadBool();
40 return true;
41 }
42
Unmarshalling(Parcel & parcel)43 InstallParam *InstallParam::Unmarshalling(Parcel &parcel)
44 {
45 InstallParam *info = new (std::nothrow) InstallParam();
46 if (info && !info->ReadFromParcel(parcel)) {
47 APP_LOGW("read from parcel failed");
48 delete info;
49 info = nullptr;
50 }
51 return info;
52 }
53
Marshalling(Parcel & parcel) const54 bool InstallParam::Marshalling(Parcel &parcel) const
55 {
56 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(installFlag));
57 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(installLocation));
58 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, userId);
59 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, isKeepData);
60 WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Bool, parcel, noCheckSignature);
61 return true;
62 }
63
64 } // namespace AppExecFwk
65 } // namespace OHOS
66