56 lines
1.5 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.WebService;
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 {
2016-11-13 03:07:16 +08:00
private String mLogUrl, mManifestUrl, mZipUrl;
private Date mLastUpdate;
2016-09-21 11:29:43 +08:00
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
mLastUpdate = lastUpdate;
2016-11-13 03:07:16 +08:00
mLogUrl = context.getString(R.string.file_url, name, "changelog.txt");
mManifestUrl = context.getString(R.string.file_url, name, "module.prop");
mZipUrl = context.getString(R.string.zip_url, name);
2016-09-21 11:29:43 +08:00
update();
2016-09-06 16:54:08 -05:00
}
2016-11-09 00:46:26 +08:00
public void update() throws CacheModException {
2016-11-13 03:07:16 +08:00
Logger.dev("Repo: Re-fetch prop");
String props = WebService.request(mManifestUrl, WebService.GET, true);
2016-09-21 11:29:43 +08:00
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 {
2017-02-12 20:53:41 +08:00
Logger.dev("Repo: Old: " + mLastUpdate + " 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
}