Merge "Add flag to separate notification audio and ui" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
dd4b1a0d7d
@@ -16,7 +16,9 @@
|
|||||||
|
|
||||||
package android.preference;
|
package android.preference;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
|
import android.annotation.RequiresPermission;
|
||||||
import android.app.NotificationManager;
|
import android.app.NotificationManager;
|
||||||
import android.compat.annotation.UnsupportedAppUsage;
|
import android.compat.annotation.UnsupportedAppUsage;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -35,6 +37,7 @@ import android.os.Handler;
|
|||||||
import android.os.HandlerThread;
|
import android.os.HandlerThread;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.preference.VolumePreference.VolumeStore;
|
import android.preference.VolumePreference.VolumeStore;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.Global;
|
import android.provider.Settings.Global;
|
||||||
import android.provider.Settings.System;
|
import android.provider.Settings.System;
|
||||||
@@ -44,6 +47,7 @@ import android.widget.SeekBar;
|
|||||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.internal.os.SomeArgs;
|
import com.android.internal.os.SomeArgs;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -115,7 +119,6 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
private final int mMaxStreamVolume;
|
private final int mMaxStreamVolume;
|
||||||
private boolean mAffectedByRingerMode;
|
private boolean mAffectedByRingerMode;
|
||||||
private boolean mNotificationOrRing;
|
private boolean mNotificationOrRing;
|
||||||
private final boolean mNotifAliasRing;
|
|
||||||
private final Receiver mReceiver = new Receiver();
|
private final Receiver mReceiver = new Receiver();
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
@@ -158,6 +161,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
this(context, streamType, defaultUri, callback, true /* playSample */);
|
this(context, streamType, defaultUri, callback, true /* playSample */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
|
||||||
public SeekBarVolumizer(
|
public SeekBarVolumizer(
|
||||||
Context context,
|
Context context,
|
||||||
int streamType,
|
int streamType,
|
||||||
@@ -180,8 +184,6 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
if (mNotificationOrRing) {
|
if (mNotificationOrRing) {
|
||||||
mRingerMode = mAudioManager.getRingerModeInternal();
|
mRingerMode = mAudioManager.getRingerModeInternal();
|
||||||
}
|
}
|
||||||
mNotifAliasRing = mContext.getResources().getBoolean(
|
|
||||||
com.android.internal.R.bool.config_alias_ring_notif_stream_types);
|
|
||||||
mZenMode = mNotificationManager.getZenMode();
|
mZenMode = mNotificationManager.getZenMode();
|
||||||
|
|
||||||
if (hasAudioProductStrategies()) {
|
if (hasAudioProductStrategies()) {
|
||||||
@@ -288,7 +290,9 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
* so that when user attempts to slide the notification seekbar out of vibrate the
|
* so that when user attempts to slide the notification seekbar out of vibrate the
|
||||||
* seekbar doesn't wrongly snap back to 0 when the streams aren't aliased
|
* seekbar doesn't wrongly snap back to 0 when the streams aren't aliased
|
||||||
*/
|
*/
|
||||||
if (mNotifAliasRing || mStreamType == AudioManager.STREAM_RING
|
if (!DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
|
||||||
|
|| mStreamType == AudioManager.STREAM_RING
|
||||||
|| (mStreamType == AudioManager.STREAM_NOTIFICATION && mMuted)) {
|
|| (mStreamType == AudioManager.STREAM_NOTIFICATION && mMuted)) {
|
||||||
mSeekBar.setProgress(0, true);
|
mSeekBar.setProgress(0, true);
|
||||||
}
|
}
|
||||||
@@ -365,7 +369,9 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
// set the time of stop volume
|
// set the time of stop volume
|
||||||
if ((mStreamType == AudioManager.STREAM_VOICE_CALL
|
if ((mStreamType == AudioManager.STREAM_VOICE_CALL
|
||||||
|| mStreamType == AudioManager.STREAM_RING
|
|| mStreamType == AudioManager.STREAM_RING
|
||||||
|| (!mNotifAliasRing && mStreamType == AudioManager.STREAM_NOTIFICATION)
|
|| (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
|
||||||
|
&& mStreamType == AudioManager.STREAM_NOTIFICATION)
|
||||||
|| mStreamType == AudioManager.STREAM_ALARM)) {
|
|| mStreamType == AudioManager.STREAM_ALARM)) {
|
||||||
sStopVolumeTime = java.lang.System.currentTimeMillis();
|
sStopVolumeTime = java.lang.System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
@@ -643,8 +649,10 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateVolumeSlider(int streamType, int streamValue) {
|
private void updateVolumeSlider(int streamType, int streamValue) {
|
||||||
final boolean streamMatch = mNotifAliasRing && mNotificationOrRing
|
final boolean streamMatch = !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
? isNotificationOrRing(streamType) : streamType == mStreamType;
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
|
||||||
|
&& mNotificationOrRing ? isNotificationOrRing(streamType) :
|
||||||
|
streamType == mStreamType;
|
||||||
if (mSeekBar != null && streamMatch && streamValue != -1) {
|
if (mSeekBar != null && streamMatch && streamValue != -1) {
|
||||||
final boolean muted = mAudioManager.isStreamMute(mStreamType)
|
final boolean muted = mAudioManager.isStreamMute(mStreamType)
|
||||||
|| streamValue == 0;
|
|| streamValue == 0;
|
||||||
|
|||||||
@@ -555,6 +555,11 @@ public final class SystemUiDeviceConfigFlags {
|
|||||||
public static final String TASK_MANAGER_SHOW_STOP_BUTTON_FOR_USER_ALLOWLISTED_APPS =
|
public static final String TASK_MANAGER_SHOW_STOP_BUTTON_FOR_USER_ALLOWLISTED_APPS =
|
||||||
"show_stop_button_for_user_allowlisted_apps";
|
"show_stop_button_for_user_allowlisted_apps";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (boolean) Whether to show notification volume control slider separate from ring.
|
||||||
|
*/
|
||||||
|
public static final String VOLUME_SEPARATE_NOTIFICATION = "volume_separate_notification";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (boolean) Whether the clipboard overlay is enabled.
|
* (boolean) Whether the clipboard overlay is enabled.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -2070,10 +2070,6 @@
|
|||||||
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 notification and ringtone volumes
|
|
||||||
are controlled together (aliasing is true) or not. -->
|
|
||||||
<bool name="config_alias_ring_notif_stream_types">true</bool>
|
|
||||||
|
|
||||||
<!-- The number of volume steps for the notification stream -->
|
<!-- The number of volume steps for the notification stream -->
|
||||||
<integer name="config_audio_notif_vol_steps">7</integer>
|
<integer name="config_audio_notif_vol_steps">7</integer>
|
||||||
|
|
||||||
|
|||||||
@@ -278,7 +278,6 @@
|
|||||||
<java-symbol type="attr" name="autofillSaveCustomSubtitleMaxHeight"/>
|
<java-symbol type="attr" name="autofillSaveCustomSubtitleMaxHeight"/>
|
||||||
<java-symbol type="bool" name="action_bar_embed_tabs" />
|
<java-symbol type="bool" name="action_bar_embed_tabs" />
|
||||||
<java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
|
<java-symbol type="bool" name="action_bar_expanded_action_views_exclusive" />
|
||||||
<java-symbol type="bool" name="config_alias_ring_notif_stream_types" />
|
|
||||||
<java-symbol type="integer" name="config_audio_notif_vol_default" />
|
<java-symbol type="integer" name="config_audio_notif_vol_default" />
|
||||||
<java-symbol type="integer" name="config_audio_notif_vol_steps" />
|
<java-symbol type="integer" name="config_audio_notif_vol_steps" />
|
||||||
<java-symbol type="integer" name="config_audio_ring_vol_default" />
|
<java-symbol type="integer" name="config_audio_ring_vol_default" />
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import android.annotation.SuppressLint;
|
|||||||
import android.annotation.UserIdInt;
|
import android.annotation.UserIdInt;
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityManagerInternal;
|
import android.app.ActivityManagerInternal;
|
||||||
|
import android.app.ActivityThread;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.AppGlobals;
|
import android.app.AppGlobals;
|
||||||
import android.app.AppOpsManager;
|
import android.app.AppOpsManager;
|
||||||
@@ -152,6 +153,7 @@ import android.os.VibrationAttributes;
|
|||||||
import android.os.VibrationEffect;
|
import android.os.VibrationEffect;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.os.VibratorManager;
|
import android.os.VibratorManager;
|
||||||
|
import android.provider.DeviceConfig;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.provider.Settings.System;
|
import android.provider.Settings.System;
|
||||||
import android.service.notification.ZenModeConfig;
|
import android.service.notification.ZenModeConfig;
|
||||||
@@ -173,6 +175,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.android.internal.annotations.GuardedBy;
|
import com.android.internal.annotations.GuardedBy;
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
|
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
|
||||||
import com.android.internal.util.DumpUtils;
|
import com.android.internal.util.DumpUtils;
|
||||||
import com.android.internal.util.Preconditions;
|
import com.android.internal.util.Preconditions;
|
||||||
import com.android.server.EventLogTags;
|
import com.android.server.EventLogTags;
|
||||||
@@ -231,6 +234,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
AudioSystemAdapter.OnVolRangeInitRequestListener {
|
AudioSystemAdapter.OnVolRangeInitRequestListener {
|
||||||
|
|
||||||
private static final String TAG = "AS.AudioService";
|
private static final String TAG = "AS.AudioService";
|
||||||
|
private static final boolean CONFIG_DEFAULT_VAL = false;
|
||||||
|
|
||||||
private final AudioSystemAdapter mAudioSystem;
|
private final AudioSystemAdapter mAudioSystem;
|
||||||
private final SystemServerAdapter mSystemServer;
|
private final SystemServerAdapter mSystemServer;
|
||||||
@@ -981,6 +985,7 @@ public class AudioService extends IAudioService.Stub
|
|||||||
* @param looper Looper to use for the service's message handler. If this is null, an
|
* @param looper Looper to use for the service's message handler. If this is null, an
|
||||||
* {@link AudioSystemThread} is created as the messaging thread instead.
|
* {@link AudioSystemThread} is created as the messaging thread instead.
|
||||||
*/
|
*/
|
||||||
|
@RequiresPermission(Manifest.permission.READ_DEVICE_CONFIG)
|
||||||
public AudioService(Context context, AudioSystemAdapter audioSystem,
|
public AudioService(Context context, AudioSystemAdapter audioSystem,
|
||||||
SystemServerAdapter systemServer, SettingsAdapter settings, @Nullable Looper looper,
|
SystemServerAdapter systemServer, SettingsAdapter settings, @Nullable Looper looper,
|
||||||
AppOpsManager appOps) {
|
AppOpsManager appOps) {
|
||||||
@@ -1020,8 +1025,12 @@ public class AudioService extends IAudioService.Stub
|
|||||||
mUseVolumeGroupAliases = mContext.getResources().getBoolean(
|
mUseVolumeGroupAliases = mContext.getResources().getBoolean(
|
||||||
com.android.internal.R.bool.config_handleVolumeAliasesUsingVolumeGroups);
|
com.android.internal.R.bool.config_handleVolumeAliasesUsingVolumeGroups);
|
||||||
|
|
||||||
mNotifAliasRing = mContext.getResources().getBoolean(
|
mNotifAliasRing = !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
com.android.internal.R.bool.config_alias_ring_notif_stream_types);
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
|
||||||
|
|
||||||
|
DeviceConfig.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
|
||||||
|
ActivityThread.currentApplication().getMainExecutor(),
|
||||||
|
this::onDeviceConfigChange);
|
||||||
|
|
||||||
// Initialize volume
|
// Initialize volume
|
||||||
// Priority 1 - Android Property
|
// Priority 1 - Android Property
|
||||||
@@ -1239,6 +1248,22 @@ public class AudioService extends IAudioService.Stub
|
|||||||
0 /* arg1 */, 0 /* arg2 */, null /* obj */, 0 /* delay */);
|
0 /* arg1 */, 0 /* arg2 */, null /* obj */, 0 /* delay */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Separating notification volume from ring is NOT of aliasing the corresponding streams
|
||||||
|
* @param properties
|
||||||
|
*/
|
||||||
|
private void onDeviceConfigChange(DeviceConfig.Properties properties) {
|
||||||
|
Set<String> changeSet = properties.getKeyset();
|
||||||
|
if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) {
|
||||||
|
boolean newNotifAliasRing = !properties.getBoolean(
|
||||||
|
SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, CONFIG_DEFAULT_VAL);
|
||||||
|
if (mNotifAliasRing != newNotifAliasRing) {
|
||||||
|
mNotifAliasRing = newNotifAliasRing;
|
||||||
|
updateStreamVolumeAlias(true, TAG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by handling of MSG_INIT_STREAMS_VOLUMES
|
* Called by handling of MSG_INIT_STREAMS_VOLUMES
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user