Fix memory leak in Ringtone
BUG: 31938615 Change-Id: Ic736f3494b4da95460bdc0cb7857cc9fcc746ab9
This commit is contained in:
@@ -368,6 +368,7 @@ public class Ringtone {
|
|||||||
|
|
||||||
private void destroyLocalPlayer() {
|
private void destroyLocalPlayer() {
|
||||||
if (mLocalPlayer != null) {
|
if (mLocalPlayer != null) {
|
||||||
|
mLocalPlayer.setOnCompletionListener(null);
|
||||||
mLocalPlayer.reset();
|
mLocalPlayer.reset();
|
||||||
mLocalPlayer.release();
|
mLocalPlayer.release();
|
||||||
mLocalPlayer = null;
|
mLocalPlayer = null;
|
||||||
@@ -464,11 +465,14 @@ public class Ringtone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MyOnCompletionListener implements MediaPlayer.OnCompletionListener {
|
class MyOnCompletionListener implements MediaPlayer.OnCompletionListener {
|
||||||
public void onCompletion(MediaPlayer mp)
|
@Override
|
||||||
{
|
public void onCompletion(MediaPlayer mp) {
|
||||||
synchronized (sActiveRingtones) {
|
synchronized (sActiveRingtones) {
|
||||||
sActiveRingtones.remove(Ringtone.this);
|
sActiveRingtones.remove(Ringtone.this);
|
||||||
}
|
}
|
||||||
|
if (mLocalPlayer != null) {
|
||||||
|
mLocalPlayer.setOnCompletionListener(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user