Improved workaround for Androidacy issue

pull/186/head
Fox2Code 2 years ago
parent 94a0ccabe9
commit 4ba30cfbe4

@ -20,13 +20,14 @@ import java.util.HashMap;
// See https://docs.github.com/en/rest/reference/repos#releases
public class AppUpdateManager {
public static int FLAG_COMPAT_LOW_QUALITY = 0x01;
public static int FLAG_COMPAT_NO_EXT = 0x02;
public static int FLAG_COMPAT_MAGISK_CMD = 0x04;
public static int FLAG_COMPAT_NEED_32BIT = 0x08;
public static int FLAG_COMPAT_MALWARE = 0x10;
public static int FLAG_COMPAT_NO_ANSI = 0x20;
public static int FLAG_COMPAT_FORCE_ANSI = 0x40;
public static final int FLAG_COMPAT_LOW_QUALITY = 0x01;
public static final int FLAG_COMPAT_NO_EXT = 0x02;
public static final int FLAG_COMPAT_MAGISK_CMD = 0x04;
public static final int FLAG_COMPAT_NEED_32BIT = 0x08;
public static final int FLAG_COMPAT_MALWARE = 0x10;
public static final int FLAG_COMPAT_NO_ANSI = 0x20;
public static final int FLAG_COMPAT_FORCE_ANSI = 0x40;
public static final int FLAG_COMPAT_FORCE_HIDE = 0x80;
private static final String TAG = "AppUpdateManager";
private static final AppUpdateManager INSTANCE = new AppUpdateManager();
private static final String RELEASES_API_URL =
@ -209,6 +210,9 @@ public class AppUpdateManager {
case "forceANSI":
value |= FLAG_COMPAT_FORCE_ANSI;
break;
case "forceHide":
value |= FLAG_COMPAT_FORCE_HIDE;
break;
}
}
compatDataId.put(line.substring(0, i), value);
@ -223,4 +227,12 @@ public class AppUpdateManager {
public static int getFlagsForModule(String moduleId) {
return INSTANCE.getCompatibilityFlags(moduleId);
}
public static boolean shouldForceHide(String repoId) {
if (BuildConfig.DEBUG || repoId.startsWith("repo_") ||
repoId.equals("magisk_alt_repo")) return false;
return !repoId.startsWith("repo_") &&
(INSTANCE.getCompatibilityFlags(repoId) &
FLAG_COMPAT_FORCE_HIDE) != 0;
}
}

@ -182,6 +182,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
if (RepoManager.getINSTANCE().getCustomRepoManager().needUpdate()) {
Log.w(TAG, "Need update on create?");
}
AppUpdateManager.getAppUpdateManager().checkUpdateCompat();
RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () ->
progressIndicator.setProgressCompat(
(int) (value * PRECISION), true) :() ->
@ -194,8 +195,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
AppUpdateManager appUpdateManager = AppUpdateManager.getAppUpdateManager();
if (BuildConfig.ENABLE_AUTO_UPDATER && appUpdateManager.checkUpdate(true))
moduleViewListBuilder.addNotification(NotificationType.UPDATE_AVAILABLE);
if (!BuildConfig.ENABLE_AUTO_UPDATER || appUpdateManager.isLastCheckSuccess())
AppUpdateManager.getAppUpdateManager().checkUpdateCompat();
if (max != 0) {
int current = 0;
for (LocalModuleInfo localModuleInfo :

@ -5,6 +5,7 @@ import android.net.Uri;
import androidx.annotation.NonNull;
import com.fox2code.mmm.AppUpdateManager;
import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.R;
@ -38,7 +39,7 @@ public class RepoData extends XRepo {
protected String defaultName, defaultWebsite,
defaultSupport, defaultDonate, defaultSubmitModule;
public String name, website, support, donate, submitModule;
private boolean enabled; // Cache for speed
private boolean forceHide, enabled; // Cache for speed
protected RepoData(String url, File cacheRoot, SharedPreferences cachedPreferences) {
this.url = url;
@ -48,7 +49,8 @@ public class RepoData extends XRepo {
this.metaDataCache = new File(cacheRoot, "modules.json");
this.moduleHashMap = new HashMap<>();
this.defaultName = url; // Set url as default name
this.enabled = !this.isLimited() && MainApplication.getSharedPreferences()
this.forceHide = AppUpdateManager.shouldForceHide(this.id);
this.enabled = (!this.forceHide) && MainApplication.getSharedPreferences()
.getBoolean("pref_" + this.id + "_enabled", this.isEnabledByDefault());
this.defaultWebsite = "https://" + Uri.parse(url).getHost() + "/";
if (!this.cacheRoot.isDirectory()) {
@ -189,13 +191,14 @@ public class RepoData extends XRepo {
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
this.enabled = enabled && !this.forceHide;
MainApplication.getSharedPreferences().edit()
.putBoolean("pref_" + this.getPreferenceId() + "_enabled", enabled).apply();
}
public void updateEnabledState() {
this.enabled = MainApplication.getSharedPreferences()
this.forceHide = AppUpdateManager.shouldForceHide(this.id);
this.enabled = (!this.forceHide) && MainApplication.getSharedPreferences()
.getBoolean("pref_" + this.getPreferenceId() + "_enabled", this.isEnabledByDefault());
}
@ -251,4 +254,8 @@ public class RepoData extends XRepo {
return this.submitModule;
return this.defaultSubmitModule;
}
public final boolean isForceHide() {
return this.forceHide;
}
}

@ -431,7 +431,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
}
private void setRepoData(final RepoData repoData, String preferenceName) {
if (repoData == null) {
if (repoData == null || repoData.isForceHide()) {
hideRepoData(preferenceName);
return;
}

Loading…
Cancel
Save