Revert "DO NOT MERGE: Decode the input of both setStream and setResource calls first"
This reverts commit fa9c73975e.
Reason for revert: will deliver a better fix for that, ag/16580245.
Change-Id: I567f20b4f545bed906938731c27eac6eb7aeddff
This commit is contained in:
@@ -1275,27 +1275,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.
|
|
||||||
if (tmp != null) {
|
|
||||||
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
||||||
tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
copyStreamToWallpaperFile(resources.openRawResource(resid), fos);
|
||||||
// The 'close()' is the trigger for any server-side image manipulation,
|
// The 'close()' is the trigger for any server-side image manipulation,
|
||||||
// so we must do that before waiting for completion.
|
// so we must do that before waiting for completion.
|
||||||
fos.close();
|
fos.close();
|
||||||
completion.waitForCompletion();
|
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) {
|
||||||
@@ -1537,22 +1528,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.
|
|
||||||
if (tmp != null) {
|
|
||||||
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
fos = new ParcelFileDescriptor.AutoCloseOutputStream(fd);
|
||||||
tmp.compress(Bitmap.CompressFormat.PNG, 100, fos);
|
copyStreamToWallpaperFile(bitmapData, fos);
|
||||||
fos.close();
|
fos.close();
|
||||||
completion.waitForCompletion();
|
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