• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 CGROUP_SCHED_FRAMEWORK_SCHED_CONTROLLER_INCLUDE_APP_STARTUP_SCENE_REC_H
17 #define CGROUP_SCHED_FRAMEWORK_SCHED_CONTROLLER_INCLUDE_APP_STARTUP_SCENE_REC_H
18 
19 #include <string>
20 #include <unordered_set>
21 #include <mutex>
22 #include <memory>
23 #include <atomic>
24 #include "ffrt.h"
25 #include "nlohmann/json.hpp"
26 namespace OHOS {
27 namespace ResourceSchedule {
28 class AppStartupSceneRec {
29 public:
30     static AppStartupSceneRec &GetInstance();
31     void Init();
32     void Deinit();
33     void RecordIsContinuousStartup(const std::string& uid, const std::string& bundleName);
34     bool IsAppStartUp(int32_t abilityState);
35 private:
36     AppStartupSceneRec();
37     ~AppStartupSceneRec();
38     void CleanRecordSceneData();
39     void UpdateAppStartupNum(std::string uid, int64_t curTime, std::string bundleName);
40     bool IsContinuousStartup();
41     int32_t appStartCount_ = 0;
42     int64_t lastAppStartTime_ = 0;
43     std::atomic_bool isReportContinuousStartup_ = false;
44     std::vector<std::string> startPkgs_;
45     std::unordered_set<std::string> startUidSet_;
46     std::shared_ptr<ffrt::queue> ffrtQueue_ = nullptr;
47     ffrt::task_handle exitContinuousStartupTask;
48     ffrt::mutex mutex_;
49 };
50 }
51 }
52 #endif // CGROUP_SCHED_FRAMEWORK_SCHED_CONTROLLER_INCLUDE_APP_STARTUP_SCENE_REC_H