• 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_LMKS_CLIENT_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_LMKS_CLIENT_H
18 
19 #include <functional>
20 #include <memory>
21 #include <string>
22 #include <utility>
23 #include <vector>
24 
25 #include "ability_running_record.h"
26 #include "app_running_record.h"
27 #include "nocopyable.h"
28 
29 namespace OHOS {
30 namespace AppExecFwk {
31 union LmksClientMsg {
32     int32_t result = -1;
33     int8_t resultBuf[sizeof(int32_t)];
34 };
35 
36 class LmksClient : public NoCopyable {
37 public:
38     using Targets = std::vector<std::pair<int, int>>;
39 
40 public:
41     LmksClient();
42     virtual ~LmksClient();
43     virtual int32_t Open();
44     virtual void Close();
45     virtual bool IsOpen() const;
46     virtual int32_t Target(const Targets &targets);
47     virtual int32_t ProcPrio(pid_t pid, uid_t uid, int oomAdj);
48     virtual int32_t ProcRemove(pid_t pid);
49     virtual bool ProcPurge();
50     static bool CheckOomAdj(int v);
51 
52 private:
53     bool Write(const void *buf, size_t len);
54     bool Read(void *buf, size_t len);
55 
56 private:
57     int socket_;
58 };
59 }  // namespace AppExecFwk
60 }  // namespace OHOS
61 
62 #endif  // FOUNDATION_APPEXECFWK_SERVICES_APPMGR_INCLUDE_LMKS_CLIENT_H
63