Resolved partial uipc channel read issue

When partial data is read the previously read size wasn't
compensated for.  Ensure we don't transmit empty a2dp frames in case
of underrun
Bug 8026551

Change-Id: I4195ed798008378b93343bf7cd266c6e2f11b094
diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c
index 8978cf6..200cf06 100755
--- a/btif/src/btif_media_task.c
+++ b/btif/src/btif_media_task.c
@@ -2098,27 +2098,33 @@
         } while (((p_buf->len + btif_media_cb.encoder.u16PacketLength) < btif_media_cb.TxAaMtuSize)
                 && (p_buf->layer_specific < 0x0F) && nb_frame);
 
-        /* coverity[SIGN_EXTENSION] False-positive: Parameter are always in range avoiding sign extension*/
-        btif_media_cb.timestamp += p_buf->layer_specific * blocm_x_subband;
-
-        /* store the time stamp in the buffer to send */
-        *((UINT32 *) (p_buf + 1)) = btif_media_cb.timestamp;
-
-        VERBOSE("TX QUEUE NOW %d", btif_media_cb.TxAaQ.count);
-
-        if (btif_media_cb.tx_flush)
+        if(p_buf->len)
         {
-            APPL_TRACE_DEBUG0("### tx suspended, discarded frame ###");
+            btif_media_cb.timestamp += p_buf->layer_specific * blocm_x_subband;
 
-            if (btif_media_cb.TxAaQ.count > 0)
-                btif_media_flush_q(&(btif_media_cb.TxAaQ));
+            /* store the time stamp in the buffer to send */
+            *((UINT32 *) (p_buf + 1)) = btif_media_cb.timestamp;
 
-            GKI_freebuf(p_buf);
-            return;
+            VERBOSE("TX QUEUE NOW %d", btif_media_cb.TxAaQ.count);
+
+            if (btif_media_cb.tx_flush)
+            {
+                APPL_TRACE_DEBUG0("### tx suspended, discarded frame ###");
+
+                if (btif_media_cb.TxAaQ.count > 0)
+                    btif_media_flush_q(&(btif_media_cb.TxAaQ));
+
+                GKI_freebuf(p_buf);
+                return;
+            }
+
+            /* Enqueue the encoded SBC frame in AA Tx Queue */
+            GKI_enqueue(&(btif_media_cb.TxAaQ), p_buf);
         }
-
-        /* Enqueue the encoded SBC frame in AA Tx Queue */
-        GKI_enqueue(&(btif_media_cb.TxAaQ), p_buf);
+        else
+        {
+            GKI_freebuf(p_buf);
+        }
     }
 }
 
diff --git a/udrv/ulinux/uipc.c b/udrv/ulinux/uipc.c
index 9bb44df..4e8a273 100644
--- a/udrv/ulinux/uipc.c
+++ b/udrv/ulinux/uipc.c
@@ -811,7 +811,7 @@
             return 0;
         }
 
-        n = recv(fd, p_buf, len, 0);
+        n = recv(fd, p_buf+n_read, len-n_read, 0);
 
         //BTIF_TRACE_EVENT1("read %d bytes", n);