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

Commit 84d1f7a0 authored by Mathias Agopian's avatar Mathias Agopian
Browse files

Merge commit 'goog/master' into merge_master

parents 2dd6727c 9ff0fe07
Loading
Loading
Loading
Loading
+99 −60
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
    LOGD("CameraService::connect E (pid %d, client %p)", callingPid,
            cameraClient->asBinder().get());

    Mutex::Autolock lock(mLock);
    Mutex::Autolock lock(mServiceLock);
    sp<Client> client;
    if (mClient != 0) {
        sp<Client> currentClient = mClient.promote();
@@ -125,12 +125,13 @@ sp<ICamera> CameraService::connect(const sp<ICameraClient>& cameraClient)
            LOGD("New client (pid %d) connecting, old reference was dangling...",
                    callingPid);
            mClient.clear();
        }
    }

    if (mUsers > 0) {
        LOGD("Still have client, rejected");
        return client;
    }
        }
    }

    // create a new Client object
    client = new Client(this, cameraClient, callingPid);
@@ -152,7 +153,7 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient)
    // destructor won't be called with the lock held.
    sp<Client> client;

    Mutex::Autolock lock(mLock);
    Mutex::Autolock lock(mServiceLock);

    if (mClient == 0) {
        // This happens when we have already disconnected.
@@ -390,8 +391,6 @@ void CameraService::Client::disconnect()
    // from the user directly, or called by the destructor.
    if (mHardware == 0) return;

    mCameraService->removeClient(mCameraClient);

    LOGD("hardware teardown");
    // Before destroying mHardware, we must make sure it's in the
    // idle state.
@@ -402,6 +401,7 @@ void CameraService::Client::disconnect()
    mHardware->release();
    mHardware.clear();

    mCameraService->removeClient(mCameraClient);
    mCameraService->decUsers();

    LOGD("Client::disconnect() X (pid %d)", callingPid);
@@ -410,11 +410,14 @@ void CameraService::Client::disconnect()
// pass the buffered ISurface to the camera service
status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface)
{
    LOGD("setPreviewDisplay(%p) (pid %d)", surface.get(), getCallingPid());
    LOGD("setPreviewDisplay(%p) (pid %d)",
         ((surface == NULL) ? NULL : surface.get()), getCallingPid());
    Mutex::Autolock lock(mLock);
    status_t result = checkPid();
    if (result != NO_ERROR) return result;

    Mutex::Autolock surfaceLock(mSurfaceLock);
    result = NO_ERROR;
    // asBinder() is safe on NULL (returns NULL)
    if (surface->asBinder() != mSurface->asBinder()) {
        if (mSurface != 0 && !mUseOverlay) {
@@ -422,8 +425,17 @@ status_t CameraService::Client::setPreviewDisplay(const sp<ISurface>& surface)
            mSurface->unregisterBuffers();
        }
        mSurface = surface;
        // If preview has been already started, set overlay or register preview
        // buffers now.
        if (mHardware->previewEnabled()) {
            if (mUseOverlay) {
                result = setOverlay();
            } else if (mSurface != 0) {
                result = registerPreviewBuffers();
            }
        }
    return NO_ERROR;
    }
    return result;
}

// set the preview callback flag to affect how the received frames from
@@ -436,7 +448,7 @@ void CameraService::Client::setPreviewCallbackFlag(int callback_flag)
    mPreviewCallbackFlag = callback_flag;
}

// start preview mode, must call setPreviewDisplay first
// start preview mode
status_t CameraService::Client::startCameraMode(camera_mode mode)
{
    int callingPid = getCallingPid();
@@ -456,16 +468,18 @@ status_t CameraService::Client::startCameraMode(camera_mode mode)
        return INVALID_OPERATION;
    }

    switch(mode) {
    case CAMERA_RECORDING_MODE:
        if (mSurface == 0) {
        LOGE("setPreviewDisplay must be called before startCameraMode!");
            LOGE("setPreviewDisplay must be called before startRecordingMode.");
            return INVALID_OPERATION;
        }

    switch(mode) {
    case CAMERA_RECORDING_MODE:
        return startRecordingMode();

    default: // CAMERA_PREVIEW_MODE
        if (mSurface == 0) {
            LOGD("mSurface is not set yet.");
        }
        return startPreviewMode();
    }
}
@@ -498,28 +512,15 @@ status_t CameraService::Client::startRecordingMode()
    return ret;
}

