Add remote volume slider to sound settings

1. Add RemoteVolumePreferenceController to control volume through
MediaSessions.
2. Add related preference to skip calling AudioManager.

Bug: 126199571
Test: RunSettingsRoboTests
Change-Id: I9cb85ccf5f49be6d127cb61caf445b2ee7dfb579
This commit is contained in:
jackqdyulei
2019-02-27 10:05:56 -08:00
parent 3329ead489
commit f25c9b0efc
8 changed files with 324 additions and 4 deletions

View File

@@ -0,0 +1,56 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.notification;
import android.content.Context;
import android.util.AttributeSet;
/**
* A slider preference that controls remote volume, which doesn't go through
* {@link android.media.AudioManager}
**/
public class RemoteVolumeSeekBarPreference extends VolumeSeekBarPreference {
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public RemoteVolumeSeekBarPreference(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RemoteVolumeSeekBarPreference(Context context) {
super(context);
}
@Override
public void setStream(int stream) {
// Do nothing here, volume is not controlled by AudioManager
}
@Override
protected void init() {
if (mSeekBar == null) return;
updateIconView();
updateSuppressionText();
}
}