Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23e5e6ec authored by Behnam Heydarshahi's avatar Behnam Heydarshahi Committed by Automerger Merge Worker
Browse files

Merge "Remove volume_separate_notification flag" into udc-dev am: 485a8116

parents 2ee31543 485a8116
Loading
Loading
Loading
Loading
+4 −17
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.VolumePreference.VolumeStore;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.provider.Settings.System;
@@ -47,7 +46,6 @@ import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.os.SomeArgs;

import java.util.concurrent.TimeUnit;
@@ -295,14 +293,8 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        if (zenMuted) {
            mSeekBar.setProgress(mLastAudibleStreamVolume, true);
        } else if (mNotificationOrRing && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            /**
             * the first variable above is preserved and the conditions below are made explicit
             * 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
             */
            if (!DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                    || mStreamType == AudioManager.STREAM_RING
            // For ringer-mode affected streams, show volume as zero when ringermode is vibrate
            if (mStreamType == AudioManager.STREAM_RING
                    || (mStreamType == AudioManager.STREAM_NOTIFICATION && mMuted)) {
                mSeekBar.setProgress(0, true);
            }
@@ -397,9 +389,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        // set the time of stop volume
        if ((mStreamType == AudioManager.STREAM_VOICE_CALL
                || mStreamType == AudioManager.STREAM_RING
                || (DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                && mStreamType == AudioManager.STREAM_NOTIFICATION)
                || mStreamType == AudioManager.STREAM_NOTIFICATION
                || mStreamType == AudioManager.STREAM_ALARM)) {
            sStopVolumeTime = java.lang.System.currentTimeMillis();
        }
@@ -686,10 +676,7 @@ public class SeekBarVolumizer implements OnSeekBarChangeListener, Handler.Callba
        }

        private void updateVolumeSlider(int streamType, int streamValue) {
            final boolean streamMatch =  !DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false)
                    && mNotificationOrRing ? isNotificationOrRing(streamType) :
                    streamType == mStreamType;
            final boolean streamMatch = (streamType == mStreamType);
            if (mSeekBar != null && streamMatch && streamValue != -1) {
                final boolean muted = mAudioManager.isStreamMute(mStreamType)
                        || streamValue == 0;
+0 −5
Original line number Diff line number Diff line
@@ -548,11 +548,6 @@ public final class SystemUiDeviceConfigFlags {
    public static final String TASK_MANAGER_INFORM_JOB_SCHEDULER_OF_PENDING_APP_STOP =
            "task_manager_inform_job_scheduler_of_pending_app_stop";

    /**
     * (boolean) Whether to show notification volume control slider separate from ring.
     */
    public static final String VOLUME_SEPARATE_NOTIFICATION = "volume_separate_notification";

    /**
     * (boolean) Whether widget provider info would be saved to / loaded from system persistence
     * layer as opposed to individual manifests in respective apps.
+2 −2
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@
                    android:layout_height="@dimen/volume_ringer_drawer_icon_size"
                    android:layout_gravity="center"
                    android:tint="?android:attr/textColorPrimary"
                    android:src="@drawable/ic_volume_ringer_mute" />
                    android:src="@drawable/ic_speaker_mute" />

            </FrameLayout>

@@ -102,7 +102,7 @@
                    android:layout_height="@dimen/volume_ringer_drawer_icon_size"
                    android:layout_gravity="center"
                    android:tint="?android:attr/textColorPrimary"
                    android:src="@drawable/ic_volume_ringer" />
                    android:src="@drawable/ic_speaker_on" />

            </FrameLayout>

+12 −87
Original line number Diff line number Diff line
@@ -73,7 +73,6 @@ import android.os.Message;
import android.os.SystemClock;
import android.os.Trace;
import android.os.VibrationEffect;
import android.provider.DeviceConfig;
import android.provider.Settings;
import android.provider.Settings.Global;
import android.text.InputFilter;
@@ -113,7 +112,6 @@ import androidx.annotation.Nullable;
import com.android.app.animation.Interpolators;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
import com.android.internal.graphics.drawable.BackgroundBlurDrawable;
import com.android.internal.jank.InteractionJankMonitor;
import com.android.internal.view.RotationPolicy;
@@ -133,15 +131,11 @@ import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.util.AlphaTintDrawableWrapper;
import com.android.systemui.util.DeviceConfigProxy;
import com.android.systemui.util.RoundedCornerProgressDrawable;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
@@ -198,9 +192,6 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    private ViewGroup mDialogRowsView;
    private ViewGroup mRinger;

    private DeviceConfigProxy mDeviceConfigProxy;
    private Executor mExecutor;

    /**
     * Container for the top part of the dialog, which contains the ringer, the ringer drawer, the
     * volume rows, and the ellipsis button. This does not include the live caption button.
@@ -290,14 +281,12 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
    private BackgroundBlurDrawable mDialogRowsViewBackground;
    private final InteractionJankMonitor mInteractionJankMonitor;

    private boolean mSeparateNotification;

    private int mWindowGravity;

    @VisibleForTesting
    int mVolumeRingerIconDrawableId;
    final int mVolumeRingerIconDrawableId = R.drawable.ic_speaker_on;
    @VisibleForTesting
    int mVolumeRingerMuteIconDrawableId;
    final int mVolumeRingerMuteIconDrawableId = R.drawable.ic_speaker_mute;

    private int mOriginalGravity;
    private final DevicePostureController.Callback mDevicePostureControllerCallback;
@@ -315,8 +304,6 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            VolumePanelFactory volumePanelFactory,
            ActivityStarter activityStarter,
            InteractionJankMonitor interactionJankMonitor,
            DeviceConfigProxy deviceConfigProxy,
            Executor executor,
            CsdWarningDialog.Factory csdWarningDialogFactory,
            DevicePostureController devicePostureController,
            Looper looper,
@@ -374,12 +361,6 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        } else {
            mDevicePostureControllerCallback = null;
        }

        mDeviceConfigProxy = deviceConfigProxy;
        mExecutor = executor;
        mSeparateNotification = mDeviceConfigProxy.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
                SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
        updateRingerModeIconSet();
    }

    /**
@@ -401,44 +382,6 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        return mWindowGravity;
    }

    /**
     * If ringer and notification are the same stream (T and earlier), use notification-like bell
     * icon set.
     * If ringer and notification are separated, then use generic speaker icons.
     */
    private void updateRingerModeIconSet() {
        if (mSeparateNotification) {
            mVolumeRingerIconDrawableId = R.drawable.ic_speaker_on;
            mVolumeRingerMuteIconDrawableId = R.drawable.ic_speaker_mute;
        } else {
            mVolumeRingerIconDrawableId = R.drawable.ic_volume_ringer;
            mVolumeRingerMuteIconDrawableId = R.drawable.ic_volume_ringer_mute;
        }

        if (mRingerDrawerMuteIcon != null) {
            mRingerDrawerMuteIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
        }
        if (mRingerDrawerNormalIcon != null) {
            mRingerDrawerNormalIcon.setImageResource(mVolumeRingerIconDrawableId);
        }
    }

    /**
     * Change icon for ring stream (not ringer mode icon)
     */
    private void updateRingRowIcon() {
        Optional<VolumeRow> volumeRow = mRows.stream().filter(row -> row.stream == STREAM_RING)
                .findFirst();
        if (volumeRow.isPresent()) {
            VolumeRow volRow = volumeRow.get();
            volRow.iconRes = mSeparateNotification ? R.drawable.ic_ring_volume
                    : R.drawable.ic_volume_ringer;
            volRow.iconMuteRes = mSeparateNotification ? R.drawable.ic_ring_volume_off
                    : R.drawable.ic_volume_ringer_mute;
            volRow.setIcon(volRow.iconRes, mContext.getTheme());
        }
    }

    @Override
    public void onUiModeChanged() {
        mContext.getTheme().applyStyle(mContext.getThemeResId(), true);
@@ -454,9 +397,6 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,

        mConfigurationController.addCallback(this);

        mDeviceConfigProxy.addOnPropertiesChangedListener(DeviceConfig.NAMESPACE_SYSTEMUI,
                mExecutor, this::onDeviceConfigChange);

        if (mDevicePostureController != null) {
            mDevicePostureController.addCallback(mDevicePostureControllerCallback);
        }
@@ -467,28 +407,11 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mController.removeCallback(mControllerCallbackH);
        mHandler.removeCallbacksAndMessages(null);
        mConfigurationController.removeCallback(this);
        mDeviceConfigProxy.removeOnPropertiesChangedListener(this::onDeviceConfigChange);
        if (mDevicePostureController != null) {
            mDevicePostureController.removeCallback(mDevicePostureControllerCallback);
        }
    }

    /**
     * Update ringer mode icon based on the config
     */
    private void onDeviceConfigChange(DeviceConfig.Properties properties) {
        Set<String> changeSet = properties.getKeyset();
        if (changeSet.contains(SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION)) {
            boolean newVal = properties.getBoolean(
                    SystemUiDeviceConfigFlags.VOLUME_SEPARATE_NOTIFICATION, false);
            if (newVal != mSeparateNotification) {
                mSeparateNotification = newVal;
                updateRingerModeIconSet();
                updateRingRowIcon();
            }
        }
    }

    @Override
    public void onComputeInternalInsets(ViewTreeObserver.InternalInsetsInfo internalInsetsInfo) {
        // Set touchable region insets on the root dialog view. This tells WindowManager that
@@ -699,7 +622,12 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
        mRingerDrawerNormalIcon = mDialog.findViewById(R.id.volume_drawer_normal_icon);
        mRingerDrawerNewSelectionBg = mDialog.findViewById(R.id.volume_drawer_selection_background);

        updateRingerModeIconSet();
        if (mRingerDrawerMuteIcon != null) {
            mRingerDrawerMuteIcon.setImageResource(mVolumeRingerMuteIconDrawableId);
        }
        if (mRingerDrawerNormalIcon != null) {
            mRingerDrawerNormalIcon.setImageResource(mVolumeRingerIconDrawableId);
        }

        setupRingerDrawer();

@@ -724,13 +652,10 @@ public class VolumeDialogImpl implements VolumeDialog, Dumpable,
            addRow(AudioManager.STREAM_MUSIC,
                    R.drawable.ic_volume_media, R.drawable.ic_volume_media_mute, true, true);
            if (!AudioSystem.isSingleVolume(mContext)) {
                if (mSeparateNotification) {

                addRow(AudioManager.STREAM_RING, R.drawable.ic_ring_volume,
                        R.drawable.ic_ring_volume_off, true, false);
                } else {
                    addRow(AudioManager.STREAM_RING, R.drawable.ic_volume_ringer,
                            R.drawable.ic_volume_ringer, true, false);
                }


                addRow(STREAM_ALARM,
                        R.drawable.ic_alarm, R.drawable.ic_volume_alarm_mute, true, false);
+0 −8
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.media.AudioManager;
import android.os.Looper;

import com.android.internal.jank.InteractionJankMonitor;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.media.dialog.MediaOutputDialogFactory;
import com.android.systemui.plugins.ActivityStarter;
@@ -31,7 +30,6 @@ import com.android.systemui.statusbar.policy.AccessibilityManagerWrapper;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.statusbar.policy.DevicePostureController;
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
import com.android.systemui.util.DeviceConfigProxy;
import com.android.systemui.volume.CsdWarningDialog;
import com.android.systemui.volume.VolumeComponent;
import com.android.systemui.volume.VolumeDialogComponent;
@@ -42,8 +40,6 @@ import dagger.Binds;
import dagger.Module;
import dagger.Provides;

import java.util.concurrent.Executor;

/** Dagger Module for code in the volume package. */
@Module
public interface VolumeModule {
@@ -63,8 +59,6 @@ public interface VolumeModule {
            VolumePanelFactory volumePanelFactory,
            ActivityStarter activityStarter,
            InteractionJankMonitor interactionJankMonitor,
            DeviceConfigProxy deviceConfigProxy,
            @Main Executor executor,
            CsdWarningDialog.Factory csdFactory,
            DevicePostureController devicePostureController,
            DumpManager dumpManager) {
@@ -78,8 +72,6 @@ public interface VolumeModule {
                volumePanelFactory,
                activityStarter,
                interactionJankMonitor,
                deviceConfigProxy,
                executor,
                csdFactory,
                devicePostureController,
                Looper.getMainLooper(),
Loading