Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): calls re-saved during permission/activity result callbacks were being released #4281

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions android/capacitor/src/main/java/com/getcapacitor/Plugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,16 @@ private void triggerPermissionCallback(Method method, Map<String, Boolean> permi

// validate permissions and invoke the permission result callback
if (bridge.validatePermissions(this, savedCall, permissionResultMap)) {
if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}

try {
method.setAccessible(true);
method.invoke(this, savedCall);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}
}
}

Expand All @@ -159,17 +159,17 @@ private void triggerActivityCallback(Method method, ActivityResult result) {
savedCall = bridge.getPluginCallForLastActivity();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}

// invoke the activity result callback
try {
method.setAccessible(true);
method.invoke(this, savedCall, result);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}

if (!savedCall.isKeptAlive()) {
savedCall.release(bridge);
}
}

/**
Expand Down