Merge "Various improvements to the wifi display implementation." into jb-mr1-dev
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index a657fe3..d10f2e5 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -147,6 +147,7 @@
 const char CameraParameters::SCENE_MODE_PARTY[] = "party";
 const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
 const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
+const char CameraParameters::SCENE_MODE_HDR[] = "hdr";
 
 const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
 const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 8668958..d521543 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -597,6 +597,10 @@
     // Applications are looking for a barcode. Camera driver will be optimized
     // for barcode reading.
     static const char SCENE_MODE_BARCODE[];
+    // A high-dynamic range mode. In this mode, the HAL module will use a
+    // capture strategy that extends the dynamic range of the captured
+    // image in some fashion. Only the final image is returned.
+    static const char SCENE_MODE_HDR[];
 
     // Pixel color formats for KEY_PREVIEW_FORMAT, KEY_PICTURE_FORMAT,
     // and KEY_VIDEO_FRAME_FORMAT
diff --git a/media/common_time/ICommonClock.cpp b/media/common_time/ICommonClock.cpp
index 28b43ac..25ae69e 100644
--- a/media/common_time/ICommonClock.cpp
+++ b/media/common_time/ICommonClock.cpp
@@ -13,7 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <linux/socket.h>
+
+#include <sys/socket.h>
 
 #include <common_time/ICommonClock.h>
 #include <binder/Parcel.h>
diff --git a/media/common_time/ICommonTimeConfig.cpp b/media/common_time/ICommonTimeConfig.cpp
index 8eb37cb..67167b0 100644
--- a/media/common_time/ICommonTimeConfig.cpp
+++ b/media/common_time/ICommonTimeConfig.cpp
@@ -13,7 +13,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-#include <linux/socket.h>
+
+#include <sys/socket.h>
 
 #include <common_time/ICommonTimeConfig.h>
 #include <binder/Parcel.h>
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 04f78eb..9f069ae 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -451,7 +451,11 @@
     }
 
     if (!haveAudio && !haveVideo) {
-        return UNKNOWN_ERROR;
+        if (mWVMExtractor != NULL) {
+            return mWVMExtractor->getError();
+        } else {
+            return UNKNOWN_ERROR;
+        }
     }
 
     mExtractorFlags = extractor->flags();
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index d94fc65..31b2bcf 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -148,6 +148,20 @@
     }
 }
 
+status_t WVMExtractor::getError() {
+    if (mImpl == NULL) {
+       return UNKNOWN_ERROR;
+    }
+
+    return mImpl->getError();
+}
+
+void WVMExtractor::setError(status_t err) {
+    if (mImpl != NULL) {
+        mImpl->setError(err);
+    }
+}
+
 bool SniffWVM(
     const sp<DataSource> &source, String8 *mimeType, float *confidence,
         sp<AMessage> *) {
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index c43c801..8e62946 100644
--- a/media/libstagefright/include/WVMExtractor.h
+++ b/media/libstagefright/include/WVMExtractor.h
@@ -33,9 +33,11 @@
     virtual ~WVMLoadableExtractor() {}
 
     virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0;
+    virtual status_t getError() = 0;
     virtual status_t getEstimatedBandwidthKbps(int32_t *kbps) = 0;
     virtual void setAdaptiveStreamingMode(bool adaptive) = 0;
     virtual void setCryptoPluginMode(bool cryptoPluginMode) = 0;
+    virtual void setError(status_t err) = 0;
     virtual void setUID(uid_t uid) = 0;
 };
 
@@ -76,6 +78,10 @@
 
     static bool getVendorLibHandle();
 
+    status_t getError();
+
+    void setError(status_t err);
+
 protected:
     virtual ~WVMExtractor();
 
diff --git a/media/mtp/Android.mk b/media/mtp/Android.mk
index fc7fc4f..bee28d4 100644
--- a/media/mtp/Android.mk
+++ b/media/mtp/Android.mk
@@ -45,31 +45,3 @@
 LOCAL_SHARED_LIBRARIES := libutils libcutils libusbhost libbinder
 
 include $(BUILD_SHARED_LIBRARY)
-
-ifeq ($(HOST_OS),linux)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:=                                       \
-                  MtpDataPacket.cpp                     \
-                  MtpDebug.cpp                          \
-                  MtpDevice.cpp                         \
-                  MtpEventPacket.cpp                    \
-                  MtpDeviceInfo.cpp                     \
-                  MtpObjectInfo.cpp                     \
-                  MtpPacket.cpp                         \
-                  MtpProperty.cpp                       \
-                  MtpRequestPacket.cpp                  \
-                  MtpResponsePacket.cpp                 \
-                  MtpStorageInfo.cpp                    \
-                  MtpStringBuffer.cpp                   \
-                  MtpStorage.cpp                        \
-                  MtpUtils.cpp                          \
-
-LOCAL_MODULE:= libmtp
-
-LOCAL_CFLAGS := -DMTP_HOST
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-endif
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index a5d4c6c..27e2ed2 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -3383,9 +3383,9 @@
 }
 
 // getTrackName_l() must be called with ThreadBase::mLock held
