Skip to content

Commit 673acb9

Browse files
committed
Refactor: Clear cache on module update
1 parent 9f37e26 commit 673acb9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

app/src/main/java/com/wmods/wppenhacer/xposed/core/devkit/UnobfuscatorCache.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ public UnobfuscatorCache(Application application) {
5656
long version = sPrefsCacheHooks.getLong("version", 0);
5757
long currentVersion = mApplication.getPackageManager().getPackageInfo(mApplication.getPackageName(), 0).getLongVersionCode();
5858
long savedUpdateTime = sPrefsCacheHooks.getLong("updateTime", 0);
59+
String savedVersionName = sPrefsCacheHooks.getString("wae_version_name", "");
60+
String versionName = BuildConfig.VERSION_NAME;
5961
long lastUpdateTime = savedUpdateTime;
6062
try {
6163
lastUpdateTime = mApplication.getPackageManager().getPackageInfo(BuildConfig.APPLICATION_ID, 0).lastUpdateTime;
6264
} catch (Exception ignored) {
6365
}
64-
if (version != currentVersion || savedUpdateTime != lastUpdateTime) {
66+
if (version != currentVersion || savedUpdateTime != lastUpdateTime || !versionName.equals(savedVersionName)) {
6567
Utils.showToast(application.getString(ResId.string.starting_cache), Toast.LENGTH_LONG);
6668
sPrefsCacheHooks.edit().clear().commit();
6769
sPrefsCacheHooks.edit().putLong("version", currentVersion).commit();
6870
sPrefsCacheHooks.edit().putLong("updateTime", lastUpdateTime).commit();
71+
sPrefsCacheHooks.edit().putString("wae_version_name", versionName).commit();
6972
if (version != currentVersion) {
7073
sPrefsCacheStrings.edit().clear().commit();
7174
}
@@ -78,7 +81,8 @@ public UnobfuscatorCache(Application application) {
7881
}
7982

8083
public static void init(Application mApp) {
81-
mInstance = new UnobfuscatorCache(mApp);
84+
if (mInstance == null)
85+
mInstance = new UnobfuscatorCache(mApp);
8286
}
8387

8488
public static UnobfuscatorCache getInstance() {

0 commit comments

Comments
 (0)