policy_hal: Update policy hal with latest AOSP refresh.

This change updates policy HAL with latest AOSP refresh.

AudioPolicyManager: remove unnecessary device reconnection
Change-Id: I2182b205c2b72cebff657a7bbee95df97f97eb55

audio policy: fix HW A/V sync rerouting
Change-Id: I1f080232e439a410ded25ca8e461113a96687a3b

Dynamic policies: support for device selection
Change-Id: I71584081e7f1b2b5252fb6c4659fdeb464f7d282

Change-Id: I8e2812f1386aa7349f4470f25bf67ce88982ab74
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index b3ba637..25d5db9 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -976,7 +976,6 @@
 {
     ALOGD("setForceUse() usage %d, config %d, mPhoneState %d", usage, config, mEngine->getPhoneState());
 
-    audio_policy_forced_cfg_t originalConfig = mEngine->getForceUse(usage);
     if (mEngine->setForceUse(usage, config) != NO_ERROR) {
         ALOGW("setForceUse() could not set force cfg %d for usage %d", config, usage);
         return;
@@ -990,32 +989,6 @@
     checkOutputForAllStrategies();
     updateDevicesAndOutputs();
 
-    // Did surround forced use change?
-    if ((usage == AUDIO_POLICY_FORCE_FOR_ENCODED_SURROUND)
-            && (originalConfig != config)) {
-        const char *device_address  = "";
-        // Is it currently connected? If so then cycle the connection
-        // so that the supported surround formats will be reloaded.
-        //
-        // FIXME As S/PDIF is not a removable device we have to handle this differently.
-        // Probably by updating the device descriptor directly and manually
-        // tearing down active playback on S/PDIF
-        if (getDeviceConnectionState(AUDIO_DEVICE_OUT_HDMI, device_address) ==
-                                             AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
-            // Disconnect and reconnect output devices so that the surround
-            // encodings can be updated.
-            const char *device_name = "";
-            // disconnect
-            setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_HDMI,
-                        AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
-                        device_address, device_name);
-            // reconnect
-            setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_HDMI,
-                        AUDIO_POLICY_DEVICE_STATE_AVAILABLE,
-                        device_address, device_name);
-        }
-    }
-
     if (mEngine->getPhoneState() == AUDIO_MODE_IN_CALL && hasPrimaryOutput()) {
         audio_devices_t newDevice = getNewOutputDevice(mPrimaryOutput, true /*fromCache*/);
         updateCallRouting(newDevice);
@@ -1810,6 +1783,13 @@
     }
 
 non_direct_output:
+
+    // A request for HW A/V sync cannot fallback to a mixed output because time
+    // stamps are embedded in audio data
+    if ((flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC) != 0) {
+        return AUDIO_IO_HANDLE_NONE;
+    }
+
     // ignoring channel mask due to downmix capability in mixer
 
     // open a non direct output
@@ -2025,7 +2005,7 @@
         // if input maps to a dynamic policy with an activity listener, notify of state change
         if ((inputDesc->mPolicyMix != NULL)
                 && ((inputDesc->mPolicyMix->mCbFlags & AudioMix::kCbFlagNotifyActivity) != 0)) {
-            mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mRegistrationId,
+            mpClientInterface->onDynamicPolicyMixStateUpdate(inputDesc->mPolicyMix->mDeviceAddress,
                     MIX_STATE_MIXING);
         }
 
@@ -2042,7 +2022,7 @@
             if (inputDesc->mPolicyMix == NULL) {
                 address = String8("0");
             } else if (inputDesc->mPolicyMix->mMixType == MIX_TYPE_PLAYERS) {
-                address = inputDesc->mPolicyMix->mRegistrationId;
+                address = inputDesc->mPolicyMix->mDeviceAddress;
             }
             if (address != "") {
                 setDeviceConnectionStateInt(AUDIO_DEVICE_OUT_REMOTE_SUBMIX,