status_t CameraService::Client::startPreviewMode()
status_t CameraService::Client::setOverlay()
{
    LOGD("startPreviewMode (pid %d)", getCallingPid());

    // if preview has been enabled, nothing needs to be done
    if (mHardware->previewEnabled()) {
        return NO_ERROR;
    }

    // start preview mode
#if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE
    debug_frame_cnt = 0;
#endif
    status_t ret = UNKNOWN_ERROR;
    LOGD("setOverlay");
    int w, h;
    CameraParameters params(mHardware->getParameters());
    params.getPreviewSize(&w, &h);

    if (mUseOverlay) {
    const char *format = params.getPreviewFormat();
    int fmt;
        LOGD("Use Overlays");
    if (!strcmp(format, "yuv422i"))
        fmt = OVERLAY_FORMAT_YCbCr_422_I;
    else if (!strcmp(format, "rgb565"))
@@ -528,22 +529,25 @@ status_t CameraService::Client::startPreviewMode()
        LOGE("Invalid preview format for overlays");
        return -EINVAL;
    }

    status_t ret = NO_ERROR;
    if (mSurface != 0) {
        sp<OverlayRef> ref = mSurface->createOverlay(w, h, fmt);
        ret = mHardware->setOverlay(new Overlay(ref));
    } else {
        ret = mHardware->setOverlay(NULL);
    }
    if (ret != NO_ERROR) {
        LOGE("mHardware->setOverlay() failed with status %d\n", ret);
    }
    return ret;
}
        ret = mHardware->startPreview(NULL, mCameraService.get());
        if (ret != NO_ERROR)
            LOGE("mHardware->startPreview() failed with status %d\n", ret);

    } else {
        ret = mHardware->startPreview(previewCallback,
                                      mCameraService.get());
        if (ret == NO_ERROR) {

            mSurface->unregisterBuffers();
status_t CameraService::Client::registerPreviewBuffers()
{
    int w, h;
    CameraParameters params(mHardware->getParameters());
    params.getPreviewSize(&w, &h);

    uint32_t transform = 0;
    if (params.getOrientation() ==
@@ -557,9 +561,44 @@ status_t CameraService::Client::startPreviewMode()
                                 0,
                                 mHardware->getPreviewHeap());

            mSurface->registerBuffers(buffers);
    status_t ret = mSurface->registerBuffers(buffers);
    if (ret != NO_ERROR) {
        LOGE("registerBuffers failed with status %d", ret);
    }
    return ret;
}

status_t CameraService::Client::startPreviewMode()
{
    LOGD("startPreviewMode (pid %d)", getCallingPid());

    // if preview has been enabled, nothing needs to be done
    if (mHardware->previewEnabled()) {
        return NO_ERROR;
    }

    // start preview mode
#if DEBUG_DUMP_PREVIEW_FRAME_TO_FILE
    debug_frame_cnt = 0;
#endif
    status_t ret = NO_ERROR;

    if (mUseOverlay) {
        // If preview display has been set, set overlay now.
        if (mSurface != 0) {
            ret = setOverlay();
        }
        if (ret != NO_ERROR) return ret;
        ret = mHardware->startPreview(NULL, mCameraService.get());
    } else {
          LOGE("mHardware->startPreview() failed with status %d", ret);
        ret = mHardware->startPreview(previewCallback,
                                      mCameraService.get());
        if (ret != NO_ERROR) return ret;
        // If preview display has been set, register preview buffers now.
        if (mSurface != 0) {
           // Unregister here because the surface registered with raw heap.
           mSurface->unregisterBuffers();
           ret = registerPreviewBuffers();
        }
    }
    return ret;
@@ -661,7 +700,7 @@ sp<CameraService::Client> CameraService::Client::getClientFromCookie(void* user)
    sp<Client> client = 0;
    CameraService *service = static_cast<CameraService*>(user);
    if (service != NULL) {
        Mutex::Autolock ourLock(service->mLock);
        Mutex::Autolock ourLock(service->mServiceLock);
        if (service->mClient != 0) {
            client = service->mClient.promote();
            if (client == 0) {
@@ -1104,7 +1143,7 @@ status_t CameraService::dump(int fd, const Vector<String16>& args)
        result.append(buffer);
        write(fd, result.string(), result.size());
    } else {
        AutoMutex lock(&mLock);
        AutoMutex lock(&mServiceLock);
        if (mClient != 0) {
            sp<Client> currentClient = mClient.promote();
            sprintf(buffer, "Client (%p) PID: %d\n",
+3 −1
Original line number Diff line number Diff line
@@ -157,6 +157,8 @@ private:
        status_t                startCameraMode(camera_mode mode);
        status_t                startPreviewMode();
        status_t                startRecordingMode();
        status_t                setOverlay();
        status_t                registerPreviewBuffers();

        // Ensures atomicity among the public methods
        mutable     Mutex                       mLock;
@@ -199,7 +201,7 @@ private:
    virtual     void                        incUsers();
    virtual     void                        decUsers();

    mutable     Mutex                       mLock;
    mutable     Mutex                       mServiceLock;
                wp<Client>                  mClient;

#if DEBUG_HEAP_LEAKS
+51 −20
Original line number Diff line number Diff line
@@ -69,6 +69,14 @@ enum tts_result {
    TTS_MISSING_RESOURCES       = -6
};

enum tts_support_result {
    TTS_LANG_COUNTRY_VAR_AVAILABLE = 2,
    TTS_LANG_COUNTRY_AVAILABLE = 1,
    TTS_LANG_AVAILABLE = 0,
    TTS_LANG_MISSING_DATA = -1,
    TTS_LANG_NOT_SUPPORTED = -2
};

class TtsEngine
{
public:
@@ -86,19 +94,32 @@ public:
    // @return TTS_SUCCESS, or TTS_FAILURE
    virtual tts_result stop();

    // Returns the level of support for the language, country and variant.
    // @return TTS_LANG_COUNTRY_VAR_AVAILABLE if the language, country and variant are supported,
    //            and the corresponding resources are correctly installed
    //         TTS_LANG_COUNTRY_AVAILABLE if the language and country are supported and the
    //             corresponding resources are correctly installed, but there is no match for
    //             the specified variant
    //         TTS_LANG_AVAILABLE if the language is supported and the
    //             corresponding resources are correctly installed, but there is no match for
    //             the specified country and variant
    //         TTS_LANG_MISSING_DATA if the required resources to provide any level of support
    //             for the language are not correctly installed
    //         TTS_LANG_NOT_SUPPORTED if the language is not supported by the TTS engine.
    virtual tts_support_result isLanguageAvailable(const char *lang, const char *country,
            const char *variant);

    // Load the resources associated with the specified language. The loaded
    // language will only be used once a call to setLanguage() with the same
    // language value is issued. Language values are based on the Android
    // conventions for localization as described in the Android platform
    // documentation on internationalization. This implies that language
    // data is specified in the format xx-rYY, where xx is a two letter
    // ISO 639-1 language code in lowercase and rYY is a two letter
    // ISO 3166-1-alpha-2 language code in uppercase preceded by a
    // lowercase "r".
    // @param value pointer to the language value
    // @param size  length of the language value
    // language value is issued. Language and country values are coded according to the ISO three
    // letter codes for languages and countries, as can be retrieved from a java.util.Locale
    // instance. The variant value is encoded as the variant string retrieved from a
    // java.util.Locale instance built with that variant data.
    // @param lang pointer to the ISO three letter code for the language
    // @param country pointer to the ISO three letter code for the country
    // @param variant pointer to the variant code
    // @return TTS_SUCCESS, or TTS_FAILURE
    virtual tts_result loadLanguage(const char *value, const size_t size);
    virtual tts_result loadLanguage(const char *lang, const char *country, const char *variant);
    
    // Load the resources associated with the specified language, country and Locale variant.
    // The loaded language will only be used once a call to setLanguageFromLocale() with the same
@@ -112,16 +133,26 @@ public:
    // @return TTS_SUCCESS, or TTS_FAILURE
    virtual tts_result setLanguage(const char *lang, const char *country, const char *variant);

    // Retrieve the currently set language, or an empty "value" if no language
    // has been set.
    // @param[out]   value pointer to the retrieved language value
    // @param[inout] iosize in: stores the size available to store the language
    //                         value in *value
    //                      out: stores the size required to hold the language
    //                         value if  getLanguage() returned
    //                         TTS_PROPERTY_SIZE_TOO_SMALL, unchanged otherwise.
    // @return TTS_SUCCESS, or TTS_PROPERTY_SIZE_TOO_SMALL, or TTS_FAILURE
    virtual tts_result getLanguage(char *value, size_t *iosize);
    // Retrieve the currently set language, country and variant, or empty strings if none of
    // parameters have been set. Language and country are represented by their 3-letter ISO code
    // @param[out]   pointer to the retrieved 3-letter code language value
    // @param[out]   pointer to the retrieved 3-letter code country value
    // @param[out]   pointer to the retrieved variant value
    // @return TTS_SUCCESS, or TTS_FAILURE
    virtual tts_result getLanguage(char *language, char *country, char *variant);

    // Notifies the engine what audio parameters should be used for the synthesis.
    // This is meant to be used as a hint, the engine implementation will set the output values
    // to those of the synthesis format, based on a given hint.
    // @param[inout] encoding in: the desired audio sample format
    //                         out: the format used by the TTS engine
    // @param[inout] rate in: the desired audio sample rate
    //                         out: the sample rate used by the TTS engine
    // @param[inout] channels in: the desired number of audio channels
    //                         out: the number of channels used by the TTS engine
    // @return TTS_SUCCESS, or TTS_FAILURE
    virtual tts_result setAudioFormat(AudioSystem::audio_format& encoding, uint32_t& rate,
            int& channels);

    // Set a property for the the TTS engine
    // "size" is the maximum size of "value" for properties "property"
+3 −7
Original line number Diff line number Diff line
@@ -63,16 +63,12 @@ namespace android {
#define FRAME_CALLBACK_FLAG_CAMERA                   0x05
#define FRAME_CALLBACK_FLAG_BARCODE_SCANNER          0x07

// msgType in notifyCallback function
// msgType in notifyCallback and dataCallback functions
enum {
    CAMERA_MSG_ERROR,
    CAMERA_MSG_ERROR = 0,
    CAMERA_MSG_SHUTTER,
    CAMERA_MSG_FOCUS,
    CAMERA_MSG_ZOOM
};

// msgType in dataCallback function
enum {
    CAMERA_MSG_ZOOM,
    CAMERA_MSG_PREVIEW_FRAME,
    CAMERA_MSG_VIDEO_FRAME,
    CAMERA_MSG_POSTVIEW_FRAME,
+45 −5
Original line number Diff line number Diff line
@@ -866,7 +866,7 @@ struct ResTable_config
            uint8_t keyboard;
            uint8_t navigation;
            uint8_t inputFlags;
            uint8_t pad0;
            uint8_t inputPad0;
        };
        uint32_t input;
    };
@@ -905,6 +905,23 @@ struct ResTable_config
        uint32_t version;
    };
    
    enum {
        SCREENLAYOUT_ANY  = 0x0000,
        SCREENLAYOUT_SMALL = 0x0001,
        SCREENLAYOUT_NORMAL = 0x0002,
        SCREENLAYOUT_LARGE = 0x0003,
    };
    
    union {
        struct {
            uint8_t screenLayout;
            uint8_t screenConfigPad0;
            uint8_t screenConfigPad1;
            uint8_t screenConfigPad2;
        };
        uint32_t screenConfig;
    };
    
    inline void copyFromDeviceNoSwap(const ResTable_config& o) {
        const size_t size = dtohl(o.size);
        if (size >= sizeof(ResTable_config)) {
@@ -950,6 +967,8 @@ struct ResTable_config
        diff = (int32_t)(screenSize - o.screenSize);
        if (diff != 0) return diff;
        diff = (int32_t)(version - o.version);
        if (diff != 0) return diff;
        diff = (int32_t)(screenLayout - o.screenLayout);
        return (int)diff;
    }
    
@@ -967,7 +986,8 @@ struct ResTable_config
        CONFIG_ORIENTATION = 0x0080,
        CONFIG_DENSITY = 0x0100,
        CONFIG_SCREEN_SIZE = 0x0200,
        CONFIG_VERSION = 0x0400
        CONFIG_VERSION = 0x0400,
        CONFIG_SCREEN_LAYOUT = 0x0800
    };
    
    // Compare two configuration, returning CONFIG_* flags set for each value
@@ -985,6 +1005,7 @@ struct ResTable_config
        if (navigation != o.navigation) diffs |= CONFIG_NAVIGATION;
        if (screenSize != o.screenSize) diffs |= CONFIG_SCREEN_SIZE;
        if (version != o.version) diffs |= CONFIG_VERSION;
        if (screenLayout != o.screenLayout) diffs |= CONFIG_SCREEN_LAYOUT;
        return diffs;
    }
    
@@ -1062,6 +1083,13 @@ struct ResTable_config
            }
        }

        if (screenConfig || o.screenConfig) {
            if (screenLayout != o.screenLayout) {
                if (!screenLayout) return false;
                if (!o.screenLayout) return true;
            }
        }

        if (version || o.version) {
            if (sdkVersion != o.sdkVersion) {
                if (!sdkVersion) return false;
@@ -1191,6 +1219,12 @@ struct ResTable_config
                }
            }

            if (screenConfig || o.screenConfig) {
                if ((screenLayout != o.screenLayout) && requested->screenLayout) {
                    return (screenLayout);
                }
            }

            if (version || o.version) {
                if ((sdkVersion != o.sdkVersion) && requested->sdkVersion) {
                    return (sdkVersion);
@@ -1282,6 +1316,12 @@ struct ResTable_config
                return false;
            }
        }
        if (screenConfig != 0) {
            if (settings.screenLayout != 0 && screenLayout != 0
                && screenLayout != settings.screenLayout) {
                return false;
            }
        }
        if (version != 0) {
            if (settings.sdkVersion != 0 && sdkVersion != 0
                && sdkVersion != settings.sdkVersion) {
@@ -1310,13 +1350,13 @@ struct ResTable_config

    String8 toString() const {
        char buf[200];
        sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=0x%02x touch=0x%02x dens=0x%02x "
                "kbd=0x%02x nav=0x%02x input=0x%02x screenW=0x%04x screenH=0x%04x vers=%d.%d",
        sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=%d touch=%d dens=%d "
                "kbd=%d nav=%d input=%d scrnW=%d scrnH=%d layout=%d vers=%d.%d",
                mcc, mnc,
                language[0] ? language[0] : '-', language[1] ? language[1] : '-',
                country[0] ? country[0] : '-', country[1] ? country[1] : '-',
                orientation, touchscreen, density, keyboard, navigation, inputFlags,
                screenWidth, screenHeight, sdkVersion, minorVersion);
                screenWidth, screenHeight, screenLayout, sdkVersion, minorVersion);
        return String8(buf);
    }
};
Loading