blob: 9afa3dfd0b8d7dbe3e95c58a4226f18fcf63ff5b [file] [log] [blame]
Ronghua Wu10305cc2015-02-22 07:55:32 -08001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Ronghua Wu14bcaca2015-03-16 11:24:30 -070017#ifndef PROCESS_INFO_H_
Ronghua Wu10305cc2015-02-22 07:55:32 -080018
Ronghua Wu14bcaca2015-03-16 11:24:30 -070019#define PROCESS_INFO_H_
20
Atneya Nairf5b68512022-05-23 20:02:49 -040021#include <mediautils/ProcessInfoInterface.h>
Chong Zhang97d367b2020-09-16 12:53:14 -070022#include <map>
23#include <mutex>
24#include <utils/Condition.h>
Ronghua Wu10305cc2015-02-22 07:55:32 -080025
26namespace android {
27
Ronghua Wu14bcaca2015-03-16 11:24:30 -070028struct ProcessInfo : public ProcessInfoInterface {
29 ProcessInfo();
30
31 virtual bool getPriority(int pid, int* priority);
Brian Lindahlcf3bafb2022-01-27 14:21:38 +010032 virtual bool isPidTrusted(int pid);
33 virtual bool isPidUidTrusted(int pid, int uid);
Chong Zhang97d367b2020-09-16 12:53:14 -070034 virtual bool overrideProcessInfo(int pid, int procState, int oomScore);
35 virtual void removeProcessInfoOverride(int pid);
Ronghua Wu10305cc2015-02-22 07:55:32 -080036
37protected:
Ronghua Wu14bcaca2015-03-16 11:24:30 -070038 virtual ~ProcessInfo();
39
40private:
Chong Zhang97d367b2020-09-16 12:53:14 -070041 struct ProcessInfoOverride {
42 int procState;
43 int oomScore;
44 };
45 std::mutex mOverrideLock;
46 std::map<int, ProcessInfoOverride> mOverrideMap GUARDED_BY(mOverrideLock);
47
Atneya Nairf5b68512022-05-23 20:02:49 -040048 ProcessInfo(const ProcessInfo&) = delete;
49 ProcessInfo& operator=(const ProcessInfo&) = delete;
Ronghua Wu10305cc2015-02-22 07:55:32 -080050};
51
52} // namespace android
53
Ronghua Wu14bcaca2015-03-16 11:24:30 -070054#endif // PROCESS_INFO_H_