ऑटोमोटिव डिस्प्ले प्रॉक्सी सेवा

यह सरल फ्रेमवर्क सेवा विक्रेता प्रक्रियाओं को libgui को लिंक किए बिना, HAL कार्यान्वयन में SurfaceFlinger/EGL का उपयोग करने देती है। AOSP इस सेवा का डिफ़ॉल्ट कार्यान्वयन प्रदान करता है, जो पूरी तरह कार्यात्मक है। हालाँकि, विक्रेता को अपने प्लेटफ़ॉर्म पर यह सेवा प्रदान करने के लिए एपीआई भी लागू करनी होगी।

package android.frameworks.automotive.display@1.0;

import android.hardware.graphics.bufferqueue@2.0::IGraphicBufferProducer;

interface IAutomotiveDisplayProxyService {
    /**
     * Gets an IGraphicBufferProducer instance from the service.
     *
     * @param  id   Target's stable display identifier
     *
     * @return igbp Returns an IGraphicBufferProducer object, that can be
     *              converted to an ANativeWindow object.
     */
    getIGraphicBufferProducer(uint64_t id) generates (IGraphicBufferProducer igbp);

    /**
     * Sets the ANativeWindow, which is associated with the
     * IGraphicBufferProducer, to be visible and to take over the display.
     *
     * @param  id      Target display ID
     *
     * @return success Returns true on success.
     */
    showWindow(uint64_t id) generates (bool success);

    /**
     * Sets the ANativeWindow, which is associated with the
     * IGraphicBufferProducer, to be invisible and to release the control
     * over display.
     *
     * @param  id      Target display ID
     *
     * @return success Returns true on success.
     */
    hideWindow(uint64_t id) generates (bool success);

    /**
     * Returns the stable identifiers of all available displays.
     *
     * @return ids A list of stable display identifiers.
     */
    getDisplayIdList() generates (vec<uint64_t> ids);

    /**
     * Returns the descriptor of the target display.
     *
     * @param  id    Stable ID of a target display.
     * @return cfg   DisplayConfig of the active display.
     * @return state Current state of the active display.
     */
    getDisplayInfo(uint64_t id) generates (HwDisplayConfig cfg, HwDisplayState state);
}

