AVRCP_Browse: Don't peek/pop elements from empty stack

In some corner cases Change Path (Folder-up) without any
prior SetBrowse Player results peeking elements from an
empty stack leading BT Reset. Instead, for empty stack
response with internal error.

CRs-Fixed: 2494100
Change-Id: I81458ac471de7b2b5012d77c9d64f66398db92c2
diff --git a/src/com/android/bluetooth/avrcp/BrowsedMediaPlayer.java b/src/com/android/bluetooth/avrcp/BrowsedMediaPlayer.java
index 0d8c45e..19183e3 100644
--- a/src/com/android/bluetooth/avrcp/BrowsedMediaPlayer.java
+++ b/src/com/android/bluetooth/avrcp/BrowsedMediaPlayer.java
@@ -572,7 +572,10 @@
                 mPathStack.push(newPath);
             }
         } else if (direction == AvrcpConstants.DIR_UP) { /* move up */
-            if (!isBrowsableFolderUp()) {
+            if (mPathStack == null || mPathStack.isEmpty()) {
+                Log.w(TAG, "Path Stack not initialized send internal error!");
+                mMediaInterface.changePathRsp(mBDAddr, AvrcpConstants.RSP_INTERNAL_ERR, 0);
+            } else if (!isBrowsableFolderUp()) {
                 /* Already on the root, cannot allow up: PTS: test case TC_TG_MCN_CB_BI_02_C
                  * This is required, otherwise some CT will keep on sending change path up
                  * until they receive error */