From ecd827ac0d7a62ea81b8123120be1fe6424c2338 Mon Sep 17 00:00:00 2001 From: Christopher Tate Date: Fri, 5 Sep 2014 17:42:34 -0700 Subject: [PATCH] Fix binder identity use when clearing wallpapers Don't restore it too soon, because the rarely-needed fallback path will need to be executed as system, too. Bug 17394246 Change-Id: Ic5e662d4eae331b016fc91ffd08647bd8d4d6ff3 --- .../wallpaper/WallpaperManagerService.java | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java index 0e596f4ecc569..802df9522439f 100644 --- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java +++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java @@ -602,33 +602,35 @@ public class WallpaperManagerService extends IWallpaperManager.Stub { f.delete(); } final long ident = Binder.clearCallingIdentity(); - RuntimeException e = null; try { - wallpaper.imageWallpaperPending = false; - if (userId != mCurrentUserId) return; - if (bindWallpaperComponentLocked(defaultFailed - ? mImageWallpaper - : null, true, false, wallpaper, reply)) { - return; + RuntimeException e = null; + try { + wallpaper.imageWallpaperPending = false; + if (userId != mCurrentUserId) return; + if (bindWallpaperComponentLocked(defaultFailed + ? mImageWallpaper + : null, true, false, wallpaper, reply)) { + return; + } + } catch (IllegalArgumentException e1) { + e = e1; + } + + // This can happen if the default wallpaper component doesn't + // exist. This should be a system configuration problem, but + // let's not let it crash the system and just live with no + // wallpaper. + Slog.e(TAG, "Default wallpaper component not found!", e); + clearWallpaperComponentLocked(wallpaper); + if (reply != null) { + try { + reply.sendResult(null); + } catch (RemoteException e1) { + } } - } catch (IllegalArgumentException e1) { - e = e1; } finally { Binder.restoreCallingIdentity(ident); } - - // This can happen if the default wallpaper component doesn't - // exist. This should be a system configuration problem, but - // let's not let it crash the system and just live with no - // wallpaper. - Slog.e(TAG, "Default wallpaper component not found!", e); - clearWallpaperComponentLocked(wallpaper); - if (reply != null) { - try { - reply.sendResult(null); - } catch (RemoteException e1) { - } - } } public boolean hasNamedWallpaper(String name) {