Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64c70211 authored by Svet Ganov's avatar Svet Ganov Committed by android-build-merger
Browse files

Add API to query if a UID is active

am: fa851800

Change-Id: I2cd9e8a863a4beab2d028abeda266233d4d920eb
parents f4f7192e fa851800
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -80,6 +80,15 @@ void ActivityManager::unregisterUidObserver(const sp<IUidObserver>& observer)
    }
}

bool ActivityManager::isUidActive(const uid_t uid, const String16& callingPackage)
{
    sp<IActivityManager> service = getService();
    if (service != NULL) {
        return service->isUidActive(uid, callingPackage);
    }
    return false;
}

status_t ActivityManager::linkToDeath(const sp<IBinder::DeathRecipient>& recipient) {
    sp<IActivityManager> service = getService();
    if (service != NULL) {
+12 −0
Original line number Diff line number Diff line
@@ -78,6 +78,18 @@ public:
         data.writeStrongBinder(IInterface::asBinder(observer));
         remote()->transact(UNREGISTER_UID_OBSERVER_TRANSACTION, data, &reply);
    }

    virtual bool isUidActive(const uid_t uid, const String16& callingPackage)
    {
         Parcel data, reply;
         data.writeInterfaceToken(IActivityManager::getInterfaceDescriptor());
         data.writeInt32(uid);
         data.writeString16(callingPackage);
         remote()->transact(IS_UID_ACTIVE_TRANSACTION, data, &reply);
         // fail on exception
         if (reply.readExceptionCode() != 0) return false;
         return reply.readInt32() == 1;
    }
};

// ------------------------------------------------------------------------------------
+1 −0
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public:
                             const int32_t cutpoint,
                             const String16& callingPackage);
    void unregisterUidObserver(const sp<IUidObserver>& observer);
    bool isUidActive(const uid_t uid, const String16& callingPackage);

    status_t linkToDeath(const sp<IBinder::DeathRecipient>& recipient);
    status_t unlinkToDeath(const sp<IBinder::DeathRecipient>& recipient);
+3 −1
Original line number Diff line number Diff line
@@ -35,11 +35,13 @@ public:
                                     const int32_t cutpoint,
                                     const String16& callingPackage) = 0;
    virtual void unregisterUidObserver(const sp<IUidObserver>& observer) = 0;
    virtual bool isUidActive(const uid_t uid, const String16& callingPackage) = 0;

    enum {
        OPEN_CONTENT_URI_TRANSACTION = IBinder::FIRST_CALL_TRANSACTION,
        REGISTER_UID_OBSERVER_TRANSACTION,
        UNREGISTER_UID_OBSERVER_TRANSACTION
        UNREGISTER_UID_OBSERVER_TRANSACTION,
        IS_UID_ACTIVE_TRANSACTION
    };
};