提交 e84d6294 编写于 作者: limuyang2's avatar limuyang2

perf: 优化保存图片时的安全性

上级 6a266afa
......@@ -1709,6 +1709,7 @@ public final class ImageUtils {
contentUri = MediaStore.Images.Media.INTERNAL_CONTENT_URI;
}
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_DCIM + "/" + Utils.getApp().getPackageName());
contentValues.put(MediaStore.Video.Media.IS_PENDING, 1);
Uri uri = Utils.getApp().getContentResolver().insert(contentUri, contentValues);
if (uri == null) {
return null;
......@@ -1717,8 +1718,14 @@ public final class ImageUtils {
try {
os = Utils.getApp().getContentResolver().openOutputStream(uri);
src.compress(format, quality, os);
contentValues.clear();
contentValues.put(MediaStore.Video.Media.IS_PENDING, 0);
Utils.getApp().getContentResolver().update(uri, contentValues, null, null);
return UtilsBridge.uri2File(uri);
} catch (Exception e) {
Utils.getApp().getContentResolver().delete(uri, null, null);
e.printStackTrace();
return null;
} finally {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册