blob: 6db606d2a30b30e9c462fc28b83c4b203bb1912f [file] [log] [blame]
Tiger Huang7c610aa2018-10-27 00:01:01 +08001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server.wm;
18
19import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
20import static android.view.WindowManager.LayoutParams.MATCH_PARENT;
21
22import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;
23
24import android.app.StatusBarManager;
25import android.os.IBinder;
26import android.view.View;
27
28import com.android.server.statusbar.StatusBarManagerInternal;
29
30/**
31 * Implements status bar specific behavior.
32 */
33public class StatusBarController extends BarController {
34
35 private final AppTransitionListener mAppTransitionListener = new AppTransitionListener() {
36
37 private Runnable mAppTransitionPending = () -> {
38 StatusBarManagerInternal statusBar = getStatusBarInternal();
39 if (statusBar != null && mWin != null) {
40 statusBar.appTransitionPending(mWin.getDisplayId());
41 }
42 };
43
44 private Runnable mAppTransitionCancelled = () -> {
45 StatusBarManagerInternal statusBar = getStatusBarInternal();
46 if (statusBar != null && mWin != null) {
47 statusBar.appTransitionCancelled(mWin.getDisplayId());
48 }
49 };
50
51 private Runnable mAppTransitionFinished = () -> {
52 StatusBarManagerInternal statusBar = getStatusBarInternal();
53 if (statusBar != null && mWin != null) {
54 statusBar.appTransitionFinished(mWin.getDisplayId());
55 }
56 };
57
58 @Override
59 public void onAppTransitionPendingLocked() {
60 mHandler.post(mAppTransitionPending);
61 }
62
63 @Override
Evan Rosky2289ba12018-11-19 18:28:18 -080064 public int onAppTransitionStartingLocked(int transit, long duration,
65 long statusBarAnimationStartTime, long statusBarAnimationDuration) {
Tiger Huang7c610aa2018-10-27 00:01:01 +080066 mHandler.post(() -> {
67 StatusBarManagerInternal statusBar = getStatusBarInternal();
68 if (statusBar != null && mWin != null) {
69 statusBar.appTransitionStarting(mWin.getDisplayId(),
70 statusBarAnimationStartTime, statusBarAnimationDuration);
71 }
72 });
73 return 0;
74 }
75
76 @Override
77 public void onAppTransitionCancelledLocked(int transit) {
78 mHandler.post(mAppTransitionCancelled);
79 }
80
81 @Override
82 public void onAppTransitionFinishedLocked(IBinder token) {
83 mHandler.post(mAppTransitionFinished);
84 }
85 };
86
87 StatusBarController() {
88 super("StatusBar",
89 View.STATUS_BAR_TRANSIENT,
90 View.STATUS_BAR_UNHIDE,
91 View.STATUS_BAR_TRANSLUCENT,
92 StatusBarManager.WINDOW_STATUS_BAR,
93 FLAG_TRANSLUCENT_STATUS,
94 View.STATUS_BAR_TRANSPARENT);
95 }
96
97 void setTopAppHidesStatusBar(boolean hidesStatusBar) {
98 StatusBarManagerInternal statusBar = getStatusBarInternal();
99 if (statusBar != null) {
100 statusBar.setTopAppHidesStatusBar(hidesStatusBar);
101 }
102 }
103
104 @Override
105 protected boolean skipAnimation() {
106 return mWin.getAttrs().height == MATCH_PARENT;
107 }
108
109 AppTransitionListener getAppTransitionListener() {
110 return mAppTransitionListener;
111 }
112}