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

Commit d1a33622 authored by Sanket Agarwal's avatar Sanket Agarwal Committed by Gerrit Code Review
Browse files

Merge changes I7f2e3ac0,Ibcd26731,I9ac5121c,Ie9135167,Ib02c74c7, ...

* changes:
  Fixing A2dpSinkStreamingStateMachine thread leak.
  Now Playing List gets stuck in a loop
  MAP Client connect after PBAP Client
  MAP MCE iPhone connectivity
  MAP MCE disconnecting automatically
  MAP MCE message filtering
  Set debug flags to false
parents ed048ac5 8361fdc4
Loading
Loading
Loading
Loading
+20 −3
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ import java.util.HashMap;
import java.util.Set;

final class A2dpSinkStateMachine extends StateMachine {
    private static final boolean DBG = true;
    private static final boolean DBG = false;

    static final int CONNECT = 1;
    static final int DISCONNECT = 2;
@@ -120,6 +120,7 @@ final class A2dpSinkStateMachine extends StateMachine {
    private BluetoothDevice mTargetDevice = null;
    private BluetoothDevice mIncomingDevice = null;
    private BluetoothDevice mPlayingDevice = null;
    private A2dpSinkStreamingStateMachine mStreaming = null;

    private final HashMap<BluetoothDevice,BluetoothAudioConfig> mAudioConfigs
            = new HashMap<BluetoothDevice,BluetoothAudioConfig>();
@@ -159,6 +160,15 @@ final class A2dpSinkStateMachine extends StateMachine {
    }

    public void doQuit() {
        if(DBG) {
            Log.d("A2dpSinkStateMachine", "Quit");
        }
        synchronized (A2dpSinkStateMachine.this) {
            if (mStreaming != null) {
                mStreaming.doQuit();
                mStreaming = null;
            }
        }
        quitNow();
    }

@@ -492,14 +502,21 @@ final class A2dpSinkStateMachine extends StateMachine {
    }

    private class Connected extends State {
        private A2dpSinkStreamingStateMachine mStreaming;
        @Override
        public void enter() {
            log("Enter Connected: " + getCurrentMessage().what);
            // Upon connected, the audio starts out as stopped
            broadcastAudioState(mCurrentDevice, BluetoothA2dpSink.STATE_NOT_PLAYING,
                                BluetoothA2dpSink.STATE_PLAYING);
            mStreaming = A2dpSinkStreamingStateMachine.make(A2dpSinkStateMachine.this, mContext);
            synchronized (A2dpSinkStateMachine.this) {
                if (mStreaming == null) {
                    if(DBG) {
                        log("Creating New A2dpSinkStreamingStateMachine");
                    }
                    mStreaming = A2dpSinkStreamingStateMachine.make(A2dpSinkStateMachine.this,
                            mContext);
                }
            }
        }

        @Override
+8 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ import com.android.internal.util.StateMachine;
 *            2. On Audio focus enable streaming in Fluoride.
 */
final class A2dpSinkStreamingStateMachine extends StateMachine {
    private static final boolean DBG = true;
    private static final boolean DBG = false;
    private static final String TAG = "A2dpSinkStreamingStateMachine";
    private static final int ACT_PLAY_NUM_RETRIES = 5;
    private static final int ACT_PLAY_RETRY_DELAY = 2000; // millis.
@@ -158,6 +158,13 @@ final class A2dpSinkStreamingStateMachine extends StateMachine {
        return a2dpStrStateMachine;
    }

    public void doQuit(){
        if(DBG) {
            Log.d(TAG, "doQuit()");
        }
        quitNow();
    }

    /**
     * Utility functions that can be used by all states.
     */
+4 −0
Original line number Diff line number Diff line
@@ -925,6 +925,10 @@ class AvrcpControllerStateMachine extends StateMachine {
            return;
        }

        if (DBG) {
            Log.d(TAG, "To Browse folder " + bn + " is cached " + bn.isCached() +
                " current folder " + mBrowseTree.getCurrentBrowsedFolder());
        }
        if (bn.equals(mBrowseTree.getCurrentBrowsedFolder()) && bn.isCached()) {
            if (DBG) {
                Log.d(TAG, "Same cached folder -- returning existing children.");
+4 −1
Original line number Diff line number Diff line
@@ -281,7 +281,10 @@ public class BrowseTree {
        }

        // Set the previous folder as not cached so that we fetch the contents again.
        if (!bn.equals(mCurrentBrowseNode)) {
            Log.d(TAG, "Set cache false " + bn + " curr " + mCurrentBrowseNode);
            mCurrentBrowseNode.setCached(false);
        }

        mCurrentBrowseNode = bn;
        return true;
+14 −0
Original line number Diff line number Diff line
@@ -1786,6 +1786,7 @@ public class AdapterService extends Service {
        HeadsetClientService headsetClientService = HeadsetClientService.getHeadsetClientService();
        A2dpSinkService a2dpSinkService = A2dpSinkService.getA2dpSinkService();
        PbapClientService pbapClientService = PbapClientService.getPbapClientService();
        MapClientService mapClientService = MapClientService.getMapClientService();
        PanService panService = PanService.getPanService();

        boolean allProfilesEmpty = true;
@@ -1794,6 +1795,7 @@ public class AdapterService extends Service {
        List<BluetoothDevice> headsetClientConnDevList = null;
        List<BluetoothDevice> a2dpSinkConnDevList = null;
        List<BluetoothDevice> pbapClientConnDevList = null;
        List<BluetoothDevice> mapClientConnDevList = null;
        List<BluetoothDevice> panConnDevList = null;

        if (hsService != null) {
@@ -1816,6 +1818,10 @@ public class AdapterService extends Service {
            pbapClientConnDevList = pbapClientService.getConnectedDevices();
            allProfilesEmpty = allProfilesEmpty && pbapClientConnDevList.isEmpty();
        }
        if (mapClientService != null) {
            mapClientConnDevList = mapClientService.getConnectedDevices();
            allProfilesEmpty = allProfilesEmpty && mapClientConnDevList.isEmpty();
        }
        if (panService != null) {
            panConnDevList = panService.getConnectedDevices();
            allProfilesEmpty = allProfilesEmpty && panConnDevList.isEmpty();
@@ -1856,6 +1862,14 @@ public class AdapterService extends Service {
                pbapClientService.connect(device);
            }
        }
        if (mapClientService != null) {
            if (mapClientConnDevList.isEmpty() &&
                    (mapClientService.getPriority(device) >= BluetoothProfile.PRIORITY_ON)) {
                if (pbapClientConnDevList.isEmpty() || pbapClientConnDevList.contains(device)) {
                    mapClientService.connect(device);
                }
            }
        }
        if (panService != null) {
            if (panConnDevList.isEmpty() &&
                (panService.getPriority(device) >= BluetoothProfile.PRIORITY_ON)) {
Loading