Skip to content

Commit a1fe38b

Browse files
authored
Merge pull request #1401 from Fry-kun/export-fix
When exporting rules, only export the types of rules that were actual…
2 parents ba86d7f + e758974 commit a1fe38b

File tree

1 file changed

+13
-14
lines changed
  • app/src/main/java/dev/ukanth/ufirewall

1 file changed

+13
-14
lines changed

app/src/main/java/dev/ukanth/ufirewall/Api.java

+13-14
Original file line numberDiff line numberDiff line change
@@ -2332,7 +2332,10 @@ public static void exportAllPreferencesToFileConfirm(final Context ctx) {
23322332
}
23332333
}
23342334

2335-
private static void updateExportPackage(Map<String, JSONObject> exportMap, String packageName, int identifier) throws JSONException {
2335+
private static void updateExportPackage(Map<String, JSONObject> exportMap, String packageName, boolean isChecked, int identifier) throws JSONException {
2336+
if (!isChecked) {
2337+
return;
2338+
}
23362339
JSONObject obj;
23372340
if (packageName != null) {
23382341
if (exportMap.containsKey(packageName)) {
@@ -2344,16 +2347,15 @@ private static void updateExportPackage(Map<String, JSONObject> exportMap, Strin
23442347
exportMap.put(packageName, obj);
23452348
}
23462349
}
2347-
23482350
}
23492351

23502352
private static void updatePackage(Context ctx, String savedPkg_uid, Map<String, JSONObject> exportMap, int identifier) throws JSONException {
23512353
StringTokenizer tok = new StringTokenizer(savedPkg_uid, "|");
23522354
while (tok.hasMoreTokens()) {
23532355
String uid = tok.nextToken();
2354-
if (!uid.equals("")) {
2356+
if (!uid.isEmpty()) {
23552357
String packageName = ctx.getPackageManager().getNameForUid(Integer.parseInt(uid));
2356-
updateExportPackage(exportMap, packageName, identifier);
2358+
updateExportPackage(exportMap, packageName, /*is_checked=*/ true, identifier);
23572359
}
23582360
}
23592361
}
@@ -2364,16 +2366,13 @@ private static Map<String, JSONObject> getCurrentRulesAsMap(Context ctx) {
23642366

23652367
try {
23662368
for (PackageInfoData app : apps) {
2367-
if (app.selected_wifi || app.selected_3g || app.selected_roam || app.selected_vpn ||
2368-
app.selected_tether || app.selected_lan || app.selected_tor) {
2369-
updateExportPackage(exportMap, app.pkgName, WIFI_EXPORT);
2370-
updateExportPackage(exportMap, app.pkgName, DATA_EXPORT);
2371-
updateExportPackage(exportMap, app.pkgName, ROAM_EXPORT);
2372-
updateExportPackage(exportMap, app.pkgName, VPN_EXPORT);
2373-
updateExportPackage(exportMap, app.pkgName, TETHER_EXPORT);
2374-
updateExportPackage(exportMap, app.pkgName, LAN_EXPORT);
2375-
updateExportPackage(exportMap, app.pkgName, TOR_EXPORT);
2376-
}
2369+
updateExportPackage(exportMap, app.pkgName, app.selected_wifi, WIFI_EXPORT);
2370+
updateExportPackage(exportMap, app.pkgName, app.selected_3g, DATA_EXPORT);
2371+
updateExportPackage(exportMap, app.pkgName, app.selected_roam, ROAM_EXPORT);
2372+
updateExportPackage(exportMap, app.pkgName, app.selected_vpn, VPN_EXPORT);
2373+
updateExportPackage(exportMap, app.pkgName, app.selected_tether, TETHER_EXPORT);
2374+
updateExportPackage(exportMap, app.pkgName, app.selected_lan, LAN_EXPORT);
2375+
updateExportPackage(exportMap, app.pkgName, app.selected_tor, TOR_EXPORT);
23772376
}
23782377
} catch (JSONException e) {
23792378
Log.e(TAG, e.getLocalizedMessage());

0 commit comments

Comments
 (0)