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

Commit 58961eba authored by Joseph Pirozzo's avatar Joseph Pirozzo Committed by Gerrit Code Review
Browse files

Merge "AVRCP ignore duplicate volume changed notifications"

parents 522041df 0625de9a
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -87,7 +87,9 @@ class AvrcpControllerStateMachine extends StateMachine {
    static final int MESSAGE_INTERNAL_BROWSE_DEPTH_INCREMENT = 401;
    static final int MESSAGE_INTERNAL_MOVE_N_LEVELS_UP = 402;
    static final int MESSAGE_INTERNAL_CMD_TIMEOUT = 403;
    static final int MESSAGE_INTERNAL_ABS_VOL_TIMEOUT = 404;

    static final int ABS_VOL_TIMEOUT_MILLIS = 1000; //1s
    static final int CMD_TIMEOUT_MILLIS = 5000; // 5s
    // Fetch only 5 items at a time.
    static final int GET_FOLDER_ITEMS_PAGINATION_SIZE = 5;
@@ -130,7 +132,7 @@ class AvrcpControllerStateMachine extends StateMachine {
    private AvrcpPlayer mAddressedPlayer;

    // Only accessed from State Machine processMessage
    private boolean mAbsoluteVolumeChangeInProgress = false;
    private int mVolumeChangedNotificationsToIgnore = 0;
    private int mPreviousPercentageVol = -1;

    // Depth from root of current browsing. This can be used to move to root directly.
@@ -377,7 +379,10 @@ class AvrcpControllerStateMachine extends StateMachine {
                        break;

                    case MESSAGE_PROCESS_SET_ABS_VOL_CMD:
                        mAbsoluteVolumeChangeInProgress = true;
                        mVolumeChangedNotificationsToIgnore++;
                        removeMessages(MESSAGE_INTERNAL_ABS_VOL_TIMEOUT);
                        sendMessageDelayed(MESSAGE_INTERNAL_ABS_VOL_TIMEOUT,
                                ABS_VOL_TIMEOUT_MILLIS);
                        setAbsVolume(msg.arg1, msg.arg2);
                        break;

@@ -396,8 +401,11 @@ class AvrcpControllerStateMachine extends StateMachine {
                    break;

                    case MESSAGE_PROCESS_VOLUME_CHANGED_NOTIFICATION: {
                        if (mAbsoluteVolumeChangeInProgress) {
                            mAbsoluteVolumeChangeInProgress = false;
                        if (mVolumeChangedNotificationsToIgnore > 0) {
                            mVolumeChangedNotificationsToIgnore--;
                            if (mVolumeChangedNotificationsToIgnore == 0) {
                                removeMessages(MESSAGE_INTERNAL_ABS_VOL_TIMEOUT);
                            }
                        } else {
                            if (mRemoteDevice.getAbsVolNotificationRequested()) {
                                int percentageVol = getVolumePercentage();
@@ -414,6 +422,14 @@ class AvrcpControllerStateMachine extends StateMachine {
                    }
                    break;

                    case MESSAGE_INTERNAL_ABS_VOL_TIMEOUT:
                        // Volume changed notifications should come back promptly from the
                        // AudioManager, if for some reason some notifications were squashed don't
                        // prevent future notifications.
                        if (DBG) Log.d(TAG, "Timed out on volume changed notification");
                        mVolumeChangedNotificationsToIgnore = 0;
                        break;

                    case MESSAGE_PROCESS_TRACK_CHANGED:
                        // Music start playing automatically and update Metadata
                        mAddressedPlayer.updateCurrentTrack((TrackInfo) msg.obj);