add status notice for safe modules

other tweaks

known issues still: local module list doesnt show actions for updates etc, module cache isn't consistently used

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/284/head
androidacy-user 1 year ago
parent 565cc1660f
commit eb838c4147

@ -45,6 +45,7 @@ public class ModuleInfo {
public int maxApi;
// Module status (0 if not from Module Manager)
public int flags;
public boolean safe;
public ModuleInfo(String id) {
this.id = id;
@ -69,6 +70,7 @@ public class ModuleInfo {
this.minApi = moduleInfo.minApi;
this.maxApi = moduleInfo.maxApi;
this.flags = moduleInfo.flags;
this.safe = moduleInfo.safe;
}
public boolean hasFlag(int flag) {

@ -216,6 +216,19 @@ public enum ActionButtonType {
new MaterialAlertDialogBuilder(button.getContext()).setTitle(R.string.warning).setMessage(R.string.warning_message).setPositiveButton(R.string.understand, (v, i) -> {
}).create().show();
}
}, SAFE() {
// SAFE is for modules that the api says are clean. only supported by androidacy currently
@Override
public void update(Chip button, ModuleHolder moduleHolder) {
button.setChipIcon(button.getContext().getDrawable(R.drawable.baseline_verified_user_24));
button.setText(R.string.safe);
}
@Override
public void doAction(Chip button, ModuleHolder moduleHolder) {
new MaterialAlertDialogBuilder(button.getContext()).setTitle(R.string.safe_module).setMessage(R.string.safe_message).setPositiveButton(R.string.understand, (v, i) -> {
}).create().show();
}
};
@DrawableRes

@ -212,6 +212,9 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
if (moduleInfo.donate != null) {
buttonTypeList.add(ActionButtonType.DONATE);
}
if (moduleInfo.safe) {
buttonTypeList.add(ActionButtonType.SAFE);
}
}
public boolean hasUpdate() {

@ -92,6 +92,7 @@ public class RepoData extends XRepo {
supportedProperties.put("repoId", "");
supportedProperties.put("installed", "");
supportedProperties.put("installedVersionCode", "");
supportedProperties.put("safe", "");
} catch (JSONException e) {
Timber.e(e, "Error while setting up supportedProperties");
}
@ -354,6 +355,7 @@ public class RepoData extends XRepo {
// should update (lastUpdate > 15 minutes)
public boolean shouldUpdate() {
Timber.d("Repo " + this.id + " should update check called");
RealmConfiguration realmConfiguration2 = new RealmConfiguration.Builder().name("ReposList.realm").allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build();
Realm realm2 = Realm.getInstance(realmConfiguration2);
ReposList repo = realm2.where(ReposList.class).equalTo("id", this.id).findFirst();
@ -367,8 +369,10 @@ public class RepoData extends XRepo {
long currentTime = System.currentTimeMillis();
long diff = currentTime - lastUpdate;
long diffMinutes = diff / (60 * 1000) % 60;
Timber.d("Repo " + this.id + " updated: " + diffMinutes + " minutes ago");
return diffMinutes > 15;
} else {
Timber.d("Repo " + this.id + " should update could not find repo in database");
return true;
}
}

@ -250,6 +250,15 @@ public class RepoUpdater {
boolean installed = false;
// get module installed version code
int installedVersionCode = 0;
// get safe property. for now, only supported by androidacy repo and they use "vt_status" key
boolean safe = false;
if (this.repoData.getName().equals("Androidacy Modules Repo")) {
if (module.has("vt_status")) {
if (module.getString("vt_status").equals("safe")) {
safe = true;
}
}
}
// insert module to realm
// first create a collection of all the properties
// then insert to realm
@ -279,6 +288,7 @@ public class RepoUpdater {
moduleListCache.setRepoId(repoId);
moduleListCache.setInstalled(installed);
moduleListCache.setInstalledVersionCode(installedVersionCode);
moduleListCache.setSafe(safe);
realm.copyToRealmOrUpdate(moduleListCache);
realm.commitTransaction();
} catch (

@ -34,6 +34,8 @@ public class ModuleListCache extends RealmObject {
private boolean installed;
private int installedVersionCode;
private int lastUpdate;
// androidacy specific, may be added by other repos
private boolean safe;
public ModuleListCache(String id, String name, String version, int versionCode, String author, String description, int minApi, int maxApi, int minMagisk, boolean needRamdisk, String support, String donate, String config, boolean changeBoot, boolean mmtReborn, String repoId, boolean installed, int installedVersionCode, int lastUpdate) {
this.id = id;
@ -55,6 +57,7 @@ public class ModuleListCache extends RealmObject {
this.installed = installed;
this.installedVersionCode = installedVersionCode;
this.lastUpdate = lastUpdate;
this.safe = false;
}
public ModuleListCache() {
@ -229,6 +232,14 @@ public class ModuleListCache extends RealmObject {
this.lastUpdate = lastUpdate;
}
public boolean isSafe() {
return safe;
}
public void setSafe(boolean safe) {
this.safe = safe;
}
private JSONObject toJson() {
JSONObject jsonObject = new JSONObject();
try {

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp"
android:height="24dp" android:autoMirrored="true"
android:tint="?attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24">
<path android:fillColor="@android:color/white" android:pathData="M12,1L3,5v6c0,5.6 3.8,10.7 9,12 5.2,-1.3 9,-6.5 9,-12L21,5l-9,-4zM10,17l-4,-4 1.4,-1.4L10,14.2l6.6,-6.6L18,9l-8,8z"/>
</vector>

@ -359,5 +359,5 @@
<string name="background_update_check_excludes_no_modules">No modules installed on device</string>
<string name="auto_updates_notifs">Notifies when module updates are found</string>
<string name="notification_group_updates">Updates</string>
<string name="low_quality_module_desc">This module has metadata that is either invalid or considered a marker for a low-quality module. Uninstallation is recommended.</string><string name="online">Online</string>
<string name="low_quality_module_desc">This module has metadata that is either invalid or considered a marker for a low-quality module. Uninstallation is recommended.</string><string name="online">Online</string><string name="safe">Safe</string><string name="safe_module">Verified safe module</string><string name="safe_message">This module has been verified by the repository as safe, meaning it passes certain quality and safety thresholds, and is checked for malware.</string>
</resources>

Loading…
Cancel
Save