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

Commit 13c2e1f5 authored by Ytai Ben-Tsvi's avatar Ytai Ben-Tsvi Committed by Automerger Merge Worker
Browse files

Invert how sound trigger capture is notified am: 85093d5e

Change-Id: I98d15ad528d1b674b60381b63761069577304213
parents e5ad38f1 85093d5e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ cc_library_shared {
        "TrackPlayerBase.cpp",
    ],
    shared_libs: [
        "capture_state_listener-aidl-cpp",
        "libaudiofoundation",
        "libaudioutils",
        "libaudiopolicy",
+52 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <math.h>
#include <sys/types.h>

#include <android/media/ICaptureStateListener.h>
#include <binder/IPCThreadState.h>
#include <binder/Parcel.h>
#include <media/AudioEffect.h>
@@ -32,6 +33,8 @@

namespace android {

using media::ICaptureStateListener;

enum {
    SET_DEVICE_CONNECTION_STATE = IBinder::FIRST_CALL_TRANSACTION,
    GET_DEVICE_CONNECTION_STATE,
@@ -115,6 +118,7 @@ enum {
    GET_DEVICES_FOR_ATTRIBUTES,
    AUDIO_MODULES_UPDATED,  // oneway
    SET_CURRENT_IME_UID,
    REGISTER_SOUNDTRIGGER_CAPTURE_STATE_LISTENER,
};

#define MAX_ITEMS_PER_LIST 1024
@@ -1470,6 +1474,27 @@ public:
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        remote()->transact(AUDIO_MODULES_UPDATED, data, &reply, IBinder::FLAG_ONEWAY);
    }

    status_t registerSoundTriggerCaptureStateListener(
            const sp<media::ICaptureStateListener>& listener,
            bool* result) override {
        Parcel data, reply;
        status_t status;
        status =
            data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        if (status != NO_ERROR) return status;
        status = data.writeStrongBinder(IInterface::asBinder(listener));
        if (status != NO_ERROR) return status;
        status =
            remote()->transact(REGISTER_SOUNDTRIGGER_CAPTURE_STATE_LISTENER,
                               data,
                               &reply,
                               0);
        if (status != NO_ERROR) return status;
        status = reply.readBool(result);
        if (status != NO_ERROR) return status;
        return NO_ERROR;
    }
};

IMPLEMENT_META_INTERFACE(AudioPolicyService, "android.media.IAudioPolicyService");
@@ -1543,7 +1568,8 @@ status_t BnAudioPolicyService::onTransact(
        case GET_DEVICES_FOR_ATTRIBUTES:
        case SET_ALLOWED_CAPTURE_POLICY:
        case AUDIO_MODULES_UPDATED:
        case SET_CURRENT_IME_UID: {
        case SET_CURRENT_IME_UID:
        case REGISTER_SOUNDTRIGGER_CAPTURE_STATE_LISTENER: {
            if (!isServiceUid(IPCThreadState::self()->getCallingUid())) {
                ALOGW("%s: transaction %d received from PID %d unauthorized UID %d",
                      __func__, code, IPCThreadState::self()->getCallingPid(),
@@ -2706,6 +2732,31 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        }

        case REGISTER_SOUNDTRIGGER_CAPTURE_STATE_LISTENER: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            sp<IBinder> binder = data.readStrongBinder();
            if (binder == nullptr) {
                return BAD_VALUE;
            }
            sp<ICaptureStateListener>
                listener = interface_cast<ICaptureStateListener>(
                binder);
            if (listener == nullptr) {
                return BAD_VALUE;
            }
            bool ret;
            status_t status =
                registerSoundTriggerCaptureStateListener(listener, &ret);
            LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
                                "Server returned unexpected status code: %d",
                                status);
            status = reply->writeBool(ret);
            if (status != NO_ERROR) {
                return status;
            }
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+11 −0
Original line number Diff line number Diff line
@@ -31,6 +31,11 @@
#include <vector>

namespace android {
namespace media {
// Must be pre-declared, or else there isn't a good way to generate a header
// library.
class ICaptureStateListener;
}

// ----------------------------------------------------------------------------

@@ -243,6 +248,12 @@ public:

    virtual status_t getPreferredDeviceForStrategy(product_strategy_t strategy,
                                                   AudioDeviceTypeAddr &device) = 0;

    // The return code here is only intended to represent transport errors. The
    // actual server implementation should always return NO_ERROR.
    virtual status_t registerSoundTriggerCaptureStateListener(
        const sp<media::ICaptureStateListener>& listener,
        bool* result) = 0;
};


+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ LOCAL_SHARED_LIBRARIES := \
    libmediautils \
    libeffectsconfig \
    libsensorprivacy \
    soundtrigger_middleware-aidl-cpp
    capture_state_listener-aidl-cpp

LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \
    libsensorprivacy
+3 −7
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@

#include "AudioPolicyService.h"

#include <android/media/soundtrigger_middleware/ISoundTriggerMiddlewareService.h>
#include <utils/Log.h>

#include "BinderProxy.h"
@@ -242,12 +241,9 @@ audio_unique_id_t AudioPolicyService::AudioPolicyClient::newAudioUniqueId(audio_
    return AudioSystem::newAudioUniqueId(use);
}

void AudioPolicyService::AudioPolicyClient::setSoundTriggerCaptureState(bool active) {
    using media::soundtrigger_middleware::ISoundTriggerMiddlewareService;

    static BinderProxy<ISoundTriggerMiddlewareService>
        proxy("soundtrigger_middleware");
    proxy.waitServiceOrDie()->setExternalCaptureState(active);
void AudioPolicyService::AudioPolicyClient::setSoundTriggerCaptureState(bool active)
{
    mAudioPolicyService->mCaptureStateNotifier.setCaptureState(active);
}

} // namespace android
Loading