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

67 lines
1.6 KiB
Java
Raw Normal View History

2017-09-29 21:04:23 +02:00
package com.topjohnwu.magisk.container;
2016-08-17 13:00:55 +02:00
2017-07-15 19:20:39 +02:00
import com.topjohnwu.magisk.utils.Shell;
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
2017-09-30 19:38:25 +02:00
public Module(Shell shell, String path) {
2016-09-02 20:18:37 +02:00
try {
parseProps(Utils.readFile(shell, path + "/module.prop"));
} catch (NumberFormatException ignored) {}
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
2017-07-15 19:20:39 +02:00
mEnable = !Utils.itemExist(shell, mDisableFile);
mRemove = Utils.itemExist(shell, mRemoveFile);
mUpdated = Utils.itemExist(shell, mUpdateFile);
2016-08-17 13:00:55 +02:00
}
2017-07-15 19:20:39 +02:00
public void createDisableFile(Shell shell) {
mEnable = false;
2017-07-15 19:20:39 +02:00
Utils.createFile(shell, mDisableFile);
}
2017-07-15 19:20:39 +02:00
public void removeDisableFile(Shell shell) {
mEnable = true;
2017-07-15 19:20:39 +02:00
Utils.removeItem(shell, mDisableFile);
}
public boolean isEnabled() {
return mEnable;
}
2017-07-15 19:20:39 +02:00
public void createRemoveFile(Shell shell) {
mRemove = true;
2017-07-15 19:20:39 +02:00
Utils.createFile(shell, mRemoveFile);
}
2017-07-15 19:20:39 +02:00
public void deleteRemoveFile(Shell shell) {
mRemove = false;
2017-07-15 19:20:39 +02:00
Utils.removeItem(shell, 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
}