Skip to content

Commit 44251a7

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Work on issue #7343200: Fails to show wallpaper in the background..." into jb-mr1-dev
2 parents 13a6df9 + ef03a7f commit 44251a7

File tree

4 files changed

+50
-28
lines changed

4 files changed

+50
-28
lines changed

core/java/android/os/Debug.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,6 +1362,23 @@ public static String getCallers(final int depth) {
13621362
return sb.toString();
13631363
}
13641364

1365+
/**
1366+
* Like {@link #getCallers(int)}, but each location is append to the string
1367+
* as a new line with <var>linePrefix</var> in front of it.
1368+
* @param depth the number of levels to return, starting with the immediate caller.
1369+
* @param linePrefix prefix to put in front of each location.
1370+
* @return a string describing the call stack.
1371+
* {@hide}
1372+
*/
1373+
public static String getCallers(final int depth, String linePrefix) {
1374+
final StackTraceElement[] callStack = Thread.currentThread().getStackTrace();
1375+
StringBuffer sb = new StringBuffer();
1376+
for (int i = 0; i < depth; i++) {
1377+
sb.append(linePrefix).append(getCaller(callStack, i)).append("\n");
1378+
}
1379+
return sb.toString();
1380+
}
1381+
13651382
/**
13661383
* @return a String describing the immediate caller of the calling function.
13671384
* {@hide}

services/java/com/android/server/wm/WindowAnimator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ void hideWallpapersLocked(final WindowState w) {
264264
WindowManagerPolicy.FINISH_LAYOUT_REDO_WALLPAPER);
265265
}
266266
}
267+
if (WindowManagerService.DEBUG_WALLPAPER_LIGHT && !token.hidden) Slog.d(TAG,
268+
"Hiding wallpaper " + token + " from " + w);
267269
token.hidden = true;
268270
}
269271
}

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ public class WindowManagerService extends IWindowManager.Stub
192192
static final boolean DEBUG_STARTING_WINDOW = false;
193193
static final boolean DEBUG_REORDER = false;
194194
static final boolean DEBUG_WALLPAPER = false;
195+
static final boolean DEBUG_WALLPAPER_LIGHT = true || DEBUG_WALLPAPER;
195196
static final boolean DEBUG_DRAG = false;
196197
static final boolean DEBUG_SCREEN_ON = false;
197198
static final boolean DEBUG_SCREENSHOT = false;
@@ -1625,7 +1626,7 @@ int adjustWallpaperWindowsLocked() {
16251626
}
16261627

16271628
if (foundW == null && windowDetachedI >= 0) {
1628-
if (DEBUG_WALLPAPER) Slog.v(TAG,
1629+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
16291630
"Found animating detached wallpaper activity: #" + i + "=" + w);
16301631
foundW = w;
16311632
foundI = windowDetachedI;
@@ -1641,20 +1642,20 @@ int adjustWallpaperWindowsLocked() {
16411642
// enough (we'll just wait until whatever transition is pending
16421643
// executes).
16431644
if (mWallpaperTarget != null && mWallpaperTarget.mAppToken != null) {
1644-
if (DEBUG_WALLPAPER) Slog.v(TAG,
1645+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
16451646
"Wallpaper not changing: waiting for app anim in current target");
16461647
return 0;
16471648
}
16481649
if (foundW != null && foundW.mAppToken != null) {
1649-
if (DEBUG_WALLPAPER) Slog.v(TAG,
1650+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
16501651
"Wallpaper not changing: waiting for app anim in found target");
16511652
return 0;
16521653
}
16531654
}
16541655

16551656
if (mWallpaperTarget != foundW
16561657
&& (mLowerWallpaperTarget == null || mLowerWallpaperTarget != foundW)) {
1657-
if (DEBUG_WALLPAPER) {
1658+
if (DEBUG_WALLPAPER_LIGHT) {
16581659
Slog.v(TAG, "New wallpaper target: " + foundW
16591660
+ " oldTarget: " + mWallpaperTarget);
16601661
}
@@ -1674,25 +1675,25 @@ int adjustWallpaperWindowsLocked() {
16741675
boolean foundAnim = foundW.mWinAnimator.mAnimation != null
16751676
|| (foundW.mAppToken != null &&
16761677
foundW.mAppToken.mAppAnimator.animation != null);
1677-
if (DEBUG_WALLPAPER) {
1678+
if (DEBUG_WALLPAPER_LIGHT) {
16781679
Slog.v(TAG, "New animation: " + foundAnim
16791680
+ " old animation: " + oldAnim);
16801681
}
16811682
if (foundAnim && oldAnim) {
16821683
int oldI = windows.indexOf(oldW);
1683-
if (DEBUG_WALLPAPER) {
1684+
if (DEBUG_WALLPAPER_LIGHT) {
16841685
Slog.v(TAG, "New i: " + foundI + " old i: " + oldI);
16851686
}
16861687
if (oldI >= 0) {
1687-
if (DEBUG_WALLPAPER) {
1688+
if (DEBUG_WALLPAPER_LIGHT) {
16881689
Slog.v(TAG, "Animating wallpapers: old#" + oldI
16891690
+ "=" + oldW + "; new#" + foundI
16901691
+ "=" + foundW);
16911692
}
16921693

16931694
// Set the new target correctly.
16941695
if (foundW.mAppToken != null && foundW.mAppToken.hiddenRequested) {
1695-
if (DEBUG_WALLPAPER) {
1696+
if (DEBUG_WALLPAPER_LIGHT) {
16961697
Slog.v(TAG, "Old wallpaper still the target.");
16971698
}
16981699
mWallpaperTarget = oldW;
@@ -1704,7 +1705,7 @@ int adjustWallpaperWindowsLocked() {
17041705
// the wallpaper below the lower.
17051706
else if (foundI > oldI) {
17061707
// The new target is on top of the old one.
1707-
if (DEBUG_WALLPAPER) {
1708+
if (DEBUG_WALLPAPER_LIGHT) {
17081709
Slog.v(TAG, "Found target above old target.");
17091710
}
17101711
mUpperWallpaperTarget = foundW;
@@ -1713,7 +1714,7 @@ else if (foundI > oldI) {
17131714
foundI = oldI;
17141715
} else {
17151716
// The new target is below the old one.
1716-
if (DEBUG_WALLPAPER) {
1717+
if (DEBUG_WALLPAPER_LIGHT) {
17171718
Slog.v(TAG, "Found target below old target.");
17181719
}
17191720
mUpperWallpaperTarget = oldW;
@@ -1732,7 +1733,7 @@ else if (foundI > oldI) {
17321733
|| (mUpperWallpaperTarget.mAppToken != null
17331734
&& mUpperWallpaperTarget.mAppToken.mAppAnimator.animation != null);
17341735
if (!lowerAnimating || !upperAnimating) {
1735-
if (DEBUG_WALLPAPER) {
1736+
if (DEBUG_WALLPAPER_LIGHT) {
17361737
Slog.v(TAG, "No longer animating wallpaper targets!");
17371738
}
17381739
mLowerWallpaperTarget = null;
@@ -1810,6 +1811,8 @@ else if (foundI > oldI) {
18101811
curTokenIndex--;
18111812
WindowToken token = mWallpaperTokens.get(curTokenIndex);
18121813
if (token.hidden == visible) {
1814+
if (DEBUG_WALLPAPER_LIGHT) Slog.d(TAG,
1815+
"Wallpaper token " + token + " hidden=" + !visible);
18131816
changed |= ADJUST_WALLPAPER_VISIBILITY_CHANGED;
18141817
token.hidden = !visible;
18151818
// Need to do a layout to ensure the wallpaper now has the
@@ -1831,7 +1834,7 @@ else if (foundI > oldI) {
18311834
dispatchWallpaperVisibility(wallpaper, visible);
18321835

18331836
wallpaper.mWinAnimator.mAnimLayer = wallpaper.mLayer + mWallpaperAnimLayerAdjustment;
1834-
if (DEBUG_LAYERS || DEBUG_WALLPAPER) Slog.v(TAG, "adjustWallpaper win "
1837+
if (DEBUG_LAYERS || DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "adjustWallpaper win "
18351838
+ wallpaper + " anim layer: " + wallpaper.mWinAnimator.mAnimLayer);
18361839

18371840
// First, if this window is at the current index, then all
@@ -1858,7 +1861,7 @@ else if (foundI > oldI) {
18581861
}
18591862

18601863
// Now stick it in.
1861-
if (DEBUG_WALLPAPER || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
1864+
if (DEBUG_WALLPAPER_LIGHT || DEBUG_WINDOW_MOVEMENT || DEBUG_ADD_REMOVE) {
18621865
Slog.v(TAG, "Moving wallpaper " + wallpaper
18631866
+ " from " + oldIndex + " to " + foundI);
18641867
}
@@ -2033,9 +2036,9 @@ void dispatchWallpaperVisibility(final WindowState wallpaper, final boolean visi
20332036
if (wallpaper.mWallpaperVisible != visible) {
20342037
wallpaper.mWallpaperVisible = visible;
20352038
try {
2036-
if (DEBUG_VISIBILITY || DEBUG_WALLPAPER) Slog.v(TAG,
2037-
"Updating visibility of wallpaper " + wallpaper
2038-
+ ": " + visible + " Callers=" + Debug.getCallers(2));
2039+
if (DEBUG_VISIBILITY || DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
2040+
"Updating vis of wallpaper " + wallpaper
2041+
+ ": " + visible + " from:\n" + Debug.getCallers(4, " "));
20392042
wallpaper.mClient.dispatchAppVisibility(visible);
20402043
} catch (RemoteException e) {
20412044
}
@@ -8800,10 +8803,10 @@ private int animateAwayWallpaperLocked() {
88008803
WindowState oldWallpaper = mWallpaperTarget;
88018804
if (mLowerWallpaperTarget != null
88028805
&& mLowerWallpaperTarget.mAppToken != null) {
8803-
if (DEBUG_WALLPAPER) Slog.v(TAG,
8806+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
88048807
"wallpaperForceHiding changed with lower="
88058808
+ mLowerWallpaperTarget);
8806-
if (DEBUG_WALLPAPER) Slog.v(TAG,
8809+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
88078810
"hidden=" + mLowerWallpaperTarget.mAppToken.hidden +
88088811
" hiddenRequested=" + mLowerWallpaperTarget.mAppToken.hiddenRequested);
88098812
if (mLowerWallpaperTarget.mAppToken.hidden) {
@@ -8815,7 +8818,7 @@ private int animateAwayWallpaperLocked() {
88158818
}
88168819
}
88178820
mInnerFields.mAdjResult |= adjustWallpaperWindowsLocked();
8818-
if (DEBUG_WALLPAPER) Slog.v(TAG, "****** OLD: " + oldWallpaper
8821+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG, "****** OLD: " + oldWallpaper
88198822
+ " NEW: " + mWallpaperTarget
88208823
+ " LOWER: " + mLowerWallpaperTarget);
88218824
return changes;
@@ -9189,7 +9192,7 @@ private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMe
91899192
}
91909193
}
91919194
if ((w.mAttrs.flags & FLAG_SHOW_WALLPAPER) != 0) {
9192-
if (DEBUG_WALLPAPER) Slog.v(TAG,
9195+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
91939196
"First draw done in potential wallpaper target " + w);
91949197
mInnerFields.mWallpaperMayChange = true;
91959198
displayContent.pendingLayoutChanges |=
@@ -9340,18 +9343,18 @@ private final void performLayoutAndPlaceSurfacesLockedInner(boolean recoveringMe
93409343
mInnerFields.mWallpaperForceHidingChanged = false;
93419344

93429345
if (mInnerFields.mWallpaperMayChange) {
9343-
if (WindowManagerService.DEBUG_WALLPAPER) Slog.v(TAG,
9346+
if (WindowManagerService.DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
93449347
"Wallpaper may change! Adjusting");
93459348
mInnerFields.mAdjResult |= adjustWallpaperWindowsLocked();
93469349
}
93479350

93489351
if ((mInnerFields.mAdjResult&ADJUST_WALLPAPER_LAYERS_CHANGED) != 0) {
9349-
if (DEBUG_WALLPAPER) Slog.v(TAG,
9352+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
93509353
"Wallpaper layer changed: assigning layers + relayout");
93519354
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
93529355
assignLayersLocked(defaultWindows);
93539356
} else if ((mInnerFields.mAdjResult&ADJUST_WALLPAPER_VISIBILITY_CHANGED) != 0) {
9354-
if (DEBUG_WALLPAPER) Slog.v(TAG,
9357+
if (DEBUG_WALLPAPER_LIGHT) Slog.v(TAG,
93559358
"Wallpaper visibility changed: relayout");
93569359
defaultDisplay.pendingLayoutChanges |= WindowManagerPolicy.FINISH_LAYOUT_REDO_LAYOUT;
93579360
}
@@ -10326,7 +10329,7 @@ void dumpTokensLocked(PrintWriter pw, boolean dumpAll) {
1032610329
Iterator<WindowToken> it = mTokenMap.values().iterator();
1032710330
while (it.hasNext()) {
1032810331
WindowToken token = it.next();
10329-
pw.print(" Token "); pw.print(token.token);
10332+
pw.print(" "); pw.print(token);
1033010333
if (dumpAll) {
1033110334
pw.println(':');
1033210335
token.dump(pw, " ");
@@ -10354,8 +10357,9 @@ void dumpTokensLocked(PrintWriter pw, boolean dumpAll) {
1035410357
pw.println();
1035510358
pw.println(" Application tokens in Z order:");
1035610359
for (int i=mAppTokens.size()-1; i>=0; i--) {
10357-
pw.print(" App #"); pw.print(i); pw.println(": ");
10358-
mAppTokens.get(i).dump(pw, " ");
10360+
pw.print(" App #"); pw.print(i);
10361+
pw.print(' '); pw.print(mAppTokens.get(i)); pw.println(":");
10362+
mAppTokens.get(i).dump(pw, " ");
1035910363
}
1036010364
}
1036110365
if (mFinishedStarting.size() > 0) {

services/java/com/android/server/wm/WindowToken.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class WindowToken {
7979
}
8080

8181
void dump(PrintWriter pw, String prefix) {
82-
pw.print(prefix); pw.print("token="); pw.println(token);
8382
pw.print(prefix); pw.print("windows="); pw.println(windows);
8483
pw.print(prefix); pw.print("windowType="); pw.print(windowType);
8584
pw.print(" hidden="); pw.print(hidden);
@@ -97,7 +96,7 @@ public String toString() {
9796
StringBuilder sb = new StringBuilder();
9897
sb.append("WindowToken{");
9998
sb.append(Integer.toHexString(System.identityHashCode(this)));
100-
sb.append(" token="); sb.append(token); sb.append('}');
99+
sb.append(" "); sb.append(token); sb.append('}');
101100
stringName = sb.toString();
102101
}
103102
return stringName;

0 commit comments

Comments
 (0)