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

Commit 06ee417b authored by The Android Open Source Project's avatar The Android Open Source Project
Browse files

Merge commit 'korg/cupcake'

Conflicts:
	core/java/android/webkit/WebView.java
	core/java/android/widget/TwoLineListItem.java
	preloaded-classes
parents f8041147 b1596ee2
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -42,7 +42,8 @@ LOCAL_SRC_FILES:= \
LOCAL_SHARED_LIBRARIES:= \
    libui \
    libutils \
    libcutils
    libcutils \
    libmedia

LOCAL_MODULE:= libcameraservice

+49 −0
Original line number Diff line number Diff line
@@ -28,8 +28,12 @@
#include <utils/MemoryHeapBase.h>
#include <ui/ICameraService.h>

#include <media/mediaplayer.h>
#include <media/AudioSystem.h>
#include "CameraService.h"

#include <cutils/properties.h>

namespace android {

extern "C" {
@@ -151,6 +155,25 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient)
    }
}

static sp<MediaPlayer> newMediaPlayer(const char *file) 
{
    sp<MediaPlayer> mp = new MediaPlayer();
    if (mp->setDataSource(file) == NO_ERROR) {
        char value[PROPERTY_VALUE_MAX];
        property_get("ro.camera.sound.forced", value, "0");
        if (atoi(value)) {
            mp->setAudioStreamType(AudioSystem::ENFORCED_AUDIBLE);
        } else {
            mp->setAudioStreamType(AudioSystem::SYSTEM);            
        }
        mp->prepare();
    } else {
        mp.clear();
        LOGE("Failed to load CameraService sounds.");
    }
    return mp;
}

CameraService::Client::Client(const sp<CameraService>& cameraService,
        const sp<ICameraClient>& cameraClient, pid_t clientPid)
{
@@ -161,6 +184,9 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
    mHardware = openCameraHardware();
    mUseOverlay = mHardware->useOverlay();

    mMediaPlayerClick = newMediaPlayer("/system/media/audio/ui/camera_click.ogg");
    mMediaPlayerBeep = newMediaPlayer("/system/media/audio/ui/VideoRecord.ogg");

    // Callback is disabled by default
    mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
    LOGD("Client X constructor");
@@ -265,6 +291,15 @@ CameraService::Client::~Client()
#endif
    }

    if (mMediaPlayerBeep.get() != NULL) {
        mMediaPlayerBeep->disconnect();
        mMediaPlayerBeep.clear();
    }
    if (mMediaPlayerClick.get() != NULL) {
        mMediaPlayerClick->disconnect();
        mMediaPlayerClick.clear();
    }

    // make sure we tear down the hardware
    mClientPid = IPCThreadState::self()->getCallingPid();
    disconnect();
@@ -464,6 +499,10 @@ status_t CameraService::Client::startPreview()

status_t CameraService::Client::startRecording()
{
    if (mMediaPlayerBeep.get() != NULL) {
        mMediaPlayerBeep->seekTo(0);
        mMediaPlayerBeep->start();
    }
    return startCameraMode(CAMERA_RECORDING_MODE);
}

@@ -502,6 +541,10 @@ void CameraService::Client::stopRecording()
        return;
    }

    if (mMediaPlayerBeep.get() != NULL) {
        mMediaPlayerBeep->seekTo(0);
        mMediaPlayerBeep->start();
    }
    mHardware->stopRecording();
    LOGV("stopRecording(), hardware stopped OK");
    mPreviewBuffer.clear();
@@ -698,6 +741,12 @@ void CameraService::Client::shutterCallback(void *user)
        return;
    }

    // Play shutter sound.
    if (client->mMediaPlayerClick.get() != NULL) {
        client->mMediaPlayerClick->seekTo(0);
        client->mMediaPlayerClick->start();
    }

    // Screen goes black after the buffer is unregistered.
    if (client->mSurface != 0 && !client->mUseOverlay) {
        client->mSurface->unregisterBuffers();
+5 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ class android::MemoryHeapBase;

namespace android {

class MediaPlayer;

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

#define LIKELY( exp )       (__builtin_expect( (exp) != 0, true  ))
@@ -178,6 +180,9 @@ private:
                    sp<MemoryHeapBase>          mPreviewBuffer;
                    int                         mPreviewCallbackFlag;

                    sp<MediaPlayer>             mMediaPlayerClick;
                    sp<MediaPlayer>             mMediaPlayerBeep;

                    // these are immutable once the object is created,
                    // they don't need to be protected by a lock
                    sp<ICameraClient>           mCameraClient;
+6 −1
Original line number Diff line number Diff line
@@ -82,6 +82,11 @@ public:
        eOrientationSwapMask    = 0x01
    };
    
    // flags for setOrientation
    enum {
        eOrientationAnimationDisable = 0x00000001
    };

    /* create connection with surface flinger, requires
     * ACCESS_SURFACE_FLINGER permission
     */
@@ -100,7 +105,7 @@ public:
    virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;

    /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */
    virtual int setOrientation(DisplayID dpy, int orientation) = 0;
    virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;

    /* signal that we're done booting.
     * recquires ACCESS_SURFACE_FLINGER permission
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ public:
    static status_t unfreezeDisplay(DisplayID dpy, uint32_t flags = 0);

    //! Set the orientation of the given display
    static int setOrientation(DisplayID dpy, int orientation);
    static int setOrientation(DisplayID dpy, int orientation, uint32_t flags);

    // Query the number of displays
    static ssize_t getNumberOfDisplays();
Loading