Skip to content

Commit

Permalink
[profile] add rule api opt, make callback nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed Feb 27, 2023
1 parent 9e8d6b2 commit e3a85b9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import github.tornaco.android.thanos.core.alarm.Alarm;
import github.tornaco.android.thanos.core.alarm.AlarmRecord;
import github.tornaco.android.thanos.core.annotation.Nullable;
import github.tornaco.android.thanos.core.pm.Pkg;
import lombok.SneakyThrows;

Expand Down Expand Up @@ -36,18 +37,45 @@ public boolean isAutoApplyForNewInstalledAppsEnabled() {
}

@SneakyThrows
public void addRule(String author, int versionCode, String ruleString, RuleAddCallback callback, int format) {
server.addRule(author, versionCode, ruleString, callback.getStub(), format);
public void addRule(String author, int versionCode, String ruleString, @Nullable RuleAddCallback callback, int format) {
RuleAddCallback fallbackCallback = callback;
if (fallbackCallback == null) {
fallbackCallback = new RuleAddCallback();
}
server.addRule(author, versionCode, ruleString, fallbackCallback.getStub(), format);
}

@SneakyThrows
public void updateRule(int ruleId, String ruleJson, RuleAddCallback callback, int format) {
server.updateRule(ruleId, ruleJson, callback.getStub(), format);
public void addRule(String author, int versionCode, String ruleString, int format) {
addRule(author, versionCode, ruleString, null, format);
}

@SneakyThrows
public void addRuleIfNotExists(String author, int versionCode, String ruleString, RuleAddCallback callback, int format) {
server.addRuleIfNotExists(author, versionCode, ruleString, callback.getStub(), format);
public void updateRule(int ruleId, String ruleJson, int format) {
updateRule(ruleId, ruleJson, null, format);
}

@SneakyThrows
public void updateRule(int ruleId, String ruleJson, @Nullable RuleAddCallback callback, int format) {
RuleAddCallback fallbackCallback = callback;
if (fallbackCallback == null) {
fallbackCallback = new RuleAddCallback();
}
server.updateRule(ruleId, ruleJson, fallbackCallback.getStub(), format);
}

@SneakyThrows
public void addRuleIfNotExists(String author, int versionCode, String ruleString, @Nullable RuleAddCallback callback, int format) {
RuleAddCallback fallbackCallback = callback;
if (fallbackCallback == null) {
fallbackCallback = new RuleAddCallback();
}
server.addRuleIfNotExists(author, versionCode, ruleString, fallbackCallback.getStub(), format);
}

@SneakyThrows
public void addRuleIfNotExists(String author, int versionCode, String ruleString, int format) {
addRuleIfNotExists(author, versionCode, ruleString, null, format);
}

@SneakyThrows
Expand Down
2 changes: 1 addition & 1 deletion android/internal/Thanox-Internal

0 comments on commit e3a85b9

Please sign in to comment.