Skip to content

Commit

Permalink
Properly clear the label cache when changing isMultiUser setting
Browse files Browse the repository at this point in the history
  • Loading branch information
infinity0 committed Aug 29, 2023
1 parent 0211125 commit 32e72dd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/dev/ukanth/ufirewall/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public final class Api {
public static final int NOTIFICATION_ID = 1;
public static final String PREF_FIREWALL_STATUS = "AFWallStaus";
public static final String DEFAULT_PREFS_NAME = "AFWallPrefs";
public static final String CACHE_PREFS_NAME = "AFWallCache";
//for import/export rules
//revertback to old approach for performance
public static final String PREF_3G_PKG_UIDS = "AllowedPKG3G_UIDS";
Expand Down Expand Up @@ -1396,8 +1397,7 @@ public static List<PackageInfoData> getApps(Context ctx, GetAppList appList) {
}
//revert back to old approach

//always use the defaul preferences to store cache value - reduces the application usage size
SharedPreferences cachePrefs = ctx.getSharedPreferences(DEFAULT_PREFS_NAME, Context.MODE_PRIVATE);
SharedPreferences cachePrefs = ctx.getSharedPreferences(CACHE_PREFS_NAME, Context.MODE_PRIVATE);

int count = 0;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
Expand Down Expand Up @@ -149,6 +150,11 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
} else {
Api.setUserOwner(this.getActivity().getApplicationContext());
}
final Context ctx = getActivity().getApplicationContext();
SharedPreferences cachePrefs = ctx.getSharedPreferences(Api.CACHE_PREFS_NAME, Context.MODE_PRIVATE);
Editor edit = cachePrefs.edit();
edit.clear();
edit.apply();
}
}

Expand Down

0 comments on commit 32e72dd

Please sign in to comment.