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 "resourcce_request.h"
17
18 #include "ipc_util.h"
19 #include "standby_service_log.h"
20
21 namespace OHOS {
22 namespace DevStandbyMgr {
Marshalling(Parcel & out) const23 bool ResourceRequest::Marshalling(Parcel& out) const
24 {
25 WRITE_PARCEL_WITH_RET(out, Uint32, allowType_, false);
26 WRITE_PARCEL_WITH_RET(out, Int32, uid_, false);
27 WRITE_PARCEL_WITH_RET(out, String, name_, false);
28 WRITE_PARCEL_WITH_RET(out, Int32, duration_, false);
29 WRITE_PARCEL_WITH_RET(out, String, reason_, false);
30 WRITE_PARCEL_WITH_RET(out, Uint32, reasonCode_, false);
31 return true;
32 }
33
Unmarshalling(Parcel & in)34 sptr<ResourceRequest> ResourceRequest::Unmarshalling(Parcel& in)
35 {
36 sptr<ResourceRequest> info = new (std::nothrow) ResourceRequest();
37 if (info != nullptr && !info->ReadFromParcel(in)) {
38 STANDBYSERVICE_LOGE("read from parcel failed");
39 info = nullptr;
40 }
41 return info;
42 }
43
ReadFromParcel(Parcel & in)44 bool ResourceRequest::ReadFromParcel(Parcel& in)
45 {
46 READ_PARCEL_WITH_RET(in, Uint32, allowType_, false);
47 READ_PARCEL_WITH_RET(in, Int32, uid_, false);
48 READ_PARCEL_WITH_RET(in, String, name_, false);
49 READ_PARCEL_WITH_RET(in, Int32, duration_, false);
50 READ_PARCEL_WITH_RET(in, String, reason_, false);
51 READ_PARCEL_WITH_RET(in, Uint32, reasonCode_, false);
52 return true;
53 }
54 } // namespace DevStandbyMgr
55 } // namespace OHOS