@@ -196,6 +196,13 @@ else if ((this.srcType == PHOTOLIBRARY) || (this.srcType == SAVEDPHOTOALBUM)) {
196
196
this .getImage (this .srcType , destType );
197
197
}
198
198
}
199
+ catch (IllegalStateException e )
200
+ {
201
+ callbackContext .error (e .getLocalizedMessage ());
202
+ PluginResult r = new PluginResult (PluginResult .Status .ERROR );
203
+ callbackContext .sendPluginResult (r );
204
+ return true ;
205
+ }
199
206
catch (IllegalArgumentException e )
200
207
{
201
208
callbackContext .error ("Illegal Argument Exception" );
@@ -238,7 +245,7 @@ private String getTempDirectoryPath() {
238
245
* @param returnType Set the type of image to return.
239
246
* @param encodingType Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality)
240
247
*/
241
- public void callTakePicture (int returnType , int encodingType ) {
248
+ public void callTakePicture (int returnType , int encodingType ) throws IllegalStateException {
242
249
243
250
// CB-10120: The CAMERA permission does not need to be requested unless it is declared
244
251
// in AndroidManifest.xml. This plugin does not declare it, but others may and so we must
@@ -282,6 +289,12 @@ else if (permission.equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
282
289
}
283
290
284
291
if (saveToPhotoAlbum && !writeExternalPermissionGranted ) {
292
+ // This block only applies for API 24-28
293
+ // because writeExternalPermissionGranted is always true on API 29+
294
+ if (!manifestContainsWriteExternalPermission ) {
295
+ throw new IllegalStateException ("WRITE_EXTERNAL_STORAGE permission not declared in AndroidManifest" );
296
+ }
297
+
285
298
requiredPermissions .add (Manifest .permission .WRITE_EXTERNAL_STORAGE );
286
299
}
287
300
0 commit comments