yashsingh1/xdaforums huggingface dataset:
[Android Software/Hacking General [Developers Only]] llrraa2010:
start of Activity--start of MainActivity--Step 30

Step 30. ApplicationThread.scheduleLaunchActivity

frameworks/base/core/java/android/app/ActivityThread.java

public final class ActivityThread {

......

private final class ApplicationThread extends ApplicationThreadNative {

......

// we use token to identify this activity without having to send the
// activity itself back to the activity manager. (matters more with ipc)
public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
ActivityInfo info, Bundle state, List<ResultInfo> pendingResults,
List<Intent> pendingNewIntents, boolean notResumed, boolean isForward) {
ActivityClientRecord r = new ActivityClientRecord();

r.token = token;
r.ident = ident;
r.intent = intent;
r.activityInfo = info;
r.state = state;

r.pendingResults = pendingResults;
r.pendingIntents = pendingNewIntents;

r.startsNotResumed = notResumed;
r.isForward = isForward;

queueOrSendMessage(H.LAUNCH_ACTIVITY, r);
}

......

}

......
}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService

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

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

Step 1. ViewRoot.performTraversals

frameworks/base/core/java/android/view/ViewRoot.java

public final class ViewRoot extends Handler implements ViewParent,

View.AttachInfo.Callbacks {

......

private void performTraversals() {

......

final View host = mView;

......

int desiredWindowWidth;

int desiredWindowHeight;

int childWidthMeasureSpec;

int childHeightMeasureSpec;

......

Rect frame = mWinFrame;

if (mFirst) {

......

DisplayMetrics packageMetrics =

mView.getContext().getResources().getDisplayMetrics();

desiredWindowWidth = packageMetrics.widthPixels;

desiredWindowHeight = packageMetrics.heightPixels;

} else {

desiredWindowWidth = frame.width();

desiredWindowHeight = frame.height();

if (desiredWindowWidth != mWidth || desiredWindowHeight != mHeight) {

......

windowResizesToFitContent = true;

}

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

Step 2. ViewRoot.relayoutWindow

frameworks/base/core/java/android/view/ViewRoot.java

public final class ViewRoot extends Handler implements ViewParent,

View.AttachInfo.Callbacks {

......

private int relayoutWindow(WindowManager.LayoutParams params, int viewVisibility,

boolean insetsPending) throws RemoteException {

float appScale = mAttachInfo.mApplicationScale;

......

int relayoutResult = sWindowSession.relayout(

mWindow, params,

(int) (mView.mMeasuredWidth * appScale + 0.5f),

(int) (mView.mMeasuredHeight * appScale + 0.5f),

viewVisibility, insetsPending, mWinFrame,

mPendingContentInsets, mPendingVisibleInsets,

mPendingConfiguration, mSurface);

......

if (mTranslator != null) {

mTranslator.translateRectInScreenToAppWinFrame(mWinFrame);

mTranslator.translateRectInScreenToAppWindow(mPendingContentInsets);

mTranslator.translateRectInScreenToAppWindow(mPendingVisibleInsets);

}

return relayoutResult;

}

......

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

Step 3. Session.relayout

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

private final class Session extends IWindowSession.Stub

implements IBinder.DeathRecipient {

......

public int relayout(IWindow window, WindowManager.LayoutParams attrs,

int requestedWidth, int requestedHeight, int viewFlags,

boolean insetsPending, Rect outFrame, Rect outContentInsets,

Rect outVisibleInsets, Configuration outConfig, Surface outSurface) {

//Log.d(TAG, ">>>>>> ENTERED relayout from " + Binder.getCallingPid());

int res = relayoutWindow(this, window, attrs,

requestedWidth, requestedHeight, viewFlags, insetsPending,

outFrame, outContentInsets, outVisibleInsets, outConfig, outSurface);

//Log.d(TAG, "<<<<<< EXITING relayout to " + Binder.getCallingPid());

return res;

}

......

}

......

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

Step 4. WindowManagerService.relayoutWindow

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

public int relayoutWindow(Session session, IWindow client,

WindowManager.LayoutParams attrs, int requestedWidth,

int requestedHeight, int viewVisibility, boolean insetsPending,

Rect outFrame, Rect outContentInsets, Rect outVisibleInsets,

Configuration outConfig, Surface outSurface) {

......

synchronized(mWindowMap) {

WindowState win = windowForClientLocked(session, client, false);

......

win.mRequestedWidth = requestedWidth;

win.mRequestedHeight = requestedHeight;

......

final boolean scaledWindow =

((win.mAttrs.flags & WindowManager.LayoutParams.FLAG_SCALED) != 0);

if (scaledWindow) {

// requested{Width|Height} Surface's physical size

// attrs.{width|height} Size on screen

win.mHScale = (attrs.width != requestedWidth) ?

(attrs.width / (float)requestedWidth) : 1.0f;

win.mVScale = (attrs.height != requestedHeight) ?

(attrs.height / (float)requestedHeight) : 1.0f;

} else {

win.mHScale = win.mVScale = 1;

}

......

win.mGivenInsetsPending = insetsPending;

......

performLayoutAndPlaceSurfacesLocked();

......

outFrame.set(win.mFrame);

outContentInsets.set(win.mContentInsets);

outVisibleInsets.set(win.mVisibleInsets);

......

}

return (inTouchMode ? WindowManagerImpl.RELAYOUT_IN_TOUCH_MODE : 0)

| (displayed ? WindowManagerImpl.RELAYOUT_FIRST_TIME : 0);

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
reference books

reference books on Linux kernel

1. Linux Kernel Development.

2. Understanding the Linux Kernel.

3. Linux Device Drivers.

reference books on Android application developing

1. Professional Android Application Development.
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window size calculation--step 5

Step 5. WindowManagerService.performLayoutAndPlaceSurfacesLocked

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

private final void performLayoutAndPlaceSurfacesLocked() {

if (mInLayout) {

......

return;

}

......

boolean recoveringMemory = false;

if (mForceRemoves != null) {

recoveringMemory = true;

// Wait a little it for things to settle down, and off we go.

for (int i=0; i<mForceRemoves.size(); i++) {

WindowState ws = mForceRemoves.get(i);

Slog.i(TAG, "Force removing: " + ws);

removeWindowInnerLocked(ws.mSession, ws);

}

mForceRemoves = null;

......

}

mInLayout = true;

try {

performLayoutAndPlaceSurfacesLockedInner(recoveringMemory);

int i = mPendingRemove.size()-1;

if (i >= 0) {

while (i >= 0) {

WindowState w = mPendingRemove.get(i);

removeWindowInnerLocked(w.mSession, w);

i--;

}

mPendingRemove.clear();

mInLayout = false;

assignLayersLocked();

mLayoutNeeded = true;

performLayoutAndPlaceSurfacesLocked();

} else {

mInLayout = false;

......

}

......

} catch (RuntimeException e) {

mInLayout = false;

......

}

}

......

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

Step 6. WindowManagerService.performLayoutAndPlaceSurfacesLockedInner

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

private final void performLayoutAndPlaceSurfacesLockedInner(

boolean recoveringMemory) {

......

Surface.openTransaction();

......

try {

......

int repeats = 0;

int changes = 0;

do {

repeats++;

if (repeats > 6) {

......

break;

}

// FIRST LOOP: Perform a layout, if needed.

if (repeats < 4) {

changes = performLayoutLockedInner();

if (changes != 0) {

continue;

}

} else {

Slog.w(TAG, "Layout repeat skipped after too many iterations");

changes = 0;

}

// SECOND LOOP: Execute animations and update visibility of windows.

......

} while (changes != 0);

// THIRD LOOP: Update the surfaces of all windows.

......

} catch (RuntimeException e) {

......

}

......

Surface.closeTransaction();

......

// Destroy the surface of any windows that are no longer visible.

......

// Time to remove any exiting tokens?

......

// Time to remove any exiting applications?

......

}

......

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

Step 7. WindowManagerService.performLayoutLockedInner

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

final WindowManagerPolicy mPolicy = PolicyManager.makeNewWindowManager();

......

/**

* Z-ordered (bottom-most first) list of all Window objects.

*/

final ArrayList<WindowState> mWindows = new ArrayList<WindowState>();

......

private final int performLayoutLockedInner() {

......

final int dw = mDisplay.getWidth();

final int dh = mDisplay.getHeight();

final int N = mWindows.size();

int i;

......

mPolicy.beginLayoutLw(dw, dh);

int seq = mLayoutSeq+1;

if (seq < 0) seq = 0;

mLayoutSeq = seq;

// First perform layout of any root windows (not attached

// to another window).

int topAttached = -1;

for (i = N-1; i >= 0; i--) {

WindowState win = mWindows.get(i);

......

final AppWindowToken atoken = win.mAppToken;

final boolean gone = win.mViewVisibility == View.GONE

|| !win.mRelayoutCalled

|| win.mRootToken.hidden

|| (atoken != null && atoken.hiddenRequested)

|| win.mAttachedHidden

|| win.mExiting || win.mDestroying;

......

if (!gone || !win.mHaveFrame) {

if (!win.mLayoutAttached) {

mPolicy.layoutWindowLw(win, win.mAttrs, null);

win.mLayoutSeq = seq;

......

} else {

if (topAttached < 0) topAttached = i;

}

}

}

......

for (i = topAttached; i >= 0; i--) {

WindowState win = mWindows.get(i);

// If this view is GONE, then skip it -- keep the current

// frame, and let the caller know so they can ignore it

// if they want. (We do the normal layout for INVISIBLE

// windows, since that means "perform layout as normal,

// just don't display").

if (win.mLayoutAttached) {

......

if ((win.mViewVisibility != View.GONE && win.mRelayoutCalled)

|| !win.mHaveFrame) {

mPolicy.layoutWindowLw(win, win.mAttrs, win.mAttachedWindow);

win.mLayoutSeq = seq;

......

}

}

}

......

return mPolicy.finishLayoutLw();

}

......

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

Step 8. PhoneWindowManager.beginLayoutLw

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

public class PhoneWindowManager implements WindowManagerPolicy {

......

WindowState mStatusBar = null;

......

// The current size of the screen.

int mW, mH;

// During layout, the current screen borders with all outer decoration

// (status bar, input method dock) accounted for.

int mCurLeft, mCurTop, mCurRight, mCurBottom;

// During layout, the frame in which content should be displayed

// to the user, accounting for all screen decoration except for any

// space they deem as available for other content. This is usually

// the same as mCur*, but may be larger if the screen decor has supplied

// content insets.

int mContentLeft, mContentTop, mContentRight, mContentBottom;

// During layout, the current screen borders along with input method

// windows are placed.

int mDockLeft, mDockTop, mDockRight, mDockBottom;

// During layout, the layer at which the doc window is placed.

int mDockLayer;

static final Rect mTmpParentFrame = new Rect();

static final Rect mTmpDisplayFrame = new Rect();

static final Rect mTmpContentFrame = new Rect();

static final Rect mTmpVisibleFrame = new Rect();

......

public void beginLayoutLw(int displayWidth, int displayHeight) {

mW = displayWidth;

mH = displayHeight;

mDockLeft = mContentLeft = mCurLeft = 0;

mDockTop = mContentTop = mCurTop = 0;

mDockRight = mContentRight = mCurRight = displayWidth;

mDockBottom = mContentBottom = mCurBottom = displayHeight;

mDockLayer = 0x10000000;

// decide where the status bar goes ahead of time

if (mStatusBar != null) {

final Rect pf = mTmpParentFrame;

final Rect df = mTmpDisplayFrame;

final Rect vf = mTmpVisibleFrame;

pf.left = df.left = vf.left = 0;

pf.top = df.top = vf.top = 0;

pf.right = df.right = vf.right = displayWidth;

pf.bottom = df.bottom = vf.bottom = displayHeight;

mStatusBar.computeFrameLw(pf, df, vf, vf);

if (mStatusBar.isVisibleLw()) {

// If the status bar is hidden, we don't want to cause

// windows behind it to scroll.

mDockTop = mContentTop = mCurTop = mStatusBar.getFrameLw().bottom;

......

}

}

}

......

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

Step 9. PhoneWindowManager.layoutWindowLw

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

public class PhoneWindowManager implements WindowManagerPolicy {

......

public void layoutWindowLw(WindowState win, WindowManager.LayoutParams attrs,

WindowState attached) {

// we've already done the status bar

if (win == mStatusBar) {

return;

}

......

final int fl = attrs.flags;

final int sim = attrs.softInputMode;

final Rect pf = mTmpParentFrame;

final Rect df = mTmpDisplayFrame;

final Rect cf = mTmpContentFrame;

final Rect vf = mTmpVisibleFrame;

if (attrs.type == TYPE_INPUT_METHOD) {

pf.left = df.left = cf.left = vf.left = mDockLeft;

pf.top = df.top = cf.top = vf.top = mDockTop;

pf.right = df.right = cf.right = vf.right = mDockRight;

pf.bottom = df.bottom = cf.bottom = vf.bottom = mDockBottom;

// IM dock windows always go to the bottom of the screen.

attrs.gravity = Gravity.BOTTOM;

mDockLayer = win.getSurfaceLayer();

} else {

if ((fl &

(FLAG_LAYOUT_IN_SCREEN | FLAG_FULLSCREEN | FLAG_LAYOUT_INSET_DECOR))

== (FLAG_LAYOUT_IN_SCREEN | FLAG_LAYOUT_INSET_DECOR)) {

// This is the case for a normal activity window: we want it

// to cover all of the screen space, and it can take care of

// moving its contents to account for screen decorations that

// intrude into that space.

if (attached != null) {

// If this window is attached to another, our display

// frame is the same as the one we are attached to.

setAttachedWindowFrames(win, fl, sim, attached, true, pf, df, cf, vf);

} else {

pf.left = df.left = 0;

pf.top = df.top = 0;

pf.right = df.right = mW;

pf.bottom = df.bottom = mH;

if ((sim & SOFT_INPUT_MASK_ADJUST) != SOFT_INPUT_ADJUST_RESIZE) {

cf.left = mDockLeft;

cf.top = mDockTop;

cf.right = mDockRight;

cf.bottom = mDockBottom;

} else {

cf.left = mContentLeft;

cf.top = mContentTop;

cf.right = mContentRight;

cf.bottom = mContentBottom;

}

vf.left = mCurLeft;

vf.top = mCurTop;

vf.right = mCurRight;

vf.bottom = mCurBottom;

}

}

......

}

win.computeFrameLw(pf, df, cf, vf);

// Dock windows carve out the bottom of the screen, so normal windows

// can't appear underneath them.

if (attrs.type == TYPE_INPUT_METHOD && !win.getGivenInsetsPendingLw()) {

int top = win.getContentFrameLw().top;

top += win.getGivenContentInsetsLw().top;

if (mContentBottom > top) {

mContentBottom = top;

}

top = win.getVisibleFrameLw().top;

top += win.getGivenVisibleInsetsLw().top;

if (mCurBottom > top) {

mCurBottom = top;

}

......

}

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management--addAppToken

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

/**

* Mapping from a token IBinder to a WindowToken object.

*/

final HashMap<IBinder, WindowToken> mTokenMap =

new HashMap<IBinder, WindowToken>();

/**

* The same tokens as mTokenMap, stored in a list for efficient iteration

* over them.

*/

final ArrayList<WindowToken> mTokenList = new ArrayList<WindowToken>();

......

/**

* Z-ordered (bottom-most first) list of all application tokens, for

* controlling the ordering of windows in different applications. This

* contains WindowToken objects.

*/

final ArrayList<AppWindowToken> mAppTokens = new ArrayList<AppWindowToken>();

......

public void addAppToken(int addPos, IApplicationToken token,

int groupId, int requestedOrientation, boolean fullscreen) {

......

synchronized(mWindowMap) {

AppWindowToken wtoken = findAppWindowToken(token.asBinder());

if (wtoken != null) {

......

return;

}

wtoken = new AppWindowToken(token);

......

mAppTokens.add(addPos, wtoken);

......

mTokenMap.put(token.asBinder(), wtoken);

mTokenList.add(wtoken);

......

}

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management--

removeAppTokensLocked

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

private void removeAppTokensLocked(List<IBinder> tokens) {

// XXX This should be done more efficiently!

// (take advantage of the fact that both lists should be

// ordered in the same way.)

int N = tokens.size();

for (int i=0; i<N; i++) {

IBinder token = tokens.get(i);

final AppWindowToken wtoken = findAppWindowToken(token);

if (!mAppTokens.remove(wtoken)) {

......

i--;

N--;

}

}

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management

moveAppToken

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

public void moveAppToken(int index, IBinder token) {

if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,

"moveAppToken()")) {

throw new SecurityException("Requires MANAGE_APP_TOKENS permission");

}

synchronized(mWindowMap) {

......

final AppWindowToken wtoken = findAppWindowToken(token);

if (wtoken == null || !mAppTokens.remove(wtoken)) {

......

return;

}

mAppTokens.add(index, wtoken);

......

final long origId = Binder.clearCallingIdentity();

......

if (tmpRemoveAppWindowsLocked(wtoken)) {

......

reAddAppWindowsLocked(findWindowOffsetLocked(index), wtoken);

......

updateFocusedWindowLocked(UPDATE_FOCUS_WILL_PLACE_SURFACES);

mLayoutNeeded = true;

performLayoutAndPlaceSurfacesLocked();

}

Binder.restoreCallingIdentity(origId);

}

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management

findWindowOffsetLocked

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

/**

* Z-ordered (bottom-most first) list of all Window objects.

*/

final ArrayList<WindowState> mWindows = new ArrayList<WindowState>();

......

private int findWindowOffsetLocked(int tokenPos) {

final int NW = mWindows.size();

if (tokenPos >= mAppTokens.size()) {

int i = NW;

while (i > 0) {

i--;

WindowState win = mWindows.get(i);

if (win.getAppToken() != null) {

return i+1;

}

}

}

while (tokenPos > 0) {

// Find the first app token below the new position that has

// a window displayed.

final AppWindowToken wtoken = mAppTokens.get(tokenPos-1);

......

if (wtoken.sendingToBottom) {

......

tokenPos--;

continue;

}

int i = wtoken.windows.size();

while (i > 0) {

i--;

WindowState win = wtoken.windows.get(i);

int j = win.mChildWindows.size();

while (j > 0) {

j--;

WindowState cwin = win.mChildWindows.get(j);

if (cwin.mSubLayer >= 0) {

for (int pos=NW-1; pos>=0; pos--) {

if (mWindows.get(pos) == cwin) {

......

return pos+1;

}

}

}

}

for (int pos=NW-1; pos>=0; pos--) {

if (mWindows.get(pos) == win) {

......

return pos+1;

}

}

}

tokenPos--;

}

return 0;

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management

4. move AppWindowToken to the top

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

public void moveAppTokensToTop(List<IBinder> tokens) {

if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,

"moveAppTokensToTop()")) {

throw new SecurityException("Requires MANAGE_APP_TOKENS permission");

}

final long origId = Binder.clearCallingIdentity();

synchronized(mWindowMap) {

removeAppTokensLocked(tokens);

final int N = tokens.size();

for (int i=0; i<N; i++) {

AppWindowToken wt = findAppWindowToken(tokens.get(i));

if (wt != null) {

mAppTokens.add(wt);

if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {

mToTopApps.remove(wt);

mToBottomApps.remove(wt);

mToTopApps.add(wt);

wt.sendingToBottom = false;

wt.sendingToTop = true;

}

}

}

if (mNextAppTransition == WindowManagerPolicy.TRANSIT_UNSET) {

moveAppWindowsLocked(tokens, mAppTokens.size());

}

}

Binder.restoreCallingIdentity(origId);

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management

moveAppTokensToBottom

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

public void moveAppTokensToBottom(List<IBinder> tokens) {

if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,

"moveAppTokensToBottom()")) {

throw new SecurityException("Requires MANAGE_APP_TOKENS permission");

}

final long origId = Binder.clearCallingIdentity();

synchronized(mWindowMap) {

removeAppTokensLocked(tokens);

final int N = tokens.size();

int pos = 0;

for (int i=0; i<N; i++) {

AppWindowToken wt = findAppWindowToken(tokens.get(i));

if (wt != null) {

mAppTokens.add(pos, wt);

if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {

mToTopApps.remove(wt);

mToBottomApps.remove(wt);

mToBottomApps.add(i, wt);

wt.sendingToTop = false;

wt.sendingToBottom = true;

}

pos++;

}

}

if (mNextAppTransition == WindowManagerPolicy.TRANSIT_UNSET) {

moveAppWindowsLocked(tokens, 0);

}

}

Binder.restoreCallingIdentity(origId);

}

......

}
[Android Software/Hacking General [Developers Only]] llrraa2010:
WindowManagerService-- window management

addWindowToken

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

public class WindowManagerService extends IWindowManager.Stub

implements Watchdog.Monitor {

......

public void addWindowToken(IBinder token, int type) {

if (!checkCallingPermission(android.Manifest.permission.MANAGE_APP_TOKENS,

"addWindowToken()")) {

throw new SecurityException("Requires MANAGE_APP_TOKENS permission");

}

synchronized(mWindowMap) {

WindowToken wtoken = mTokenMap.get(token);

if (wtoken != null) {

Slog.w(TAG, "Attempted to add existing input method token: " + token);

return;

}

wtoken = new WindowToken(token, type, true);

mTokenMap.put(token, wtoken);

mTokenList.add(wtoken);

if (type == TYPE_WALLPAPER) {

mWallpaperTokens.add(wtoken);

}

}

}

......

}