From 59377cab5c4afa9ccca5d5613eef4406e7ef0df6 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Tue, 31 Jan 2017 21:32:26 -0800 Subject: [PATCH] Fix a wrong UID can be logged This is a prepartion for fixing Bug 34838583 Currently Binder.clearCallingIdentity() is called too early, which ends up always blaming the system UID when calledWithValidToken() fails in InputMethodManagerService#updateStatusIcon(). Test: Compile Bug: 34838583 Change-Id: Id69da24de8269c0c7e31ea9ef3c595c3d69fe40e --- .../server/InputMethodManagerService.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index 0292db97b5b0f..8020f0e42c37d 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -1660,15 +1660,15 @@ public class InputMethodManagerService extends IInputMethodManager.Stub @Override public void updateStatusIcon(IBinder token, String packageName, int iconId) { - long ident = Binder.clearCallingIdentity(); - try { - synchronized (mMethodMap) { - if (!calledWithValidToken(token)) { - final int uid = Binder.getCallingUid(); - Slog.e(TAG, "Ignoring updateStatusIcon due to an invalid token. uid:" + uid - + " token:" + token); - return; - } + synchronized (mMethodMap) { + if (!calledWithValidToken(token)) { + final int uid = Binder.getCallingUid(); + Slog.e(TAG, "Ignoring updateStatusIcon due to an invalid token. uid:" + uid + + " token:" + token); + return; + } + final long ident = Binder.clearCallingIdentity(); + try { if (iconId == 0) { if (DEBUG) Slog.d(TAG, "hide the small icon for the input method"); if (mStatusBar != null) { @@ -1693,9 +1693,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub mStatusBar.setIconVisibility(mSlotIme, true); } } + } finally { + Binder.restoreCallingIdentity(ident); } - } finally { - Binder.restoreCallingIdentity(ident); } }