From 19566543c4833f50e7c22aff0c707388f8a338d2 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Mon, 7 Oct 2013 17:10:08 -0700 Subject: 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 --- media/java/android/media/MediaFocusControl.java | 7 +++++++ media/java/android/media/RemoteController.java | 26 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'media') diff --git a/media/java/android/media/MediaFocusControl.java b/media/java/android/media/MediaFocusControl.java index d185321..07d91ac 100644 --- a/media/java/android/media/MediaFocusControl.java +++ b/media/java/android/media/MediaFocusControl.java @@ -275,6 +275,13 @@ public class MediaFocusControl implements OnFinished { // tell the RCCs about the change for this RCD enableRemoteControlDisplayForClient_syncRcStack( 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) { Log.e(TAG, "Error en/disabling RCD: ", e); } diff --git a/media/java/android/media/RemoteController.java b/media/java/android/media/RemoteController.java index c6d6296..32e85d9 100644 --- a/media/java/android/media/RemoteController.java +++ b/media/java/android/media/RemoteController.java @@ -784,8 +784,34 @@ public final class RemoteController } private void onDisplayEnable(boolean enabled) { + final OnClientUpdateListener l; synchronized(mInfoLock) { 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*/); } } -- cgit v1.1