• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H
17 #define FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H
18 
19 #include <string>
20 #include <memory>
21 
22 #include "parcel.h"
23 namespace OHOS {
24 namespace DevStandbyMgr {
25 class AllowInfo : public Parcelable {
26 public:
27     AllowInfo() = default;
AllowInfo(uint32_t allowType,const std::string & name,int32_t duration)28     AllowInfo(uint32_t allowType, const std::string& name, int32_t duration) :allowType_(allowType),
29         name_(name), duration_(duration) {}
30 
31     /**
32      * @brief Unmarshals a purpose from a Parcel.
33      *
34      * @param parcel Indicates the parcel object for unmarshalling.
35      * @return The info of delay suspend.
36      */
37     static sptr<AllowInfo> Unmarshalling(Parcel& in);
38 
39     /**
40      * @brief Marshals a purpose into a parcel.
41      *
42      * @param parcel Indicates the parcel object for marshalling.
43      * @return True if success, else false.
44      */
45     bool Marshalling(Parcel& out) const override;
46 
47     /**
48      * @brief Get the allow type used to represent resource type.
49      *
50      * @return the allow type.
51      */
GetAllowType()52     inline uint32_t GetAllowType() const
53     {
54         return allowType_;
55     }
56 
57     /**
58      * @brief Get the app name.
59      *
60      * @return the name of the app.
61      */
GetName()62     inline std::string GetName() const
63     {
64         return name_;
65     }
66 
67     /**
68      * @brief Get the duration.
69      *
70      * @return the duration.
71      */
GetDuration()72     inline int32_t GetDuration() const
73     {
74         return duration_;
75     }
76 
77     /**
78      * @brief Set the allow type which represents the resources.
79      *
80      * @param allowType represents allow type.
81      */
SetAllowType(uint32_t allowType)82     inline void SetAllowType(uint32_t allowType)
83     {
84         allowType_ = allowType;
85     }
86 
87     /**
88      * @brief Set the name of the allowed native process or apps.
89      *
90      * @param name the name of the allowed object.
91      */
SetName(const std::string & name)92     inline void SetName(const std::string& name)
93     {
94         name_ = name;
95     }
96 
97     /**
98      * @brief Set the Duration object.
99      *
100      * @param duration timeOut.
101      */
SetDuration(int32_t duration)102     inline void SetDuration(int32_t duration)
103     {
104         duration_ = duration;
105     }
106 private:
107     bool ReadFromParcel(Parcel& in);
108 
109     uint32_t allowType_;
110     std::string name_;
111     int32_t duration_;
112 };
113 }  // namespace DevStandbyMgr
114 }  // namespace OHOS
115 #endif  // FOUNDATION_RESOURCESCHEDULE_STANDBY_SERVICE_INTERFACES_INNERKITS_ALLOW_INFO_H