diff --git a/camera/Android.mk b/camera/Android.mk index 91d87edad5..c0bdea8826 100644 --- a/camera/Android.mk +++ b/camera/Android.mk @@ -38,7 +38,6 @@ LOCAL_SRC_FILES := \ LOCAL_SRC_FILES += \ Camera.cpp \ CameraMetadata.cpp \ - CameraParameters.cpp \ CaptureResult.cpp \ CameraParameters2.cpp \ ICamera.cpp \ @@ -73,6 +72,21 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ LOCAL_CFLAGS += -Werror -Wall -Wextra +ifneq ($(TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY),) +LOCAL_WHOLE_STATIC_LIBRARIES += $(TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY) +else +LOCAL_WHOLE_STATIC_LIBRARIES += libcamera_parameters +endif + LOCAL_MODULE:= libcamera_client include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) + +LOCAL_SRC_FILES := \ + CameraParameters.cpp + +LOCAL_MODULE := libcamera_parameters + +include $(BUILD_STATIC_LIBRARY) diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk index d32e2526b0..1df66d891a 100644 --- a/camera/cameraserver/Android.mk +++ b/camera/cameraserver/Android.mk @@ -14,6 +14,9 @@ LOCAL_PATH:= $(call my-dir) +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +$(warning Target has integrated cameraserver into mediaserver. This is weakening security measures introduced in 7.0) +else include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ @@ -41,3 +44,4 @@ LOCAL_CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter LOCAL_INIT_RC := cameraserver.rc include $(BUILD_EXECUTABLE) +endif diff --git a/camera/cameraserver/cameraserver.rc b/camera/cameraserver/cameraserver.rc index fea5a1d5c6..9b637b2127 100644 --- a/camera/cameraserver/cameraserver.rc +++ b/camera/cameraserver/cameraserver.rc @@ -3,4 +3,4 @@ service cameraserver /system/bin/cameraserver user cameraserver group audio camera input drmrpc ioprio rt 4 - writepid /dev/cpuset/camera-daemon/tasks /dev/stune/top-app/tasks + writepid /dev/cpuset/camera-daemon/tasks /dev/stune/foreground/tasks diff --git a/camera/include/camera/CameraParameters2.h b/camera/include/camera/CameraParameters2.h index f691cd6ea0..5fae079376 100644 --- a/camera/include/camera/CameraParameters2.h +++ b/camera/include/camera/CameraParameters2.h @@ -19,7 +19,7 @@ #include #include -#include "CameraParameters.h" +#include namespace android { diff --git a/media/audioserver/audioserver.rc b/media/audioserver/audioserver.rc index 9d42bce069..be87c8329d 100644 --- a/media/audioserver/audioserver.rc +++ b/media/audioserver/audioserver.rc @@ -2,7 +2,7 @@ service audioserver /system/bin/audioserver class main user audioserver # media gid needed for /dev/fm (radio) and for /data/misc/media (tee) - group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct + group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct oem_2901 ioprio rt 4 writepid /dev/cpuset/foreground/tasks /dev/stune/foreground/tasks onrestart restart audio-hal-2-0 diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp index 18fd857f51..77f0cab58a 100644 --- a/media/libmediaplayerservice/MediaPlayerService.cpp +++ b/media/libmediaplayerservice/MediaPlayerService.cpp @@ -83,6 +83,9 @@ #include "HTTPBase.h" #include "RemoteDisplay.h" +static const int kDumpLockRetries = 50; +static const int kDumpLockSleepUs = 20000; + namespace { using android::media::Metadata; using android::status_t; @@ -392,12 +395,32 @@ status_t MediaPlayerService::Client::dump(int fd, const Vector& args) snprintf(buffer, 255, " pid(%d), connId(%d), status(%d), looping(%s)\n", mPid, mConnId, mStatus, mLoop?"true": "false"); result.append(buffer); + + sp p; + sp audioOutput; + bool locked = false; + for (int i = 0; i < kDumpLockRetries; ++i) { + if (mLock.tryLock() == NO_ERROR) { + locked = true; + break; + } + usleep(kDumpLockSleepUs); + } + + if (locked) { + p = mPlayer; + audioOutput = mAudioOutput; + mLock.unlock(); + } else { + result.append(" lock is taken, no dump from player and audio output\n"); + } write(fd, result.string(), result.size()); - if (mPlayer != NULL) { - mPlayer->dump(fd, args); + + if (p != NULL) { + p->dump(fd, args); } - if (mAudioOutput != 0) { - mAudioOutput->dump(fd, args); + if (audioOutput != 0) { + audioOutput->dump(fd, args); } write(fd, "\n", 1); return NO_ERROR; @@ -577,7 +600,10 @@ MediaPlayerService::Client::Client( MediaPlayerService::Client::~Client() { ALOGV("Client(%d) destructor pid = %d", mConnId, mPid); - mAudioOutput.clear(); + { + Mutex::Autolock l(mLock); + mAudioOutput.clear(); + } wp client(this); disconnect(); mService->removeClient(client); @@ -597,10 +623,9 @@ void MediaPlayerService::Client::disconnect() Mutex::Autolock l(mLock); p = mPlayer; mClient.clear(); + mPlayer.clear(); } - mPlayer.clear(); - // clear the notification to prevent callbacks to dead client // and reset the player. We assume the player will serialize // access to itself if necessary. @@ -621,7 +646,7 @@ void MediaPlayerService::Client::disconnect() sp MediaPlayerService::Client::createPlayer(player_type playerType) { // determine if we have the right player type - sp p = mPlayer; + sp p = getPlayer(); if ((p != NULL) && (p->playerType() != playerType)) { ALOGV("delete player"); p.clear(); @@ -772,6 +797,7 @@ void MediaPlayerService::Client::setDataSource_post( } if (mStatus == OK) { + Mutex::Autolock l(mLock); mPlayer = p; } } diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp index 9f1be2296b..07ca944734 100644 --- a/media/libstagefright/ACodec.cpp +++ b/media/libstagefright/ACodec.cpp @@ -4833,7 +4833,16 @@ status_t ACodec::getPortFormat(OMX_U32 portIndex, sp ¬ify) { rect.nWidth = videoDef->nFrameWidth; rect.nHeight = videoDef->nFrameHeight; } - +#ifdef MTK_HARDWARE + if (!strncmp(mComponentName.c_str(), "OMX.MTK.", 8) && mOMX->getConfig( + mNode, (OMX_INDEXTYPE) 0x7f00001c /* OMX_IndexVendorMtkOmxVdecGetCropInfo */, + &rect, sizeof(rect)) != OK) { + rect.nLeft = 0; + rect.nTop = 0; + rect.nWidth = videoDef->nFrameWidth; + rect.nHeight = videoDef->nFrameHeight; + } +#endif if (rect.nLeft < 0 || rect.nTop < 0 || rect.nLeft + rect.nWidth > videoDef->nFrameWidth || diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk index 372b11a94f..ebb83b64da 100644 --- a/media/libstagefright/Android.mk +++ b/media/libstagefright/Android.mk @@ -126,6 +126,10 @@ LOCAL_SHARED_LIBRARIES += \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := libmedia +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +LOCAL_CFLAGS += -DCAMCORDER_GRALLOC_SOURCE +endif + LOCAL_CFLAGS += -Wno-multichar -Werror -Wno-error=deprecated-declarations -Wall # enable experiments only in userdebug and eng builds diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp index a569f5d265..0e3fd406b8 100644 --- a/media/libstagefright/CameraSource.cpp +++ b/media/libstagefright/CameraSource.cpp @@ -970,6 +970,14 @@ void CameraSource::releaseRecordingFrame(const sp& frame) { } if (handle != nullptr) { + ssize_t offset; + size_t size; + sp heap = frame->getMemory(&offset, &size); + if (heap->getHeapID() != mMemoryHeapBase->getHeapID()) { + ALOGE("%s: Mismatched heap ID, ignoring release (got %x, expected %x)", + __FUNCTION__, heap->getHeapID(), mMemoryHeapBase->getHeapID()); + return; + } uint32_t batchSize = 0; { Mutex::Autolock autoLock(mBatchLock); @@ -1367,6 +1375,10 @@ void CameraSource::processBufferQueueFrame(BufferItem& buffer) { MetadataBufferType CameraSource::metaDataStoredInVideoBuffers() const { ALOGV("metaDataStoredInVideoBuffers"); +#ifdef CAMCORDER_GRALLOC_SOURCE + return kMetadataBufferTypeGrallocSource; +#endif + // Output buffers will contain metadata if camera sends us buffer in metadata mode or via // buffer queue. switch (mVideoBufferMode) { diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp index d0d82b3fdb..8b169724cd 100644 --- a/media/libstagefright/SurfaceMediaSource.cpp +++ b/media/libstagefright/SurfaceMediaSource.cpp @@ -128,7 +128,11 @@ status_t SurfaceMediaSource::setFrameRate(int32_t fps) MetadataBufferType SurfaceMediaSource::metaDataStoredInVideoBuffers() const { ALOGV("isMetaDataStoredInVideoBuffers"); +#ifdef CAMCORDER_GRALLOC_SOURCE + return kMetadataBufferTypeGrallocSource; +#else return kMetadataBufferTypeANWBuffer; +#endif } int32_t SurfaceMediaSource::getFrameRate( ) const { @@ -249,6 +253,35 @@ sp SurfaceMediaSource::getFormat() return meta; } +#ifdef CAMCORDER_GRALLOC_SOURCE +// Pass the data to the MediaBuffer. Pass in only the metadata +// The metadata passed consists of two parts: +// 1. First, there is an integer indicating that it is a GRAlloc +// source (kMetadataBufferTypeGrallocSource) +// 2. This is followed by the buffer_handle_t that is a handle to the +// GRalloc buffer. The encoder needs to interpret this GRalloc handle +// and encode the frames. +// -------------------------------------------------------------- +// | kMetadataBufferTypeGrallocSource | sizeof(buffer_handle_t) | +// -------------------------------------------------------------- +// Note: Call only when you have the lock +static void passMetadataBuffer(MediaBuffer **buffer, + buffer_handle_t bufferHandle) { + *buffer = new MediaBuffer(4 + sizeof(buffer_handle_t)); + char *data = (char *)(*buffer)->data(); + if (data == NULL) { + ALOGE("Cannot allocate memory for metadata buffer!"); + return; + } + OMX_U32 type = kMetadataBufferTypeGrallocSource; + memcpy(data, &type, 4); + memcpy(data + 4, &bufferHandle, sizeof(buffer_handle_t)); + + ALOGV("handle = %p, , offset = %zu, length = %zu", + bufferHandle, (*buffer)->range_length(), (*buffer)->range_offset()); +} +#endif + // Pass the data to the MediaBuffer. Pass in only the metadata // Note: Call only when you have the lock void SurfaceMediaSource::passMetadataBuffer_l(MediaBuffer **buffer, @@ -351,7 +384,11 @@ status_t SurfaceMediaSource::read( mNumFramesEncoded++; // Pass the data to the MediaBuffer. Pass in only the metadata +#ifdef CAMCORDER_GRALLOC_SOURCE + passMetadataBuffer(buffer, mSlots[mCurrentSlot].mGraphicBuffer->handle); +#else passMetadataBuffer_l(buffer, mSlots[mCurrentSlot].mGraphicBuffer->getNativeBuffer()); +#endif (*buffer)->setObserver(this); (*buffer)->add_ref(); @@ -389,7 +426,7 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { buffer_handle_t bufferHandle = getMediaBufferHandle(buffer); for (size_t i = 0; i < mCurrentBuffers.size(); i++) { - if (mCurrentBuffers[i]->handle == bufferHandle) { + if ((buffer_handle_t)mCurrentBuffers[i]->getNativeBuffer() == bufferHandle) { mCurrentBuffers.removeAt(i); foundBuffer = true; break; @@ -405,7 +442,7 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) { continue; } - if (bufferHandle == mSlots[id].mGraphicBuffer->handle) { + if (bufferHandle == (buffer_handle_t)mSlots[id].mGraphicBuffer->getNativeBuffer()) { ALOGV("Slot %d returned, matches handle = %p", id, mSlots[id].mGraphicBuffer->handle); diff --git a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp index 6e70ded182..9a692266ea 100644 --- a/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp +++ b/media/libstagefright/codecs/mpeg2dec/SoftMPEG2.cpp @@ -89,10 +89,10 @@ SoftMPEG2::~SoftMPEG2() { } -static size_t getMinTimestampIdx(OMX_S64 *pNTimeStamp, bool *pIsTimeStampValid) { +static ssize_t getMinTimestampIdx(OMX_S64 *pNTimeStamp, bool *pIsTimeStampValid) { OMX_S64 minTimeStamp = LLONG_MAX; - int idx = -1; - for (size_t i = 0; i < MAX_TIME_STAMPS; i++) { + ssize_t idx = -1; + for (ssize_t i = 0; i < MAX_TIME_STAMPS; i++) { if (pIsTimeStampValid[i]) { if (pNTimeStamp[i] < minTimeStamp) { minTimeStamp = pNTimeStamp[i]; @@ -788,10 +788,15 @@ void SoftMPEG2::onQueueFilled(OMX_U32 portIndex) { } if (s_dec_op.u4_output_present) { - size_t timeStampIdx; + ssize_t timeStampIdx; outHeader->nFilledLen = (mWidth * mHeight * 3) / 2; timeStampIdx = getMinTimestampIdx(mTimeStamps, mTimeStampsValid); + if (timeStampIdx < 0) { + ALOGE("b/62872863, Invalid timestamp index!"); + android_errorWriteLog(0x534e4554, "62872863"); + return; + } outHeader->nTimeStamp = mTimeStamps[timeStampIdx]; mTimeStampsValid[timeStampIdx] = false; diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp index f1b44ae224..1cf9744799 100644 --- a/media/libstagefright/mpeg2ts/ESQueue.cpp +++ b/media/libstagefright/mpeg2ts/ESQueue.cpp @@ -892,6 +892,11 @@ sp ElementaryStreamQueue::dequeueAccessUnitAAC() { bits.skipBits(2); unsigned aac_frame_length = bits.getBits(13); + if (aac_frame_length == 0){ + ALOGE("b/62673179, Invalid AAC frame length!"); + android_errorWriteLog(0x534e4554, "62673179"); + return NULL; + } bits.skipBits(11); // adts_buffer_fullness diff --git a/media/libstagefright/omx/Android.mk b/media/libstagefright/omx/Android.mk index 29e2ccc83b..922f1d4aeb 100644 --- a/media/libstagefright/omx/Android.mk +++ b/media/libstagefright/omx/Android.mk @@ -56,6 +56,16 @@ LOCAL_EXPORT_C_INCLUDES := \ LOCAL_EXPORT_SHARED_LIBRARY_HEADERS := \ android.hidl.memory@1.0 +ifneq ($(filter msm7x27a msm7x30 msm8660 msm8960,$(TARGET_BOARD_PLATFORM)),) +LOCAL_CFLAGS += -DQCOM_BSP_LEGACY +endif + +ifneq ($(TARGET_USES_MEDIA_EXTENSIONS),true) +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) +LOCAL_CFLAGS += -DCAMCORDER_GRALLOC_SOURCE +endif +endif + LOCAL_MODULE:= libstagefright_omx LOCAL_CFLAGS += -Werror -Wall -Wno-unused-parameter -Wno-documentation LOCAL_SANITIZE := unsigned-integer-overflow signed-integer-overflow cfi diff --git a/media/libstagefright/omx/GraphicBufferSource.cpp b/media/libstagefright/omx/GraphicBufferSource.cpp index 47d80bb756..152eeefecc 100644 --- a/media/libstagefright/omx/GraphicBufferSource.cpp +++ b/media/libstagefright/omx/GraphicBufferSource.cpp @@ -774,11 +774,13 @@ status_t GraphicBufferSource::submitBuffer_l(const VideoBuffer &item) { return UNKNOWN_ERROR; } +#ifndef QCOM_BSP_LEGACY if ((android_dataspace)item.mDataspace != mLastDataspace) { onDataspaceChanged_l( item.mDataspace, (android_pixel_format)item.mBuffer->getGraphicBuffer()->format); } +#endif std::shared_ptr buffer = item.mBuffer; // use a GraphicBuffer for now as OMXNodeInstance is using GraphicBuffers to hold references diff --git a/media/libstagefright/omx/OMXNodeInstance.cpp b/media/libstagefright/omx/OMXNodeInstance.cpp index db99ef2851..78b5a3df34 100644 --- a/media/libstagefright/omx/OMXNodeInstance.cpp +++ b/media/libstagefright/omx/OMXNodeInstance.cpp @@ -1632,10 +1632,30 @@ status_t OMXNodeInstance::emptyBuffer_l( BufferMeta *buffer_meta = static_cast(header->pAppPrivate); +#ifndef CAMCORDER_GRALLOC_SOURCE // set up proper filled length if component is configured for gralloc metadata mode // ignore rangeOffset in this case (as client may be assuming ANW meta buffers). if (mMetadataType[kPortIndexInput] == kMetadataBufferTypeGrallocSource) { header->nFilledLen = rangeLength ? sizeof(VideoGrallocMetadata) : 0; +#else + sp backup = buffer_meta->getBuffer(header, false /* limit */); + sp codec = buffer_meta->getBuffer(header, false /* limit */); + + // convert incoming ANW meta buffers if component is configured for gralloc metadata mode + // ignore rangeOffset in this case + if (mMetadataType[kPortIndexInput] == kMetadataBufferTypeGrallocSource + && backup->capacity() >= sizeof(VideoNativeMetadata) + && codec->capacity() >= sizeof(VideoGrallocMetadata) + && ((VideoNativeMetadata *)backup->base())->eType + == kMetadataBufferTypeANWBuffer) { + VideoNativeMetadata &backupMeta = *(VideoNativeMetadata *)backup->base(); + VideoGrallocMetadata &codecMeta = *(VideoGrallocMetadata *)codec->base(); + CLOG_BUFFER(emptyBuffer, "converting ANWB %p to handle %p", + backupMeta.pBuffer, backupMeta.pBuffer->handle); + codecMeta.pHandle = backupMeta.pBuffer != NULL ? backupMeta.pBuffer->handle : NULL; + codecMeta.eType = kMetadataBufferTypeGrallocSource; + header->nFilledLen = rangeLength ? sizeof(codecMeta) : 0; +#endif header->nOffset = 0; } else { // rangeLength and rangeOffset must be a subset of the allocated data in the buffer. diff --git a/media/mediaserver/Android.mk b/media/mediaserver/Android.mk index f7597db816..fdf0ca3d76 100644 --- a/media/mediaserver/Android.mk +++ b/media/mediaserver/Android.mk @@ -38,4 +38,16 @@ LOCAL_INIT_RC := mediaserver.rc LOCAL_CFLAGS := -Werror -Wall +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) + LOCAL_CFLAGS += -DNO_CAMERA_SERVER + + LOCAL_SHARED_LIBRARIES += \ + libcameraservice \ + android.hardware.camera.common@1.0 \ + android.hardware.camera.provider@2.4 + + LOCAL_STATIC_LIBRARIES += \ + libarect +endif + include $(BUILD_EXECUTABLE) diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp index ecddc48272..0abe6ac959 100644 --- a/media/mediaserver/main_mediaserver.cpp +++ b/media/mediaserver/main_mediaserver.cpp @@ -25,6 +25,9 @@ #include "RegisterExtensions.h" // from LOCAL_C_INCLUDES +#ifdef NO_CAMERA_SERVER +#include "CameraService.h" +#endif #include "IcuUtils.h" #include "MediaPlayerService.h" #include "ResourceManagerService.h" @@ -41,6 +44,9 @@ int main(int argc __unused, char **argv __unused) InitializeIcuOrDie(); MediaPlayerService::instantiate(); ResourceManagerService::instantiate(); +#ifdef NO_CAMERA_SERVER + CameraService::instantiate(); +#endif registerExtensions(); ProcessState::self()->startThreadPool(); IPCThreadState::self()->joinThreadPool(); diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp index b4029c7047..60eca7e5c3 100644 --- a/services/audioflinger/Effects.cpp +++ b/services/audioflinger/Effects.cpp @@ -1334,6 +1334,24 @@ status_t AudioFlinger::EffectHandle::command(uint32_t cmdCode, ALOGVV("command(), cmdCode: %d, mHasControl: %d, mEffect: %p", cmdCode, mHasControl, mEffect.unsafe_get()); + // reject commands reserved for internal use by audio framework if coming from outside + // of audioserver + switch(cmdCode) { + case EFFECT_CMD_ENABLE: + case EFFECT_CMD_DISABLE: + case EFFECT_CMD_SET_PARAM: + case EFFECT_CMD_SET_PARAM_DEFERRED: + case EFFECT_CMD_SET_PARAM_COMMIT: + case EFFECT_CMD_GET_PARAM: + break; + default: + if (cmdCode >= EFFECT_CMD_FIRST_PROPRIETARY) { + break; + } + android_errorWriteLog(0x534e4554, "62019992"); + return BAD_VALUE; + } + if (cmdCode == EFFECT_CMD_ENABLE) { if (*replySize < sizeof(int)) { android_errorWriteLog(0x534e4554, "32095713"); diff --git a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h index c09cb5a942..ddee177423 100644 --- a/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h +++ b/services/audiopolicy/common/managerdefinitions/include/AudioOutputDescriptor.h @@ -78,6 +78,7 @@ class AudioOutputDescriptor: public AudioPortConfig sp mPort; audio_devices_t mDevice; // current device this output is routed to + audio_io_handle_t mIoHandle; // output handle uint32_t mRefCount[AUDIO_STREAM_CNT]; // number of streams of each type using this output nsecs_t mStopTime[AUDIO_STREAM_CNT]; float mCurVolume[AUDIO_STREAM_CNT]; // current stream volume in dB @@ -123,7 +124,6 @@ class SwAudioOutputDescriptor: public AudioOutputDescriptor virtual void toAudioPort(struct audio_port *port) const; const sp mProfile; // I/O profile this output derives from - audio_io_handle_t mIoHandle; // output handle uint32_t mLatency; // audio_output_flags_t mFlags; // AudioMix *mPolicyMix; // non NULL when used by a dynamic policy diff --git a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp index 8593444aba..e29e0efaa3 100644 --- a/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp +++ b/services/audiopolicy/common/managerdefinitions/src/AudioOutputDescriptor.cpp @@ -33,7 +33,7 @@ namespace android { AudioOutputDescriptor::AudioOutputDescriptor(const sp& port, AudioPolicyClientInterface *clientInterface) - : mPort(port), mDevice(AUDIO_DEVICE_NONE), + : mPort(port), mDevice(AUDIO_DEVICE_NONE), mIoHandle(0), mClientInterface(clientInterface), mPatchHandle(AUDIO_PATCH_HANDLE_NONE), mId(0) { // clear usage count for all stream types @@ -221,7 +221,7 @@ void AudioOutputDescriptor::log(const char* indent) SwAudioOutputDescriptor::SwAudioOutputDescriptor(const sp& profile, AudioPolicyClientInterface *clientInterface) : AudioOutputDescriptor(profile, clientInterface), - mProfile(profile), mIoHandle(0), mLatency(0), + mProfile(profile), mLatency(0), mFlags((audio_output_flags_t)0), mPolicyMix(NULL), mOutput1(0), mOutput2(0), mDirectOpenCount(0), mDirectClientSession(AUDIO_SESSION_NONE), mGlobalRefCount(0) diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.h b/services/audiopolicy/managerdefault/AudioPolicyManager.h index c831d46a14..03e476dc83 100644 --- a/services/audiopolicy/managerdefault/AudioPolicyManager.h +++ b/services/audiopolicy/managerdefault/AudioPolicyManager.h @@ -482,12 +482,12 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage // if argument "device" is different from AUDIO_DEVICE_NONE, startSource() will force // the re-evaluation of the output device. - status_t startSource(const sp& outputDesc, + virtual status_t startSource(const sp& outputDesc, audio_stream_type_t stream, audio_devices_t device, const char *address, uint32_t *delayMs); - status_t stopSource(const sp& outputDesc, + virtual status_t stopSource(const sp& outputDesc, audio_stream_type_t stream, bool forceDeviceUpdate); @@ -592,7 +592,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage // Audio Policy Engine Interface. AudioPolicyManagerInterface *mEngine; -private: +protected: // Add or remove AC3 DTS encodings based on user preferences. void filterSurroundFormats(FormatVector *formatsPtr); void filterSurroundChannelMasks(ChannelsVector *channelMasksPtr); @@ -624,7 +624,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage SortedVector& outputs /*out*/); uint32_t curAudioPortGeneration() const { return mAudioPortGeneration; } // internal method to return the output handle for the given device and format - audio_io_handle_t getOutputForDevice( + virtual audio_io_handle_t getOutputForDevice( audio_devices_t device, audio_session_t session, audio_stream_type_t stream, @@ -660,7 +660,7 @@ class AudioPolicyManager : public AudioPolicyInterface, public AudioPolicyManage AudioMix **policyMix = NULL); // Called by setDeviceConnectionState(). - status_t setDeviceConnectionStateInt(audio_devices_t device, + virtual status_t setDeviceConnectionStateInt(audio_devices_t device, audio_policy_dev_state_t state, const char *device_address, const char *device_name); diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk index 502ac5d86e..80c04b9e2e 100644 --- a/services/camera/libcameraservice/Android.mk +++ b/services/camera/libcameraservice/Android.mk @@ -91,6 +91,10 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := \ LOCAL_CFLAGS += -Wall -Wextra -Werror +ifeq ($(TARGET_HAS_LEGACY_CAMERA_HAL1),true) + LOCAL_CFLAGS += -DNO_CAMERA_SERVER +endif + LOCAL_MODULE:= libcameraservice include $(BUILD_SHARED_LIBRARY) diff --git a/services/camera/libcameraservice/CameraFlashlight.cpp b/services/camera/libcameraservice/CameraFlashlight.cpp index e06a81fb23..2bd71aa68f 100644 --- a/services/camera/libcameraservice/CameraFlashlight.cpp +++ b/services/camera/libcameraservice/CameraFlashlight.cpp @@ -514,6 +514,23 @@ status_t CameraHardwareInterfaceFlashControl::initializePreviewWindow( return device->setPreviewWindow(mSurface); } +static void notifyCallback(int32_t, int32_t, int32_t, void*) { + /* Empty */ +} + +static void dataCallback(int32_t, const sp&, camera_frame_metadata_t*, void*) { + /* Empty */ +} + +static void dataCallbackTimestamp(nsecs_t, int32_t, const sp&, void*) { + /* Empty */ +} + +static void dataCallbackTimestampBatch(int32_t, const std::vector&, + void*) { + /* Empty */ +} + status_t CameraHardwareInterfaceFlashControl::connectCameraDevice( const String8& cameraId) { sp device = @@ -527,7 +544,8 @@ status_t CameraHardwareInterfaceFlashControl::connectCameraDevice( } // need to set __get_memory in set_callbacks(). - device->setCallbacks(NULL, NULL, NULL, NULL, NULL); + device->setCallbacks(notifyCallback, dataCallback, dataCallbackTimestamp, + dataCallbackTimestampBatch, this); mParameters = device->getParameters(); diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp index c2b71a2372..0d856e6be7 100644 --- a/services/camera/libcameraservice/CameraService.cpp +++ b/services/camera/libcameraservice/CameraService.cpp @@ -739,7 +739,11 @@ int32_t CameraService::mapToInterface(StatusInternal status) { Status CameraService::initializeShimMetadata(int cameraId) { int uid = getCallingUid(); +#ifdef NO_CAMERA_SERVER + String16 internalPackageName("media"); +#else String16 internalPackageName("cameraserver"); +#endif String8 id = String8::format("%d", cameraId); Status ret = Status::ok(); sp tmp = nullptr; @@ -820,7 +824,9 @@ Status CameraService::getLegacyParametersLazy(int cameraId, static bool isTrustedCallingUid(uid_t uid) { switch (uid) { case AID_MEDIA: // mediaserver +#ifndef NO_CAMERA_SERVER case AID_CAMERASERVER: // cameraserver +#endif case AID_RADIO: // telephony return true; default: diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index 075c2e3166..3c5afb46cb 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -779,6 +779,9 @@ void CameraClient::disableMsgType(int32_t msgType) { #define CHECK_MESSAGE_INTERVAL 10 // 10ms bool CameraClient::lockIfMessageWanted(int32_t msgType) { +#ifdef MTK_HARDWARE + return true; +#endif int sleepCount = 0; while (mMsgEnabled & msgType) { if (mLock.tryLock() == NO_ERROR) { diff --git a/services/soundtrigger/SoundTriggerHwService.cpp b/services/soundtrigger/SoundTriggerHwService.cpp index 5b8d990704..5c01fad450 100644 --- a/services/soundtrigger/SoundTriggerHwService.cpp +++ b/services/soundtrigger/SoundTriggerHwService.cpp @@ -254,6 +254,37 @@ void SoundTriggerHwService::sendRecognitionEvent(struct sound_trigger_recognitio if (module == NULL) { return; } + struct sound_trigger_phrase_recognition_event newEvent; + if (event-> type == SOUND_MODEL_TYPE_KEYPHRASE && event->data_size != 0 + && event->data_offset != sizeof(struct sound_trigger_phrase_recognition_event)) { + // set some defaults for the phrase if the recognition event won't be parsed properly + // TODO: read defaults from the config + + memset(&newEvent, 0, sizeof(struct sound_trigger_phrase_recognition_event)); + + sp model = module->getModel(event->model); + + newEvent.num_phrases = 1; + newEvent.phrase_extras[0].id = 100; + newEvent.phrase_extras[0].recognition_modes = RECOGNITION_MODE_VOICE_TRIGGER; + newEvent.phrase_extras[0].confidence_level = 100; + newEvent.phrase_extras[0].num_levels = 1; + newEvent.phrase_extras[0].levels[0].level = 100; + newEvent.phrase_extras[0].levels[0].user_id = 100; + newEvent.common.status = event->status; + newEvent.common.type = event->type; + newEvent.common.model = event->model; + newEvent.common.capture_available = event->capture_available; + newEvent.common.capture_session = event->capture_session; + newEvent.common.capture_delay_ms = event->capture_delay_ms; + newEvent.common.capture_preamble_ms = event->capture_preamble_ms; + newEvent.common.trigger_in_data = event->trigger_in_data; + newEvent.common.audio_config = event->audio_config; + newEvent.common.data_size = event->data_size; + newEvent.common.data_offset = sizeof(struct sound_trigger_phrase_recognition_event); + + event = &newEvent.common; + } sp eventMemory = prepareRecognitionEvent_l(event); if (eventMemory == 0) { return;