Loading android/app/src/com/android/bluetooth/audio_util/BrowsablePlayerConnector.java +19 −18 Original line number Diff line number Diff line Loading @@ -119,16 +119,21 @@ public class BrowsablePlayerConnector { if (DEBUG) Log.d(TAG, "Received a message: msg.what=" + msg.what); switch(msg.what) { case MSG_GET_FOLDER_ITEMS_CB: { int status = msg.arg1; int results_size = msg.arg2; BrowsedPlayerWrapper wrapper = (BrowsedPlayerWrapper) msg.obj; // If we failed to remove the wrapper from the pending set, that // means a timeout occurred and the callback was triggered afterwards if (!mPendingPlayers.remove(wrapper)) { return; } if (status == BrowsedPlayerWrapper.STATUS_SUCCESS && results_size != 0) { Log.i(TAG, "Successfully added package to results: " + wrapper.getPackageName()); mResults.add(wrapper); } } break; case MSG_CONNECT_CB: { Loading @@ -136,9 +141,13 @@ public class BrowsablePlayerConnector { if (msg.arg1 != BrowsedPlayerWrapper.STATUS_SUCCESS) { Log.i(TAG, wrapper.getPackageName() + " is not browsable"); mPendingPlayers.remove(wrapper); // If we failed to remove the wrapper from the pending set, that // means a timeout occurred and the callback was triggered afterwards if (!mPendingPlayers.remove(wrapper)) { return; } break; } // Check to see if the root folder has any items if (DEBUG) { Loading @@ -146,22 +155,14 @@ public class BrowsablePlayerConnector { } wrapper.getFolderItems(wrapper.getRootId(), (int status, String mediaId, List<ListItem> results) -> { if (status != BrowsedPlayerWrapper.STATUS_SUCCESS) { mPendingPlayers.remove(wrapper); return; } if (results.size() == 0) { mPendingPlayers.remove(wrapper); return; } // Send the response as a message so that it is properly // synchronized Message success = Message cb = mHandler.obtainMessage(MSG_GET_FOLDER_ITEMS_CB); success.obj = wrapper; mHandler.sendMessage(success); cb.arg1 = status; cb.arg2 = results.size(); cb.obj = wrapper; mHandler.sendMessage(cb); }); } break; Loading Loading
android/app/src/com/android/bluetooth/audio_util/BrowsablePlayerConnector.java +19 −18 Original line number Diff line number Diff line Loading @@ -119,16 +119,21 @@ public class BrowsablePlayerConnector { if (DEBUG) Log.d(TAG, "Received a message: msg.what=" + msg.what); switch(msg.what) { case MSG_GET_FOLDER_ITEMS_CB: { int status = msg.arg1; int results_size = msg.arg2; BrowsedPlayerWrapper wrapper = (BrowsedPlayerWrapper) msg.obj; // If we failed to remove the wrapper from the pending set, that // means a timeout occurred and the callback was triggered afterwards if (!mPendingPlayers.remove(wrapper)) { return; } if (status == BrowsedPlayerWrapper.STATUS_SUCCESS && results_size != 0) { Log.i(TAG, "Successfully added package to results: " + wrapper.getPackageName()); mResults.add(wrapper); } } break; case MSG_CONNECT_CB: { Loading @@ -136,9 +141,13 @@ public class BrowsablePlayerConnector { if (msg.arg1 != BrowsedPlayerWrapper.STATUS_SUCCESS) { Log.i(TAG, wrapper.getPackageName() + " is not browsable"); mPendingPlayers.remove(wrapper); // If we failed to remove the wrapper from the pending set, that // means a timeout occurred and the callback was triggered afterwards if (!mPendingPlayers.remove(wrapper)) { return; } break; } // Check to see if the root folder has any items if (DEBUG) { Loading @@ -146,22 +155,14 @@ public class BrowsablePlayerConnector { } wrapper.getFolderItems(wrapper.getRootId(), (int status, String mediaId, List<ListItem> results) -> { if (status != BrowsedPlayerWrapper.STATUS_SUCCESS) { mPendingPlayers.remove(wrapper); return; } if (results.size() == 0) { mPendingPlayers.remove(wrapper); return; } // Send the response as a message so that it is properly // synchronized Message success = Message cb = mHandler.obtainMessage(MSG_GET_FOLDER_ITEMS_CB); success.obj = wrapper; mHandler.sendMessage(success); cb.arg1 = status; cb.arg2 = results.size(); cb.obj = wrapper; mHandler.sendMessage(cb); }); } break; Loading