Home | History | Annotate | Download | only in binder
      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 gone
     35         UID_OBSERVER_GONE = 1<<1,
     36         // Flag for registerUidObserver: report uid has become idle
     37         UID_OBSERVER_IDLE = 1<<2,
     38         // Flag for registerUidObserver: report uid has become active
     39         UID_OBSERVER_ACTIVE = 1<<3
     40     };
     41 
     42     enum {
     43         // Not a real process state
     44         PROCESS_STATE_UNKNOWN = -1
     45     };
     46 
     47     ActivityManager();
     48 
     49     int openContentUri(const String16& stringUri);
     50     void registerUidObserver(const sp<IUidObserver>& observer,
     51                              const int32_t event,
     52                              const int32_t cutpoint,
     53                              const String16& callingPackage);
     54     void unregisterUidObserver(const sp<IUidObserver>& observer);
     55     bool isUidActive(const uid_t uid, const String16& callingPackage);
     56 
     57     status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
     58     status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);
     59 
     60 private:
     61     Mutex mLock;
     62     sp<IActivityManager> mService;
     63     sp<IActivityManager> getService();
     64 };
     65 
     66 
     67 }; // namespace android
     68 // ---------------------------------------------------------------------------
     69 #else // __ANDROID_VNDK__
     70 #error "This header is not visible to vendors"
     71 #endif // __ANDROID_VNDK__
     72 
     73 #endif // ANDROID_ACTIVITY_MANAGER_H
     74