Skip to content

Commit

Permalink
Fix: #970 revert to old logic to check root during apply.
Browse files Browse the repository at this point in the history
  • Loading branch information
ukanth committed Jun 12, 2019
1 parent 3384d68 commit 1d9cc72
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions aFWall/src/main/java/dev/ukanth/ufirewall/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2277,39 +2277,42 @@ protected void onPreExecute() {
@Override
protected Boolean doInBackground(Void... params) {
//set the progress
if (!Shell.SU.available()) return false;

Api.setRulesUpToDate(false);
Api.applySavedIptablesRules(getApplicationContext(), true, new RootCommand()
.setSuccessToast(R.string.rules_applied)
.setFailureToast(R.string.error_apply)
.setReopenShell(true)
.setCallback(new RootCommand.Callback() {
public void cbFunc(RootCommand state) {
try {
if (runProgress != null) {
runProgress.dismiss();
if (G.hasRoot() && Shell.SU.available()) {
Api.setRulesUpToDate(false);
Api.applySavedIptablesRules(getApplicationContext(), true, new RootCommand()
.setSuccessToast(R.string.rules_applied)
.setFailureToast(R.string.error_apply)
.setReopenShell(true)
.setCallback(new RootCommand.Callback() {
public void cbFunc(RootCommand state) {
try {
if (runProgress != null) {
runProgress.dismiss();
}
} catch (Exception ex) {
}
} catch (Exception ex) {
}
if (state.exitCode == 0) {
setDirty(false);
}
//queue.clear();
runOnUiThread(() -> {
setDirty(false);
if (state.exitCode != 0) {
Api.errorNotification(ctx);
menuSetApplyOrSave(MainActivity.this.mainMenu, false);
Api.setEnabled(ctx, false, true);
} else {
menuSetApplyOrSave(MainActivity.this.mainMenu, enabled);
Api.setEnabled(ctx, enabled, true);
if (state.exitCode == 0) {
setDirty(false);
}
});
}
}));
return true;
//queue.clear();
runOnUiThread(() -> {
setDirty(false);
if (state.exitCode != 0) {
Api.errorNotification(ctx);
menuSetApplyOrSave(MainActivity.this.mainMenu, false);
Api.setEnabled(ctx, false, true);
} else {
menuSetApplyOrSave(MainActivity.this.mainMenu, enabled);
Api.setEnabled(ctx, enabled, true);
}
});
}
}));
return true;
} else {
return false;
}

}

@Override
Expand Down

0 comments on commit 1d9cc72

Please sign in to comment.