summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/core/java/com/android/server/audio/MusicFxHelper.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/audio/MusicFxHelper.java b/services/core/java/com/android/server/audio/MusicFxHelper.java
index ba453101046f..cf0b2ae15618 100644
--- a/services/core/java/com/android/server/audio/MusicFxHelper.java
+++ b/services/core/java/com/android/server/audio/MusicFxHelper.java
@@ -70,6 +70,8 @@ public class MusicFxHelper {
// The binder token identifying the UidObserver registration.
private IBinder mUidObserverToken = null;
+ private boolean mIsBound;
+
// Package name and list of open audio sessions for this package
private static class PackageSessions {
String mPackageName;
@@ -109,6 +111,7 @@ public class MusicFxHelper {
if (procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
Intent bindIntent = new Intent().setClassName(mMusicFxPackageName,
"com.android.musicfx.KeepAliveService");
+ mIsBound = true;
mContext.bindServiceAsUser(
bindIntent, mMusicFxBindConnection, Context.BIND_AUTO_CREATE,
UserHandle.of(getCurrentUserId()));
@@ -157,9 +160,12 @@ public class MusicFxHelper {
Log.e(TAG, "RemoteException with unregisterUidObserver: " + e);
}
mUidObserverToken = null;
- mContext.unbindService(mMusicFxBindConnection);
- Log.i(TAG, "last session closed, unregister UID observer, and unbind "
- + mMusicFxPackageName);
+ if (mIsBound) {
+ mContext.unbindService(mMusicFxBindConnection);
+ mIsBound = false;
+ Log.i(TAG, "last session closed, unregister UID observer, and unbind "
+ + mMusicFxPackageName);
+ }
}
}
}