Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cde46406 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix unbind service error for MusicFxHelper" into main am: 52a3a399 am: 3917932a

parents 9b8b5330 3917932a
Loading
Loading
Loading
Loading
+9 −3
Original line number Original line Diff line number Diff line
@@ -70,6 +70,8 @@ public class MusicFxHelper {
    // The binder token identifying the UidObserver registration.
    // The binder token identifying the UidObserver registration.
    private IBinder mUidObserverToken = null;
    private IBinder mUidObserverToken = null;


    private boolean mIsBound;

    // Package name and list of open audio sessions for this package
    // Package name and list of open audio sessions for this package
    private static class PackageSessions {
    private static class PackageSessions {
        String mPackageName;
        String mPackageName;
@@ -109,6 +111,7 @@ public class MusicFxHelper {
                if (procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
                if (procState > ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND) {
                    Intent bindIntent = new Intent().setClassName(mMusicFxPackageName,
                    Intent bindIntent = new Intent().setClassName(mMusicFxPackageName,
                            "com.android.musicfx.KeepAliveService");
                            "com.android.musicfx.KeepAliveService");
                    mIsBound = true;
                    mContext.bindServiceAsUser(
                    mContext.bindServiceAsUser(
                            bindIntent, mMusicFxBindConnection, Context.BIND_AUTO_CREATE,
                            bindIntent, mMusicFxBindConnection, Context.BIND_AUTO_CREATE,
                            UserHandle.of(getCurrentUserId()));
                            UserHandle.of(getCurrentUserId()));
@@ -157,12 +160,15 @@ public class MusicFxHelper {
                    Log.e(TAG, "RemoteException with unregisterUidObserver: " + e);
                    Log.e(TAG, "RemoteException with unregisterUidObserver: " + e);
                }
                }
                mUidObserverToken = null;
                mUidObserverToken = null;
                if (mIsBound) {
                    mContext.unbindService(mMusicFxBindConnection);
                    mContext.unbindService(mMusicFxBindConnection);
                    mIsBound = false;
                    Log.i(TAG, "last session closed, unregister UID observer, and unbind "
                    Log.i(TAG, "last session closed, unregister UID observer, and unbind "
                            + mMusicFxPackageName);
                            + mMusicFxPackageName);
                }
                }
            }
            }
        }
        }
    }


    // Hashmap of UID and list of open sessions for this UID.
    // Hashmap of UID and list of open sessions for this UID.
    @GuardedBy("mClientUidMapLock")
    @GuardedBy("mClientUidMapLock")