Skip to content

Commit 291a878

Browse files
committed
Properly clear the label cache when changing isMultiUser setting
1 parent 6e17e17 commit 291a878

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public final class Api {
169169
public static final int NOTIFICATION_ID = 1;
170170
public static final String PREF_FIREWALL_STATUS = "AFWallStaus";
171171
public static final String DEFAULT_PREFS_NAME = "AFWallPrefs";
172+
public static final String CACHE_PREFS_NAME = "AFWallCache";
172173
//for import/export rules
173174
//revertback to old approach for performance
174175
public static final String PREF_3G_PKG_UIDS = "AllowedPKG3G_UIDS";
@@ -1396,8 +1397,7 @@ public static List<PackageInfoData> getApps(Context ctx, GetAppList appList) {
13961397
}
13971398
//revert back to old approach
13981399

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

14021402
int count = 0;
14031403
try {

app/src/main/java/dev/ukanth/ufirewall/preferences/ExpPreferenceFragment.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.app.Activity;
88
import android.content.Context;
99
import android.content.SharedPreferences;
10+
import android.content.SharedPreferences.Editor;
1011
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
1112
import android.content.pm.PackageManager;
1213
import android.content.pm.PackageManager.NameNotFoundException;
@@ -149,6 +150,11 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
149150
} else {
150151
Api.setUserOwner(this.getActivity().getApplicationContext());
151152
}
153+
final Context ctx = getActivity().getApplicationContext();
154+
SharedPreferences cachePrefs = ctx.getSharedPreferences(Api.CACHE_PREFS_NAME, Context.MODE_PRIVATE);
155+
Editor edit = cachePrefs.edit();
156+
edit.clear();
157+
edit.apply();
152158
}
153159
}
154160

0 commit comments

Comments
 (0)