FileDocCategorySizeDatePackage
StatusBarWindowManager.javaAPI DocAndroid 5.1 API9386Thu Mar 12 22:22:42 GMT 2015com.android.systemui.statusbar.phone

StatusBarWindowManager

public class StatusBarWindowManager extends Object
Encapsulates all logic for the status bar window state management.

Fields Summary
private final android.content.Context
mContext
private final android.view.WindowManager
mWindowManager
private android.view.View
mStatusBarView
private WindowManager.LayoutParams
mLp
private WindowManager.LayoutParams
mLpChanged
private int
mBarHeight
private final boolean
mKeyguardScreenRotation
private final State
mCurrentState
Constructors Summary
public StatusBarWindowManager(android.content.Context context)


       
        mContext = context;
        mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
        mKeyguardScreenRotation = shouldEnableKeyguardScreenRotation();
    
Methods Summary
public voidadd(android.view.View statusBarView, int barHeight)
Adds the status bar view to the window manager.

param
statusBarView The view to add.
param
barHeight The height of the status bar in collapsed state.


        // Now that the status bar window encompasses the sliding panel and its
        // translucent backdrop, the entire thing is made TRANSLUCENT and is
        // hardware-accelerated.
        mLp = new WindowManager.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                barHeight,
                WindowManager.LayoutParams.TYPE_STATUS_BAR,
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                        | WindowManager.LayoutParams.FLAG_TOUCHABLE_WHEN_WAKING
                        | WindowManager.LayoutParams.FLAG_SPLIT_TOUCH
                        | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                        | WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS,
                PixelFormat.TRANSLUCENT);
        mLp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
        mLp.gravity = Gravity.TOP;
        mLp.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE;
        mLp.setTitle("StatusBar");
        mLp.packageName = mContext.getPackageName();
        mStatusBarView = statusBarView;
        mBarHeight = barHeight;
        mWindowManager.addView(mStatusBarView, mLp);
        mLpChanged = new WindowManager.LayoutParams();
        mLpChanged.copyFrom(mLp);
    
private voidadjustScreenOrientation(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        if (state.isKeyguardShowingAndNotOccluded()) {
            if (mKeyguardScreenRotation) {
                mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_USER;
            } else {
                mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
            }
        } else {
            mLpChanged.screenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
        }
    
private voidapply(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        applyKeyguardFlags(state);
        applyFocusableFlag(state);
        adjustScreenOrientation(state);
        applyHeight(state);
        applyUserActivityTimeout(state);
        applyInputFeatures(state);
        applyFitsSystemWindows(state);
        if (mLp.copyFrom(mLpChanged) != 0) {
            mWindowManager.updateViewLayout(mStatusBarView, mLp);
        }
    
private voidapplyFitsSystemWindows(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        mStatusBarView.setFitsSystemWindows(!state.isKeyguardShowingAndNotOccluded());
    
private voidapplyFocusableFlag(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        if (state.isKeyguardShowingAndNotOccluded() && state.keyguardNeedsInput
                && state.bouncerShowing) {
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        } else if (state.isKeyguardShowingAndNotOccluded() || state.statusBarFocusable) {
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
            mLpChanged.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        } else {
            mLpChanged.flags |= WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        }
    
private voidapplyHeight(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        boolean expanded = state.isKeyguardShowingAndNotOccluded() || state.statusBarExpanded
                || state.keyguardFadingAway || state.bouncerShowing;
        if (expanded) {
            mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT;
        } else {
            mLpChanged.height = mBarHeight;
        }
    
private voidapplyInputFeatures(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        if (state.isKeyguardShowingAndNotOccluded()
                && state.statusBarState == StatusBarState.KEYGUARD
                && !state.qsExpanded) {
            mLpChanged.inputFeatures |=
                    WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
        } else {
            mLpChanged.inputFeatures &=
                    ~WindowManager.LayoutParams.INPUT_FEATURE_DISABLE_USER_ACTIVITY;
        }
    
private voidapplyKeyguardFlags(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        if (state.keyguardShowing) {
            mLpChanged.flags |= WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
            mLpChanged.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
        } else {
            mLpChanged.flags &= ~WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER;
            mLpChanged.privateFlags &= ~WindowManager.LayoutParams.PRIVATE_FLAG_KEYGUARD;
        }
    
private voidapplyUserActivityTimeout(com.android.systemui.statusbar.phone.StatusBarWindowManager$State state)

        if (state.isKeyguardShowingAndNotOccluded()
                && state.statusBarState == StatusBarState.KEYGUARD
                && !state.qsExpanded) {
            mLpChanged.userActivityTimeout = state.keyguardUserActivityTimeout;
        } else {
            mLpChanged.userActivityTimeout = -1;
        }
    
public voidsetBouncerShowing(boolean showing)

        mCurrentState.bouncerShowing = showing;
        apply(mCurrentState);
    
public voidsetKeyguardFadingAway(boolean keyguardFadingAway)

        mCurrentState.keyguardFadingAway = keyguardFadingAway;
        apply(mCurrentState);
    
public voidsetKeyguardNeedsInput(boolean needsInput)

        mCurrentState.keyguardNeedsInput = needsInput;
        apply(mCurrentState);
    
public voidsetKeyguardOccluded(boolean occluded)

        mCurrentState.keyguardOccluded = occluded;
        apply(mCurrentState);
    
public voidsetKeyguardShowing(boolean showing)

        mCurrentState.keyguardShowing = showing;
        apply(mCurrentState);
    
public voidsetKeyguardUserActivityTimeout(long timeout)

        mCurrentState.keyguardUserActivityTimeout = timeout;
        apply(mCurrentState);
    
public voidsetQsExpanded(boolean expanded)

        mCurrentState.qsExpanded = expanded;
        apply(mCurrentState);
    
public voidsetStatusBarExpanded(boolean expanded)

        mCurrentState.statusBarExpanded = expanded;
        mCurrentState.statusBarFocusable = expanded;
        apply(mCurrentState);
    
public voidsetStatusBarFocusable(boolean focusable)

        mCurrentState.statusBarFocusable = focusable;
        apply(mCurrentState);
    
public voidsetStatusBarState(int state)

param
state The {@link StatusBarState} of the status bar.

        mCurrentState.statusBarState = state;
        apply(mCurrentState);
    
private booleanshouldEnableKeyguardScreenRotation()

        Resources res = mContext.getResources();
        return SystemProperties.getBoolean("lockscreen.rot_override", false)
                || res.getBoolean(R.bool.config_enableLockScreenRotation);