Ronghua Wu | 10305cc | 2015-02-22 07:55:32 -0800 | [diff] [blame] | 1 | /* |
| 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 Wu | 14bcaca | 2015-03-16 11:24:30 -0700 | [diff] [blame] | 17 | #ifndef PROCESS_INFO_H_ |
Ronghua Wu | 10305cc | 2015-02-22 07:55:32 -0800 | [diff] [blame] | 18 | |
Ronghua Wu | 14bcaca | 2015-03-16 11:24:30 -0700 | [diff] [blame] | 19 | #define PROCESS_INFO_H_ |
| 20 | |
Atneya Nair | f5b6851 | 2022-05-23 20:02:49 -0400 | [diff] [blame] | 21 | #include <mediautils/ProcessInfoInterface.h> |
Chong Zhang | 97d367b | 2020-09-16 12:53:14 -0700 | [diff] [blame] | 22 | #include <map> |
| 23 | #include <mutex> |
| 24 | #include <utils/Condition.h> |
Ronghua Wu | 10305cc | 2015-02-22 07:55:32 -0800 | [diff] [blame] | 25 | |
| 26 | namespace android { |
| 27 | |
Ronghua Wu | 14bcaca | 2015-03-16 11:24:30 -0700 | [diff] [blame] | 28 | struct ProcessInfo : public ProcessInfoInterface { |
| 29 | ProcessInfo(); |
| 30 | |
| 31 | virtual bool getPriority(int pid, int* priority); |
Brian Lindahl | cf3bafb | 2022-01-27 14:21:38 +0100 | [diff] [blame] | 32 | virtual bool isPidTrusted(int pid); |
| 33 | virtual bool isPidUidTrusted(int pid, int uid); |
Chong Zhang | 97d367b | 2020-09-16 12:53:14 -0700 | [diff] [blame] | 34 | virtual bool overrideProcessInfo(int pid, int procState, int oomScore); |
| 35 | virtual void removeProcessInfoOverride(int pid); |
Ronghua Wu | 10305cc | 2015-02-22 07:55:32 -0800 | [diff] [blame] | 36 | |
| 37 | protected: |
Ronghua Wu | 14bcaca | 2015-03-16 11:24:30 -0700 | [diff] [blame] | 38 | virtual ~ProcessInfo(); |
| 39 | |
| 40 | private: |
Chong Zhang | 97d367b | 2020-09-16 12:53:14 -0700 | [diff] [blame] | 41 | struct ProcessInfoOverride { |
| 42 | int procState; |
| 43 | int oomScore; |
| 44 | }; |
| 45 | std::mutex mOverrideLock; |
| 46 | std::map<int, ProcessInfoOverride> mOverrideMap GUARDED_BY(mOverrideLock); |
| 47 | |
Atneya Nair | f5b6851 | 2022-05-23 20:02:49 -0400 | [diff] [blame] | 48 | ProcessInfo(const ProcessInfo&) = delete; |
| 49 | ProcessInfo& operator=(const ProcessInfo&) = delete; |
Ronghua Wu | 10305cc | 2015-02-22 07:55:32 -0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | } // namespace android |
| 53 | |
Ronghua Wu | 14bcaca | 2015-03-16 11:24:30 -0700 | [diff] [blame] | 54 | #endif // PROCESS_INFO_H_ |