-int AudioFlinger::MixerThread::getTrackName_l(audio_channel_mask_t channelMask)
+int AudioFlinger::MixerThread::getTrackName_l(audio_channel_mask_t channelMask, int sessionId)
 {
-    return mAudioMixer->getTrackName(channelMask);
+    return mAudioMixer->getTrackName(channelMask, sessionId);
 }
 
 // deleteTrackName_l() must be called with ThreadBase::mLock held
@@ -3498,7 +3498,7 @@
                 readOutputParameters();
                 mAudioMixer = new AudioMixer(mNormalFrameCount, mSampleRate);
                 for (size_t i = 0; i < mTracks.size() ; i++) {
-                    int name = getTrackName_l(mTracks[i]->mChannelMask);
+                    int name = getTrackName_l(mTracks[i]->mChannelMask, mTracks[i]->mSessionId);
                     if (name < 0) break;
                     mTracks[i]->mName = name;
                     // limit track sample rate to 2 x new output sample rate
@@ -3828,7 +3828,8 @@
 }
 
 // getTrackName_l() must be called with ThreadBase::mLock held
-int AudioFlinger::DirectOutputThread::getTrackName_l(audio_channel_mask_t channelMask)
+int AudioFlinger::DirectOutputThread::getTrackName_l(audio_channel_mask_t channelMask,
+        int sessionId)
 {
     return 0;
 }
@@ -4293,7 +4294,7 @@
         // 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
         mCblk->frameSize = audio_is_linear_pcm(format) ? mChannelCount * sizeof(int16_t) : sizeof(uint8_t);
         // to avoid leaking a track name, do not allocate one unless there is an mCblk
-        mName = thread->getTrackName_l(channelMask);
+        mName = thread->getTrackName_l(channelMask, sessionId);
         mCblk->mName = mName;
         if (mName < 0) {
             ALOGE("no more track names available");
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 5ffa5a6..c956861 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1086,7 +1086,7 @@
 
         // Allocate a track name for a given channel mask.
         //   Returns name >= 0 if successful, -1 on failure.
-        virtual int             getTrackName_l(audio_channel_mask_t channelMask) = 0;
+        virtual int             getTrackName_l(audio_channel_mask_t channelMask, int sessionId) = 0;
         virtual void            deleteTrackName_l(int name) = 0;
 
         // Time to sleep between cycles when:
@@ -1202,7 +1202,7 @@
 
     protected:
         virtual     mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
-        virtual     int         getTrackName_l(audio_channel_mask_t channelMask);
+        virtual     int         getTrackName_l(audio_channel_mask_t channelMask, int sessionId);
         virtual     void        deleteTrackName_l(int name);
         virtual     uint32_t    idleSleepTimeUs() const;
         virtual     uint32_t    suspendSleepTimeUs() const;
@@ -1254,7 +1254,7 @@
         virtual     bool        checkForNewParameters_l();
 
     protected:
-        virtual     int         getTrackName_l(audio_channel_mask_t channelMask);
+        virtual     int         getTrackName_l(audio_channel_mask_t channelMask, int sessionId);
         virtual     void        deleteTrackName_l(int name);
         virtual     uint32_t    activeSleepTimeUs() const;
         virtual     uint32_t    idleSleepTimeUs() const;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index a9814a1..ab75dd0 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -163,7 +163,7 @@
     delete [] mState.resampleTemp;
 }
 
