• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_LONGTIME_TASK_EVENT_DATA_H
17 #define FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_LONGTIME_TASK_EVENT_DATA_H
18 
19 #include <cstdint>
20 #include <sys/types.h>
21 #include <string>
22 
23 #include "parcel.h"
24 
25 namespace OHOS {
26 namespace BackgroundTaskMgr {
27 class ContinuousTaskCallbackInfo : public Parcelable {
28 public:
29     ContinuousTaskCallbackInfo();
30     ContinuousTaskCallbackInfo(uint32_t typeId, int32_t creatorUid,
31         pid_t creatorPid, std::string abilityName, bool isFromWebview = false)
typeId_(typeId)32         : typeId_(typeId), creatorUid_(creatorUid), creatorPid_(creatorPid), abilityName_(abilityName),
33         isFromWebview_(isFromWebview) {}
34 
35     /**
36      * @brief Get the id of type.
37      *
38      * @return The id of type.
39      */
40     uint32_t GetTypeId() const;
41 
42     /**
43      * @brief Get the uid of notification crector.
44      *
45      * @return The uid of the notification creator.
46      */
47     int32_t GetCreatorUid() const;
48 
49     /**
50      * @brief Get the pid of notification crector.
51      *
52      * @return The pid of the notification creator.
53      */
54     pid_t GetCreatorPid() const;
55 
56     /**
57      * @brief Get the name of ability.
58      *
59      * @return The name of ability.
60      */
61     std::string GetAbilityName() const;
62 
63     /**
64      * @brief Judge whether this ability come from webview.
65      *
66      * @return True if success, else false.
67      */
68     bool IsFromWebview() const;
69 
70     /**
71      * @brief Marshals a purpose into a parcel.
72      *
73      * @param parcel Indicates the parcel object for marshalling.
74      * @return True if success, else false.
75      */
76     bool Marshalling(Parcel &parcel) const override;
77     static ContinuousTaskCallbackInfo *Unmarshalling(Parcel &parcel);
78 
79 private:
80     bool ReadFromParcel(Parcel &parcel);
81 
82 private:
83     uint32_t typeId_ {0};
84     int32_t creatorUid_ {0};
85     pid_t creatorPid_ {0};
86     std::string abilityName_ {""};
87     bool isFromWebview_ {false};
88 };
89 }  // namespace BackgroundTaskMgr
90 }  // namespace OHOS
91 #endif  // FOUNDATION_RESOURCESCHEDULE_BACKGROUND_TASK_MGR_INTERFACES_INNERKITS_INCLUDE_LONGTIME_TASK_EVENT_DATA_H