Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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_ACTIVITY_MANAGER_H |
| 18 | #define ANDROID_ACTIVITY_MANAGER_H |
| 19 | |
Jiyong Park | 47f876b | 2018-04-17 13:56:46 +0900 | [diff] [blame] | 20 | #ifndef __ANDROID_VNDK__ |
| 21 | |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 22 | #include <binder/IActivityManager.h> |
| 23 | |
| 24 | #include <utils/threads.h> |
| 25 | |
| 26 | // --------------------------------------------------------------------------- |
| 27 | namespace android { |
| 28 | |
| 29 | class ActivityManager |
| 30 | { |
| 31 | public: |
| 32 | |
| 33 | enum { |
Eric Laurent | 0559589 | 2018-10-18 14:56:24 -0700 | [diff] [blame] | 34 | // Flag for registerUidObserver: report uid state changed |
| 35 | UID_OBSERVER_PROCSTATE = 1<<0, |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 36 | // Flag for registerUidObserver: report uid gone |
| 37 | UID_OBSERVER_GONE = 1<<1, |
| 38 | // Flag for registerUidObserver: report uid has become idle |
| 39 | UID_OBSERVER_IDLE = 1<<2, |
| 40 | // Flag for registerUidObserver: report uid has become active |
| 41 | UID_OBSERVER_ACTIVE = 1<<3 |
| 42 | }; |
| 43 | |
| 44 | enum { |
Eric Laurent | 0559589 | 2018-10-18 14:56:24 -0700 | [diff] [blame] | 45 | PROCESS_STATE_UNKNOWN = -1, |
| 46 | PROCESS_STATE_PERSISTENT = 0, |
| 47 | PROCESS_STATE_PERSISTENT_UI = 1, |
| 48 | PROCESS_STATE_TOP = 2, |
| 49 | PROCESS_STATE_FOREGROUND_SERVICE = 3, |
| 50 | PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 4, |
| 51 | PROCESS_STATE_IMPORTANT_FOREGROUND = 5, |
| 52 | PROCESS_STATE_IMPORTANT_BACKGROUND = 6, |
| 53 | PROCESS_STATE_TRANSIENT_BACKGROUND = 7, |
| 54 | PROCESS_STATE_BACKUP = 8, |
| 55 | PROCESS_STATE_SERVICE = 9, |
| 56 | PROCESS_STATE_RECEIVER = 10, |
| 57 | PROCESS_STATE_TOP_SLEEPING = 11, |
| 58 | PROCESS_STATE_HEAVY_WEIGHT = 12, |
| 59 | PROCESS_STATE_HOME = 13, |
| 60 | PROCESS_STATE_LAST_ACTIVITY = 14, |
| 61 | PROCESS_STATE_CACHED_ACTIVITY = 15, |
| 62 | PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 16, |
| 63 | PROCESS_STATE_CACHED_RECENT = 17, |
| 64 | PROCESS_STATE_CACHED_EMPTY = 18, |
| 65 | PROCESS_STATE_NONEXISTENT = 19, |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | ActivityManager(); |
| 69 | |
| 70 | int openContentUri(const String16& stringUri); |
| 71 | void registerUidObserver(const sp<IUidObserver>& observer, |
| 72 | const int32_t event, |
| 73 | const int32_t cutpoint, |
| 74 | const String16& callingPackage); |
| 75 | void unregisterUidObserver(const sp<IUidObserver>& observer); |
Svet Ganov | fa85180 | 2018-03-27 17:17:46 -0700 | [diff] [blame] | 76 | bool isUidActive(const uid_t uid, const String16& callingPackage); |
Eric Laurent | 0559589 | 2018-10-18 14:56:24 -0700 | [diff] [blame] | 77 | int getUidProcessState(const uid_t uid, const String16& callingPackage); |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 78 | |
Eric Laurent | 0559589 | 2018-10-18 14:56:24 -0700 | [diff] [blame] | 79 | |
| 80 | status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient); |
Eino-Ville Talvala | ae8b20d | 2018-03-20 11:05:23 -0700 | [diff] [blame] | 81 | status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient); |
| 82 | |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 83 | private: |
| 84 | Mutex mLock; |
| 85 | sp<IActivityManager> mService; |
| 86 | sp<IActivityManager> getService(); |
| 87 | }; |
| 88 | |
| 89 | |
| 90 | }; // namespace android |
| 91 | // --------------------------------------------------------------------------- |
Jiyong Park | 47f876b | 2018-04-17 13:56:46 +0900 | [diff] [blame] | 92 | #else // __ANDROID_VNDK__ |
| 93 | #error "This header is not visible to vendors" |
| 94 | #endif // __ANDROID_VNDK__ |
| 95 | |
Ganesh Mahendran | 4d85b8c | 2017-11-02 14:43:38 +0000 | [diff] [blame] | 96 | #endif // ANDROID_ACTIVITY_MANAGER_H |