-int AudioMixer::getTrackName(audio_channel_mask_t channelMask)
+int AudioMixer::getTrackName(audio_channel_mask_t channelMask, int sessionId)
 {
     uint32_t names = (~mTrackNames) & mConfiguredNames;
     if (names != 0) {
@@ -189,6 +189,7 @@
         t->enabled = false;
         t->format = 16;
         t->channelMask = AUDIO_CHANNEL_OUT_STEREO;
+        t->sessionId = sessionId;
         // setBufferProvider(name, AudioBufferProvider *) is required before enable(name)
         t->bufferProvider = NULL;
         t->downmixerBufferProvider = NULL;
@@ -270,7 +271,7 @@
     }
 
     if (EffectCreate(&dwnmFxDesc.uuid,
-            -2 /*sessionId*/, -2 /*ioId*/,// both not relevant here, using random value
+            pTrack->sessionId /*sessionId*/, -2 /*ioId not relevant here, using random value*/,
             &pDbp->mDownmixHandle/*pHandle*/) != 0) {
         ALOGE("prepareTrackForDownmix(%d) fails: error creating downmixer effect", trackName);
         goto noDownmixForActiveTrack;
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 6e34cd1..6333357 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -91,7 +91,7 @@
     // For all APIs with "name": TRACK0 <= name < TRACK0 + MAX_NUM_TRACKS
 
     // Allocate a track name.  Returns new track name if successful, -1 on failure.
-    int         getTrackName(audio_channel_mask_t channelMask);
+    int         getTrackName(audio_channel_mask_t channelMask, int sessionId);
 
     // Free an allocated track by name
     void        deleteTrackName(int name);
@@ -192,7 +192,7 @@
 
         DownmixerBufferProvider* downmixerBufferProvider; // 4 bytes
 
-        int32_t     padding;
+        int32_t     sessionId;
 
         // 16-byte boundary
 
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index cdc27a2..13003d9 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -281,8 +281,9 @@
                     AudioBufferProvider *bufferProvider = fastTrack->mBufferProvider;
                     ALOG_ASSERT(bufferProvider != NULL && fastTrackNames[i] == -1);
                     if (mixer != NULL) {
-                        // calling getTrackName with default channel mask
-                        name = mixer->getTrackName(AUDIO_CHANNEL_OUT_STEREO);
+                        // calling getTrackName with default channel mask and a random invalid
+                        //   sessionId (no effects here)
+                        name = mixer->getTrackName(AUDIO_CHANNEL_OUT_STEREO, -555);
                         ALOG_ASSERT(name >= 0);
                         fastTrackNames[i] = name;
                         mixer->setBufferProvider(name, bufferProvider);
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
index 4237afb..eb72412 100644
--- a/services/camera/libcameraservice/Camera2Client.cpp
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -64,15 +64,6 @@
 
     SharedParameters::Lock l(mParameters);
     l.mParameters.state = Parameters::DISCONNECTED;
-
-    char value[PROPERTY_VALUE_MAX];
-    property_get("camera.zsl_mode", value, "0");
-    if (!strcmp(value,"1")) {
-        ALOGI("Camera %d: Enabling ZSL mode", cameraId);
-        l.mParameters.zslMode = true;
-    } else {
-        l.mParameters.zslMode = false;
-    }
 }
 
 status_t Camera2Client::checkPid(const char* checkLocation) const {
diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp
index 562384d..c9c816a 100644
--- a/services/camera/libcameraservice/CameraClient.cpp
+++ b/services/camera/libcameraservice/CameraClient.cpp
@@ -608,11 +608,9 @@
     } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) {
         switch (arg1) {
             case 0:
-                enableShutterSound(false);
-                break;
+                return enableShutterSound(false);
             case 1:
-                enableShutterSound(true);
-                break;
+                return enableShutterSound(true);
             default:
                 return BAD_VALUE;
         }
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp
index f490b2a..c07a6ac 100644
--- a/services/camera/libcameraservice/camera2/Parameters.cpp
+++ b/services/camera/libcameraservice/camera2/Parameters.cpp
@@ -23,6 +23,7 @@
 
 #include <math.h>
 #include <stdlib.h>
+#include <cutils/properties.h>
 
 #include "Parameters.h"
 #include "system/camera.h"
@@ -748,7 +749,14 @@
 
     previewCallbackFlags = 0;
 
-    zslMode = false;
+    char value[PROPERTY_VALUE_MAX];
+    property_get("camera.zsl_mode", value, "0");
+    if (!strcmp(value,"1")) {
+        ALOGI("Camera %d: Enabling ZSL mode", cameraId);
+        zslMode = true;
+    } else {
+        zslMode = false;
+    }
 
     lightFx = LIGHTFX_NONE;
 
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
index ea1c2b9..0771872 100644
--- a/services/camera/libcameraservice/camera2/ZslProcessor.cpp
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -132,8 +132,8 @@
                     client->getCameraId(), strerror(-res), res);
             return res;
         }
-        if (currentWidth != (uint32_t)params.pictureWidth ||
-                currentHeight != (uint32_t)params.pictureHeight) {
+        if (currentWidth != (uint32_t)params.fastInfo.arrayWidth ||
+                currentHeight != (uint32_t)params.fastInfo.arrayHeight) {
             res = device->deleteReprocessStream(mZslReprocessStreamId);
             if (res != OK) {
                 ALOGE("%s: Camera %d: Unable to delete old reprocess stream "
@@ -154,8 +154,9 @@
 
     if (mZslStreamId == NO_STREAM) {
         // Create stream for HAL production
+        // TODO: Sort out better way to select resolution for ZSL
         res = device->createStream(mZslWindow,
-                params.pictureWidth, params.pictureHeight,
+                params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
                 HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED, 0,
                 &mZslStreamId);
         if (res != OK) {