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

Commit e3c6e46e authored by Selim Cinek's avatar Selim Cinek
Browse files

Showing heads up for music when bypassing

Users where missing the music controls so
we are showing a headsup for them on the
lockscreen.

Fixes: 	134543453
Change-Id: I089fa8ff35b918f485f79e09393173f05971a73e
parent 5fedd81a
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -8275,6 +8275,16 @@ public final class Settings {
        private static final Validator FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR =
        private static final Validator FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR =
                BOOLEAN_VALIDATOR;
                BOOLEAN_VALIDATOR;
        /**
         * Whether or not media is shown automatically when bypassing as a heads up.
         * @hide
         */
        public static final String SHOW_MEDIA_WHEN_BYPASSING =
                "show_media_when_bypassing";
        private static final Validator SHOW_MEDIA_WHEN_BYPASSING_VALIDATOR =
                BOOLEAN_VALIDATOR;
        /**
        /**
         * Whether or not face unlock requires attention. This is a cached value, the source of
         * Whether or not face unlock requires attention. This is a cached value, the source of
         * truth is obtained through the HAL.
         * truth is obtained through the HAL.
@@ -8979,6 +8989,7 @@ public final class Settings {
            NFC_PAYMENT_DEFAULT_COMPONENT,
            NFC_PAYMENT_DEFAULT_COMPONENT,
            AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
            AUTOMATIC_STORAGE_MANAGER_DAYS_TO_RETAIN,
            FACE_UNLOCK_KEYGUARD_ENABLED,
            FACE_UNLOCK_KEYGUARD_ENABLED,
            SHOW_MEDIA_WHEN_BYPASSING,
            FACE_UNLOCK_DISMISSES_KEYGUARD,
            FACE_UNLOCK_DISMISSES_KEYGUARD,
            FACE_UNLOCK_APP_ENABLED,
            FACE_UNLOCK_APP_ENABLED,
            FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
            FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
@@ -9155,6 +9166,7 @@ public final class Settings {
            VALIDATORS.put(FACE_UNLOCK_KEYGUARD_ENABLED, FACE_UNLOCK_KEYGUARD_ENABLED_VALIDATOR);
            VALIDATORS.put(FACE_UNLOCK_KEYGUARD_ENABLED, FACE_UNLOCK_KEYGUARD_ENABLED_VALIDATOR);
            VALIDATORS.put(FACE_UNLOCK_DISMISSES_KEYGUARD,
            VALIDATORS.put(FACE_UNLOCK_DISMISSES_KEYGUARD,
                    FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR);
                    FACE_UNLOCK_DISMISSES_KEYGUARD_VALIDATOR);
            VALIDATORS.put(SHOW_MEDIA_WHEN_BYPASSING, SHOW_MEDIA_WHEN_BYPASSING_VALIDATOR);
            VALIDATORS.put(FACE_UNLOCK_APP_ENABLED, FACE_UNLOCK_APP_ENABLED_VALIDATOR);
            VALIDATORS.put(FACE_UNLOCK_APP_ENABLED, FACE_UNLOCK_APP_ENABLED_VALIDATOR);
            VALIDATORS.put(FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
            VALIDATORS.put(FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION,
                    FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION_VALIDATOR);
                    FACE_UNLOCK_ALWAYS_REQUIRE_CONFIRMATION_VALIDATOR);
+3 −0
Original line number Original line Diff line number Diff line
@@ -138,6 +138,9 @@
    <!-- The number of milliseconds before the heads up notification auto-dismisses. -->
    <!-- The number of milliseconds before the heads up notification auto-dismisses. -->
    <integer name="heads_up_notification_decay">5000</integer>
    <integer name="heads_up_notification_decay">5000</integer>


    <!-- The number of milliseconds before the heads up notification sent automatically by the system auto-dismisses. -->
    <integer name="auto_heads_up_notification_decay">3000</integer>

    <!-- The number of milliseconds after a heads up notification is pushed back
    <!-- The number of milliseconds after a heads up notification is pushed back
     before the app can interrupt again. -->
     before the app can interrupt again. -->
    <integer name="heads_up_default_snooze_length_ms">60000</integer>
    <integer name="heads_up_default_snooze_length_ms">60000</integer>
+10 −12
Original line number Original line Diff line number Diff line
@@ -52,6 +52,7 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.phone.DozeParameters;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NextAlarmController;
import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
import com.android.systemui.statusbar.policy.NextAlarmControllerImpl;
@@ -103,8 +104,8 @@ public class KeyguardSliceProvider extends SliceProvider implements
    private final Date mCurrentTime = new Date();
    private final Date mCurrentTime = new Date();
    private final Handler mHandler;
    private final Handler mHandler;
    private final AlarmManager.OnAlarmListener mUpdateNextAlarm = this::updateNextAlarm;
    private final AlarmManager.OnAlarmListener mUpdateNextAlarm = this::updateNextAlarm;
    private final HashSet<Integer> mMediaInvisibleStates;
    private final Object mMediaToken = new Object();
    private final Object mMediaToken = new Object();
    private DozeParameters mDozeParameters;
    @VisibleForTesting
    @VisibleForTesting
    protected SettableWakeLock mMediaWakeLock;
    protected SettableWakeLock mMediaWakeLock;
    @VisibleForTesting
    @VisibleForTesting
@@ -184,11 +185,6 @@ public class KeyguardSliceProvider extends SliceProvider implements
        mAlarmUri = Uri.parse(KEYGUARD_NEXT_ALARM_URI);
        mAlarmUri = Uri.parse(KEYGUARD_NEXT_ALARM_URI);
        mDndUri = Uri.parse(KEYGUARD_DND_URI);
        mDndUri = Uri.parse(KEYGUARD_DND_URI);
        mMediaUri = Uri.parse(KEYGUARD_MEDIA_URI);
        mMediaUri = Uri.parse(KEYGUARD_MEDIA_URI);

        mMediaInvisibleStates = new HashSet<>();
        mMediaInvisibleStates.add(PlaybackState.STATE_NONE);
        mMediaInvisibleStates.add(PlaybackState.STATE_STOPPED);
        mMediaInvisibleStates.add(PlaybackState.STATE_PAUSED);
    }
    }


    /**
    /**
@@ -201,12 +197,14 @@ public class KeyguardSliceProvider extends SliceProvider implements
    public void initDependencies(
    public void initDependencies(
            NotificationMediaManager mediaManager,
            NotificationMediaManager mediaManager,
            StatusBarStateController statusBarStateController,
            StatusBarStateController statusBarStateController,
            KeyguardBypassController keyguardBypassController) {
            KeyguardBypassController keyguardBypassController,
            DozeParameters dozeParameters) {
        mMediaManager = mediaManager;
        mMediaManager = mediaManager;
        mMediaManager.addCallback(this);
        mMediaManager.addCallback(this);
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController = statusBarStateController;
        mStatusBarStateController.addCallback(this);
        mStatusBarStateController.addCallback(this);
        mKeyguardBypassController = keyguardBypassController;
        mKeyguardBypassController = keyguardBypassController;
        mDozeParameters = dozeParameters;
    }
    }


    @AnyThread
    @AnyThread
@@ -231,9 +229,9 @@ public class KeyguardSliceProvider extends SliceProvider implements
    }
    }


    protected boolean needsMediaLocked() {
    protected boolean needsMediaLocked() {
        boolean isBypass = mKeyguardBypassController != null
        boolean keepWhenAwake = mKeyguardBypassController != null
                && mKeyguardBypassController.getBypassEnabled();
                && mKeyguardBypassController.getBypassEnabled() && mDozeParameters.getAlwaysOn();
        return !TextUtils.isEmpty(mMediaTitle) && mMediaIsVisible && (mDozing || isBypass);
        return !TextUtils.isEmpty(mMediaTitle) && mMediaIsVisible && (mDozing || keepWhenAwake);
    }
    }


    protected void addMediaLocked(ListBuilder listBuilder) {
    protected void addMediaLocked(ListBuilder listBuilder) {
@@ -458,7 +456,7 @@ public class KeyguardSliceProvider extends SliceProvider implements
    @Override
    @Override
    public void onMetadataOrStateChanged(MediaMetadata metadata, @PlaybackState.State int state) {
    public void onMetadataOrStateChanged(MediaMetadata metadata, @PlaybackState.State int state) {
        synchronized (this) {
        synchronized (this) {
            boolean nextVisible = !mMediaInvisibleStates.contains(state);
            boolean nextVisible = NotificationMediaManager.isPlayingState(state);
            mHandler.removeCallbacksAndMessages(mMediaToken);
            mHandler.removeCallbacksAndMessages(mMediaToken);
            if (mMediaIsVisible && !nextVisible) {
            if (mMediaIsVisible && !nextVisible) {
                // We need to delay this event for a few millis when stopping to avoid jank in the
                // We need to delay this event for a few millis when stopping to avoid jank in the
@@ -477,7 +475,7 @@ public class KeyguardSliceProvider extends SliceProvider implements
    }
    }


    private void updateMediaStateLocked(MediaMetadata metadata, @PlaybackState.State int state) {
    private void updateMediaStateLocked(MediaMetadata metadata, @PlaybackState.State int state) {
        boolean nextVisible = !mMediaInvisibleStates.contains(state);
        boolean nextVisible = NotificationMediaManager.isPlayingState(state);
        CharSequence title = null;
        CharSequence title = null;
        if (metadata != null) {
        if (metadata != null) {
            title = metadata.getText(MediaMetadata.METADATA_KEY_TITLE);
            title = metadata.getText(MediaMetadata.METADATA_KEY_TITLE);
+13 −0
Original line number Original line Diff line number Diff line
@@ -69,6 +69,7 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.lang.ref.WeakReference;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.List;
import java.util.Set;
import java.util.Set;


@@ -91,6 +92,14 @@ public class NotificationMediaManager implements Dumpable {
    private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
    private final SysuiColorExtractor mColorExtractor = Dependency.get(SysuiColorExtractor.class);
    private final KeyguardMonitor mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
    private final KeyguardMonitor mKeyguardMonitor = Dependency.get(KeyguardMonitor.class);
    private final KeyguardBypassController mKeyguardBypassController;
    private final KeyguardBypassController mKeyguardBypassController;
    private static final HashSet<Integer> PAUSED_MEDIA_STATES = new HashSet<>();
    static {
        PAUSED_MEDIA_STATES.add(PlaybackState.STATE_NONE);
        PAUSED_MEDIA_STATES.add(PlaybackState.STATE_STOPPED);
        PAUSED_MEDIA_STATES.add(PlaybackState.STATE_PAUSED);
        PAUSED_MEDIA_STATES.add(PlaybackState.STATE_ERROR);
    }



    // Late binding
    // Late binding
    private NotificationEntryManager mEntryManager;
    private NotificationEntryManager mEntryManager;
@@ -207,6 +216,10 @@ public class NotificationMediaManager implements Dumpable {
                mPropertiesChangedListener);
                mPropertiesChangedListener);
    }
    }


    public static boolean isPlayingState(int state) {
        return !PAUSED_MEDIA_STATES.contains(state);
    }

    public void setUpWithPresenter(NotificationPresenter presenter) {
    public void setUpWithPresenter(NotificationPresenter presenter) {
        mPresenter = presenter;
        mPresenter = presenter;
    }
    }
+15 −2
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar;


import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN_REVERSE;
import static com.android.systemui.Interpolators.FAST_OUT_SLOW_IN_REVERSE;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE;
import static com.android.systemui.statusbar.phone.NotificationIconContainer.IconState.NO_VALUE;
import static com.android.systemui.util.InjectionInflationController.VIEW_CONTEXT;


import android.content.Context;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Configuration;
@@ -48,8 +49,12 @@ import com.android.systemui.statusbar.notification.stack.AnimationProperties;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.ExpandableViewState;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.notification.stack.ViewState;
import com.android.systemui.statusbar.notification.stack.ViewState;
import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.NotificationIconContainer;
import com.android.systemui.statusbar.phone.NotificationIconContainer;


import javax.inject.Inject;
import javax.inject.Named;

/**
/**
 * A notification shelf view that is placed inside the notification scroller. It manages the
 * A notification shelf view that is placed inside the notification scroller. It manages the
 * overflow icons that don't fit into the regular list anymore.
 * overflow icons that don't fit into the regular list anymore.
@@ -63,6 +68,7 @@ public class NotificationShelf extends ActivatableNotificationView implements
            = SystemProperties.getBoolean("debug.icon_scroll_animations", true);
            = SystemProperties.getBoolean("debug.icon_scroll_animations", true);
    private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag;
    private static final int TAG_CONTINUOUS_CLIPPING = R.id.continuous_clipping_tag;
    private static final String TAG = "NotificationShelf";
    private static final String TAG = "NotificationShelf";
    private final KeyguardBypassController mBypassController;


    private NotificationIconContainer mShelfIcons;
    private NotificationIconContainer mShelfIcons;
    private int[] mTmp = new int[2];
    private int[] mTmp = new int[2];
@@ -93,8 +99,12 @@ public class NotificationShelf extends ActivatableNotificationView implements
    private int mCutoutHeight;
    private int mCutoutHeight;
    private int mGapHeight;
    private int mGapHeight;


    public NotificationShelf(Context context, AttributeSet attrs) {
    @Inject
    public NotificationShelf(@Named(VIEW_CONTEXT) Context context,
            AttributeSet attrs,
            KeyguardBypassController keyguardBypassController) {
        super(context, attrs);
        super(context, attrs);
        mBypassController = keyguardBypassController;
    }
    }


    @Override
    @Override
@@ -309,7 +319,10 @@ public class NotificationShelf extends ActivatableNotificationView implements
                    colorTwoBefore = previousColor;
                    colorTwoBefore = previousColor;
                    transitionAmount = inShelfAmount;
                    transitionAmount = inShelfAmount;
                }
                }
                if (isLastChild) {
                // We don't want to modify the color if the notification is hun'd
                boolean canModifyColor = mAmbientState.isShadeExpanded()
                        && !(mAmbientState.isOnKeyguard() && mBypassController.getBypassEnabled());
                if (isLastChild && canModifyColor) {
                    if (colorOfViewBeforeLast == NO_COLOR) {
                    if (colorOfViewBeforeLast == NO_COLOR) {
                        colorOfViewBeforeLast = ownColorUntinted;
                        colorOfViewBeforeLast = ownColorUntinted;
                    }
                    }
Loading