John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
Jorim Jaggi | b10e33f | 2015-02-04 21:57:40 +0100 | [diff] [blame] | 17 | package com.android.server.policy; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 18 | |
| 19 | import android.app.StatusBarManager; |
| 20 | import android.os.Handler; |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 21 | import android.os.SystemClock; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 22 | import android.util.Slog; |
| 23 | import android.view.View; |
Adrian Roos | db1bc6b | 2016-04-14 17:49:43 -0700 | [diff] [blame] | 24 | import android.view.ViewGroup; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 25 | import android.view.WindowManager; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 26 | import android.view.WindowManagerPolicy.WindowState; |
| 27 | |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 28 | import com.android.server.LocalServices; |
| 29 | import com.android.server.statusbar.StatusBarManagerInternal; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 30 | |
| 31 | import java.io.PrintWriter; |
| 32 | |
| 33 | /** |
| 34 | * Controls state/behavior specific to a system bar window. |
| 35 | */ |
| 36 | public class BarController { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 37 | private static final boolean DEBUG = false; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 38 | |
| 39 | private static final int TRANSIENT_BAR_NONE = 0; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 40 | private static final int TRANSIENT_BAR_SHOW_REQUESTED = 1; |
| 41 | private static final int TRANSIENT_BAR_SHOWING = 2; |
| 42 | private static final int TRANSIENT_BAR_HIDING = 3; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 43 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 44 | private static final int TRANSLUCENT_ANIMATION_DELAY_MS = 1000; |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 45 | |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 46 | protected final String mTag; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 47 | private final int mTransientFlag; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 48 | private final int mUnhideFlag; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 49 | private final int mTranslucentFlag; |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 50 | private final int mTransparentFlag; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 51 | private final int mStatusBarManagerId; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 52 | private final int mTranslucentWmFlag; |
Jorim Jaggi | 24bec7c | 2015-02-04 12:40:14 +0100 | [diff] [blame] | 53 | protected final Handler mHandler; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 54 | private final Object mServiceAquireLock = new Object(); |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 55 | protected StatusBarManagerInternal mStatusBarInternal; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 56 | |
Adrian Roos | db1bc6b | 2016-04-14 17:49:43 -0700 | [diff] [blame] | 57 | protected WindowState mWin; |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 58 | private int mState = StatusBarManager.WINDOW_STATE_SHOWING; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 59 | private int mTransientBarState; |
| 60 | private boolean mPendingShow; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 61 | private long mLastTranslucent; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 62 | private boolean mShowTransparent; |
| 63 | private boolean mSetUnHideFlagWhenNextTransparent; |
| 64 | private boolean mNoAnimationOnNextShow; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 65 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 66 | public BarController(String tag, int transientFlag, int unhideFlag, int translucentFlag, |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 67 | int statusBarManagerId, int translucentWmFlag, int transparentFlag) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 68 | mTag = "BarController." + tag; |
| 69 | mTransientFlag = transientFlag; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 70 | mUnhideFlag = unhideFlag; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 71 | mTranslucentFlag = translucentFlag; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 72 | mStatusBarManagerId = statusBarManagerId; |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 73 | mTranslucentWmFlag = translucentWmFlag; |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 74 | mTransparentFlag = transparentFlag; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 75 | mHandler = new Handler(); |
| 76 | } |
| 77 | |
| 78 | public void setWindow(WindowState win) { |
| 79 | mWin = win; |
| 80 | } |
| 81 | |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 82 | public void setShowTransparent(boolean transparent) { |
| 83 | if (transparent != mShowTransparent) { |
| 84 | mShowTransparent = transparent; |
| 85 | mSetUnHideFlagWhenNextTransparent = transparent; |
| 86 | mNoAnimationOnNextShow = true; |
| 87 | } |
| 88 | } |
| 89 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 90 | public void showTransient() { |
| 91 | if (mWin != null) { |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 92 | setTransientBarState(TRANSIENT_BAR_SHOW_REQUESTED); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 93 | } |
| 94 | } |
| 95 | |
| 96 | public boolean isTransientShowing() { |
| 97 | return mTransientBarState == TRANSIENT_BAR_SHOWING; |
| 98 | } |
| 99 | |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 100 | public boolean isTransientShowRequested() { |
| 101 | return mTransientBarState == TRANSIENT_BAR_SHOW_REQUESTED; |
| 102 | } |
| 103 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 104 | public boolean wasRecentlyTranslucent() { |
| 105 | return (SystemClock.uptimeMillis() - mLastTranslucent) < TRANSLUCENT_ANIMATION_DELAY_MS; |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 106 | } |
| 107 | |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 108 | public void adjustSystemUiVisibilityLw(int oldVis, int vis) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 109 | if (mWin != null && mTransientBarState == TRANSIENT_BAR_SHOWING && |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 110 | (vis & mTransientFlag) == 0) { |
| 111 | // sysui requests hide |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 112 | setTransientBarState(TRANSIENT_BAR_HIDING); |
| 113 | setBarShowingLw(false); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 114 | } else if (mWin != null && (oldVis & mUnhideFlag) != 0 && (vis & mUnhideFlag) == 0) { |
| 115 | // sysui ready to unhide |
| 116 | setBarShowingLw(true); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 120 | public int applyTranslucentFlagLw(WindowState win, int vis, int oldVis) { |
| 121 | if (mWin != null) { |
| 122 | if (win != null && (win.getAttrs().privateFlags |
| 123 | & WindowManager.LayoutParams.PRIVATE_FLAG_INHERIT_TRANSLUCENT_DECOR) == 0) { |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 124 | int fl = PolicyControl.getWindowFlags(win, null); |
| 125 | if ((fl & mTranslucentWmFlag) != 0) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 126 | vis |= mTranslucentFlag; |
| 127 | } else { |
| 128 | vis &= ~mTranslucentFlag; |
| 129 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 130 | if ((fl & WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) != 0) { |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 131 | vis |= mTransparentFlag; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 132 | } else { |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 133 | vis &= ~mTransparentFlag; |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 134 | } |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 135 | } else { |
| 136 | vis = (vis & ~mTranslucentFlag) | (oldVis & mTranslucentFlag); |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 137 | vis = (vis & ~mTransparentFlag) | (oldVis & mTransparentFlag); |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 138 | } |
| 139 | } |
| 140 | return vis; |
| 141 | } |
| 142 | |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 143 | public boolean setBarShowingLw(final boolean show) { |
| 144 | if (mWin == null) return false; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 145 | if (show && mTransientBarState == TRANSIENT_BAR_HIDING) { |
| 146 | mPendingShow = true; |
| 147 | return false; |
| 148 | } |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 149 | final boolean wasVis = mWin.isVisibleLw(); |
| 150 | final boolean wasAnim = mWin.isAnimatingLw(); |
Adrian Roos | db1bc6b | 2016-04-14 17:49:43 -0700 | [diff] [blame] | 151 | final boolean change = show ? mWin.showLw(!mNoAnimationOnNextShow && !skipAnimation()) |
| 152 | : mWin.hideLw(!mNoAnimationOnNextShow && !skipAnimation()); |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 153 | mNoAnimationOnNextShow = false; |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 154 | final int state = computeStateLw(wasVis, wasAnim, mWin, change); |
John Spurlock | c23bd80 | 2013-11-06 12:20:38 -0500 | [diff] [blame] | 155 | final boolean stateChanged = updateStateLw(state); |
| 156 | return change || stateChanged; |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 157 | } |
| 158 | |
Adrian Roos | db1bc6b | 2016-04-14 17:49:43 -0700 | [diff] [blame] | 159 | protected boolean skipAnimation() { |
| 160 | return false; |
| 161 | } |
| 162 | |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 163 | private int computeStateLw(boolean wasVis, boolean wasAnim, WindowState win, boolean change) { |
Adrian Roos | 76d2fe4 | 2015-07-09 14:54:08 -0700 | [diff] [blame] | 164 | if (win.isDrawnLw()) { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 165 | final boolean vis = win.isVisibleLw(); |
| 166 | final boolean anim = win.isAnimatingLw(); |
| 167 | if (mState == StatusBarManager.WINDOW_STATE_HIDING && !change && !vis) { |
| 168 | return StatusBarManager.WINDOW_STATE_HIDDEN; |
John Spurlock | c23bd80 | 2013-11-06 12:20:38 -0500 | [diff] [blame] | 169 | } else if (mState == StatusBarManager.WINDOW_STATE_HIDDEN && vis) { |
| 170 | return StatusBarManager.WINDOW_STATE_SHOWING; |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 171 | } else if (change) { |
| 172 | if (wasVis && vis && !wasAnim && anim) { |
| 173 | return StatusBarManager.WINDOW_STATE_HIDING; |
| 174 | } else { |
| 175 | return StatusBarManager.WINDOW_STATE_SHOWING; |
| 176 | } |
| 177 | } |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 178 | } |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 179 | return mState; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 180 | } |
| 181 | |
John Spurlock | c23bd80 | 2013-11-06 12:20:38 -0500 | [diff] [blame] | 182 | private boolean updateStateLw(final int state) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 183 | if (state != mState) { |
| 184 | mState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 185 | if (DEBUG) Slog.d(mTag, "mState: " + StatusBarManager.windowStateToString(state)); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 186 | mHandler.post(new Runnable() { |
| 187 | @Override |
| 188 | public void run() { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 189 | StatusBarManagerInternal statusbar = getStatusBarInternal(); |
| 190 | if (statusbar != null) { |
| 191 | statusbar.setWindowState(mStatusBarManagerId, state); |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | }); |
John Spurlock | c23bd80 | 2013-11-06 12:20:38 -0500 | [diff] [blame] | 195 | return true; |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 196 | } |
John Spurlock | c23bd80 | 2013-11-06 12:20:38 -0500 | [diff] [blame] | 197 | return false; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | public boolean checkHiddenLw() { |
Adrian Roos | 76d2fe4 | 2015-07-09 14:54:08 -0700 | [diff] [blame] | 201 | if (mWin != null && mWin.isDrawnLw()) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 202 | if (!mWin.isVisibleLw() && !mWin.isAnimatingLw()) { |
John Spurlock | 7edfbca | 2013-09-14 11:58:55 -0400 | [diff] [blame] | 203 | updateStateLw(StatusBarManager.WINDOW_STATE_HIDDEN); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 204 | } |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 205 | if (mTransientBarState == TRANSIENT_BAR_HIDING && !mWin.isVisibleLw()) { |
| 206 | // Finished animating out, clean up and reset style |
| 207 | setTransientBarState(TRANSIENT_BAR_NONE); |
| 208 | if (mPendingShow) { |
| 209 | setBarShowingLw(true); |
| 210 | mPendingShow = false; |
| 211 | } |
| 212 | return true; |
| 213 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 214 | } |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | public boolean checkShowTransientBarLw() { |
| 219 | if (mTransientBarState == TRANSIENT_BAR_SHOWING) { |
| 220 | if (DEBUG) Slog.d(mTag, "Not showing transient bar, already shown"); |
| 221 | return false; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 222 | } else if (mTransientBarState == TRANSIENT_BAR_SHOW_REQUESTED) { |
| 223 | if (DEBUG) Slog.d(mTag, "Not showing transient bar, already requested"); |
| 224 | return false; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 225 | } else if (mWin == null) { |
| 226 | if (DEBUG) Slog.d(mTag, "Not showing transient bar, bar doesn't exist"); |
| 227 | return false; |
| 228 | } else if (mWin.isDisplayedLw()) { |
| 229 | if (DEBUG) Slog.d(mTag, "Not showing transient bar, bar already visible"); |
| 230 | return false; |
| 231 | } else { |
| 232 | return true; |
| 233 | } |
| 234 | } |
| 235 | |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 236 | public int updateVisibilityLw(boolean transientAllowed, int oldVis, int vis) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 237 | if (mWin == null) return vis; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 238 | if (isTransientShowing() || isTransientShowRequested()) { // transient bar requested |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 239 | if (transientAllowed) { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 240 | vis |= mTransientFlag; |
| 241 | if ((oldVis & mTransientFlag) == 0) { |
John Spurlock | 5b9145b | 2013-08-20 15:13:47 -0400 | [diff] [blame] | 242 | vis |= mUnhideFlag; // tell sysui we're ready to unhide |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 243 | } |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 244 | setTransientBarState(TRANSIENT_BAR_SHOWING); // request accepted |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 245 | } else { |
| 246 | setTransientBarState(TRANSIENT_BAR_NONE); // request denied |
| 247 | } |
| 248 | } |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 249 | if (mShowTransparent) { |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 250 | vis |= mTransparentFlag; |
Selim Cinek | 4a4a2bddc | 2015-05-07 12:50:19 -0700 | [diff] [blame] | 251 | if (mSetUnHideFlagWhenNextTransparent) { |
| 252 | vis |= mUnhideFlag; |
| 253 | mSetUnHideFlagWhenNextTransparent = false; |
| 254 | } |
| 255 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 256 | if (mTransientBarState != TRANSIENT_BAR_NONE) { |
| 257 | vis |= mTransientFlag; // ignore clear requests until transition completes |
| 258 | vis &= ~View.SYSTEM_UI_FLAG_LOW_PROFILE; // never show transient bars in low profile |
| 259 | } |
Adrian Roos | ea56251 | 2014-05-05 13:33:03 +0200 | [diff] [blame] | 260 | if ((vis & mTranslucentFlag) != 0 || (oldVis & mTranslucentFlag) != 0 || |
Jorim Jaggi | 4fa7892 | 2015-11-30 17:13:56 -0800 | [diff] [blame] | 261 | ((vis | oldVis) & mTransparentFlag) != 0) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 262 | mLastTranslucent = SystemClock.uptimeMillis(); |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 263 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 264 | return vis; |
| 265 | } |
| 266 | |
| 267 | private void setTransientBarState(int state) { |
| 268 | if (mWin != null && state != mTransientBarState) { |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 269 | if (mTransientBarState == TRANSIENT_BAR_SHOWING || state == TRANSIENT_BAR_SHOWING) { |
John Spurlock | bd95740 | 2013-10-03 11:38:39 -0400 | [diff] [blame] | 270 | mLastTranslucent = SystemClock.uptimeMillis(); |
John Spurlock | b77edbf | 2013-08-21 21:04:12 -0400 | [diff] [blame] | 271 | } |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 272 | mTransientBarState = state; |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 273 | if (DEBUG) Slog.d(mTag, "mTransientBarState: " + transientBarStateToString(state)); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 274 | } |
| 275 | } |
| 276 | |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 277 | protected StatusBarManagerInternal getStatusBarInternal() { |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 278 | synchronized (mServiceAquireLock) { |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 279 | if (mStatusBarInternal == null) { |
| 280 | mStatusBarInternal = LocalServices.getService(StatusBarManagerInternal.class); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 281 | } |
Adrian Roos | f2efdd8 | 2016-04-15 17:43:18 -0700 | [diff] [blame] | 282 | return mStatusBarInternal; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 283 | } |
| 284 | } |
| 285 | |
| 286 | private static String transientBarStateToString(int state) { |
| 287 | if (state == TRANSIENT_BAR_HIDING) return "TRANSIENT_BAR_HIDING"; |
| 288 | if (state == TRANSIENT_BAR_SHOWING) return "TRANSIENT_BAR_SHOWING"; |
John Spurlock | f25706f | 2013-11-07 18:02:43 -0500 | [diff] [blame] | 289 | if (state == TRANSIENT_BAR_SHOW_REQUESTED) return "TRANSIENT_BAR_SHOW_REQUESTED"; |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 290 | if (state == TRANSIENT_BAR_NONE) return "TRANSIENT_BAR_NONE"; |
| 291 | throw new IllegalArgumentException("Unknown state " + state); |
| 292 | } |
| 293 | |
| 294 | public void dump(PrintWriter pw, String prefix) { |
| 295 | if (mWin != null) { |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 296 | pw.print(prefix); pw.println(mTag); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 297 | pw.print(prefix); pw.print(" "); pw.print("mState"); pw.print('='); |
John Spurlock | 0ec64c6 | 2013-08-26 15:37:58 -0400 | [diff] [blame] | 298 | pw.println(StatusBarManager.windowStateToString(mState)); |
John Spurlock | d4e6575 | 2013-08-28 14:17:09 -0400 | [diff] [blame] | 299 | pw.print(prefix); pw.print(" "); pw.print("mTransientBar"); pw.print('='); |
John Spurlock | 27735a4 | 2013-08-14 17:57:38 -0400 | [diff] [blame] | 300 | pw.println(transientBarStateToString(mTransientBarState)); |
| 301 | } |
| 302 | } |
| 303 | } |