Merge "Add flag for remote streams" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
f9343c8baf
@@ -1894,6 +1894,9 @@
|
|||||||
STREAM_MUSIC as if it's on TV platform. -->
|
STREAM_MUSIC as if it's on TV platform. -->
|
||||||
<bool name="config_single_volume">false</bool>
|
<bool name="config_single_volume">false</bool>
|
||||||
|
|
||||||
|
<!-- Flag indicating whether the volume panel should show remote sessions. -->
|
||||||
|
<bool name="config_volumeShowRemoteSessions">true</bool>
|
||||||
|
|
||||||
<!-- Flag indicating that an outbound call must have a call capable phone account
|
<!-- Flag indicating that an outbound call must have a call capable phone account
|
||||||
that has declared it can process the call's handle. -->
|
that has declared it can process the call's handle. -->
|
||||||
<bool name="config_requireCallCapableAccountForHandle">false</bool>
|
<bool name="config_requireCallCapableAccountForHandle">false</bool>
|
||||||
|
|||||||
@@ -4408,4 +4408,6 @@
|
|||||||
<java-symbol type="integer" name="config_hotwordDetectedResultMaxBundleSize" />
|
<java-symbol type="integer" name="config_hotwordDetectedResultMaxBundleSize" />
|
||||||
|
|
||||||
<java-symbol type="dimen" name="config_wallpaperDimAmount" />
|
<java-symbol type="dimen" name="config_wallpaperDimAmount" />
|
||||||
|
|
||||||
|
<java-symbol type="bool" name="config_volumeShowRemoteSessions" />
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
private final MediaSessions mMediaSessions;
|
private final MediaSessions mMediaSessions;
|
||||||
protected C mCallbacks = new C();
|
protected C mCallbacks = new C();
|
||||||
private final State mState = new State();
|
private final State mState = new State();
|
||||||
protected final MediaSessionsCallbacks mMediaSessionsCallbacksW = new MediaSessionsCallbacks();
|
protected final MediaSessionsCallbacks mMediaSessionsCallbacksW;
|
||||||
private final Optional<Vibrator> mVibrator;
|
private final Optional<Vibrator> mVibrator;
|
||||||
private final boolean mHasVibrator;
|
private final boolean mHasVibrator;
|
||||||
private boolean mShowA11yStream;
|
private boolean mShowA11yStream;
|
||||||
@@ -179,6 +179,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mWorkerLooper = theadFactory.buildLooperOnNewThread(
|
mWorkerLooper = theadFactory.buildLooperOnNewThread(
|
||||||
VolumeDialogControllerImpl.class.getSimpleName());
|
VolumeDialogControllerImpl.class.getSimpleName());
|
||||||
mWorker = new W(mWorkerLooper);
|
mWorker = new W(mWorkerLooper);
|
||||||
|
mMediaSessionsCallbacksW = new MediaSessionsCallbacks(mContext);
|
||||||
mMediaSessions = createMediaSessions(mContext, mWorkerLooper, mMediaSessionsCallbacksW);
|
mMediaSessions = createMediaSessions(mContext, mWorkerLooper, mMediaSessionsCallbacksW);
|
||||||
mAudio = audioManager;
|
mAudio = audioManager;
|
||||||
mNoMan = notificationManager;
|
mNoMan = notificationManager;
|
||||||
@@ -1148,16 +1149,24 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
private final HashMap<Token, Integer> mRemoteStreams = new HashMap<>();
|
private final HashMap<Token, Integer> mRemoteStreams = new HashMap<>();
|
||||||
|
|
||||||
private int mNextStream = DYNAMIC_STREAM_START_INDEX;
|
private int mNextStream = DYNAMIC_STREAM_START_INDEX;
|
||||||
|
private final boolean mShowRemoteSessions;
|
||||||
|
|
||||||
|
public MediaSessionsCallbacks(Context context) {
|
||||||
|
mShowRemoteSessions = context.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_volumeShowRemoteSessions);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) {
|
public void onRemoteUpdate(Token token, String name, PlaybackInfo pi) {
|
||||||
|
if (mShowRemoteSessions) {
|
||||||
addStream(token, "onRemoteUpdate");
|
addStream(token, "onRemoteUpdate");
|
||||||
|
|
||||||
int stream = 0;
|
int stream = 0;
|
||||||
synchronized (mRemoteStreams) {
|
synchronized (mRemoteStreams) {
|
||||||
stream = mRemoteStreams.get(token);
|
stream = mRemoteStreams.get(token);
|
||||||
}
|
}
|
||||||
Slog.d(TAG, "onRemoteUpdate: stream: " + stream + " volume: " + pi.getCurrentVolume());
|
Slog.d(TAG,
|
||||||
|
"onRemoteUpdate: stream: " + stream + " volume: " + pi.getCurrentVolume());
|
||||||
boolean changed = mState.states.indexOfKey(stream) < 0;
|
boolean changed = mState.states.indexOfKey(stream) < 0;
|
||||||
final StreamState ss = streamStateW(stream);
|
final StreamState ss = streamStateW(stream);
|
||||||
ss.dynamic = true;
|
ss.dynamic = true;
|
||||||
@@ -1177,9 +1186,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mCallbacks.onStateChanged(mState);
|
mCallbacks.onStateChanged(mState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoteVolumeChanged(Token token, int flags) {
|
public void onRemoteVolumeChanged(Token token, int flags) {
|
||||||
|
if (mShowRemoteSessions) {
|
||||||
addStream(token, "onRemoteVolumeChanged");
|
addStream(token, "onRemoteVolumeChanged");
|
||||||
int stream = 0;
|
int stream = 0;
|
||||||
synchronized (mRemoteStreams) {
|
synchronized (mRemoteStreams) {
|
||||||
@@ -1199,9 +1210,11 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
mCallbacks.onShowRequested(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED);
|
mCallbacks.onShowRequested(Events.SHOW_REASON_REMOTE_VOLUME_CHANGED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRemoteRemoved(Token token) {
|
public void onRemoteRemoved(Token token) {
|
||||||
|
if (mShowRemoteSessions) {
|
||||||
int stream = 0;
|
int stream = 0;
|
||||||
synchronized (mRemoteStreams) {
|
synchronized (mRemoteStreams) {
|
||||||
if (!mRemoteStreams.containsKey(token)) {
|
if (!mRemoteStreams.containsKey(token)) {
|
||||||
@@ -1217,8 +1230,10 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
mCallbacks.onStateChanged(mState);
|
mCallbacks.onStateChanged(mState);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setStreamVolume(int stream, int level) {
|
public void setStreamVolume(int stream, int level) {
|
||||||
|
if (mShowRemoteSessions) {
|
||||||
final Token t = findToken(stream);
|
final Token t = findToken(stream);
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
Log.w(TAG, "setStreamVolume: No token found for stream: " + stream);
|
Log.w(TAG, "setStreamVolume: No token found for stream: " + stream);
|
||||||
@@ -1226,6 +1241,7 @@ public class VolumeDialogControllerImpl implements VolumeDialogController, Dumpa
|
|||||||
}
|
}
|
||||||
mMediaSessions.setVolume(t, level);
|
mMediaSessions.setVolume(t, level);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Token findToken(int stream) {
|
private Token findToken(int stream) {
|
||||||
synchronized (mRemoteStreams) {
|
synchronized (mRemoteStreams) {
|
||||||
|
|||||||
Reference in New Issue
Block a user