Skip to content

Commit 90bd57e

Browse files
lColinDldaum
andauthored
Return error if permissions are denied (NGhebreial#29)
Co-authored-by: daum <colin.daum@apirious.com>
1 parent 29b4f1c commit 90bd57e

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

android/src/main/java/io/flutter/plugins/flutterexifrotation/FlutterExifRotationPlugin.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,24 @@ public void onMethodCall(MethodCall call, Result result) {
8989
@Override
9090
public boolean onRequestPermissionsResult(
9191
int requestCode, String[] permissions, int[] grantResults) {
92-
boolean permissionGranted =
93-
grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
94-
switch (requestCode) {
95-
case REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION:
92+
if (requestCode == REQUEST_EXTERNAL_IMAGE_STORAGE_PERMISSION) {
93+
boolean permissionGranted =
94+
grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED;
95+
96+
if (this.call != null && this.result != null) {
9697
if (permissionGranted) {
97-
if (this.call != null)
98-
launchRotateImage();
99-
return true;
98+
launchRotateImage();
99+
} else {
100+
result.error("error", "PERMISSION_DENIED", null);
101+
call = null;
102+
result = null;
100103
}
101-
break;
102-
103-
default:
104-
return false;
105-
}
104+
}
106105

107-
if (!permissionGranted) {
106+
return true;
107+
} else {
108108
return false;
109109
}
110-
111-
return true;
112110
}
113111

114112

@@ -179,6 +177,9 @@ public void launchRotateImage() {
179177
} catch (IOException e) {
180178
result.error("error", "IOexception", null);
181179
e.printStackTrace();
180+
} finally {
181+
call = null;
182+
result = null;
182183
}
183184

184185
}

0 commit comments

Comments
 (0)