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

Commit 5b001d8d authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Handle stopped apps

Do not bind to MediaBrowserService for a stopped package.

Bug: 238433770
Bug: 314855224
Test: m -j
Test: manually force-stop an app with MediaBrowserService and toggle bluetooth off/on
      App should not be unstopped by bluetooth

Change-Id: I8809fb1dd81b2a5fc1b55be1b39d36e47e2f11b2
parent 17b71ae0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ import android.util.Log;

import com.android.bluetooth.BluetoothEventLogger;
import com.android.bluetooth.Utils;
import com.android.bluetooth.flags.FeatureFlags;
import com.android.bluetooth.flags.FeatureFlagsImpl;
import com.android.internal.annotations.VisibleForTesting;

import java.util.ArrayList;
@@ -90,6 +92,7 @@ public class MediaPlayerList {
    private MediaSessionManager mMediaSessionManager;
    private MediaData mCurrMediaData = null;
    private final AudioManager mAudioManager;
    private final FeatureFlags mFeatureFlags = new FeatureFlagsImpl();

    private final BluetoothEventLogger mActivePlayerLogger =
            new BluetoothEventLogger(ACTIVE_PLAYER_LOGGER_SIZE, ACTIVE_PLAYER_LOGGER_TITLE);
@@ -208,6 +211,10 @@ public class MediaPlayerList {

        // Build the list of browsable players and afterwards, build the list of media players
        Intent intent = new Intent(android.service.media.MediaBrowserService.SERVICE_INTERFACE);
        if (mFeatureFlags.keepStoppedMediaBrowserService()) {
            // Don't query stopped apps, that would end up unstopping them
            intent.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES);
        }
        List<ResolveInfo> playerList =
                mContext
                    .getApplicationContext()