Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.server.wm; |
| 18 | |
| 19 | import static android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 20 | |
| 21 | import static com.android.server.wm.WindowManagerInternal.AppTransitionListener; |
| 22 | |
| 23 | import android.app.StatusBarManager; |
| 24 | import android.os.IBinder; |
| 25 | import android.view.View; |
| 26 | |
| 27 | import com.android.server.statusbar.StatusBarManagerInternal; |
| 28 | |
| 29 | /** |
| 30 | * Implements status bar specific behavior. |
| 31 | */ |
| 32 | public class StatusBarController extends BarController { |
| 33 | |
| 34 | private final AppTransitionListener mAppTransitionListener = new AppTransitionListener() { |
| 35 | |
| 36 | private Runnable mAppTransitionPending = () -> { |
| 37 | StatusBarManagerInternal statusBar = getStatusBarInternal(); |
Riddle Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 38 | if (statusBar != null) { |
| 39 | statusBar.appTransitionPending(mDisplayId); |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 40 | } |
| 41 | }; |
| 42 | |
| 43 | private Runnable mAppTransitionCancelled = () -> { |
| 44 | StatusBarManagerInternal statusBar = getStatusBarInternal(); |
Riddle Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 45 | if (statusBar != null) { |
| 46 | statusBar.appTransitionCancelled(mDisplayId); |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 47 | } |
| 48 | }; |
| 49 | |
| 50 | private Runnable mAppTransitionFinished = () -> { |
| 51 | StatusBarManagerInternal statusBar = getStatusBarInternal(); |
Riddle Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 52 | if (statusBar != null) { |
| 53 | statusBar.appTransitionFinished(mDisplayId); |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 54 | } |
| 55 | }; |
| 56 | |
| 57 | @Override |
| 58 | public void onAppTransitionPendingLocked() { |
| 59 | mHandler.post(mAppTransitionPending); |
| 60 | } |
| 61 | |
| 62 | @Override |
Evan Rosky | 2289ba1 | 2018-11-19 18:28:18 -0800 | [diff] [blame] | 63 | public int onAppTransitionStartingLocked(int transit, long duration, |
| 64 | long statusBarAnimationStartTime, long statusBarAnimationDuration) { |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 65 | mHandler.post(() -> { |
| 66 | StatusBarManagerInternal statusBar = getStatusBarInternal(); |
Riddle Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 67 | if (statusBar != null) { |
| 68 | statusBar.appTransitionStarting(mDisplayId, |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 69 | 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 Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 86 | StatusBarController(int displayId) { |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 87 | super("StatusBar", |
Riddle Hsu | d80ae9b | 2019-03-26 00:40:35 +0800 | [diff] [blame] | 88 | displayId, |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 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 | |
Tiger Huang | 7c610aa | 2018-10-27 00:01:01 +0800 | [diff] [blame] | 104 | AppTransitionListener getAppTransitionListener() { |
| 105 | return mAppTransitionListener; |
| 106 | } |
| 107 | } |