Skip to content

Commit

Permalink
fix: works around a permission problem when deleting duplicate images
Browse files Browse the repository at this point in the history
This implementation just swallows the Exception, because we do not want to bother our users with a permission question for each photo we take.
For more information and other approaches refer to apache#679
  • Loading branch information
meidlinga committed Apr 27, 2022
1 parent 4608f8e commit c627d71
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/android/CameraLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.json.JSONArray;
import org.json.JSONException;

import java.lang.SecurityException;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -1239,7 +1240,11 @@ private void checkForDuplicateImage(int type) {
id--;
}
Uri uri = Uri.parse(contentStore + "/" + id);
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
try {
this.cordova.getActivity().getContentResolver().delete(uri, null, null);
} catch (SecurityException e) {
LOG.d(LOG_TAG, "Swallowed error, probably caused by missing permissions, while trying to delete duplicate image.");
}
cursor.close();
}
}
Expand Down

0 comments on commit c627d71

Please sign in to comment.