blob: eb1efd690984459167c92b3aa6d24946541c38ad [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
21#include <media/stagefright/foundation/ABase.h>
Girish1f002cf2023-02-17 00:36:29 +000022#include <mediautils/ProcessInfoInterface.h>
Chong Zhang97d367b2020-09-16 12:53:14 -070023#include <map>
24#include <mutex>
25#include <utils/Condition.h>
Ronghua Wu10305cc2015-02-22 07:55:32 -080026
27namespace android {
28
Ronghua Wu14bcaca2015-03-16 11:24:30 -070029struct ProcessInfo : public ProcessInfoInterface {
30 ProcessInfo();
31
32 virtual bool getPriority(int pid, int* priority);
Brian Lindahlcf3bafb2022-01-27 14:21:38 +010033 virtual bool isPidTrusted(int pid);
34 virtual bool isPidUidTrusted(int pid, int uid);
Chong Zhang97d367b2020-09-16 12:53:14 -070035 virtual bool overrideProcessInfo(int pid, int procState, int oomScore);
36 virtual void removeProcessInfoOverride(int pid);
Girish1f002cf2023-02-17 00:36:29 +000037 bool checkProcessExistent(const std::vector<int32_t>& pids,
38 std::vector<bool>* existent) override;
Ronghua Wu10305cc2015-02-22 07:55:32 -080039
40protected:
Ronghua Wu14bcaca2015-03-16 11:24:30 -070041 virtual ~ProcessInfo();
42
43private:
Chong Zhang97d367b2020-09-16 12:53:14 -070044 struct ProcessInfoOverride {
45 int procState;
46 int oomScore;
47 };
48 std::mutex mOverrideLock;
49 std::map<int, ProcessInfoOverride> mOverrideMap GUARDED_BY(mOverrideLock);
50
Ronghua Wu14bcaca2015-03-16 11:24:30 -070051 DISALLOW_EVIL_CONSTRUCTORS(ProcessInfo);
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_