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 20 #ifndef __ANDROID_VNDK__ 21 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 { 34 // Flag for registerUidObserver: report uid state changed 35 UID_OBSERVER_PROCSTATE = 1<<0, 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 { 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_LOCATION = 3, 50 PROCESS_STATE_BOUND_TOP = 4, 51 PROCESS_STATE_FOREGROUND_SERVICE = 5, 52 PROCESS_STATE_BOUND_FOREGROUND_SERVICE = 6, 53 PROCESS_STATE_IMPORTANT_FOREGROUND = 7, 54 PROCESS_STATE_IMPORTANT_BACKGROUND = 8, 55 PROCESS_STATE_TRANSIENT_BACKGROUND = 9, 56 PROCESS_STATE_BACKUP = 10, 57 PROCESS_STATE_SERVICE = 11, 58 PROCESS_STATE_RECEIVER = 12, 59 PROCESS_STATE_TOP_SLEEPING = 13, 60 PROCESS_STATE_HEAVY_WEIGHT = 14, 61 PROCESS_STATE_HOME = 15, 62 PROCESS_STATE_LAST_ACTIVITY = 16, 63 PROCESS_STATE_CACHED_ACTIVITY = 17, 64 PROCESS_STATE_CACHED_ACTIVITY_CLIENT = 18, 65 PROCESS_STATE_CACHED_RECENT = 19, 66 PROCESS_STATE_CACHED_EMPTY = 20, 67 PROCESS_STATE_NONEXISTENT = 21, 68 }; 69 70 ActivityManager(); 71 72 int openContentUri(const String16& stringUri); 73 void registerUidObserver(const sp<IUidObserver>& observer, 74 const int32_t event, 75 const int32_t cutpoint, 76 const String16& callingPackage); 77 void unregisterUidObserver(const sp<IUidObserver>& observer); 78 bool isUidActive(const uid_t uid, const String16& callingPackage); 79 int getUidProcessState(const uid_t uid, const String16& callingPackage); 80 81 82 status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient); 83 status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient); 84 85 private: 86 Mutex mLock; 87 sp<IActivityManager> mService; 88 sp<IActivityManager> getService(); 89 }; 90 91 92 }; // namespace android 93 // --------------------------------------------------------------------------- 94 #else // __ANDROID_VNDK__ 95 #error "This header is not visible to vendors" 96 #endif // __ANDROID_VNDK__ 97 98 #endif // ANDROID_ACTIVITY_MANAGER_H 99