199552fe9Sopenharmony_ci/*
299552fe9Sopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
399552fe9Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
499552fe9Sopenharmony_ci * you may not use this file except in compliance with the License.
599552fe9Sopenharmony_ci * You may obtain a copy of the License at
699552fe9Sopenharmony_ci *
799552fe9Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
899552fe9Sopenharmony_ci *
999552fe9Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1099552fe9Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1199552fe9Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1299552fe9Sopenharmony_ci * See the License for the specific language governing permissions and
1399552fe9Sopenharmony_ci * limitations under the License.
1499552fe9Sopenharmony_ci */
1599552fe9Sopenharmony_ci
1699552fe9Sopenharmony_ci#include "resourcce_request.h"
1799552fe9Sopenharmony_ci
1899552fe9Sopenharmony_ci#include "ipc_util.h"
1999552fe9Sopenharmony_ci#include "standby_service_log.h"
2099552fe9Sopenharmony_ci
2199552fe9Sopenharmony_cinamespace OHOS {
2299552fe9Sopenharmony_cinamespace DevStandbyMgr {
2399552fe9Sopenharmony_cibool ResourceRequest::Marshalling(Parcel& out) const
2499552fe9Sopenharmony_ci{
2599552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, Uint32, allowType_, false);
2699552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, Int32, uid_, false);
2799552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, String, name_, false);
2899552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, Int32, duration_, false);
2999552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, String, reason_, false);
3099552fe9Sopenharmony_ci    WRITE_PARCEL_WITH_RET(out, Uint32, reasonCode_, false);
3199552fe9Sopenharmony_ci    return true;
3299552fe9Sopenharmony_ci}
3399552fe9Sopenharmony_ci
3499552fe9Sopenharmony_cisptr<ResourceRequest> ResourceRequest::Unmarshalling(Parcel& in)
3599552fe9Sopenharmony_ci{
3699552fe9Sopenharmony_ci    sptr<ResourceRequest> info = new (std::nothrow) ResourceRequest();
3799552fe9Sopenharmony_ci    if (info != nullptr && !info->ReadFromParcel(in)) {
3899552fe9Sopenharmony_ci        STANDBYSERVICE_LOGE("read from parcel failed");
3999552fe9Sopenharmony_ci        info = nullptr;
4099552fe9Sopenharmony_ci    }
4199552fe9Sopenharmony_ci    return info;
4299552fe9Sopenharmony_ci}
4399552fe9Sopenharmony_ci
4499552fe9Sopenharmony_cibool ResourceRequest::ReadFromParcel(Parcel& in)
4599552fe9Sopenharmony_ci{
4699552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, Uint32, allowType_, false);
4799552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, Int32, uid_, false);
4899552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, String, name_, false);
4999552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, Int32, duration_, false);
5099552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, String, reason_, false);
5199552fe9Sopenharmony_ci    READ_PARCEL_WITH_RET(in, Uint32, reasonCode_, false);
5299552fe9Sopenharmony_ci    return true;
5399552fe9Sopenharmony_ci}
5499552fe9Sopenharmony_ci}  // namespace DevStandbyMgr
5599552fe9Sopenharmony_ci}  // namespace OHOS