Merge "Merge "Update scroll chip on rotation" into 24D1-dev am: e577313649" into main
diff --git a/services/core/java/com/android/server/audio/MusicFxHelper.java b/services/core/java/com/android/server/audio/MusicFxHelper.java
index ba45310..cf0b2ae 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 @@
// 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 @@
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 @@
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);
+ }
}
}
}