Magisk/app/src/main/java/com/topjohnwu/magisk/module/Module.java

89 lines
2.1 KiB
Java
Raw Normal View History

2016-08-22 23:18:28 +02:00
package com.topjohnwu.magisk.module;
2016-08-17 13:00:55 +02:00
2016-09-02 20:18:37 +02:00
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;
import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Logger;
2016-08-22 23:18:28 +02:00
import com.topjohnwu.magisk.utils.Utils;
public class Module extends BaseModule {
2016-08-17 13:00:55 +02:00
private String mRemoveFile;
private String mDisableFile;
2016-08-17 13:00:55 +02:00
private String mZipUrl, mLogUrl;
private boolean mEnable, mRemove, mUpdateAvailable = false;
2016-08-29 00:35:07 +02:00
2016-09-21 05:29:43 +02:00
public Module(Context context, String path) {
2016-09-02 20:18:37 +02:00
2016-09-21 05:29:43 +02:00
super();
parseProps(Utils.readFile(path + "/module.prop"));
mRemoveFile = path + "/remove";
mDisableFile = path + "/disable";
if (mId == null) {
int sep = path.lastIndexOf('/');
mId = path.substring(sep + 1);
}
if (mName == null)
mName = mId;
2016-09-06 23:54:08 +02:00
if (mDescription == null)
mDescription = context.getString(R.string.no_info_provided);
2016-09-06 23:54:08 +02:00
if (mVersion == null)
mVersion = context.getString(R.string.no_info_provided);
Logger.dh("Module id: " + mId);
2016-09-06 23:54:08 +02:00
mEnable = !Utils.itemExist(mDisableFile);
mRemove = Utils.itemExist(mRemoveFile);
2016-08-17 13:00:55 +02:00
}
2016-09-23 11:12:29 +02:00
public void checkUpdate() {
Repo repo = RepoHelper.repoMap.get(mId);
if (repo != null) {
repo.setInstalled();
if (repo.getVersionCode() > mVersionCode) {
repo.setUpdate();
}
}
}
2016-09-13 22:44:07 +02:00
public String getmLogUrl() {return mLogUrl; }
public void createDisableFile() {
mEnable = !Utils.createFile(mDisableFile);
}
2016-08-22 19:44:34 +02:00
public void removeDisableFile() {
mEnable = Utils.removeFile(mDisableFile);
}
public boolean isEnabled() {
return mEnable;
}
public void createRemoveFile() {
mRemove = Utils.createFile(mRemoveFile);
}
2016-08-22 19:44:34 +02:00
public void deleteRemoveFile() {
mRemove = !Utils.removeFile(mRemoveFile);
}
public boolean willBeRemoved() {
return mRemove;
}
2016-09-13 22:44:07 +02:00
public String getmZipUrl() { return mZipUrl; }
public boolean isUpdateAvailable() { return mUpdateAvailable; }
2016-09-06 23:54:08 +02:00
2016-08-17 13:00:55 +02:00
}