am c38c93f4: am 1a1e24f1: Merge "Update RemoteController info when enabling/disabling it" into klp-dev

* commit 'c38c93f4deb80d1df7acf915cdf2df17cc7cc548':
  Update RemoteController info when enabling/disabling it
This commit is contained in:
Jean-Michel Trivi
2013-10-07 17:50:08 -07:00
committed by Android Git Automerger
2 changed files with 33 additions and 0 deletions

View File

@@ -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);
}

View File

@@ -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*/);
}
}