blob: c27c939ce04ae7680d74ac76aa9f8f0ad73f82ad [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);
Girish4e531c82023-02-17 00:36:29 +000036 bool checkProcessExistent(const std::vector<int32_t>& pids,
37 std::vector<bool>* existent) override;
Ronghua Wu10305cc2015-02-22 07:55:32 -080038
39protected:
Ronghua Wu14bcaca2015-03-16 11:24:30 -070040 virtual ~ProcessInfo();
41
42private:
Chong Zhang97d367b2020-09-16 12:53:14 -070043 struct ProcessInfoOverride {
44 int procState;
45 int oomScore;
46 };
47 std::mutex mOverrideLock;
48 std::map<int, ProcessInfoOverride> mOverrideMap GUARDED_BY(mOverrideLock);
49
Atneya Nairf5b68512022-05-23 20:02:49 -040050 ProcessInfo(const ProcessInfo&) = delete;
51 ProcessInfo& operator=(const ProcessInfo&) = delete;
Ronghua Wu10305cc2015-02-22 07:55:32 -080052};
53
54} // namespace android
55
Ronghua Wu14bcaca2015-03-16 11:24:30 -070056#endif // PROCESS_INFO_H_