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#ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H
1799552fe9Sopenharmony_ci#define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H
1899552fe9Sopenharmony_ci
1999552fe9Sopenharmony_ci#include <string>
2099552fe9Sopenharmony_ci#include <memory>
2199552fe9Sopenharmony_ci
2299552fe9Sopenharmony_ci#include "parcel.h"
2399552fe9Sopenharmony_cinamespace OHOS {
2499552fe9Sopenharmony_cinamespace DevStandbyMgr {
2599552fe9Sopenharmony_ciclass AllowInfo : public Parcelable {
2699552fe9Sopenharmony_cipublic:
2799552fe9Sopenharmony_ci    AllowInfo() = default;
2899552fe9Sopenharmony_ci    AllowInfo(uint32_t allowType, const std::string& name, int32_t duration) :allowType_(allowType),
2999552fe9Sopenharmony_ci        name_(name), duration_(duration) {}
3099552fe9Sopenharmony_ci
3199552fe9Sopenharmony_ci    /**
3299552fe9Sopenharmony_ci     * @brief Unmarshals a purpose from a Parcel.
3399552fe9Sopenharmony_ci     *
3499552fe9Sopenharmony_ci     * @param parcel Indicates the parcel object for unmarshalling.
3599552fe9Sopenharmony_ci     * @return The info of delay suspend.
3699552fe9Sopenharmony_ci     */
3799552fe9Sopenharmony_ci    static sptr<AllowInfo> Unmarshalling(Parcel& in);
3899552fe9Sopenharmony_ci
3999552fe9Sopenharmony_ci    /**
4099552fe9Sopenharmony_ci     * @brief Marshals a purpose into a parcel.
4199552fe9Sopenharmony_ci     *
4299552fe9Sopenharmony_ci     * @param parcel Indicates the parcel object for marshalling.
4399552fe9Sopenharmony_ci     * @return True if success, else false.
4499552fe9Sopenharmony_ci     */
4599552fe9Sopenharmony_ci    bool Marshalling(Parcel& out) const override;
4699552fe9Sopenharmony_ci
4799552fe9Sopenharmony_ci    /**
4899552fe9Sopenharmony_ci     * @brief Get the allow type used to represent resource type.
4999552fe9Sopenharmony_ci     *
5099552fe9Sopenharmony_ci     * @return the allow type.
5199552fe9Sopenharmony_ci     */
5299552fe9Sopenharmony_ci    inline uint32_t GetAllowType() const
5399552fe9Sopenharmony_ci    {
5499552fe9Sopenharmony_ci        return allowType_;
5599552fe9Sopenharmony_ci    }
5699552fe9Sopenharmony_ci
5799552fe9Sopenharmony_ci    /**
5899552fe9Sopenharmony_ci     * @brief Get the app name.
5999552fe9Sopenharmony_ci     *
6099552fe9Sopenharmony_ci     * @return the name of the app.
6199552fe9Sopenharmony_ci     */
6299552fe9Sopenharmony_ci    inline std::string GetName() const
6399552fe9Sopenharmony_ci    {
6499552fe9Sopenharmony_ci        return name_;
6599552fe9Sopenharmony_ci    }
6699552fe9Sopenharmony_ci
6799552fe9Sopenharmony_ci    /**
6899552fe9Sopenharmony_ci     * @brief Get the duration.
6999552fe9Sopenharmony_ci     *
7099552fe9Sopenharmony_ci     * @return the duration.
7199552fe9Sopenharmony_ci     */
7299552fe9Sopenharmony_ci    inline int32_t GetDuration() const
7399552fe9Sopenharmony_ci    {
7499552fe9Sopenharmony_ci        return duration_;
7599552fe9Sopenharmony_ci    }
7699552fe9Sopenharmony_ci
7799552fe9Sopenharmony_ci    /**
7899552fe9Sopenharmony_ci     * @brief Set the allow type which represents the resources.
7999552fe9Sopenharmony_ci     *
8099552fe9Sopenharmony_ci     * @param allowType represents allow type.
8199552fe9Sopenharmony_ci     */
8299552fe9Sopenharmony_ci    inline void SetAllowType(uint32_t allowType)
8399552fe9Sopenharmony_ci    {
8499552fe9Sopenharmony_ci        allowType_ = allowType;
8599552fe9Sopenharmony_ci    }
8699552fe9Sopenharmony_ci
8799552fe9Sopenharmony_ci    /**
8899552fe9Sopenharmony_ci     * @brief Set the name of the allowed native process or apps.
8999552fe9Sopenharmony_ci     *
9099552fe9Sopenharmony_ci     * @param name the name of the allowed object.
9199552fe9Sopenharmony_ci     */
9299552fe9Sopenharmony_ci    inline void SetName(const std::string& name)
9399552fe9Sopenharmony_ci    {
9499552fe9Sopenharmony_ci        name_ = name;
9599552fe9Sopenharmony_ci    }
9699552fe9Sopenharmony_ci
9799552fe9Sopenharmony_ci    /**
9899552fe9Sopenharmony_ci     * @brief Set the Duration object.
9999552fe9Sopenharmony_ci     *
10099552fe9Sopenharmony_ci     * @param duration timeOut.
10199552fe9Sopenharmony_ci     */
10299552fe9Sopenharmony_ci    inline void SetDuration(int32_t duration)
10399552fe9Sopenharmony_ci    {
10499552fe9Sopenharmony_ci        duration_ = duration;
10599552fe9Sopenharmony_ci    }
10699552fe9Sopenharmony_ciprivate:
10799552fe9Sopenharmony_ci    bool ReadFromParcel(Parcel& in);
10899552fe9Sopenharmony_ci
10999552fe9Sopenharmony_ci    uint32_t allowType_;
11099552fe9Sopenharmony_ci    std::string name_;
11199552fe9Sopenharmony_ci    int32_t duration_;
11299552fe9Sopenharmony_ci};
11399552fe9Sopenharmony_ci}  // namespace DevStandbyMgr
11499552fe9Sopenharmony_ci}  // namespace OHOS
11599552fe9Sopenharmony_ci#endif  // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H