Merge "Fix memory leak in MediaScannerConnection"

This commit is contained in:
Marco Nelissen
2016-07-26 15:37:32 +00:00
committed by Gerrit Code Review

View File

@@ -133,6 +133,10 @@ public class MediaScannerConnection implements ServiceConnection {
} }
try { try {
mContext.unbindService(this); mContext.unbindService(this);
if (mClient instanceof ClientProxy) {
mClient = null;
}
mService = null;
} catch (IllegalArgumentException ex) { } catch (IllegalArgumentException ex) {
if (false) { if (false) {
Log.v(TAG, "disconnect failed: " + ex); Log.v(TAG, "disconnect failed: " + ex);
@@ -205,6 +209,7 @@ public class MediaScannerConnection implements ServiceConnection {
void scanNextPath() { void scanNextPath() {
if (mNextPath >= mPaths.length) { if (mNextPath >= mPaths.length) {
mConnection.disconnect(); mConnection.disconnect();
mConnection = null;
return; return;
} }
String mimeType = mMimeTypes != null ? mMimeTypes[mNextPath] : null; String mimeType = mMimeTypes != null ? mMimeTypes[mNextPath] : null;