blob: cac992a67541ec0f68ed8178c1dd0bb52ae570d7 [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;
Tiger Huang7c610aa2018-10-27 00:01:01 +080020
21import static com.android.server.wm.WindowManagerInternal.AppTransitionListener;
22
23import android.app.StatusBarManager;
24import android.os.IBinder;
25import android.view.View;
26
27import com.android.server.statusbar.StatusBarManagerInternal;
28
29/**
30 * Implements status bar specific behavior.
31 */
32public class StatusBarController extends BarController {
33
34 private final AppTransitionListener mAppTransitionListener = new AppTransitionListener() {
35
36 private Runnable mAppTransitionPending = () -> {
37 StatusBarManagerInternal statusBar = getStatusBarInternal();
Riddle Hsud80ae9b2019-03-26 00:40:35 +080038 if (statusBar != null) {
39 statusBar.appTransitionPending(mDisplayId);
Tiger Huang7c610aa2018-10-27 00:01:01 +080040 }
41 };
42
43 private Runnable mAppTransitionCancelled = () -> {
44 StatusBarManagerInternal statusBar = getStatusBarInternal();
Riddle Hsud80ae9b2019-03-26 00:40:35 +080045 if (statusBar != null) {
46 statusBar.appTransitionCancelled(mDisplayId);
Tiger Huang7c610aa2018-10-27 00:01:01 +080047 }
48 };
49
50 private Runnable mAppTransitionFinished = () -> {
51 StatusBarManagerInternal statusBar = getStatusBarInternal();
Riddle Hsud80ae9b2019-03-26 00:40:35 +080052 if (statusBar != null) {
53 statusBar.appTransitionFinished(mDisplayId);
Tiger Huang7c610aa2018-10-27 00:01:01 +080054 }
55 };
56
57 @Override
58 public void onAppTransitionPendingLocked() {
59 mHandler.post(mAppTransitionPending);
60 }
61
62 @Override
Evan Rosky2289ba12018-11-19 18:28:18 -080063 public int onAppTransitionStartingLocked(int transit, long duration,
64 long statusBarAnimationStartTime, long statusBarAnimationDuration) {
Tiger Huang7c610aa2018-10-27 00:01:01 +080065 mHandler.post(() -> {
66 StatusBarManagerInternal statusBar = getStatusBarInternal();
Riddle Hsud80ae9b2019-03-26 00:40:35 +080067 if (statusBar != null) {
68 statusBar.appTransitionStarting(mDisplayId,
Tiger Huang7c610aa2018-10-27 00:01:01 +080069 statusBarAnimationStartTime, statusBarAnimationDuration);
70 }
71 });
72 return 0;
73 }
74
75 @Override
76 public void onAppTransitionCancelledLocked(int transit) {
77 mHandler.post(mAppTransitionCancelled);
78 }
79
80 @Override
81 public void onAppTransitionFinishedLocked(IBinder token) {
82 mHandler.post(mAppTransitionFinished);
83 }
84 };
85
Riddle Hsud80ae9b2019-03-26 00:40:35 +080086 StatusBarController(int displayId) {
Tiger Huang7c610aa2018-10-27 00:01:01 +080087 super("StatusBar",
Riddle Hsud80ae9b2019-03-26 00:40:35 +080088 displayId,
Tiger Huang7c610aa2018-10-27 00:01:01 +080089 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
Tiger Huang7c610aa2018-10-27 00:01:01 +0800104 AppTransitionListener getAppTransitionListener() {
105 return mAppTransitionListener;
106 }
107}