Merge "cameraserver: ICameraDevice.dumpState -> dump." into tm-dev
diff --git a/drm/libmediadrm/CryptoHalAidl.cpp b/drm/libmediadrm/CryptoHalAidl.cpp
index 642264f..3dc62e9 100644
--- a/drm/libmediadrm/CryptoHalAidl.cpp
+++ b/drm/libmediadrm/CryptoHalAidl.cpp
@@ -355,8 +355,7 @@
     std::string msgStr(statusAidl.getMessage());
     *errorDetailMsg = toString8(msgStr);
     if (err != OK) {
-        ALOGE("Failed on decrypt, error message:%s, bytes written:%d", statusAidl.getMessage(),
-              result);
+        ALOGE("Failed on decrypt, error description:%s", statusAidl.getDescription().c_str());
         return err;
     }
 
@@ -376,7 +375,7 @@
     mHeapSizes.add(seqNum, heap->size());
 
     SharedBufferAidl memAidl;
-    memAidl.handle = ::android::makeToAidl(heap->handle());
+    memAidl.handle = ::android::dupToAidl(heap->handle());
     memAidl.size = heap->size();
     memAidl.bufferId = bufferId;
 
diff --git a/drm/libmediadrm/DrmHalAidl.cpp b/drm/libmediadrm/DrmHalAidl.cpp
index dc6d23e..284abd5 100644
--- a/drm/libmediadrm/DrmHalAidl.cpp
+++ b/drm/libmediadrm/DrmHalAidl.cpp
@@ -19,6 +19,7 @@
 
 #include <array>
 #include <algorithm>
+#include <map>
 #include <android/binder_auto_utils.h>
 #include <android/binder_manager.h>
 #include <media/PluginMetricsReporting.h>
@@ -52,6 +53,7 @@
 using ::aidl::android::hardware::drm::SecureStopId;
 using ::aidl::android::hardware::drm::SecurityLevel;
 using ::aidl::android::hardware::drm::Status;
+using ::aidl::android::hardware::drm::SupportedContentType;
 using ::aidl::android::hardware::drm::Uuid;
 using DrmMetricGroupAidl = ::aidl::android::hardware::drm::DrmMetricGroup;
 using DrmMetricGroupHidl = ::android::hardware::drm::V1_1::DrmMetricGroup;
@@ -420,16 +422,30 @@
             continue;
         }
 
-        if (levelAidl != SecurityLevel::DEFAULT && levelAidl != SecurityLevel::UNKNOWN) {
-            if (levelAidl > schemes.maxLevel || levelAidl < schemes.minLevel) {
-                continue;
-            }
+        ALOGV("supported schemes: %s; query: level %d mime %s",
+              schemes.toString().c_str(), levelAidl, mimeType.c_str());
+        std::map<std::string, SupportedContentType> contentTypes;
+        for (auto ct : schemes.mimeTypes) {
+            contentTypes[ct.mime] = ct;
         }
 
-        if (!mimeTypeStr.empty()) {
-            if (!std::count(schemes.mimeTypes.begin(), schemes.mimeTypes.end(), mimeTypeStr)) {
-                continue;
+        // handle default value cases
+        if (levelAidl == SecurityLevel::DEFAULT || levelAidl == SecurityLevel::UNKNOWN) {
+            if (mimeType == "") {
+                // isCryptoSchemeSupported(uuid)
+                *isSupported = true;
+            } else {
+                // isCryptoSchemeSupported(uuid, mimeType)
+                *isSupported = contentTypes.count(mimeTypeStr);
             }
+            return OK;
+        } else if (mimeType == "") {
+            return BAD_VALUE;
+        }
+
+        auto ct = contentTypes[mimeTypeStr];
+        if (levelAidl > ct.maxLevel || levelAidl < ct.minLevel) {
+              continue;
         }
 
         *isSupported = true;
diff --git a/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp b/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
index 651d8f5..201cf02 100644
--- a/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
@@ -227,7 +227,7 @@
 }
 
 SharedBufferBase::~SharedBufferBase() {
-    if (munmap(mBase, mSize)) {
+    if (mBase && munmap(mBase, mSize)) {
         ALOGE("munmap err: base %p; errno %s",
               mBase, strerror(errno));
     }
diff --git a/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp b/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
index bef05ec..30db4c0 100644
--- a/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
+++ b/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
@@ -82,10 +82,12 @@
     for (const auto& uuid : ::aidl::android::hardware::drm::clearkey::getSupportedCryptoSchemes()) {
         schemes.uuids.push_back({uuid});
     }
-    schemes.minLevel = SecurityLevel::SW_SECURE_CRYPTO;
-    schemes.maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
-    schemes.mimeTypes = {kIsoBmffVideoMimeType, kIsoBmffAudioMimeType, kCencInitDataFormat,
-                         kWebmVideoMimeType, kWebmAudioMimeType, kWebmInitDataFormat};
+    for (auto mime : {kIsoBmffVideoMimeType, kIsoBmffAudioMimeType, kCencInitDataFormat,
+                      kWebmVideoMimeType, kWebmAudioMimeType, kWebmInitDataFormat}) {
+        const auto minLevel = SecurityLevel::SW_SECURE_CRYPTO;
+        const auto maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
+        schemes.mimeTypes.push_back({mime, minLevel, maxLevel});
+    }
     *_aidl_return = schemes;
     return ndk::ScopedAStatus::ok();
 }
diff --git a/media/libaaudio/src/utility/AAudioUtilities.cpp b/media/libaaudio/src/utility/AAudioUtilities.cpp
index a0952fe..4b42203 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.cpp
+++ b/media/libaaudio/src/utility/AAudioUtilities.cpp
@@ -560,9 +560,10 @@
 }
 
 int32_t AAudioProperty_getMinimumSleepMicros() {
-    const int32_t minMicros = 20; // arbitrary
-    const int32_t defaultMicros = 200; // arbitrary
-    const int32_t maxMicros = 2000; // arbitrary
+    const int32_t minMicros = 1; // arbitrary
+    // Higher values can increase latency for moderate workloads.
+    const int32_t defaultMicros = 1; // arbitrary
+    const int32_t maxMicros = 200; // arbitrary
     int32_t prop = property_get_int32(AAUDIO_PROP_MINIMUM_SLEEP_USEC, defaultMicros);
     if (prop < minMicros) {
         ALOGW("AAudioProperty_getMinimumSleepMicros: clipped %d to %d", prop, minMicros);
diff --git a/services/audiopolicy/service/SpatializerPoseController.cpp b/services/audiopolicy/service/SpatializerPoseController.cpp
index 6a3c9d1..58a57ac 100644
--- a/services/audiopolicy/service/SpatializerPoseController.cpp
+++ b/services/audiopolicy/service/SpatializerPoseController.cpp
@@ -57,7 +57,7 @@
 constexpr float kAutoRecenterTranslationThreshold = 0.1f;
 
 // Auto-recenter considers head not still if rotated by this much (in radians, approx).
-constexpr float kAutoRecenterRotationThreshold = 7.0f / 180 * M_PI;
+constexpr float kAutoRecenterRotationThreshold = 10.5f / 180 * M_PI;
 
 // Screen is considered to be unstable (not still) if it has moved significantly within the last
 // time window of this duration.