Merge "Update volume slider on device changed." into mnc-dr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ae5a53d78c
@@ -383,6 +383,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
final IntentFilter filter = new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION);
|
final IntentFilter filter = new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION);
|
||||||
filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
|
filter.addAction(AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION);
|
||||||
filter.addAction(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
|
filter.addAction(NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED);
|
||||||
|
filter.addAction(AudioManager.STREAM_DEVICES_CHANGED_ACTION);
|
||||||
mContext.registerReceiver(this, filter);
|
mContext.registerReceiver(this, filter);
|
||||||
} else {
|
} else {
|
||||||
mContext.unregisterReceiver(this);
|
mContext.unregisterReceiver(this);
|
||||||
@@ -395,13 +396,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
|
if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) {
|
||||||
int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||||
int streamValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1);
|
int streamValue = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, -1);
|
||||||
final boolean streamMatch = mNotificationOrRing ? isNotificationOrRing(streamType)
|
updateVolumeSlider(streamType, streamValue);
|
||||||
: (streamType == mStreamType);
|
|
||||||
if (mSeekBar != null && streamMatch && streamValue != -1) {
|
|
||||||
final boolean muted = mAudioManager.isStreamMute(mStreamType)
|
|
||||||
|| streamValue == 0;
|
|
||||||
mUiHandler.postUpdateSlider(streamValue, mLastAudibleStreamVolume, muted);
|
|
||||||
}
|
|
||||||
} else if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) {
|
} else if (AudioManager.INTERNAL_RINGER_MODE_CHANGED_ACTION.equals(action)) {
|
||||||
if (mNotificationOrRing) {
|
if (mNotificationOrRing) {
|
||||||
mRingerMode = mAudioManager.getRingerModeInternal();
|
mRingerMode = mAudioManager.getRingerModeInternal();
|
||||||
@@ -409,10 +404,24 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
if (mAffectedByRingerMode) {
|
if (mAffectedByRingerMode) {
|
||||||
updateSlider();
|
updateSlider();
|
||||||
}
|
}
|
||||||
|
} else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) {
|
||||||
|
int streamType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1);
|
||||||
|
int streamVolume = mAudioManager.getStreamVolume(streamType);
|
||||||
|
updateVolumeSlider(streamType, streamVolume);
|
||||||
} else if (NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED.equals(action)) {
|
} else if (NotificationManager.ACTION_INTERRUPTION_FILTER_CHANGED.equals(action)) {
|
||||||
mZenMode = mNotificationManager.getZenMode();
|
mZenMode = mNotificationManager.getZenMode();
|
||||||
updateSlider();
|
updateSlider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateVolumeSlider(int streamType, int streamValue) {
|
||||||
|
final boolean streamMatch = mNotificationOrRing ? isNotificationOrRing(streamType)
|
||||||
|
: (streamType == mStreamType);
|
||||||
|
if (mSeekBar != null && streamMatch && streamValue != -1) {
|
||||||
|
final boolean muted = mAudioManager.isStreamMute(mStreamType)
|
||||||
|
|| streamValue == 0;
|
||||||
|
mUiHandler.postUpdateSlider(streamValue, mLastAudibleStreamVolume, muted);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user