[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window size calculation--step 10

Step 10.*WindowState.computeFrameLw

frameworks/base/services/java/com/android/server/WindowManagerService.java

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

private final class WindowState implements WindowManagerPolicy.WindowState {

......

boolean mHaveFrame;

......

// "Real" frame that the application sees.

final Rect mFrame = new Rect();

......

final Rect mContainingFrame = new Rect();

final Rect mDisplayFrame = new Rect();

final Rect mContentFrame = new Rect();

final Rect mVisibleFrame = new Rect();

public void computeFrameLw(Rect pf, Rect df, Rect cf, Rect vf) {

mHaveFrame = true;

final Rect container = mContainingFrame;

container.set(pf);

final Rect display = mDisplayFrame;

display.set(df);

if ((mAttrs.flags & FLAG_COMPATIBLE_WINDOW) != 0) {

container.intersect(mCompatibleScreenFrame);

if ((mAttrs.flags & FLAG_LAYOUT_NO_LIMITS) == 0) {

display.intersect(mCompatibleScreenFrame);

}

}

final int pw = container.right - container.left;

final int ph = container.bottom - container.top;

int w,h;

if ((mAttrs.flags & mAttrs.FLAG_SCALED) != 0) {

w = mAttrs.width < 0 ? pw : mAttrs.width;

h = mAttrs.height< 0 ? ph : mAttrs.height;

} else {

w = mAttrs.width == mAttrs.MATCH_PARENT ? pw : mRequestedWidth;

h = mAttrs.height== mAttrs.MATCH_PARENT ? ph : mRequestedHeight;

}

final Rect content = mContentFrame;

content.set(cf);

final Rect visible = mVisibleFrame;

visible.set(vf);

final Rect frame = mFrame;

final int fw = frame.width();

final int fh = frame.height();

......

Gravity.apply(mAttrs.gravity, w, h, container,

(int) (mAttrs.x + mAttrs.horizontalMargin * pw),

(int) (mAttrs.y + mAttrs.verticalMargin * ph), frame);

......

// Now make sure the window fits in the overall display.

Gravity.applyDisplay(mAttrs.gravity, df, frame);

// Make sure the content and visible frames are inside of the

// final window frame.

if (content.left < frame.left) content.left = frame.left;

if (content.top < frame.top) content.top = frame.top;

if (content.right > frame.right) content.right = frame.right;

if (content.bottom > frame.bottom) content.bottom = frame.bottom;

if (visible.left < frame.left) visible.left = frame.left;

if (visible.top < frame.top) visible.top = frame.top;

if (visible.right > frame.right) visible.right = frame.right;

if (visible.bottom > frame.bottom) visible.bottom = frame.bottom;

final Rect contentInsets = mContentInsets;

contentInsets.left = content.left-frame.left;

contentInsets.top = content.top-frame.top;

contentInsets.right = frame.right-content.right;

contentInsets.bottom = frame.bottom-content.bottom;

final Rect visibleInsets = mVisibleInsets;

visibleInsets.left = visible.left-frame.left;

visibleInsets.top = visible.top-frame.top;

visibleInsets.right = frame.right-visible.right;

visibleInsets.bottom = frame.bottom-visible.bottom;

if (mIsWallpaper && (fw != frame.width() || fh != frame.height())) {

updateWallpaperOffsetLocked(this, mDisplay.getWidth(),

mDisplay.getHeight(), false);

}

......

}

......

}

......

}

Step 11.*PhoneWindowManager.finishLayoutLw

frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

public class PhoneWindowManager implements WindowManagerPolicy {

......

public int finishLayoutLw() {

return 0;

}

......

}