Skip to content

Commit

Permalink
fix(android): fall through request permissions (#11563)
Browse files Browse the repository at this point in the history
Fixes TIMOB-27741
  • Loading branch information
garymathews committed Apr 9, 2020
1 parent 8e3ce4d commit 7bede6f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.ArrayList;

import android.provider.CalendarContract;

import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollModule;
import org.appcelerator.kroll.annotations.Kroll;
Expand Down Expand Up @@ -127,6 +129,9 @@ public boolean hasCalendarPermissions()
public void requestCalendarPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasCalendarPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public boolean hasContactsPermissions()
public void requestContactsPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasContactsPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import org.appcelerator.kroll.KrollDict;
import org.appcelerator.kroll.KrollFunction;
import org.appcelerator.kroll.KrollInvocation;
import org.appcelerator.kroll.KrollModule;
Expand Down Expand Up @@ -111,6 +112,9 @@ private boolean hasStoragePermissions()
public void requestStoragePermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasStoragePermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,9 @@ public void showCamera(@SuppressWarnings("rawtypes") HashMap options)
public void requestCameraPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasCameraPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}

Expand All @@ -565,6 +568,9 @@ public void requestCameraPermissions(@Kroll.argument(optional = true) KrollFunct
public void requestAudioRecorderPermissions(@Kroll.argument(optional = true) KrollFunction permissionCallback)
{
if (hasAudioRecorderPermissions()) {
KrollDict response = new KrollDict();
response.putCodeAndMessage(0, null);
permissionCallback.callAsync(getKrollObject(), response);
return;
}
String[] permissions = new String[] { Manifest.permission.RECORD_AUDIO };
Expand Down

0 comments on commit 7bede6f

Please sign in to comment.