blob: 26dafd0a12e258cbef10b64a74d22a16bd25715f [file] [log] [blame]
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +00001/*
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 Park47f876b2018-04-17 13:56:46 +090020#ifndef __ANDROID_VNDK__
21
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +000022#include <binder/IActivityManager.h>
23
24#include <utils/threads.h>
25
26// ---------------------------------------------------------------------------
27namespace android {
28
29class ActivityManager
30{
31public:
32
33 enum {
Eric Laurent05595892018-10-18 14:56:24 -070034 // Flag for registerUidObserver: report uid state changed
35 UID_OBSERVER_PROCSTATE = 1<<0,
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +000036 // 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 Laurent05595892018-10-18 14:56:24 -070045 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 Mahendran4d85b8c2017-11-02 14:43:38 +000066 };
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 Ganovfa851802018-03-27 17:17:46 -070076 bool isUidActive(const uid_t uid, const String16& callingPackage);
Eric Laurent05595892018-10-18 14:56:24 -070077 int getUidProcessState(const uid_t uid, const String16& callingPackage);
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +000078
Eric Laurent05595892018-10-18 14:56:24 -070079
80 status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
Eino-Ville Talvalaae8b20d2018-03-20 11:05:23 -070081 status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);
82
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +000083private:
84 Mutex mLock;
85 sp<IActivityManager> mService;
86 sp<IActivityManager> getService();
87};
88
89
90}; // namespace android
91// ---------------------------------------------------------------------------
Jiyong Park47f876b2018-04-17 13:56:46 +090092#else // __ANDROID_VNDK__
93#error "This header is not visible to vendors"
94#endif // __ANDROID_VNDK__
95
Ganesh Mahendran4d85b8c2017-11-02 14:43:38 +000096#endif // ANDROID_ACTIVITY_MANAGER_H