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

Commit 8fdb533e authored by Beverly's avatar Beverly
Browse files

Make StatusBarStateController available to plugins

Test: atest SystemUITests
Bug: 115322193
Change-Id: I46e4b23c9839720a3eb10e381d7aaf79a74c6b33
parent f86397d7
Loading
Loading
Loading
Loading
+98 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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.plugins.statusbar;

import com.android.systemui.plugins.annotations.DependsOn;
import com.android.systemui.plugins.annotations.ProvidesInterface;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;


/**
 * Sends updates to {@link StateListener}s about changes to the status bar state and dozing state
 */
@ProvidesInterface(version = StatusBarStateController.VERSION)
@DependsOn(target = StatusBarStateController.StateListener.class)
public interface StatusBarStateController {
    int VERSION = 1;

    /**
     * Current status bar state
     */
    int getState();

    /**
     * Is device dozing
     */
    boolean isDozing();

    /**
     * Adds a state listener
     */
    void addCallback(StateListener listener);

    /**
     * Removes callback from listeners
     */
    void removeCallback(StateListener listener);

    /**
     * Get amount of doze
     */
    float getDozeAmount();

    /**
     * Listener for StatusBarState updates
     */
    @ProvidesInterface(version = StateListener.VERSION)
    public interface StateListener {
        int VERSION = 1;

        /**
         * Callback before the new state is applied, for those who need to preempt the change.
         */
        default void onStatePreChange(int oldState, int newState) {
        }

        /**
         * Callback after all listeners have had a chance to update based on the state change
         */
        default void onStatePostChange() {
        }

        /**
         * Required callback. Get the new state and do what you will with it. Keep in mind that
         * other listeners are typically unordered and don't rely on your work being done before
         * other peers.
         *
         * Only called if the state is actually different.
         */
        default void onStateChanged(int newState) {
        }

        /**
         * Callback to be notified when Dozing changes. Dozing is stored separately from state.
         */
        default void onDozingChanged(boolean isDozing) {}

        /**
         * Callback to be notified when the doze amount changes. Useful for animations.
         * Note: this will be called for each animation frame. Please be careful to avoid
         * performance regressions.
         */
        default void onDozeAmountChanged(float linear, float eased) {}
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -15,8 +15,8 @@ import androidx.annotation.VisibleForTesting;
import com.android.keyguard.clock.ClockManager;
import com.android.systemui.Dependency;
import com.android.systemui.plugins.ClockPlugin;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.StatusBarStateController;

import java.util.TimeZone;

+1 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.PluginDependencyProvider;
import com.android.systemui.plugins.VolumeDialogController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.EnhancedEstimates;
import com.android.systemui.power.PowerUI;
import com.android.systemui.privacy.PrivacyItemController;
@@ -55,7 +56,6 @@ import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationRemoteInputManager;
import com.android.systemui.statusbar.NotificationViewHierarchyManager;
import com.android.systemui.statusbar.SmartReplyController;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.VibratorHelper;
import com.android.systemui.statusbar.notification.NotificationAlertingManager;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
+11 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.systemui.assist.AssistManager;
import com.android.systemui.classifier.FalsingManager;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.power.EnhancedEstimates;
import com.android.systemui.power.EnhancedEstimatesImpl;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -40,7 +41,7 @@ import com.android.systemui.statusbar.NotificationListener;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationLockscreenUserManagerImpl;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.StatusBarStateControllerImpl;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
import com.android.systemui.statusbar.notification.collection.NotificationData;
@@ -152,6 +153,15 @@ public class SystemUIFactory {
        return new VolumeDialogComponent(systemUi, context);
    }

    /**
     * Provides status bar state controller implementation
     */
    @Singleton
    @Provides
    public StatusBarStateController provideStatusBarStateController(Context context) {
        return new StatusBarStateControllerImpl();
    }

    @Singleton
    @Provides
    public NotificationData.KeyguardEnvironment provideKeyguardEnvironment(Context context) {
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.NotificationVisibility;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.statusbar.notification.NotificationEntryListener;
import com.android.systemui.statusbar.notification.NotificationEntryManager;
import com.android.systemui.statusbar.notification.NotificationInterruptionStateProvider;
Loading