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

Commit fa851800 authored by Svet Ganov's avatar Svet Ganov Committed by Svetoslav Ganov
Browse files

Add API to query if a UID is active

Test: cts-tradefed run cts-dev -m CtsCameraTestCases

Bug: 72863398

Change-Id: I8e5021f2ef4cd77fc89ae3b47cc32ad6913da0d6
parent b900363e
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
    };
};