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

Commit e1baaaae authored by Steve Elliott's avatar Steve Elliott Committed by Android (Google) Code Review
Browse files

Merge "Introduce NICViewModel#iconsViewData" into main

parents cf0c4825 da362ca1
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -95,7 +95,7 @@ fun Flow<Boolean>.logDiffsForTable(
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue, isInitial = true)
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: Boolean ->
    return this.pairwiseBy(initialValueFun) { prevVal: Boolean, newVal: Boolean ->
        if (prevVal != newVal) {
            tableLogBuffer.logChange(columnPrefix, columnName, newVal)
        }
@@ -114,7 +114,7 @@ fun Flow<Int>.logDiffsForTable(
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue, isInitial = true)
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: Int ->
    return this.pairwiseBy(initialValueFun) { prevVal: Int, newVal: Int ->
        if (prevVal != newVal) {
            tableLogBuffer.logChange(columnPrefix, columnName, newVal)
        }
@@ -133,7 +133,7 @@ fun Flow<Int?>.logDiffsForTable(
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue, isInitial = true)
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: Int? ->
    return this.pairwiseBy(initialValueFun) { prevVal: Int?, newVal: Int? ->
        if (prevVal != newVal) {
            tableLogBuffer.logChange(columnPrefix, columnName, newVal)
        }
@@ -152,7 +152,7 @@ fun Flow<String?>.logDiffsForTable(
        tableLogBuffer.logChange(columnPrefix, columnName, initialValue, isInitial = true)
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: String? ->
    return this.pairwiseBy(initialValueFun) { prevVal: String?, newVal: String? ->
        if (prevVal != newVal) {
            tableLogBuffer.logChange(columnPrefix, columnName, newVal)
        }
@@ -176,7 +176,7 @@ fun <T> Flow<List<T>>.logDiffsForTable(
        )
        initialValue
    }
    return this.pairwiseBy(initialValueFun) { prevVal, newVal: List<T> ->
    return this.pairwiseBy(initialValueFun) { prevVal: List<T>, newVal: List<T> ->
        if (prevVal != newVal) {
            // TODO(b/267761156): Can we log list changes without using toString?
            tableLogBuffer.logChange(columnPrefix, columnName, newVal.toString())
+17 −2
Original line number Diff line number Diff line
@@ -29,8 +29,11 @@ import android.util.Log;

import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.flags.FeatureFlagsClassic;
import com.android.systemui.flags.Flags;
import com.android.systemui.plugins.PluginManager;
import com.android.systemui.statusbar.dagger.CentralSurfacesModule;
import com.android.systemui.statusbar.domain.interactor.SilentNotificationStatusIconsVisibilityInteractor;
import com.android.systemui.statusbar.notification.collection.NotifCollection;
import com.android.systemui.statusbar.notification.collection.PipelineDumpable;
import com.android.systemui.statusbar.notification.collection.PipelineDumper;
@@ -59,7 +62,9 @@ public class NotificationListener extends NotificationListenerWithPlugins implem
    private static final long MAX_RANKING_DELAY_MILLIS = 500L;

    private final Context mContext;
    private final FeatureFlagsClassic mFeatureFlags;
    private final NotificationManager mNotificationManager;
    private final SilentNotificationStatusIconsVisibilityInteractor mStatusIconInteractor;
    private final SystemClock mSystemClock;
    private final Executor mMainExecutor;
    private final List<NotificationHandler> mNotificationHandlers = new ArrayList<>();
@@ -75,13 +80,17 @@ public class NotificationListener extends NotificationListenerWithPlugins implem
    @Inject
    public NotificationListener(
            Context context,
            FeatureFlagsClassic featureFlags,
            NotificationManager notificationManager,
            SilentNotificationStatusIconsVisibilityInteractor statusIconInteractor,
            SystemClock systemClock,
            @Main Executor mainExecutor,
            PluginManager pluginManager) {
        super(pluginManager);
        mContext = context;
        mFeatureFlags = featureFlags;
        mNotificationManager = notificationManager;
        mStatusIconInteractor = statusIconInteractor;
        mSystemClock = systemClock;
        mMainExecutor = mainExecutor;
    }
@@ -95,6 +104,7 @@ public class NotificationListener extends NotificationListenerWithPlugins implem
    }

    /** Registers a listener that's notified when any notification-related settings change. */
    @Deprecated
    public void addNotificationSettingsListener(NotificationSettingsListener listener) {
        mSettingsListeners.add(listener);
    }
@@ -230,10 +240,14 @@ public class NotificationListener extends NotificationListenerWithPlugins implem

    @Override
    public void onSilentStatusBarIconsVisibilityChanged(boolean hideSilentStatusIcons) {
        if (mFeatureFlags.isEnabled(Flags.NOTIFICATION_ICON_CONTAINER_REFACTOR)) {
            mStatusIconInteractor.setHideSilentStatusIcons(hideSilentStatusIcons);
        } else {
            for (NotificationSettingsListener listener : mSettingsListeners) {
                listener.onStatusBarIconsBehaviorChanged(hideSilentStatusIcons);
            }
        }
    }

    public final void unsnoozeNotification(@NonNull String key) {
        if (!isBound()) return;
@@ -294,6 +308,7 @@ public class NotificationListener extends NotificationListenerWithPlugins implem
        return ranking;
    }

    @Deprecated
    public interface NotificationSettingsListener {

        default void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { }
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.systemui.statusbar.data.repository

import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.NotificationListener
import javax.inject.Inject
import kotlinx.coroutines.flow.MutableStateFlow

/** Exposes state pertaining to settings tracked over the [NotificationListener] boundary. */
@SysUISingleton
class NotificationListenerSettingsRepository @Inject constructor() {
    /** Should icons for silent notifications be shown in the status bar? */
    val showSilentStatusIcons = MutableStateFlow(true)
}
+28 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.systemui.statusbar.domain.interactor

import com.android.systemui.statusbar.data.repository.NotificationListenerSettingsRepository
import javax.inject.Inject

class SilentNotificationStatusIconsVisibilityInteractor
@Inject
constructor(private val repository: NotificationListenerSettingsRepository) {
    /** Set whether icons for silent notifications be hidden in the status bar. */
    fun setHideSilentStatusIcons(hideIcons: Boolean) {
        repository.showSilentStatusIcons.value = !hideIcons
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -225,7 +225,7 @@ public class NotifCollection implements Dumpable, PipelineDumpable {

    /** @see NotifPipeline#getEntry(String) () */
    @Nullable
    NotificationEntry getEntry(@NonNull String key) {
    public NotificationEntry getEntry(@NonNull String key) {
        return mNotificationSet.get(key);
    }

Loading