• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H
18 
19 #include "app_scheduler_proxy.h"
20 #include "app_launch_data.h"
21 #include "ability_running_record.h"
22 
23 namespace OHOS {
24 namespace AppExecFwk {
25 class AppLifeCycleDeal {
26 public:
27     AppLifeCycleDeal();
28     virtual ~AppLifeCycleDeal();
29 
30     /**
31      * LaunchApplication, call ScheduleLaunchApplication() through proxy project,
32      * Notify application to launch application.
33      *
34      * @param The app data value.
35      *
36      * @return
37      */
38     void LaunchApplication(const AppLaunchData &launchData_);
39 
40     /**
41      * LaunchAbility, call ScheduleLaunchAbility() through proxy project,
42      * Notify application to launch ability.
43      *
44      * @param The ability info.
45      * @return
46      */
47     void LaunchAbility(const std::shared_ptr<AbilityRunningRecord> &ability);
48 
49     /**
50      * ScheduleTerminate, call ScheduleTerminateApplication() through proxy project,
51      * Notify application to terminate.
52      *
53      * @return
54      */
55     void ScheduleTerminate();
56 
57     /**
58      * ScheduleForegroundRunning, call ScheduleForegroundApplication() through proxy project,
59      * Notify application to switch to foreground.
60      *
61      * @return
62      */
63     void ScheduleForegroundRunning();
64 
65     /**
66      * ScheduleBackgroundRunning, call ScheduleBackgroundApplication() through proxy project,
67      * Notify application to switch to background.
68      *
69      * @return
70      */
71     void ScheduleBackgroundRunning();
72 
73     /**
74      * ScheduleTrimMemory, call ScheduleShrinkMemory() through proxy project,
75      * Notifies the application of the memory seen.
76      *
77      * @param The memory value.
78      *
79      * @return
80      */
81     void ScheduleTrimMemory(int32_t timeLevel);
82 
83     /**
84      * LowMemoryWarning, call ScheduleLowMemory() through proxy project,
85      * Notify application to low memory.
86      *
87      * @return
88      */
89     void LowMemoryWarning();
90 
91     /**
92      * ScheduleCleanAbility, call ScheduleCleanAbility() through proxy project,
93      * Notify application to clean ability.
94      *
95      * @param token, The ability token.
96      * @return
97      */
98     void ScheduleCleanAbility(const sptr<IRemoteObject> &token);
99 
100     /**
101      * ScheduleProcessSecurityExit, call ScheduleTerminateApplication() through proxy project,
102      * Notify application process exit safely.
103      *
104      * @return
105      */
106     void ScheduleProcessSecurityExit();
107 
108     /**
109      * @brief Setting client for application record.
110      *
111      * @param thread, the application client.
112      */
113     void SetApplicationClient(const sptr<IAppScheduler> &thread);
114 
115     /**
116      * @brief Obtains the client of the application record.
117      *
118      * @return Returns the application client.
119      */
120     sptr<IAppScheduler> GetApplicationClient() const;
121 
122 private:
123     sptr<IAppScheduler> appThread_;
124 };
125 }  // namespace AppExecFwk
126 }  // namespace OHOS
127 
128 #endif  // FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_APP_LIFECYCLE_DEAL_H