Merge "Close ParcelFileDesciptor properly" into sc-v2-dev am: bae76ba745 am: b1cde22071

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16084831

Change-Id: I1814cbe79fb6cba1cd4f94137ea65e98b22da93e
This commit is contained in:
TreeHugger Robot
2021-11-02 10:30:26 +00:00
committed by Automerger Merge Worker

View File

@@ -587,12 +587,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;
@@ -601,6 +601,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.