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

Commit 8edbbda2 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4376088 from 7932c6d1 to oc-mr1-release

Change-Id: Ic75625ea785bb670688ea113bba16fc6d4580906
parents 913ef2ea 7932c6d1
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -32,9 +32,11 @@
#include <hwbinder/ProcessState.h>

// from LOCAL_C_INCLUDES
#include "aaudio/AAudioTesting.h"
#include "AudioFlinger.h"
#include "AudioPolicyService.h"
#include "AAudioService.h"
#include "utility/AAudioUtilities.h"
#include "MediaLogService.h"
#include "SoundTriggerHwService.h"

@@ -131,7 +133,16 @@ int main(int argc __unused, char **argv)
        ALOGI("ServiceManager: %p", sm.get());
        AudioFlinger::instantiate();
        AudioPolicyService::instantiate();

        // AAudioService should only be used in OC-MR1 and later.
        // And only enable the AAudioService if the system MMAP policy explicitly allows it.
        // This prevents a client from misusing AAudioService when it is not supported.
        aaudio_policy_t mmapPolicy = property_get_int32(AAUDIO_PROP_MMAP_POLICY,
                                                        AAUDIO_POLICY_NEVER);
        if (mmapPolicy == AAUDIO_POLICY_AUTO || mmapPolicy == AAUDIO_POLICY_ALWAYS) {
            AAudioService::instantiate();
        }

        SoundTriggerHwService::instantiate();
        ProcessState::self()->startThreadPool();

+2 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public:
        data.writeInterfaceToken(IMediaAnalyticsService::getInterfaceDescriptor());
        err = remote()->transact(GENERATE_UNIQUE_SESSIONID, data, &reply);
        if (err != NO_ERROR) {
            ALOGW("bad response from service");
            ALOGW("bad response from service for generateSessionId, err=%d", err);
            return MediaAnalyticsItem::SessionIDInvalid;
        }
        sessionid = reply.readInt64();
@@ -94,6 +94,7 @@ public:

        err = remote()->transact(SUBMIT_ITEM, data, &reply);
        if (err != NO_ERROR) {
            ALOGW("bad response from service for submit, err=%d", err);
            return MediaAnalyticsItem::SessionIDInvalid;
        }

