Skip to content

Commit 2ea9bae

Browse files
author
Dianne Hackborn
committed
Fix issue #7457380: IME leaves a mark after user switching
The gnarly stuff where we keep track of the old input method window as if it was still there was sitting around leaving things in a stuck state. Now we clear this out at key points in the window manager (freezing screen, user change), and the input method manager service is less aggressive about asking the window manager to do it. Also fixed a problem that was causing flickers during some wallpaper transitions -- when we are animating two things on top of the wallpaper and one of them disappears, we need to make sure the wallpaper target points to whatever the current target should be (if any), not left pointing to the old target that has gone away. Change-Id: I2fb9600f569a5bd5e3528aaf24cde9340af56cb0
1 parent 841ce67 commit 2ea9bae

File tree

4 files changed

+66
-15
lines changed

4 files changed

+66
-15
lines changed

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

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4500,6 +4500,7 @@ public void setCurrentUserLw(int newUserId) {
45004500
// oh well
45014501
}
45024502
}
4503+
setLastInputMethodWindowLw(null, null);
45034504
}
45044505

45054506
@Override
@@ -4581,8 +4582,42 @@ public void dump(String prefix, PrintWriter pw, String[] args) {
45814582
pw.print(prefix); pw.print("mShowingLockscreen="); pw.print(mShowingLockscreen);
45824583
pw.print(" mShowingDream="); pw.print(mShowingDream);
45834584
pw.print(" mDreamingLockscreen="); pw.println(mDreamingLockscreen);
4584-
pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState=");
4585-
pw.println(mTopFullscreenOpaqueWindowState);
4585+
if (mLastInputMethodWindow != null) {
4586+
pw.print(prefix); pw.print("mLastInputMethodWindow=");
4587+
pw.println(mLastInputMethodWindow);
4588+
}
4589+
if (mLastInputMethodTargetWindow != null) {
4590+
pw.print(prefix); pw.print("mLastInputMethodTargetWindow=");
4591+
pw.println(mLastInputMethodTargetWindow);
4592+
}
4593+
if (mStatusBar != null) {
4594+
pw.print(prefix); pw.print("mStatusBar=");
4595+
pw.println(mStatusBar);
4596+
}
4597+
if (mNavigationBar != null) {
4598+
pw.print(prefix); pw.print("mNavigationBar=");
4599+
pw.println(mNavigationBar);
4600+
}
4601+
if (mKeyguard != null) {
4602+
pw.print(prefix); pw.print("mKeyguard=");
4603+
pw.println(mKeyguard);
4604+
}
4605+
if (mFocusedWindow != null) {
4606+
pw.print(prefix); pw.print("mFocusedWindow=");
4607+
pw.println(mFocusedWindow);
4608+
}
4609+
if (mFocusedApp != null) {
4610+
pw.print(prefix); pw.print("mFocusedApp=");
4611+
pw.println(mFocusedApp);
4612+
}
4613+
if (mWinDismissingKeyguard != null) {
4614+
pw.print(prefix); pw.print("mWinDismissingKeyguard=");
4615+
pw.println(mWinDismissingKeyguard);
4616+
}
4617+
if (mTopFullscreenOpaqueWindowState != null) {
4618+
pw.print(prefix); pw.print("mTopFullscreenOpaqueWindowState=");
4619+
pw.println(mTopFullscreenOpaqueWindowState);
4620+
}
45864621
pw.print(prefix); pw.print("mTopIsFullscreen="); pw.print(mTopIsFullscreen);
45874622
pw.print(" mHideLockScreen="); pw.println(mHideLockScreen);
45884623
pw.print(prefix); pw.print("mForceStatusBar="); pw.print(mForceStatusBar);

services/java/com/android/server/InputMethodManagerService.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ private void resetAllInternalStateLocked(boolean updateOnlyWhenLocaleChanged) {
730730
if (!updateOnlyWhenLocaleChanged) {
731731
hideCurrentInputLocked(0, null);
732732
mCurMethodId = null;
733-
unbindCurrentMethodLocked(true);
733+
unbindCurrentMethodLocked(true, false);
734734
}
735735
if (DEBUG) {
736736
Slog.i(TAG, "Locale has been changed to " + newLocale);
@@ -1201,7 +1201,7 @@ InputBindResult startInputInnerLocked() {
12011201
throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
12021202
}
12031203

1204-
unbindCurrentMethodLocked(false);
1204+
unbindCurrentMethodLocked(false, true);
12051205

12061206
mCurIntent = new Intent(InputMethod.SERVICE_INTERFACE);
12071207
mCurIntent.setComponent(info.getComponent());
@@ -1257,7 +1257,7 @@ public void onServiceConnected(ComponentName name, IBinder service) {
12571257
mCurMethod = IInputMethod.Stub.asInterface(service);
12581258
if (mCurToken == null) {
12591259
Slog.w(TAG, "Service connected without a token!");
1260-
unbindCurrentMethodLocked(false);
1260+
unbindCurrentMethodLocked(false, false);
12611261
return;
12621262
}
12631263
if (DEBUG) Slog.v(TAG, "Initiating attach with token: " + mCurToken);
@@ -1292,7 +1292,7 @@ void onSessionCreated(IInputMethod method, IInputMethodSession session) {
12921292
}
12931293
}
12941294

1295-
void unbindCurrentMethodLocked(boolean reportToClient) {
1295+
void unbindCurrentMethodLocked(boolean reportToClient, boolean savePosition) {
12961296
if (mVisibleBound) {
12971297
mContext.unbindService(mVisibleConnection);
12981298
mVisibleBound = false;
@@ -1306,7 +1306,7 @@ void unbindCurrentMethodLocked(boolean reportToClient) {
13061306
if (mCurToken != null) {
13071307
try {
13081308
if (DEBUG) Slog.v(TAG, "Removing window token: " + mCurToken);
1309-
if ((mImeWindowVis & InputMethodService.IME_ACTIVE) != 0) {
1309+
if ((mImeWindowVis & InputMethodService.IME_ACTIVE) != 0 && savePosition) {
13101310
// The current IME is shown. Hence an IME switch (transition) is happening.
13111311
mWindowManagerService.saveLastInputMethodWindowForTransition();
13121312
}
@@ -1589,13 +1589,13 @@ void updateFromSettingsLocked() {
15891589
} catch (IllegalArgumentException e) {
15901590
Slog.w(TAG, "Unknown input method from prefs: " + id, e);
15911591
mCurMethodId = null;
1592-
unbindCurrentMethodLocked(true);
1592+
unbindCurrentMethodLocked(true, false);
15931593
}
15941594
mShortcutInputMethodsAndSubtypes.clear();
15951595
} else {
15961596
// There is no longer an input method set, so stop any current one.
15971597
mCurMethodId = null;
1598-
unbindCurrentMethodLocked(true);
1598+
unbindCurrentMethodLocked(true, false);
15991599
}
16001600
}
16011601

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,9 @@ void hideWallpapersLocked(final WindowState w, final WindowState wallpaperTarget
296296
}
297297
}
298298
if (WindowManagerService.DEBUG_WALLPAPER_LIGHT && !token.hidden) Slog.d(TAG,
299-
"Hiding wallpaper " + token + " from " + w + "\n"
300-
+ Debug.getCallers(5, " "));
299+
"Hiding wallpaper " + token + " from " + w
300+
+ " target=" + wallpaperTarget + " lower=" + lowerWallpaperTarget
301+
+ "\n" + Debug.getCallers(5, " "));
301302
token.hidden = true;
302303
}
303304
}

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,7 @@ final boolean isWallpaperVisible(WindowState wallpaperTarget) {
15661566
int adjustWallpaperWindowsLocked() {
15671567
mInnerFields.mWallpaperMayChange = false;
15681568
int changed = 0;
1569+
boolean targetChanged = false;
15691570

15701571
// TODO(multidisplay): Wallpapers on main screen only.
15711572
final DisplayInfo displayInfo = getDefaultDisplayContentLocked().getDisplayInfo();
@@ -1608,7 +1609,7 @@ int adjustWallpaperWindowsLocked() {
16081609
if ((w.mAttrs.flags&FLAG_SHOW_WALLPAPER) != 0 && w.isReadyForDisplay()
16091610
&& (mWallpaperTarget == w || w.isDrawnLw())) {
16101611
if (DEBUG_WALLPAPER) Slog.v(TAG,
1611-
"Found wallpaper activity: #" + i + "=" + w);
1612+
"Found wallpaper target: #" + i + "=" + w);
16121613
foundW = w;
16131614
foundI = i;
16141615
if (w == mWallpaperTarget && w.mWinAnimator.isAnimating()) {
@@ -1665,6 +1666,7 @@ int adjustWallpaperWindowsLocked() {
16651666

16661667
WindowState oldW = mWallpaperTarget;
16671668
mWallpaperTarget = foundW;
1669+
targetChanged = true;
16681670

16691671
// Now what is happening... if the current and new targets are
16701672
// animating, then we are in our super special mode!
@@ -1738,6 +1740,8 @@ else if (foundI > oldI) {
17381740
}
17391741
mLowerWallpaperTarget = null;
17401742
mUpperWallpaperTarget = null;
1743+
mWallpaperTarget = foundW;
1744+
targetChanged = true;
17411745
}
17421746
}
17431747

@@ -1872,6 +1876,12 @@ else if (foundI > oldI) {
18721876
}
18731877
}
18741878

1879+
if (targetChanged && DEBUG_WALLPAPER_LIGHT) {
1880+
Slog.d(TAG, "New wallpaper: target=" + mWallpaperTarget
1881+
+ " lower=" + mLowerWallpaperTarget + " upper="
1882+
+ mUpperWallpaperTarget);
1883+
}
1884+
18751885
return changed;
18761886
}
18771887

@@ -9696,9 +9706,9 @@ void updateLayoutToAnimationLocked() {
96969706
if (mWallpaperTarget != layoutToAnim.mWallpaperTarget
96979707
|| mLowerWallpaperTarget != layoutToAnim.mLowerWallpaperTarget
96989708
|| mUpperWallpaperTarget != layoutToAnim.mUpperWallpaperTarget) {
9699-
Slog.d(TAG, "Pushing anim wallpaper: target=" + layoutToAnim.mWallpaperTarget
9700-
+ " lower=" + layoutToAnim.mLowerWallpaperTarget + " upper="
9701-
+ layoutToAnim.mUpperWallpaperTarget + "\n" + Debug.getCallers(5, " "));
9709+
Slog.d(TAG, "Pushing anim wallpaper: target=" + mWallpaperTarget
9710+
+ " lower=" + mLowerWallpaperTarget + " upper="
9711+
+ mUpperWallpaperTarget + "\n" + Debug.getCallers(5, " "));
97029712
}
97039713
}
97049714
layoutToAnim.mWallpaperTarget = mWallpaperTarget;
@@ -10063,6 +10073,11 @@ private void startFreezingDisplayLocked(boolean inTransaction,
1006310073

1006410074
mInputMonitor.freezeInputDispatchingLw();
1006510075

10076+
// Clear the last input window -- that is just used for
10077+
// clean transitions between IMEs, and if we are freezing
10078+
// the screen then the whole world is changing behind the scenes.
10079+
mPolicy.setLastInputMethodWindowLw(null, null);
10080+
1006610081
if (mNextAppTransition != WindowManagerPolicy.TRANSIT_UNSET) {
1006710082
mNextAppTransition = WindowManagerPolicy.TRANSIT_UNSET;
1006810083
mNextAppTransitionType = ActivityOptions.ANIM_NONE;

0 commit comments

Comments
 (0)