Methods Summary |
---|
protected void | clear()
super.clear();
if (mSentKeyPressed) {
sendVolumeKeyReleased();
}
if (mLastAvrVolume != UNKNOWN_AVR_VOLUME) {
tv().setAudioStatus(mLastAvrMute, mLastAvrVolume);
mLastAvrVolume = UNKNOWN_AVR_VOLUME;
mLastAvrMute = false;
}
|
private boolean | handleFeatureAbort(HdmiCecMessage cmd)
int originalOpcode = cmd.getParams()[0] & 0xFF;
// Since it sends <User Control Released> only when it finishes this action,
// it takes care of <User Control Pressed> only here.
if (originalOpcode == MESSAGE_USER_CONTROL_PRESSED) {
finish();
return true;
}
return false;
|
private boolean | handleReportAudioStatus(HdmiCecMessage cmd)
byte params[] = cmd.getParams();
boolean mute = (params[0] & 0x80) == 0x80;
int volume = params[0] & 0x7F;
mLastAvrVolume = volume;
mLastAvrMute = mute;
if (shouldUpdateAudioVolume(mute)) {
HdmiLogger.debug("Force volume change[mute:%b, volume=%d]", mute, volume);
tv().setAudioStatus(mute, volume);
mLastAvrVolume = UNKNOWN_AVR_VOLUME;
mLastAvrMute = false;
}
return true;
|
void | handleTimerEvent(int state)
if (state != STATE_WAIT_FOR_NEXT_VOLUME_PRESS) {
return;
}
if (System.currentTimeMillis() - mLastKeyUpdateTime >= IRT_MS) {
finish();
} else {
sendVolumeKeyPressed();
resetTimer();
}
|
void | handleVolumeChange(boolean isVolumeUp)
if (mIsVolumeUp != isVolumeUp) {
HdmiLogger.debug("Volume Key Status Changed[old:%b new:%b]", mIsVolumeUp, isVolumeUp);
sendVolumeKeyReleased();
mIsVolumeUp = isVolumeUp;
sendVolumeKeyPressed();
resetTimer();
}
updateLastKeyUpdateTime();
|
boolean | processCommand(HdmiCecMessage cmd)
if (mState != STATE_WAIT_FOR_NEXT_VOLUME_PRESS || cmd.getSource() != mAvrAddress) {
return false;
}
switch (cmd.getOpcode()) {
case MESSAGE_REPORT_AUDIO_STATUS:
return handleReportAudioStatus(cmd);
case MESSAGE_FEATURE_ABORT:
return handleFeatureAbort(cmd);
}
return false;
|
private void | resetTimer()
mActionTimer.clearTimerMessage();
addTimer(STATE_WAIT_FOR_NEXT_VOLUME_PRESS, IRT_MS);
|
public static int | scaleToCecVolume(int volume, int scale)Scale a custom volume value to cec volume scale.
return (volume * MAX_VOLUME) / scale;
|
public static int | scaleToCustomVolume(int cecVolume, int scale)Scale a cec volume which is in range of 0 to 100 to custom volume level.
return (cecVolume * scale) / MAX_VOLUME;
|
private void | sendVolumeKeyPressed()
sendCommand(HdmiCecMessageBuilder.buildUserControlPressed(getSourceAddress(), mAvrAddress,
mIsVolumeUp ? HdmiCecKeycode.CEC_KEYCODE_VOLUME_UP
: HdmiCecKeycode.CEC_KEYCODE_VOLUME_DOWN));
mSentKeyPressed = true;
|
private void | sendVolumeKeyReleased()
sendCommand(HdmiCecMessageBuilder.buildUserControlReleased(
getSourceAddress(), mAvrAddress));
mSentKeyPressed = false;
|
private boolean | shouldUpdateAudioVolume(boolean mute)
// Do nothing if in mute.
if (mute) {
return true;
}
// Update audio status if current volume position is edge of volume bar,
// i.e max or min volume.
AudioManager audioManager = tv().getService().getAudioManager();
int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (mIsVolumeUp) {
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
return currentVolume == maxVolume;
} else {
return currentVolume == 0;
}
|
boolean | start()
mState = STATE_WAIT_FOR_NEXT_VOLUME_PRESS;
sendVolumeKeyPressed();
resetTimer();
return true;
|
private void | updateLastKeyUpdateTime()
mLastKeyUpdateTime = System.currentTimeMillis();
|