From ba4eba6ca134fc4d7766f523b8b4bf17534be385 Mon Sep 17 00:00:00 2001 From: Wu Ahan Date: Tue, 19 Oct 2021 12:56:53 +0000 Subject: [PATCH] Close ParcelFileDesciptor properly We missed closing ParcelFileDescriptor, so close it. Bug: 200947065 Test: Manually Change-Id: If8ee9153898801f7c57cecebbc79e0cad611efc4 --- core/java/android/app/WallpaperManager.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/WallpaperManager.java b/core/java/android/app/WallpaperManager.java index b570ae60ee91d..11c01e61911c3 100644 --- a/core/java/android/app/WallpaperManager.java +++ b/core/java/android/app/WallpaperManager.java @@ -586,12 +586,12 @@ public class WallpaperManager { Rect dimensions = null; synchronized (this) { + ParcelFileDescriptor pfd = null; try { Bundle params = new Bundle(); + pfd = mService.getWallpaperWithFeature(context.getOpPackageName(), + context.getAttributionTag(), this, FLAG_SYSTEM, params, userId); // Let's peek user wallpaper first. - ParcelFileDescriptor pfd = mService.getWallpaperWithFeature( - context.getOpPackageName(), context.getAttributionTag(), this, - FLAG_SYSTEM, params, userId); if (pfd != null) { BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; @@ -600,6 +600,13 @@ public class WallpaperManager { } } catch (RemoteException ex) { Log.w(TAG, "peek wallpaper dimensions failed", ex); + } finally { + if (pfd != null) { + try { + pfd.close(); + } catch (IOException ignored) { + } + } } } // If user wallpaper is unavailable, may be the default one instead.