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

Commit 63b5c828 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Get notification snoozing setting for current user" into udc-dev...

Merge "Merge "Get notification snoozing setting for current user" into udc-dev am: b6e1127f am: 86c234dc"
parents dae2e5fd 217954f1
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -5754,8 +5754,8 @@ public class Notification implements Parcelable
        private boolean isSnoozeSettingEnabled() {
        private boolean isSnoozeSettingEnabled() {
            try {
            try {
                return Settings.Secure.getInt(mContext.getContentResolver(),
                return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                    Settings.Secure.SHOW_NOTIFICATION_SNOOZE, 0) == 1;
                    Settings.Secure.SHOW_NOTIFICATION_SNOOZE, 0, UserHandle.USER_CURRENT) == 1;
            } catch (SecurityException ex) {
            } catch (SecurityException ex) {
                // Most 3p apps can't access this snooze setting, so their NotificationListeners
                // Most 3p apps can't access this snooze setting, so their NotificationListeners
                // would be unable to create notification views if we propagated this exception.
                // would be unable to create notification views if we propagated this exception.
+2 −1
Original line number Original line Diff line number Diff line
@@ -359,7 +359,8 @@ public class PreparationCoordinator implements Coordinator {
    }
    }


    NotifInflater.Params getInflaterParams(NotifUiAdjustment adjustment, String reason) {
    NotifInflater.Params getInflaterParams(NotifUiAdjustment adjustment, String reason) {
        return new NotifInflater.Params(adjustment.isMinimized(), reason);
        return new NotifInflater.Params(adjustment.isMinimized(), reason,
                adjustment.isSnoozeEnabled());
    }
    }


    private void abortInflation(NotificationEntry entry, String reason) {
    private void abortInflation(NotificationEntry entry, String reason) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -61,5 +61,5 @@ interface NotifInflater {
    /**
    /**
     * A class holding parameters used when inflating the notification row
     * A class holding parameters used when inflating the notification row
     */
     */
    class Params(val isLowPriority: Boolean, val reason: String)
    class Params(val isLowPriority: Boolean, val reason: String, val showSnooze: Boolean)
}
}
+20 −2
Original line number Original line Diff line number Diff line
@@ -16,12 +16,15 @@


package com.android.systemui.statusbar.notification.collection.inflation
package com.android.systemui.statusbar.notification.collection.inflation


import android.content.Context
import android.database.ContentObserver
import android.database.ContentObserver
import android.os.Handler
import android.os.Handler
import android.os.HandlerExecutor
import android.os.UserHandle
import android.os.UserHandle
import android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE
import android.provider.Settings.Secure.SHOW_NOTIFICATION_SNOOZE
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.settings.UserTracker
import com.android.systemui.statusbar.NotificationLockscreenUserManager
import com.android.systemui.statusbar.NotificationLockscreenUserManager
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.GroupEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.collection.NotificationEntry
@@ -39,11 +42,25 @@ class NotifUiAdjustmentProvider @Inject constructor(
    @Main private val handler: Handler,
    @Main private val handler: Handler,
    private val secureSettings: SecureSettings,
    private val secureSettings: SecureSettings,
    private val lockscreenUserManager: NotificationLockscreenUserManager,
    private val lockscreenUserManager: NotificationLockscreenUserManager,
    private val sectionStyleProvider: SectionStyleProvider
    private val sectionStyleProvider: SectionStyleProvider,
    private val userTracker: UserTracker
) {
) {
    private val dirtyListeners = ListenerSet<Runnable>()
    private val dirtyListeners = ListenerSet<Runnable>()
    private var isSnoozeEnabled = false
    private var isSnoozeEnabled = false


    /**
     *  Update the snooze enabled value on user switch
     */
    private val userTrackerCallback = object : UserTracker.Callback {
        override fun onUserChanged(newUser: Int, userContext: Context) {
            updateSnoozeEnabled()
        }
    }

    init {
        userTracker.addCallback(userTrackerCallback, HandlerExecutor(handler))
    }

    fun addDirtyListener(listener: Runnable) {
    fun addDirtyListener(listener: Runnable) {
        if (dirtyListeners.isEmpty()) {
        if (dirtyListeners.isEmpty()) {
            lockscreenUserManager.addNotificationStateChangedListener(notifStateChangedListener)
            lockscreenUserManager.addNotificationStateChangedListener(notifStateChangedListener)
@@ -78,7 +95,8 @@ class NotifUiAdjustmentProvider @Inject constructor(
    }
    }


    private fun updateSnoozeEnabled() {
    private fun updateSnoozeEnabled() {
        isSnoozeEnabled = secureSettings.getInt(SHOW_NOTIFICATION_SNOOZE, 0) == 1
        isSnoozeEnabled =
            secureSettings.getIntForUser(SHOW_NOTIFICATION_SNOOZE, 0, UserHandle.USER_CURRENT) == 1
    }
    }


    private fun isEntryMinimized(entry: NotificationEntry): Boolean {
    private fun isEntryMinimized(entry: NotificationEntry): Boolean {
+3 −0
Original line number Original line Diff line number Diff line
@@ -212,6 +212,9 @@ public class NotificationRowBinderImpl implements NotificationRowBinder {
                mMessagingUtil.isImportantMessaging(entry.getSbn(), entry.getImportance());
                mMessagingUtil.isImportantMessaging(entry.getSbn(), entry.getImportance());
        final boolean isLowPriority = inflaterParams.isLowPriority();
        final boolean isLowPriority = inflaterParams.isLowPriority();


        // Set show snooze action
        row.setShowSnooze(inflaterParams.getShowSnooze());

        RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
        RowContentBindParams params = mRowContentBindStage.getStageParams(entry);
        params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
        params.requireContentViews(FLAG_CONTENT_VIEW_CONTRACTED);
        params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
        params.requireContentViews(FLAG_CONTENT_VIEW_EXPANDED);
Loading