58 lines
1.6 KiB
Java
Raw Normal View History

package com.topjohnwu.magisk.module;
import android.content.Context;
2016-09-08 15:47:10 -05:00
import com.topjohnwu.magisk.R;
2016-09-30 03:18:08 +08:00
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.WebRequest;
2016-09-02 13:18:37 -05:00
import java.util.Date;
2016-09-21 11:29:43 +08:00
public class Repo extends BaseModule {
protected String repoName, mLogUrl, mManifestUrl, mZipUrl;
protected Date mLastUpdate;
2016-11-09 00:46:26 +08:00
public Repo(Context context, String name, Date lastUpdate) throws CacheModException {
2016-09-21 11:29:43 +08:00
repoName = name;
mLastUpdate = lastUpdate;
mLogUrl = context.getString(R.string.file_url, repoName, "changelog.txt");
mManifestUrl = context.getString(R.string.file_url, repoName, "module.prop");
mZipUrl = context.getString(R.string.zip_url, repoName);
update();
2016-09-06 16:54:08 -05:00
}
2016-11-09 00:46:26 +08:00
public void update() throws CacheModException {
2016-09-30 03:18:08 +08:00
Logger.dev("Repo: Re-fetch prop " + mId);
2016-09-21 11:29:43 +08:00
String props = WebRequest.makeWebServiceCall(mManifestUrl, WebRequest.GET, true);
String lines[] = props.split("\\n");
parseProps(lines);
2016-09-06 16:54:08 -05:00
}
2016-11-09 00:46:26 +08:00
public void update(Date lastUpdate) throws CacheModException {
2016-09-30 03:18:08 +08:00
Logger.dev("Repo: Old: " + mLastUpdate);
Logger.dev("Repo: New: " + lastUpdate);
2016-11-09 00:46:26 +08:00
if (mIsCacheModule)
throw new CacheModException(mId);
2016-09-21 11:29:43 +08:00
if (lastUpdate.after(mLastUpdate)) {
mLastUpdate = lastUpdate;
update();
}
2016-09-06 16:54:08 -05:00
}
2016-09-21 11:29:43 +08:00
public String getZipUrl() {
2016-09-06 16:54:08 -05:00
return mZipUrl;
}
2016-09-21 11:29:43 +08:00
public String getLogUrl() {
2016-09-13 15:44:07 -05:00
return mLogUrl;
2016-09-06 16:54:08 -05:00
}
2016-09-21 11:29:43 +08:00
public String getManifestUrl() {
2016-09-06 16:54:08 -05:00
return mManifestUrl;
}
2016-09-21 11:29:43 +08:00
public Date getLastUpdate() {
return mLastUpdate;
}
2016-09-06 16:54:08 -05:00
}