Merge "Revert "DO NOT MERGE: Decode the input of both setStream and setResource calls first"" into qt-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
13ad919ff5
@@ -1180,27 +1180,18 @@ public class WallpaperManager {
|
|||||||
mContext.getUserId());
|
mContext.getUserId());
|
||||||
if (fd != null) {
|
if (fd != null) {
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
final Bitmap tmp = BitmapFactory.decodeStream(resources.openRawResource(resid));
|
boolean ok = false;
|
||||||
try {
|
try {
|
||||||
// If the stream can't be decoded, treat it as an invalid input.
|
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
||||||
if (tmp != null) {
|
copyStreamToWallpaperFile(resources.openRawResource(resid), fos);
|
||||||
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
// The 'close()' is the trigger for any server-side image manipulation,
|
||||||
tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
// so we must do that before waiting for completion.
|
||||||
// The 'close()' is the trigger for any server-side image manipulation,
|
fos.close();
|
||||||
// so we must do that before waiting for completion.
|
completion.waitForCompletion();
|
||||||
fos.close();
|
|
||||||
completion.waitForCompletion();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Resource 0x" + Integer.toHexString(resid) + " is invalid");
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
// Might be redundant but completion shouldn't wait unless the write
|
// Might be redundant but completion shouldn't wait unless the write
|
||||||
// succeeded; this is a fallback if it threw past the close+wait.
|
// succeeded; this is a fallback if it threw past the close+wait.
|
||||||
IoUtils.closeQuietly(fos);
|
IoUtils.closeQuietly(fos);
|
||||||
if (tmp != null) {
|
|
||||||
tmp.recycle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
@@ -1442,22 +1433,13 @@ public class WallpaperManager {
|
|||||||
result, which, completion, mContext.getUserId());
|
result, which, completion, mContext.getUserId());
|
||||||
if (fd != null) {
|
if (fd != null) {
|
||||||
FileOutputStream fos = null;
|
FileOutputStream fos = null;
|
||||||
final Bitmap tmp = BitmapFactory.decodeStream(bitmapData);
|
|
||||||
try {
|
try {
|
||||||
// If the stream can't be decoded, treat it as an invalid input.
|
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
||||||
if (tmp != null) {
|
copyStreamToWallpaperFile(bitmapData, fos);
|
||||||
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
fos.close();
|
||||||
tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
completion.waitForCompletion();
|
||||||
fos.close();
|
|
||||||
completion.waitForCompletion();
|
|
||||||
} else {
|
|
||||||
throw new IllegalArgumentException("InputStream is invalid");
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
IoUtils.closeQuietly(fos);
|
IoUtils.closeQuietly(fos);
|
||||||
if (tmp != null) {
|
|
||||||
tmp.recycle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user