Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a770c9d2 authored by Jay Shrauner's avatar Jay Shrauner Committed by syphyr
Browse files

Fix NPE when copying photo URI

Bug:19564741
Change-Id: I0a4e0ccf2a917d403d1411fc737da293c81aded0
parent c66a14a5
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -142,7 +142,10 @@ public class AttachPhotoActivity extends ContactsActivity {
            // we can add the FLAG_GRANT_WRITE_URI_PERMISSION flag to the eventual
            // crop intent for read-only URI's.
            // TODO: With b/10837468 fixed should be able to avoid this copy.
            ContactPhotoUtils.savePhotoFromUriToUri(this, inputUri, mTempPhotoUri, false);
            if (!ContactPhotoUtils.savePhotoFromUriToUri(this, inputUri, mTempPhotoUri, false)) {
                finish();
                return;
            }
            toCrop = mTempPhotoUri;

            final Intent intent = new Intent("com.android.camera.action.CROP", toCrop);
+4 −2
Original line number Diff line number Diff line
@@ -161,8 +161,10 @@ public abstract class PhotoSelectionHandler implements OnClickListener {
                    } else {
                        toCrop = mTempPhotoUri;
                        try {
                            ContactPhotoUtils.savePhotoFromUriToUri(mContext, uri,
                                    toCrop, false);
                            if (!ContactPhotoUtils.savePhotoFromUriToUri(mContext, uri,
                                            toCrop, false)) {
                                return false;
                            }
                        } catch (SecurityException e) {
                            Log.d(TAG, "Did not have read-access to uri : " + uri);
                            return false;
+3 −0
Original line number Diff line number Diff line
@@ -145,6 +145,9 @@ public class ContactPhotoUtils {
     */
    public static boolean savePhotoFromUriToUri(Context context, Uri inputUri, Uri outputUri,
            boolean deleteAfterSave) {
        if (inputUri == null || outputUri == null) {
            return false;
        }
        FileOutputStream outputStream = null;
        InputStream inputStream = null;
        try {