• 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 BUNDLE_ACTIVE_ISERVICE_H
17 #define BUNDLE_ACTIVE_ISERVICE_H
18 
19 #include <map>
20 #include <vector>
21 #include <set>
22 #include <utility>
23 #include <algorithm>
24 #include <cstdint>
25 
26 #include "iremote_broker.h"
27 #include "iremote_stub.h"
28 #include "iremote_proxy.h"
29 #include "iremote_object.h"
30 #include "ipc_skeleton.h"
31 #include "system_ability_definition.h"
32 #include "if_system_ability_manager.h"
33 #include "iservice_registry.h"
34 #include "iapp_group_callback.h"
35 #include "app_group_callback_proxy.h"
36 
37 #include "bundle_active_log.h"
38 
39 namespace OHOS {
40 namespace DeviceUsageStats {
41 class BundleActivePackageStats;
42 class BundleActiveEvent;
43 class BundleActiveEventStats;
44 class BundleActiveModuleRecord;
45 
46 class IBundleActiveService : public IRemoteBroker {
47 public:
48     IBundleActiveService() = default;
49     ~IBundleActiveService() override = default;
50     DISALLOW_COPY_AND_MOVE(IBundleActiveService);
51 
52     /*
53     * function: ReportEvent, used to report event.
54     * parameters: event, userId
55     * return: errorcode.
56     */
57     virtual ErrCode ReportEvent(BundleActiveEvent& event, const int32_t userId) = 0;
58 
59     /*
60     * function: IsBundleIdle, used to check whether specific bundle is idle.
61     * parameters: bundleName
62     * return: if bundle is idle, return true. if bundle is not idle, return false.
63     */
64     virtual ErrCode IsBundleIdle(bool& isBundleIdle, const std::string& bundleName, int32_t userId) = 0;
65 
66     /*
67     * function: QueryBundleStatsInfoByInterval, query all usage statistics in specific time span for calling user.
68     * parameters: intervalType, beginTime, endTime, errCode
69     * return: errCode.
70     */
71     virtual ErrCode QueryBundleStatsInfoByInterval(std::vector<BundleActivePackageStats>& PackageStats,
72         const int32_t intervalType, const int64_t beginTime, const int64_t endTime, int32_t userId) = 0;
73 
74     /*
75     * function: QueryBundleEvents, query all events in specific time span for calling user.
76     * parameters: beginTime, endTime, errCode
77     * return: errCode.
78     */
79     virtual ErrCode QueryBundleEvents(std::vector<BundleActiveEvent>& bundleActiveEvents, const int64_t beginTime,
80         const int64_t endTime, int32_t userId) = 0;
81 
82     /*
83     * function: QueryBundleStatsInfos, query bundle usage statistics in specific time span for calling bundle.
84     * parameters: intervalType, beginTime, endTime
85     * return: vector of calling bundle usage statistics.
86     */
87     virtual ErrCode QueryBundleStatsInfos(std::vector<BundleActivePackageStats>& bundleActivePackageStats,
88         const int32_t intervalType, const int64_t beginTime, const int64_t endTime) = 0;
89 
90     /*
91     * function: QueryCurrentBundleEvents, query bundle usage statistics in specific time span for calling bundle.
92     * parameters: beginTime, endTime
93     * return: errCode.
94     */
95     virtual ErrCode QueryCurrentBundleEvents(std::vector<BundleActiveEvent>& bundleActiveEvents,
96         const int64_t beginTime, const int64_t endTime) = 0;
97 
98     /*
99     * function: QueryAppGroup, query app group by bundleName and userId.
100     * parameters: bundleName, userId.
101     * return: the priority group of calling bundle.
102     */
103     virtual ErrCode QueryAppGroup(int32_t& appGroup, std::string& bundleName, const int32_t userId) = 0;
104 
105     /*
106     * function: SetAppGroup, set specific bundle of specific user to a priority group.
107     * parameters: bundleName, newGroup, userId
108     * return: errorcode.
109     */
110     virtual ErrCode SetAppGroup(const std::string& bundleName, int32_t newGroup, int32_t userId) = 0;
111 
112     /*
113     * function: QueryModuleUsageRecords, query all from usage statistics in specific time span for calling user.
114     * parameters: maxNum, results, userId, default userId is -1 for JS API,
115     * if other SAs call this API, they should explicit define userId.
116     * return: errorcode.
117     */
118     virtual ErrCode QueryModuleUsageRecords(int32_t maxNum, std::vector<BundleActiveModuleRecord>& results,
119         int32_t userId) = 0;
120 
121     /*
122     * function: RegisterAppGroupCallBack, register the observer to groupObservers.
123     * parameters: observer
124     * return: errorcode.
125     */
126     virtual ErrCode RegisterAppGroupCallBack(const sptr<IAppGroupCallback> &observer) = 0;
127 
128     /*
129     * function: UnRegisterAppGroupCallBack, remove the observer from groupObservers.
130     * parameters: observer
131     * return: errorcode.
132     */
133     virtual ErrCode UnRegisterAppGroupCallBack(const sptr<IAppGroupCallback> &observer) = 0;
134 
135     /*
136     * function: QueryDeviceEventStats, query all from event stats in specific time span for calling user.
137     * parameters: beginTime, endTime, eventStats, userId, default userId is -1 for JS API,
138     * if other SAs call this API, they should explicit define userId.
139     * return: errorcode.
140     */
141     virtual ErrCode QueryDeviceEventStats(int64_t beginTime, int64_t endTime,
142         std::vector<BundleActiveEventStats>& eventStats, int32_t userId) = 0;
143 
144     /*
145     * function: QueryNotificationEventStats, query all app notification number in specific time span for calling user.
146     * parameters: beginTime, endTime, eventStats, userId, default userId is -1 for JS API,
147     * if other SAs call this API, they should explicit define userId.
148     * return: errorcode.
149     */
150     virtual ErrCode QueryNotificationEventStats(int64_t beginTime, int64_t endTime,
151         std::vector<BundleActiveEventStats>& eventStats, int32_t userId) = 0;
152 public:
153     DECLARE_INTERFACE_DESCRIPTOR(u"Resourceschedule.IBundleActiveService");
154 };
155 }  // namespace DeviceUsageStats
156 }  // namespace OHOS
157 #endif  // BUNDLE_ACTIVE_ISERVICE_H
158 
159