Close ParcelFileDesciptor properly

We missed closing ParcelFileDescriptor, so close it.

Bug: 200947065
Test: Manually
Change-Id: If8ee9153898801f7c57cecebbc79e0cad611efc4
This commit is contained in:
Wu Ahan
2021-10-19 12:56:53 +00:00
parent 4b55fab5d5
commit ba4eba6ca1

View File

@@ -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.