Officially drop Cache Modules

This commit is contained in:
topjohnwu
2016-11-09 00:46:26 +08:00
parent 436b0624e7
commit aababe1a87
6 changed files with 53 additions and 56 deletions
@@ -1,6 +1,8 @@
package com.topjohnwu.magisk.module;
import com.topjohnwu.magisk.utils.Logger;
import java.util.List;
public abstract class BaseModule {
@@ -9,9 +11,9 @@ public abstract class BaseModule {
protected boolean mIsCacheModule = false;
protected int mVersionCode = 0;
protected void parseProps(List<String> props) { parseProps(props.toArray(new String[props.size()])); }
protected void parseProps(List<String> props) throws CacheModException { parseProps(props.toArray(new String[props.size()])); }
protected void parseProps(String[] props) {
protected void parseProps(String[] props) throws CacheModException {
for (String line : props) {
String[] prop = line.split("=", 2);
if (prop.length != 2) {
@@ -34,7 +36,9 @@ public abstract class BaseModule {
this.mVersion = prop[1];
break;
case "versionCode":
this.mVersionCode = Integer.parseInt(prop[1]);
try {
this.mVersionCode = Integer.parseInt(prop[1]);
} catch (NumberFormatException ignored) {}
break;
case "author":
this.mAuthor = prop[1];
@@ -55,6 +59,8 @@ public abstract class BaseModule {
break;
}
}
if (mIsCacheModule)
throw new CacheModException(mId);
}
public String getName() {
@@ -75,14 +81,6 @@ public abstract class BaseModule {
return mDescription;
}
public boolean isCache() {
return mIsCacheModule;
}
public void setCache() {
mIsCacheModule = true;
}
public int getVersionCode() {
return mVersionCode;
}
@@ -94,4 +92,10 @@ public abstract class BaseModule {
public String getSupportUrl() {
return mSupportUrl;
}
public static class CacheModException extends Exception {
public CacheModException(String id) {
Logger.dev("Cache mods are no longer supported! id: " + id);
}
}
}
@@ -8,7 +8,7 @@ public class Module extends BaseModule {
private String mRemoveFile, mDisableFile, mUpdateFile;
private boolean mEnable, mRemove, mUpdated;
public Module(String path) {
public Module(String path) throws CacheModException {
parseProps(Utils.readFile(path + "/module.prop"));
@@ -12,7 +12,7 @@ public class Repo extends BaseModule {
protected String repoName, mLogUrl, mManifestUrl, mZipUrl;
protected Date mLastUpdate;
public Repo(Context context, String name, Date lastUpdate) {
public Repo(Context context, String name, Date lastUpdate) throws CacheModException {
repoName = name;
mLastUpdate = lastUpdate;
mLogUrl = context.getString(R.string.file_url, repoName, "changelog.txt");
@@ -21,16 +21,18 @@ public class Repo extends BaseModule {
update();
}
public void update() {
public void update() throws CacheModException {
Logger.dev("Repo: Re-fetch prop " + mId);
String props = WebRequest.makeWebServiceCall(mManifestUrl, WebRequest.GET, true);
String lines[] = props.split("\\n");
parseProps(lines);
}
public void update(Date lastUpdate) {
public void update(Date lastUpdate) throws CacheModException {
Logger.dev("Repo: Old: " + mLastUpdate);
Logger.dev("Repo: New: " + lastUpdate);
if (mIsCacheModule)
throw new CacheModException(mId);
if (lastUpdate.after(mLastUpdate)) {
mLastUpdate = lastUpdate;
update();