需求:进入某个应用只保留左侧5个图标区域 代码路径: frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java 在PhoneWindowManager.java文件中beginLayoutLw()方法中修改,在每进入一个窗口的时候都会执行beginLayoutLw()方法,在该方法中会去重新初始化一下窗口的变量以及导航栏和状态栏,其中layoutNavigationBar初始化导航栏,layoutStatusBar初始化状态栏
@Override
public void beginLayoutLw(boolean isDefaultDisplay, int displayWidth, int displayHeight,
int displayRotation, int uiMode) {
boolean updateSysUiVisibility = layoutNavigationBar(displayWidth, displayHeight,
displayRotation, uiMode, overscanLeft, overscanRight, overscanBottom, dcf, navVisible, navTranslucent,
navAllowedHidden, statusBarExpandedNotKeyguard);
if (DEBUG_LAYOUT) Slog.i(TAG, String.format("mDock rect: (%d,%d - %d,%d)",
mDockLeft, mDockTop, mDockRight, mDockBottom));
updateSysUiVisibility |= layoutStatusBar(pf, df, of, vf, dcf, sysui, isKeyguardShowing, displayRotation, uiMode);
if (updateSysUiVisibility) {
updateSystemUiVisibilityLw();
}
}
在PhoneWindowManager.java文件中layoutNavigationBar方法中修改应用区域的宽度,right就是距离右边区域的宽度值
private boolean layoutNavigationBar(int displayWidth, int displayHeight, int displayRotation,
int uiMode, int overscanLeft, int overscanRight, int overscanBottom, Rect dcf,
boolean navVisible, boolean navTranslucent, boolean navAllowedHidden,
boolean statusBarExpandedNotKeyguard) {
if (mNavigationBar != null) {
boolean transientNavBarShowing = mNavigationBarController.isTransientShowing();
// Force the navigation bar to its appropriate place and
// size. We need to do this directly, instead of relying on
// it to bubble up from the nav bar, because this needs to
// change atomically with screen rotations.
mNavigationBarPosition = navigationBarPosition(displayWidth, displayHeight,
displayRotation);
if (mNavigationBarPosition == NAV_BAR_BOTTOM) {
top = displayHeight - overscanBottom
- getNavigationBarHeight(displayRotation, uiMode);
mTmpNavigationFrame.set(0, top, displayWidth, displayHeight - overscanBottom);
}
if (mNaviHided) { // SPRD: add for dynamic navigationbar
mTmpNavigationFrame.offset(0, getNavigationBarHeight(displayRotation, uiMode));
}
if(HIDE_BOTTOM_NAVI){
mStableBottom = mStableFullscreenBottom = displayHeight;
}else {
mStableBottom = mStableFullscreenBottom = mTmpNavigationFrame.top;
}
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
} else if (navVisible) {
mNavigationBarController.setBarShowingLw(true);
mDockBottom = mTmpNavigationFrame.top;
mRestrictedScreenHeight = mDockBottom - mRestrictedScreenTop;
mRestrictedOverscanScreenHeight = mDockBottom - mRestrictedOverscanScreenTop;
} else {
// We currently want to hide the navigation UI - unless we expanded the status
// bar.
mNavigationBarController.setBarShowingLw(statusBarExpandedNotKeyguard);
}
if (navVisible && !navTranslucent && !navAllowedHidden
&& !mNavigationBar.isAnimatingLw()
&& !mNavigationBarController.wasRecentlyTranslucent()) {
// If the opaque nav bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemBottom = mTmpNavigationFrame.top;
}
} else if (mNavigationBarPosition == NAV_BAR_RIGHT) {
int left = displayWidth - overscanRight- getNavigationBarWidth(displayRotation, uiMode);
mTmpNavigationFrame.set(left, 0, displayWidth - overscanRight, displayHeight);
if (mNaviHided) { // SPRD: add for dynamic navigationbar
mTmpNavigationFrame.offset(getNavigationBarWidth(displayRotation, uiMode), 0);
}
mStableRight = mStableFullscreenRight = mTmpNavigationFrame.left;
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
} else if (navVisible) {
mNavigationBarController.setBarShowingLw(true);
mDockRight = mTmpNavigationFrame.left;
mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
} else {
// We currently want to hide the navigation UI - unless we expanded the status
// bar.
mNavigationBarController.setBarShowingLw(statusBarExpandedNotKeyguard);
}
if (navVisible && !navTranslucent && !navAllowedHidden
&& !mNavigationBar.isAnimatingLw()
&& !mNavigationBarController.wasRecentlyTranslucent()) {
// If the nav bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemRight = mTmpNavigationFrame.left;
}
}else if (mNavigationBarPosition == NAV_BAR_LEFT) {
int right = overscanLeft + getNavigationBarWidth(displayRotation, uiMode);
if (SystemProperties.getBoolean("persist.sys.navigationbar.right",false)){
right = 110;
}
mTmpNavigationFrame.set(overscanLeft, 0, right, displayHeight);
if (mNaviHided) { // SPRD: add for dynamic navigationbar
mTmpNavigationFrame.offset(-getNavigationBarWidth(displayRotation, uiMode), 0);
}
mStableLeft = mStableFullscreenLeft = mTmpNavigationFrame.right;
if (transientNavBarShowing) {
mNavigationBarController.setBarShowingLw(true);
} else if (navVisible) {
mNavigationBarController.setBarShowingLw(true);
mDockLeft = mTmpNavigationFrame.right;
// TODO: not so sure about those:
mRestrictedScreenLeft = mRestrictedOverscanScreenLeft = mDockLeft;
mRestrictedScreenWidth = mDockRight - mRestrictedScreenLeft;
mRestrictedOverscanScreenWidth = mDockRight - mRestrictedOverscanScreenLeft;
} else {
// We currently want to hide the navigation UI - unless we expanded the status
// bar.
mNavigationBarController.setBarShowingLw(statusBarExpandedNotKeyguard);
}
if (navVisible && !navTranslucent && !navAllowedHidden
&& !mNavigationBar.isAnimatingLw()
&& !mNavigationBarController.wasRecentlyTranslucent()) {
// If the nav bar is currently requested to be visible,
// and not in the process of animating on or off, then
// we can tell the app that it is covered by it.
mSystemLeft = mTmpNavigationFrame.right;
}
}
}
}
// Make sure the content and current rectangles are updated to
// account for the restrictions from the navigation bar.
mContentTop = mVoiceContentTop = mCurTop = mDockTop;
mContentBottom = mVoiceContentBottom = mCurBottom = mDockBottom;
mContentLeft = mVoiceContentLeft = mCurLeft = mDockLeft;
mContentRight = mVoiceContentRight = mCurRight = mDockRight;
mStatusBarLayer = mNavigationBar.getSurfaceLayer();
// And compute the final frame.
mNavigationBar.computeFrameLw(mTmpNavigationFrame, mTmpNavigationFrame,
mTmpNavigationFrame, mTmpNavigationFrame, mTmpNavigationFrame, dcf,
mTmpNavigationFrame, mTmpNavigationFrame);
if (DEBUG_LAYOUT) Slog.i(TAG, "mNavigationBar frame: " + mTmpNavigationFrame);
if (mNavigationBarController.checkHiddenLw()) {
return true;
}
return false;
}
备注:主要控制应用区域的函数
mTmpNavigationFrame.set(overscanLeft, 0, right, displayHeight);
|