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

62 lines
1.5 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
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
2016-09-28 21:37:57 +02:00
private String mRemoveFile, mDisableFile, mUpdateFile;
private boolean mEnable, mRemove, mUpdated;
2016-08-29 00:35:07 +02:00
2016-11-08 17:46:26 +01:00
public Module(String path) throws CacheModException {
2016-09-02 20:18:37 +02:00
2016-09-21 05:29:43 +02:00
parseProps(Utils.readFile(path + "/module.prop"));
mRemoveFile = path + "/remove";
mDisableFile = path + "/disable";
2016-09-28 21:37:57 +02:00
mUpdateFile = path + "/update";
if (getId() == null) {
int sep = path.lastIndexOf('/');
setId(path.substring(sep + 1));
}
if (getName() == null)
setName(getId());
2016-09-06 23:54:08 +02:00
Logger.dev("Creating Module, id: " + getId());
2016-09-06 23:54:08 +02:00
2016-10-17 10:07:47 +02:00
mEnable = !Utils.itemExist(mDisableFile);
mRemove = Utils.itemExist(mRemoveFile);
mUpdated = Utils.itemExist(mUpdateFile);
2016-08-17 13:00:55 +02:00
}
public void createDisableFile() {
2016-10-17 10:07:47 +02:00
mEnable = !Utils.createFile(mDisableFile);
}
2016-08-22 19:44:34 +02:00
public void removeDisableFile() {
2016-10-17 10:07:47 +02:00
mEnable = Utils.removeItem(mDisableFile);
}
public boolean isEnabled() {
return mEnable;
}
public void createRemoveFile() {
2016-10-17 10:07:47 +02:00
mRemove = Utils.createFile(mRemoveFile);
}
2016-08-22 19:44:34 +02:00
public void deleteRemoveFile() {
2016-10-17 10:07:47 +02:00
mRemove = !Utils.removeItem(mRemoveFile);
}
public boolean willBeRemoved() {
return mRemove;
}
2016-09-28 21:37:57 +02:00
public boolean isUpdated() {
return mUpdated;
}
2016-08-17 13:00:55 +02:00
}