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

Commit 01f84438 authored by Kwangkyu Park's avatar Kwangkyu Park
Browse files

Camera: fix an issue regarding ndk/vndk availability callback

If NDK user only uses availability callback then no service connection
will be made. Thus, no availability callback will be posted to the user.

Also, the camera service used to unconditionally filter out the status
change, if the listener is vendor listener. So, VNDK user will never
receive the availability callback.

With this patch, availability callback routine explicitly makes
connection to the service, and the status change will be filtered from
the service properly using shouldSkipStatusUpdates().

Test: use availability callback only from jni sample, vendor sample
Change-Id: Ic1d5951e3ee3b24ffe19aa780c67a98db781545b
parent 6999bc03
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -256,6 +256,7 @@ void CameraManagerGlobal::drainPendingCallbacksLocked() {
template<class T>
void CameraManagerGlobal::registerAvailCallback(const T *callback) {
    Mutex::Autolock _l(mLock);
    getCameraServiceLocked();
    Callback cb(callback);
    auto pair = mCallbacks.insert(cb);
    // Send initial callbacks if callback is newly registered
+1 −0
Original line number Diff line number Diff line
@@ -360,6 +360,7 @@ void CameraManagerGlobal::drainPendingCallbacksLocked() {

template <class T>
void CameraManagerGlobal::registerAvailCallback(const T *callback) {
    getCameraService();
    Mutex::Autolock _l(mLock);
    Callback cb(callback);
    auto pair = mCallbacks.insert(cb);
+1 −2
Original line number Diff line number Diff line
@@ -4686,8 +4686,7 @@ void CameraService::updateStatus(StatusInternal status, const std::string& camer
            for (auto& listener : mListenerList) {
                bool isVendorListener = listener->isVendorListener();
                if (shouldSkipStatusUpdates(deviceKind, isVendorListener,
                        listener->getListenerPid(), listener->getListenerUid()) ||
                        isVendorListener) {
                        listener->getListenerPid(), listener->getListenerUid())) {
                    ALOGV("Skipping discovery callback for system-only camera device %s",
                            cameraId.c_str());
                    continue;