Loading android/app/src/com/android/bluetooth/avrcp/MediaPlayerList.java +4 −1 Original line number Diff line number Diff line Loading @@ -514,7 +514,10 @@ public class MediaPlayerList { final MediaPlayerWrapper wrapper = mMediaPlayers.get(playerId); d("Removing media player " + wrapper.getPackageName()); mMediaPlayerIds.remove(wrapper.getPackageName()); if (!mBrowsablePlayers.containsKey(playerId)) { d(wrapper.getPackageName() + " doesn't have a browse service. Recycle player ID."); mMediaPlayers.remove(playerId); } wrapper.cleanup(); } Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +1 −1 Original line number Diff line number Diff line Loading @@ -502,7 +502,7 @@ class AvrcpControllerStateMachine extends StateMachine { // Let the addressed player know we got an image so it can see if the current // track now has cover artwork boolean addedArtwork = mAddressedPlayer.notifyImageDownload(handle, uri); if (addedArtwork) { if (addedArtwork && isActive()) { BluetoothMediaBrowserService.trackChanged( mAddressedPlayer.getCurrentTrack()); } Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class AvrcpCoverArtManager { mContext = context; mCoverArtStorage = new AvrcpCoverArtStorage(mContext); mCallback = callback; mCoverArtStorage.clear(); } /** Loading Loading @@ -123,6 +124,7 @@ public class AvrcpCoverArtManager { for (BluetoothDevice device : mClients.keySet()) { disconnect(device); } mCoverArtStorage.clear(); } /** Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtStorage.java +49 −10 Original line number Diff line number Diff line Loading @@ -88,12 +88,17 @@ public class AvrcpCoverArtStorage { String path = getImagePath(device, imageHandle); if (path == null) { debug("Cannot store image. Cannot provide a valid path to storage"); error("Cannot store image. Cannot provide a valid path to storage"); return null; } try { File deviceDirectory = new File(getDevicePath(device)); String deviceDirectoryPath = getDevicePath(device); if (deviceDirectoryPath == null) { error("Cannot store image. Cannot get a valid path to per-device storage"); return null; } File deviceDirectory = new File(deviceDirectoryPath); if (!deviceDirectory.exists()) { deviceDirectory.mkdirs(); } Loading Loading @@ -122,6 +127,10 @@ public class AvrcpCoverArtStorage { debug("Removing image '" + imageHandle + "' from device " + device); if (device == null || imageHandle == null || "".equals(imageHandle)) return; String path = getImagePath(device, imageHandle); if (path == null) { error("Cannot remove image. Cannot get a valid path to storage"); return; } File file = new File(path); if (!file.exists()) return; file.delete(); Loading @@ -136,17 +145,26 @@ public class AvrcpCoverArtStorage { public void removeImagesForDevice(BluetoothDevice device) { if (device == null) return; debug("Remove cover art for device " + device.getAddress()); File deviceDirectory = new File(getDevicePath(device)); File[] files = deviceDirectory.listFiles(); if (files == null) { debug("No cover art files to delete"); String deviceDirectoryPath = getDevicePath(device); if (deviceDirectoryPath == null) { error("Cannot remove images for device. Cannot get a valid path to storage"); return; } for (int i = 0; i < files.length; i++) { debug("Deleted " + files[i].getAbsolutePath()); files[i].delete(); File deviceDirectory = new File(deviceDirectoryPath); deleteStorageDirectory(deviceDirectory); } /** * Clear the entirety of storage */ public void clear() { String storageDirectoryPath = getStorageDirectory(); if (storageDirectoryPath == null) { error("Cannot remove images, cannot get a valid path to storage. Is it mounted?"); return; } deviceDirectory.delete(); File storageDirectory = new File(storageDirectoryPath); deleteStorageDirectory(storageDirectory); } private String getStorageDirectory() { Loading @@ -171,6 +189,27 @@ public class AvrcpCoverArtStorage { return deviceDir + "/" + imageHandle + ".png"; } private void deleteStorageDirectory(File directory) { if (directory == null) { error("Cannot delete directory, file is null"); return; } if (!directory.exists()) return; File[] files = directory.listFiles(); if (files == null) { return; } for (int i = 0; i < files.length; i++) { debug("Deleting " + files[i].getAbsolutePath()); if (files[i].isDirectory()) { deleteStorageDirectory(files[i]); } else { files[i].delete(); } } directory.delete(); } @Override public String toString() { String s = "CoverArtStorage:\n"; Loading android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpPlayer.java +3 −1 Original line number Diff line number Diff line Loading @@ -187,8 +187,10 @@ class AvrcpPlayer { public synchronized boolean notifyImageDownload(String handle, Uri imageUri) { if (DBG) Log.d(TAG, "Got an image download -- handle=" + handle + ", uri=" + imageUri); if (mCurrentTrack != null && mCurrentTrack.getCoverArtHandle() == handle) { if (handle == null || imageUri == null || mCurrentTrack == null) return false; if (handle.equals(mCurrentTrack.getCoverArtHandle())) { mCurrentTrack.setCoverArtLocation(imageUri); if (DBG) Log.d(TAG, "Handle '" + handle + "' was added to current track."); return true; } return false; Loading Loading
android/app/src/com/android/bluetooth/avrcp/MediaPlayerList.java +4 −1 Original line number Diff line number Diff line Loading @@ -514,7 +514,10 @@ public class MediaPlayerList { final MediaPlayerWrapper wrapper = mMediaPlayers.get(playerId); d("Removing media player " + wrapper.getPackageName()); mMediaPlayerIds.remove(wrapper.getPackageName()); if (!mBrowsablePlayers.containsKey(playerId)) { d(wrapper.getPackageName() + " doesn't have a browse service. Recycle player ID."); mMediaPlayers.remove(playerId); } wrapper.cleanup(); } Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpControllerStateMachine.java +1 −1 Original line number Diff line number Diff line Loading @@ -502,7 +502,7 @@ class AvrcpControllerStateMachine extends StateMachine { // Let the addressed player know we got an image so it can see if the current // track now has cover artwork boolean addedArtwork = mAddressedPlayer.notifyImageDownload(handle, uri); if (addedArtwork) { if (addedArtwork && isActive()) { BluetoothMediaBrowserService.trackChanged( mAddressedPlayer.getCurrentTrack()); } Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ public class AvrcpCoverArtManager { mContext = context; mCoverArtStorage = new AvrcpCoverArtStorage(mContext); mCallback = callback; mCoverArtStorage.clear(); } /** Loading Loading @@ -123,6 +124,7 @@ public class AvrcpCoverArtManager { for (BluetoothDevice device : mClients.keySet()) { disconnect(device); } mCoverArtStorage.clear(); } /** Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpCoverArtStorage.java +49 −10 Original line number Diff line number Diff line Loading @@ -88,12 +88,17 @@ public class AvrcpCoverArtStorage { String path = getImagePath(device, imageHandle); if (path == null) { debug("Cannot store image. Cannot provide a valid path to storage"); error("Cannot store image. Cannot provide a valid path to storage"); return null; } try { File deviceDirectory = new File(getDevicePath(device)); String deviceDirectoryPath = getDevicePath(device); if (deviceDirectoryPath == null) { error("Cannot store image. Cannot get a valid path to per-device storage"); return null; } File deviceDirectory = new File(deviceDirectoryPath); if (!deviceDirectory.exists()) { deviceDirectory.mkdirs(); } Loading Loading @@ -122,6 +127,10 @@ public class AvrcpCoverArtStorage { debug("Removing image '" + imageHandle + "' from device " + device); if (device == null || imageHandle == null || "".equals(imageHandle)) return; String path = getImagePath(device, imageHandle); if (path == null) { error("Cannot remove image. Cannot get a valid path to storage"); return; } File file = new File(path); if (!file.exists()) return; file.delete(); Loading @@ -136,17 +145,26 @@ public class AvrcpCoverArtStorage { public void removeImagesForDevice(BluetoothDevice device) { if (device == null) return; debug("Remove cover art for device " + device.getAddress()); File deviceDirectory = new File(getDevicePath(device)); File[] files = deviceDirectory.listFiles(); if (files == null) { debug("No cover art files to delete"); String deviceDirectoryPath = getDevicePath(device); if (deviceDirectoryPath == null) { error("Cannot remove images for device. Cannot get a valid path to storage"); return; } for (int i = 0; i < files.length; i++) { debug("Deleted " + files[i].getAbsolutePath()); files[i].delete(); File deviceDirectory = new File(deviceDirectoryPath); deleteStorageDirectory(deviceDirectory); } /** * Clear the entirety of storage */ public void clear() { String storageDirectoryPath = getStorageDirectory(); if (storageDirectoryPath == null) { error("Cannot remove images, cannot get a valid path to storage. Is it mounted?"); return; } deviceDirectory.delete(); File storageDirectory = new File(storageDirectoryPath); deleteStorageDirectory(storageDirectory); } private String getStorageDirectory() { Loading @@ -171,6 +189,27 @@ public class AvrcpCoverArtStorage { return deviceDir + "/" + imageHandle + ".png"; } private void deleteStorageDirectory(File directory) { if (directory == null) { error("Cannot delete directory, file is null"); return; } if (!directory.exists()) return; File[] files = directory.listFiles(); if (files == null) { return; } for (int i = 0; i < files.length; i++) { debug("Deleting " + files[i].getAbsolutePath()); if (files[i].isDirectory()) { deleteStorageDirectory(files[i]); } else { files[i].delete(); } } directory.delete(); } @Override public String toString() { String s = "CoverArtStorage:\n"; Loading
android/app/src/com/android/bluetooth/avrcpcontroller/AvrcpPlayer.java +3 −1 Original line number Diff line number Diff line Loading @@ -187,8 +187,10 @@ class AvrcpPlayer { public synchronized boolean notifyImageDownload(String handle, Uri imageUri) { if (DBG) Log.d(TAG, "Got an image download -- handle=" + handle + ", uri=" + imageUri); if (mCurrentTrack != null && mCurrentTrack.getCoverArtHandle() == handle) { if (handle == null || imageUri == null || mCurrentTrack == null) return false; if (handle.equals(mCurrentTrack.getCoverArtHandle())) { mCurrentTrack.setCoverArtLocation(imageUri); if (DBG) Log.d(TAG, "Handle '" + handle + "' was added to current track."); return true; } return false; Loading