इस सेवा का उपयोग करने के लिए:

  1. IAutomotiveDisplayProxyService प्राप्त करें।
    android::sp<IAutomotiveDisplayProxyService> windowProxyService =
        IAutomotiveDisplayProxyService::getService("default");
    if (windowProxyService == nullptr) {
        LOG(ERROR) << "Cannot use AutomotiveDisplayProxyService. Exiting.";
        return 1;
    }
    
  2. रिज़ॉल्यूशन निर्धारित करने के लिए सेवा से सक्रिय प्रदर्शन जानकारी प्राप्त करें।
    // We use the first display in the list as the primary.
    pWindowProxy->getDisplayInfo(displayId, [this](auto dpyConfig, auto dpyState) {
        DisplayConfig *pConfig = (DisplayConfig*)dpyConfig.data();
        mWidth = pConfig->resolution.getWidth();
        mHeight = pConfig->resolution.getHeight();
    
        ui::DisplayState* pState = (ui::DisplayState*)dpyState.data();
        if (pState->orientation != ui::ROTATION_0 &&
            pState->orientation != ui::ROTATION_180) {
            // rotate
            std::swap(mWidth, mHeight);
        }
    
        LOG(DEBUG) << "Display resolution is " << mWidth << " x " << mHeight;
    });
    
  3. IAutomotiveDisplayProxyService से एक हार्डवेयर IGraphicBufferProducer (या, HIDL ग्राफ़िकबफ़रप्रोड्यूसर (HGBP) पुनर्प्राप्त करें:
    mGfxBufferProducer = pWindowProxy->getIGraphicBufferProducer(displayId);
    if (mGfxBufferProducer == nullptr) {
        LOG(ERROR) << "Failed to get IGraphicBufferProducer from "
                   << "IAutomotiveDisplayProxyService.";
        return false;
    }
    
  4. एपीआई libbufferqueueconverter का उपयोग करके पुनर्प्राप्त HGBP से एक SurfaceHolder प्राप्त करें:
    mSurfaceHolder = getSurfaceFromHGBP(mGfxBufferProducer);
    if (mSurfaceHolder == nullptr) {
        LOG(ERROR) << "Failed to get a Surface from HGBP.";
        return false;
    }
    
  5. एपीआई libbufferqueueconverter का उपयोग करके SurfaceHolder मूल विंडो में कनवर्ट करें:
    mWindow = getNativeWindow(mSurfaceHolder.get());
    if (mWindow == nullptr) {
        LOG(ERROR) << "Failed to get a native window from Surface.";
        return false;
    }
    
  6. मूल विंडो के साथ एक ईजीएल विंडो सतह बनाएं और फिर प्रस्तुत करें:
    // Set up our OpenGL ES context associated with the default display
    mDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
    if (mDisplay == EGL_NO_DISPLAY) {
        LOG(ERROR) << "Failed to get egl display";
        return false;
    }
    ...
    
    // Create the EGL render target surface
    mSurface = eglCreateWindowSurface(mDisplay, egl_config, mWindow, nullptr);
    if (mSurface == EGL_NO_SURFACE) {
        LOG(ERROR) << "eglCreateWindowSurface failed.";
        return false;
    }
    ...
    
  7. स्क्रीन पर प्रस्तुत दृश्य प्रदर्शित करने के लिए IAutomotiveDisplayProxyService::showWindow() पर कॉल करें। इस सेवा की सर्वोच्च प्राथमिकता है और इसलिए, यह हमेशा वर्तमान स्वामी से स्क्रीन का नियंत्रण लेती है:
    mAutomotiveDisplayProxyService->showWindow();
    

अधिक कार्यान्वयन विवरण के लिए $ANDROID_BUILD_TOP/packages/services/Car/evs/sampleDriver/ में service.cpp और GlWrapper.cpp देखें।

ईवीएस एचएएल कार्यान्वयन के लिए नीचे बोल्ड में प्रदर्शित अतिरिक्त लाइब्रेरी की आवश्यकता होती है।

cc_binary {
    name: "android.hardware.automotive.evs@1.1-sample",

    vendor: true,

    srcs: [
        ...
    ],

    shared_libs: [
        ...
        "libbufferqueueconverter",
        "android.hidl.token@1.0-utils",
        "android.frameworks.automotive.display@1.0",
        "android.hardware.graphics.bufferqueue@1.0",
        "android.hardware.graphics.bufferqueue@2.0",
    ],

मल्टी-डिस्प्ले समर्थन

डिवाइस गणना प्रदर्शित करें और प्रदर्शन जानकारी पुनर्प्राप्त करें

कैमरा डिवाइस गणना की तरह, ईवीएस ढांचा उपलब्ध डिस्प्ले की गणना करने की एक विधि प्रदान करता है। स्थिर प्रदर्शन पहचानकर्ता एक प्रकार-लंबे पहचानकर्ता, निचले बाइट में डिस्प्ले पोर्ट जानकारी और ऊपरी बिट्स में Extended Display IDentification Data एन्कोड करता है। IAutomotiveDisplayProxyService::getDisplayIdList() भौतिक स्थानीय डिस्प्ले की डिस्प्ले आईडी की एक सूची लौटाता है, जो EVS सेवा के लिए उपलब्ध हैं, और IEvsEnumerator::getDisplayIdList() उन डिस्प्ले पोर्ट की एक सूची देता है जिनसे डिस्प्ले जुड़े हुए हैं। सूची में पहली आईडी हमेशा प्राथमिक डिस्प्ले की होती है।

interface IEvsEnumerator extends @1.0::IEvsEnumerator {
    ...
    /**
     * Returns a list of all EVS displays available to the system
     *
     * @return displayIds Identifiers of available displays.
     */
    getDisplayIdList() generates (vec<uint8_t> displayIds);
};

लक्ष्य डिस्प्ले डिवाइस खोलें

EVS ऐप लक्ष्य डिस्प्ले पोर्ट नंबर के साथ IEvsEnumerator::openDisplay_1_1() को कॉल करता है:

android::sp<IEvsDisplay> pDisplay = pEvs->openDisplay_1_1(displayId);
if (pDisplay.get() == nullptr) {
    LOG(ERROR) << "EVS Display unavailable. Exiting.";
    return 1;
}

ध्यान दें: एक समय में केवल एक ही डिस्प्ले का उपयोग किया जा सकता है, जिसका अर्थ है कि जब कोई अन्य ईवीएस क्लाइंट डिस्प्ले खोलने का अनुरोध करता है तो वर्तमान ईवीएस क्लाइंट अपना डिस्प्ले खो देता है, भले ही वे समान न हों।