• 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 SERVICES_SAFWK_INCLUDE_SYSTEM_ABILITY_ONDEMAND_REASON_H
17 #define SERVICES_SAFWK_INCLUDE_SYSTEM_ABILITY_ONDEMAND_REASON_H
18 
19 #include <map>
20 #include "parcel.h"
21 
22 namespace OHOS {
23 enum class OnDemandReasonId {
24     INTERFACE_CALL = 0,
25     DEVICE_ONLINE = 1,
26     SETTING_SWITCH = 2,
27     PARAM = 3,
28     COMMON_EVENT = 4,
29     TIMED_EVENT = 5,
30     UNREF_EVENT = 6,
31 };
32 
33 class OnDemandReasonExtraData : public Parcelable {
34 public:
35     OnDemandReasonExtraData() = default;
36     OnDemandReasonExtraData(int32_t code, const std::string& data, const std::map<std::string, std::string>& want);
37     std::string GetData() const;
38     int32_t GetCode() const;
39     const std::map<std::string, std::string>& GetWant() const;
40     bool Marshalling(Parcel& parcel) const override;
41     static OnDemandReasonExtraData *Unmarshalling(Parcel& parcel);
42 private:
43     int32_t code_ = -1;
44     std::string data_;
45     std::map<std::string, std::string> want_;
46 };
47 
48 class SystemAbilityOnDemandReason {
49 public:
50     SystemAbilityOnDemandReason() = default;
51     SystemAbilityOnDemandReason(OnDemandReasonId reasonId, const std::string& reasonName,
52         const std::string& reasonValue, int64_t extraDataId);
53     OnDemandReasonId GetId() const;
54     void SetId(OnDemandReasonId reasonId);
55     std::string GetName() const;
56     void SetName(const std::string& reasonName);
57     std::string GetValue() const;
58     void SetValue(const std::string& reasonValue);
59     int64_t GetExtraDataId() const;
60     void SetExtraDataId(int64_t extraDataId);
61     bool HasExtraData() const;
62     void SetExtraData(OnDemandReasonExtraData& extraData);
63     const OnDemandReasonExtraData& GetExtraData() const;
64 private:
65     OnDemandReasonId reasonId_;
66     std::string reasonName_;
67     std::string reasonValue_;
68     int64_t extraDataId_ = -1;
69     OnDemandReasonExtraData extraData_;
70 };
71 }
72 #endif /* SERVICES_SAFWK_INCLUDE_SYSTEM_ABILITY_ONDEMAND_REASON_H */