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

93 lines
2.0 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 android.util.Log;
2016-08-22 23:18:28 +02:00
import com.topjohnwu.magisk.utils.Utils;
2016-08-17 13:00:55 +02:00
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
public class Module {
private String mRemoveFile;
private String mDisableFile;
2016-08-17 13:00:55 +02:00
private String mName;
private String mVersion;
private String mDescription;
private boolean mEnable;
private boolean mRemove;
2016-08-17 13:00:55 +02:00
public Module(String path) {
mRemoveFile = path + "/remove";
mDisableFile = path + "/disable";
for (String line : Utils.readFile(path + "/module.prop")) {
String[] parts = line.split("=", 2);
if (parts.length != 2) {
continue;
}
String key = parts[0].trim();
if (key.charAt(0) == '#') {
continue;
}
String value = parts[1].trim();
switch (key) {
case "name":
mName = value;
break;
case "version":
mVersion = value;
break;
case "description":
mDescription = value;
break;
}
}
mEnable = !Utils.fileExist(mDisableFile);
mRemove = Utils.fileExist(mRemoveFile);
2016-08-17 13:00:55 +02:00
}
public String getName() {
return mName;
}
public String getVersion() {
return mVersion;
}
public String getDescription() {
return mDescription;
}
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-08-17 13:00:55 +02:00
}