+39 −10
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ void MediaAnalyticsItem::clear() {

    // clean attributes
    // contents of the attributes
    for (size_t i = 0 ; i < mPropSize; i++ ) {
    for (size_t i = 0 ; i < mPropCount; i++ ) {
        clearProp(&mProps[i]);
    }
    // the attribute records themselves
@@ -300,7 +300,8 @@ bool MediaAnalyticsItem::removeProp(const char *name) {
        clearProp(prop);
        if (i != mPropCount-1) {
            // in the middle, bring last one down to fill gap
            mProps[i] = mProps[mPropCount-1];
            copyProp(prop, &mProps[mPropCount-1]);
            clearProp(&mProps[mPropCount-1]);
        }
        mPropCount--;
        return true;
@@ -819,11 +820,16 @@ bool MediaAnalyticsItem::selfrecord(bool forcenew) {
    sp<IMediaAnalyticsService> svc = getInstance();

    if (svc != NULL) {
        svc->submit(this, forcenew);
        MediaAnalyticsItem::SessionID_t newid = svc->submit(this, forcenew);
        if (newid == SessionIDInvalid) {
            AString p = this->toString();
            ALOGW("Failed to record: %s [forcenew=%d]", p.c_str(), forcenew);
            return false;
        }
        return true;
    } else {
        AString p = this->toString();
        ALOGD("Unable to record: %s [forcenew=%d]", p.c_str(), forcenew);
        ALOGW("Unable to record: %s [forcenew=%d]", p.c_str(), forcenew);
        return false;
    }
}
@@ -832,6 +838,7 @@ bool MediaAnalyticsItem::selfrecord(bool forcenew) {
// static
sp<IMediaAnalyticsService> MediaAnalyticsItem::sAnalyticsService;
static Mutex sInitMutex;
static int remainingBindAttempts = SVC_TRIES;

//static
bool MediaAnalyticsItem::isEnabled() {
@@ -849,10 +856,28 @@ bool MediaAnalyticsItem::isEnabled() {
    return true;
}


// monitor health of our connection to the metrics service
class MediaMetricsDeathNotifier : public IBinder::DeathRecipient {
        virtual void binderDied(const wp<IBinder> &) {
            ALOGW("Reacquire service connection on next request");
            MediaAnalyticsItem::dropInstance();
        }
};

static sp<MediaMetricsDeathNotifier> sNotifier = NULL;

// static
void MediaAnalyticsItem::dropInstance() {
    Mutex::Autolock _l(sInitMutex);
    remainingBindAttempts = SVC_TRIES;
    sAnalyticsService = NULL;
}

//static
sp<IMediaAnalyticsService> MediaAnalyticsItem::getInstance() {

    static const char *servicename = "media.metrics";
    static int tries_remaining = SVC_TRIES;
    int enabled = isEnabled();

    if (enabled == false) {
@@ -884,15 +909,20 @@ sp<IMediaAnalyticsService> MediaAnalyticsItem::getInstance() {
        Mutex::Autolock _l(sInitMutex);
        const char *badness = "";

        // think of tries_remaining as telling us whether service==NULL because
        // think of remainingBindAttempts as telling us whether service==NULL because
        // (1) we haven't tried to initialize it yet
        // (2) we've tried to initialize it, but failed.
        if (sAnalyticsService == NULL && tries_remaining > 0) {
        if (sAnalyticsService == NULL && remainingBindAttempts > 0) {
            sp<IServiceManager> sm = defaultServiceManager();
            if (sm != NULL) {
                sp<IBinder> binder = sm->getService(String16(servicename));
                if (binder != NULL) {
                    sAnalyticsService = interface_cast<IMediaAnalyticsService>(binder);
                    if (sNotifier != NULL) {
                        sNotifier = NULL;
                    }
                    sNotifier = new MediaMetricsDeathNotifier();
                    binder->linkToDeath(sNotifier);
                } else {
                    badness = "did not find service";
                }
@@ -901,8 +931,8 @@ sp<IMediaAnalyticsService> MediaAnalyticsItem::getInstance() {
            }

            if (sAnalyticsService == NULL) {
                if (tries_remaining > 0) {
                    tries_remaining--;
                if (remainingBindAttempts > 0) {
                    remainingBindAttempts--;
                }
                if (DEBUG_SERVICEACCESS) {
                    ALOGD("Unable to bind to service %s: %s", servicename, badness);
@@ -914,7 +944,6 @@ sp<IMediaAnalyticsService> MediaAnalyticsItem::getInstance() {
    }
}


// merge the info from 'incoming' into this record.
// we finish with a union of this+incoming and special handling for collisions
bool MediaAnalyticsItem::merge(MediaAnalyticsItem *incoming) {
+2 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ class MediaAnalyticsItem {
    friend class IMediaAnalyticsService;
    friend class MediaMetricsJNI;
    friend class MetricsSummarizer;
    friend class MediaMetricsDeathNotifier;

    public:

@@ -209,6 +210,7 @@ class MediaAnalyticsItem {
        // let's reuse a binder connection
        static sp<IMediaAnalyticsService> sAnalyticsService;
        static sp<IMediaAnalyticsService> getInstance();
        static void dropInstance();

        // tracking information
        SessionID_t mSessionID;         // grouping similar records
+16 −3
Original line number Diff line number Diff line
@@ -67,7 +67,14 @@ struct TWGraphicBufferSource::TWOmxNodeWrapper : public IOmxNodeWrapper {
        tMsg.data.eventData.data1 = dataSpace;
        tMsg.data.eventData.data2 = aspects;
        tMsg.data.eventData.data3 = pixelFormat;
        mOmxNode->dispatchMessage(tMsg);
        if (!mOmxNode->dispatchMessage(tMsg).isOk()) {
            ALOGE("TWOmxNodeWrapper failed to dispatch message "
                    "OMX_EventDataSpaceChanged: "
                    "dataSpace = %ld, aspects = %ld, pixelFormat = %ld",
                    static_cast<long>(dataSpace),
                    static_cast<long>(aspects),
                    static_cast<long>(pixelFormat));
        }
    }
};

@@ -143,10 +150,13 @@ Return<Status> TWGraphicBufferSource::configure(
                        outParams.data() + outParams.size(),
                        params);
            });
    omxNode->getParameter(
    auto transStatus = omxNode->getParameter(
            static_cast<uint32_t>(OMX_IndexParamConsumerUsageBits),
            inHidlBytes(&consumerUsage, sizeof(consumerUsage)),
            _hidl_cb);
    if (!transStatus.isOk()) {
        return toStatus(FAILED_TRANSACTION);
    }
    if (fnStatus != OK) {
        consumerUsage = 0;
    }
@@ -157,10 +167,13 @@ Return<Status> TWGraphicBufferSource::configure(

    _params = &def;
    params = static_cast<uint8_t*>(_params);
    omxNode->getParameter(
    transStatus = omxNode->getParameter(
            static_cast<uint32_t>(OMX_IndexParamPortDefinition),
            inHidlBytes(&def, sizeof(def)),
            _hidl_cb);
    if (!transStatus.isOk()) {
        return toStatus(FAILED_TRANSACTION);
    }
    if (fnStatus != NO_ERROR) {
        ALOGE("Failed to get port definition: %d", fnStatus);
        return toStatus(fnStatus);