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

Commit 19566543 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Update RemoteController info when enabling/disabling it

When a RemoteController listener is disabled: send its listener
 "blank" information (no artist, "stopped state"...)
When a RemoteController listener is enabled: have the current
 RemoteControlClient send the current information.

Bug 8209392

Change-Id: I375bf3c42a425ada94c61453b51669d7e819dde4
parent 619fc89a
Loading
Loading
Loading
Loading
+7 −0
Original line number Original line Diff line number Diff line
@@ -275,6 +275,13 @@ public class MediaFocusControl implements OnFinished {
                                // tell the RCCs about the change for this RCD
                                // tell the RCCs about the change for this RCD
                                enableRemoteControlDisplayForClient_syncRcStack(
                                enableRemoteControlDisplayForClient_syncRcStack(
                                        di.mRcDisplay, di.mEnabled);
                                        di.mRcDisplay, di.mEnabled);
                                // when enabling, refresh the information on the display
                                if (di.mEnabled) {
                                    sendMsg(mEventHandler, MSG_RCDISPLAY_INIT_INFO, SENDMSG_QUEUE,
                                            di.mArtworkExpectedWidth /*arg1*/,
                                            di.mArtworkExpectedHeight/*arg2*/,
                                            di.mRcDisplay /*obj*/, 0/*delay*/);
                                }
                            } catch (RemoteException e) {
                            } catch (RemoteException e) {
                                Log.e(TAG, "Error en/disabling RCD: ", e);
                                Log.e(TAG, "Error en/disabling RCD: ", e);
                            }
                            }
+26 −0
Original line number Original line Diff line number Diff line
@@ -784,8 +784,34 @@ public final class RemoteController
    }
    }


    private void onDisplayEnable(boolean enabled) {
    private void onDisplayEnable(boolean enabled) {
        final OnClientUpdateListener l;
        synchronized(mInfoLock) {
        synchronized(mInfoLock) {
            mEnabled = enabled;
            mEnabled = enabled;
            l = this.mOnClientUpdateListener;
        }
        if (!enabled) {
            // when disabling, reset all info sent to the user
            final int genId;
            synchronized (mGenLock) {
                genId = mClientGenerationIdCurrent;
            }
            // send "stopped" state, happened "now", playback position is 0, speed 0.0f
            final PlaybackInfo pi = new PlaybackInfo(RemoteControlClient.PLAYSTATE_STOPPED,
                    SystemClock.elapsedRealtime() /*stateChangeTimeMs*/,
                    0 /*currentPosMs*/, 0.0f /*speed*/);
            sendMsg(mEventHandler, MSG_NEW_PLAYBACK_INFO, SENDMSG_REPLACE,
                    genId /*arg1*/, 0 /*arg2, ignored*/, pi /*obj*/, 0 /*delay*/);
            // send "blank" transport control info: no controls are supported
            sendMsg(mEventHandler, MSG_NEW_TRANSPORT_INFO, SENDMSG_REPLACE,
                    genId /*arg1*/, 0 /*arg2, no flags*/,
                    null /*obj, ignored*/, 0 /*delay*/);
            // send dummy metadata with empty string for title and artist, duration of 0
            Bundle metadata = new Bundle(3);
            metadata.putString(String.valueOf(MediaMetadataRetriever.METADATA_KEY_TITLE), "");
            metadata.putString(String.valueOf(MediaMetadataRetriever.METADATA_KEY_ARTIST), "");
            metadata.putLong(String.valueOf(MediaMetadataRetriever.METADATA_KEY_DURATION), 0);
            sendMsg(mEventHandler, MSG_NEW_METADATA, SENDMSG_QUEUE,
                    genId /*arg1*/, 0 /*arg2, ignored*/, metadata /*obj*/, 0 /*delay*/);
        }
        }
    }
    }