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

Commit 24bec7ce authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Implement nice transitions for light status bar

- When the flag changes, apply an animation from the current value
- When the flag change is caused by an app transition, synchronize
  the status bar animation with the app transition animation.
  PhoneWindowManager calculates the timings based on some heuristics
  of the app transition animations and supplies these timings to
  StatusBarService.

Bug: 19233606
Change-Id: I4f99afba8f1eebb3524699ed4d7fbafee5463a37
parent 37875615
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -224,4 +224,11 @@ public abstract class WindowManagerInternal {
     * @param removeWindows Whether to also remove the windows associated with the token.
     */
    public abstract void removeWindowToken(android.os.IBinder token, boolean removeWindows);

    /**
     * Registers a listener to be notified about app transition events.
     *
     * @param listener The listener to register.
     */
    public abstract void registerAppTransitionListener(AppTransitionListener listener);
}
+30 −9
Original line number Diff line number Diff line
@@ -43,5 +43,26 @@ oneway interface IStatusBar
    void preloadRecentApps();
    void cancelPreloadRecentApps();
    void showScreenPinningRequest();

    /**
     * Notifies the status bar that an app transition is pending to delay applying some flags with
     * visual impact until {@link #appTransitionReady} is called.
     */
    void appTransitionPending();

    /**
     * Notifies the status bar that a pending app transition has been cancelled.
     */
    void appTransitionCancelled();

    /**
     * Notifies the status bar that an app transition is now being executed.
     *
     * @param statusBarAnimationsStartTime the desired start time for all visual animations in the
     *        status bar caused by this app transition in uptime millis
     * @param statusBarAnimationsDuration the duration for all visual animations in the status
     *        bar caused by this app transition in millis
     */
    void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);
}
+29 −8
Original line number Diff line number Diff line
@@ -61,4 +61,25 @@ interface IStatusBarService
    void toggleRecentApps();
    void preloadRecentApps();
    void cancelPreloadRecentApps();

    /**
     * Notifies the status bar that an app transition is pending to delay applying some flags with
     * visual impact until {@link #appTransitionReady} is called.
     */
    void appTransitionPending();

    /**
     * Notifies the status bar that a pending app transition has been cancelled.
     */
    void appTransitionCancelled();

    /**
     * Notifies the status bar that an app transition is now being executed.
     *
     * @param statusBarAnimationsStartTime the desired start time for all visual animations in the
     *        status bar caused by this app transition in uptime millis
     * @param statusBarAnimationsDuration the duration for all visual animations in the status
     *        bar caused by this app transition in millis
     */
    void appTransitionStarting(long statusBarAnimationsStartTime, long statusBarAnimationsDuration);
}
+39 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.systemui.statusbar;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.util.Pair;

import com.android.internal.statusbar.IStatusBar;
import com.android.internal.statusbar.StatusBarIcon;
@@ -57,6 +58,9 @@ public class CommandQueue extends IStatusBar.Stub {
    private static final int MSG_NOTIFICATION_LIGHT_OFF     = 16 << MSG_SHIFT;
    private static final int MSG_NOTIFICATION_LIGHT_PULSE   = 17 << MSG_SHIFT;
    private static final int MSG_SHOW_SCREEN_PIN_REQUEST    = 18 << MSG_SHIFT;
    private static final int MSG_APP_TRANSITION_PENDING     = 19 << MSG_SHIFT;
    private static final int MSG_APP_TRANSITION_CANCELLED   = 20 << MSG_SHIFT;
    private static final int MSG_APP_TRANSITION_STARTING    = 21 << MSG_SHIFT;

    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
@@ -99,6 +103,9 @@ public class CommandQueue extends IStatusBar.Stub {
        public void notificationLightOff();
        public void notificationLightPulse(int argb, int onMillis, int offMillis);
        public void showScreenPinningRequest();
        public void appTransitionPending();
        public void appTransitionCancelled();
        public void appTransitionStarting(long startTime, long duration);
    }

    public CommandQueue(Callbacks callbacks, StatusBarIconList list) {
@@ -246,6 +253,28 @@ public class CommandQueue extends IStatusBar.Stub {
        }
    }

    public void appTransitionPending() {
        synchronized (mList) {
            mHandler.removeMessages(MSG_APP_TRANSITION_PENDING);
            mHandler.sendEmptyMessage(MSG_APP_TRANSITION_PENDING);
        }
    }

    public void appTransitionCancelled() {
        synchronized (mList) {
            mHandler.removeMessages(MSG_APP_TRANSITION_PENDING);
            mHandler.sendEmptyMessage(MSG_APP_TRANSITION_PENDING);
        }
    }

    public void appTransitionStarting(long startTime, long duration) {
        synchronized (mList) {
            mHandler.removeMessages(MSG_APP_TRANSITION_STARTING);
            mHandler.obtainMessage(MSG_APP_TRANSITION_STARTING, Pair.create(startTime, duration))
                    .sendToTarget();
        }
    }

    private final class H extends Handler {
        public void handleMessage(Message msg) {
            final int what = msg.what & MSG_MASK;
@@ -328,6 +357,16 @@ public class CommandQueue extends IStatusBar.Stub {
                case MSG_SHOW_SCREEN_PIN_REQUEST:
                    mCallbacks.showScreenPinningRequest();
                    break;
                case MSG_APP_TRANSITION_PENDING:
                    mCallbacks.appTransitionPending();
                    break;
                case MSG_APP_TRANSITION_CANCELLED:
                    mCallbacks.appTransitionCancelled();
                    break;
                case MSG_APP_TRANSITION_STARTING:
                    Pair<Long, Long> data = (Pair<Long, Long>) msg.obj;
                    mCallbacks.appTransitionStarting(data.first, data.second);
                    break;
            }
        }
    }
+15 −3
Original line number Diff line number Diff line
@@ -101,7 +101,6 @@ import android.view.WindowManagerGlobal;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import android.view.animation.PathInterpolator;
@@ -115,7 +114,6 @@ import com.android.systemui.BatteryMeterView;
import com.android.systemui.DemoMode;
import com.android.systemui.EventLogConstants;
import com.android.systemui.EventLogTags;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
@@ -138,7 +136,6 @@ import com.android.systemui.statusbar.NotificationOverflowContainer;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.SignalClusterView;
import com.android.systemui.statusbar.SpeedBumpView;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.phone.UnlockMethodCache.OnUnlockMethodChangedListener;
import com.android.systemui.statusbar.policy.AccessibilityController;
@@ -3638,6 +3635,21 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        }
    }

    @Override
    public void appTransitionPending() {
        mIconController.appTransitionPending();
    }

    @Override
    public void appTransitionCancelled() {
        mIconController.appTransitionCancelled();
    }

    @Override
    public void appTransitionStarting(long startTime, long duration) {
        mIconController.appTransitionStarting(startTime, duration);
    }

    private final class ShadeUpdates {
        private final ArraySet<String> mVisibleNotifications = new ArraySet<String>();
        private final ArraySet<String> mNewVisibleNotifications = new ArraySet<String>();
Loading