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

Commit 3df0f4a1 authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Promotion of bt.lnx.2.1.c1-00008.

CRs      Change ID                                   Subject
--------------------------------------------------------------------------------------------------------------
1084472   I0c3837dbe05dd3bdc527e5bba5ac3d45ef127698   Bluetooth: Adapterservice Cleanup and unbind uncondition
1086579   I766538debaec330c5694844c4b7145bc9402dc6e   Serialize the RC Cleanup events in BT-App context

Change-Id: I500f7e949206430aa824453e2042f4aa281f56ee
CRs-Fixed: 1084472, 1086579
parents eea9bc66 5c86e667
Loading
Loading
Loading
Loading
+44 −14
Original line number Diff line number Diff line
@@ -153,6 +153,10 @@ public final class Avrcp {
    private static final int MESSAGE_CHANGE_PLAY_POS = 12;
    private static final int MESSAGE_SET_A2DP_AUDIO_STATE = 13;
    private static final int MESSAGE_SET_ADDR_PLAYER_REQ_TIMEOUT = 14;
    private static final int MESSAGE_DEVICE_RC_CLEANUP = 15;

    private static final int STACK_CLEANUP = 0;
    private static final int APP_CLEANUP = 1;

    private static final int AVRCP_BR_RSP_TIMEOUT = 2000;
    private static final int MESSAGE_SEND_PASS_THROUGH_CMD = 2001;
@@ -749,16 +753,10 @@ public final class Avrcp {
    public void doQuit() {
        if (DEBUG)
            Log.v(TAG, "doQuit");
        mHandler.removeCallbacksAndMessages(null);
        Looper looper = mHandler.getLooper();
        if (looper != null) {
            looper.quit();
        }
        mMediaSessionManager.removeOnActiveSessionsChangedListener(mSessionChangeListener);
        clearDeviceDependentFeature();
        for (int i = 0; i < maxAvrcpConnections; i++) {
            cleanupDeviceFeaturesIndex(i);
        }
        Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_RC_CLEANUP, APP_CLEANUP,
               0, null);
        mHandler.sendMessage(msg);

        mAvrcpBipRsp.stop();
        try {
            mContext.unregisterReceiver(mIntentReceiver);
@@ -771,6 +769,13 @@ public final class Avrcp {
            if (DEBUG)
                Log.v(TAG, "Addressed player message cleanup as part of doQuit");
        }

        mHandler.removeCallbacksAndMessages(null);
        Looper looper = mHandler.getLooper();
        if (looper != null) {
            looper.quit();
        }
        mMediaSessionManager.removeOnActiveSessionsChangedListener(mSessionChangeListener);
    }

    public void clearDeviceDependentFeature() {
@@ -1539,6 +1544,31 @@ public final class Avrcp {
                updateA2dpAudioState(msg.arg1, (BluetoothDevice)msg.obj);
                break;

            case MESSAGE_DEVICE_RC_CLEANUP:
                if (DEBUG)
                    Log.v(TAG,"MESSAGE_DEVICE_RC_CLEANUP: " + msg.arg1);
                if (msg.arg1 == STACK_CLEANUP) {
                    deviceIndex = getIndexForDevice((BluetoothDevice) msg.obj);
                    if (deviceIndex == INVALID_DEVICE_INDEX) {
                        Log.e(TAG,"invalid device index for cleanup");
                        break;
                    }
                    cleanupDeviceFeaturesIndex(deviceIndex);
                } else if (msg.arg1 == APP_CLEANUP) {
                    if (msg.obj == null) {
                        clearDeviceDependentFeature();
                        for (int i = 0; i < maxAvrcpConnections; i++) {
                            cleanupDeviceFeaturesIndex(i);
                        }
                    } else {
                        Log.v(TAG, "Invalid message params");
                        break;
                    }
                } else {
                    Log.v(TAG, "Invalid Arguments to MESSAGE_DEVICE_RC_CLEANUP");
                }
                break;

            case MSG_UPDATE_RCC_CHANGE:
                Log.v(TAG, "MSG_UPDATE_RCC_CHANGE");
                String callingPackageName = (String)msg.obj;
@@ -1729,7 +1759,7 @@ public final class Avrcp {
        deviceFeatures[deviceIndex].mCurrentPlayState = state;

        if ((deviceFeatures[deviceIndex].mPlayStatusChangedNT == NOTIFICATION_TYPE_INTERIM) &&
               (oldPlayStatus != newPlayStatus)) {
               (oldPlayStatus != newPlayStatus) && deviceFeatures[deviceIndex].mCurrentDevice != null) {
            deviceFeatures[deviceIndex].mPlayStatusChangedNT = NOTIFICATION_TYPE_CHANGED;
            registerNotificationRspPlayStatusNative(
                    deviceFeatures[deviceIndex].mPlayStatusChangedNT,
@@ -5353,11 +5383,11 @@ public final class Avrcp {
            if (deviceFeatures[i].mCurrentDevice !=null &&
                    deviceFeatures[i].mCurrentDevice.equals(device)) {
                // initiate cleanup for all variables;

                Message msg = mHandler.obtainMessage(MESSAGE_DEVICE_RC_CLEANUP, STACK_CLEANUP,
                       0, device);
                mHandler.sendMessage(msg);
                Log.i(TAG,"Device removed is " + device);
                Log.i(TAG,"removed at " + i);
                deviceFeatures[i].mCurrentDevice = null;
                cleanupDeviceFeaturesIndex(i);
                /* device is disconnect and some response form music app was
                 * pending for this device clear it.*/
                if (mBrowserDevice != null &&
+3 −6
Original line number Diff line number Diff line
@@ -547,13 +547,10 @@ public class AdapterService extends Service {
        return mBinder;
    }
    public boolean onUnbind(Intent intent) {
        if (getState() == BluetoothAdapter.STATE_OFF) {
        Log.w(TAG, "onUnbind, calling cleanup");
        cleanup();
        return super.onUnbind(intent);
    }
        return false;
    }

    public void onDestroy() {
        debugLog("onDestroy()");