| Ruben Brunk | 52f0407 | 2015-01-28 18:13:33 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright 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 |  | 
|  | 17 | #ifndef ANDROID_PROCESS_INFO_SERVICE_H | 
|  | 18 | #define ANDROID_PROCESS_INFO_SERVICE_H | 
|  | 19 |  | 
|  | 20 | #include <binder/IProcessInfoService.h> | 
|  | 21 | #include <utils/Errors.h> | 
|  | 22 | #include <utils/Singleton.h> | 
|  | 23 | #include <sys/types.h> | 
|  | 24 |  | 
|  | 25 | namespace android { | 
|  | 26 |  | 
|  | 27 | // ---------------------------------------------------------------------- | 
|  | 28 |  | 
|  | 29 | class ProcessInfoService : public Singleton<ProcessInfoService> { | 
|  | 30 |  | 
|  | 31 | friend class Singleton<ProcessInfoService>; | 
|  | 32 | sp<IProcessInfoService> mProcessInfoService; | 
|  | 33 | Mutex mProcessInfoLock; | 
|  | 34 |  | 
|  | 35 | ProcessInfoService(); | 
|  | 36 |  | 
|  | 37 | status_t getProcessStatesImpl(size_t length, /*in*/ int32_t* pids, /*out*/ int32_t* states); | 
|  | 38 | void updateBinderLocked(); | 
|  | 39 |  | 
|  | 40 | static const int BINDER_ATTEMPT_LIMIT = 5; | 
|  | 41 |  | 
|  | 42 | public: | 
|  | 43 |  | 
|  | 44 | /** | 
|  | 45 | * For each PID in the given "pids" input array, write the current process state | 
|  | 46 | * for that process into the "states" output array, or | 
|  | 47 | * ActivityManager.PROCESS_STATE_NONEXISTENT * to indicate that no process with the given PID | 
|  | 48 | * exists. | 
|  | 49 | * | 
|  | 50 | * Returns NO_ERROR if this operation was successful, or a negative error code otherwise. | 
|  | 51 | */ | 
|  | 52 | static status_t getProcessStatesFromPids(size_t length, /*in*/ int32_t* pids, | 
|  | 53 | /*out*/ int32_t* states) { | 
|  | 54 | return ProcessInfoService::getInstance().getProcessStatesImpl(length, /*in*/ pids, | 
|  | 55 | /*out*/ states); | 
|  | 56 | } | 
|  | 57 |  | 
|  | 58 | }; | 
|  | 59 |  | 
|  | 60 | // ---------------------------------------------------------------------- | 
|  | 61 |  | 
|  | 62 | }; // namespace android | 
|  | 63 |  | 
|  | 64 | #endif // ANDROID_PROCESS_INFO_SERVICE_H | 
|  | 65 |  |