2017-09-29 21:04:23 +02:00
|
|
|
package com.topjohnwu.magisk.container;
|
2016-08-17 13:00:55 +02:00
|
|
|
|
2018-02-12 16:07:35 +01:00
|
|
|
import com.topjohnwu.superuser.Shell;
|
|
|
|
import com.topjohnwu.superuser.io.SuFile;
|
|
|
|
|
2016-09-19 05:47:52 +02:00
|
|
|
public class Module extends BaseModule {
|
2016-08-17 13:00:55 +02:00
|
|
|
|
2018-02-12 16:07:35 +01:00
|
|
|
private SuFile mRemoveFile, mDisableFile, mUpdateFile;
|
2016-09-28 21:37:57 +02:00
|
|
|
private boolean mEnable, mRemove, mUpdated;
|
2016-08-29 00:35:07 +02:00
|
|
|
|
2017-10-15 17:02:44 +02:00
|
|
|
public Module(String path) {
|
2016-09-02 20:18:37 +02:00
|
|
|
|
2017-10-13 20:51:42 +02:00
|
|
|
try {
|
2018-05-05 20:51:23 +02:00
|
|
|
parseProps(Shell.Sync.su("dos2unix < " + path + "/module.prop"));
|
2017-10-13 20:51:42 +02:00
|
|
|
} catch (NumberFormatException ignored) {}
|
2016-09-19 05:47:52 +02:00
|
|
|
|
2018-06-19 22:43:03 +02:00
|
|
|
mRemoveFile = new SuFile(path + "/remove");
|
|
|
|
mDisableFile = new SuFile(path + "/disable");
|
|
|
|
mUpdateFile = new SuFile(path + "/update");
|
2016-08-24 23:58:15 +02:00
|
|
|
|
2017-02-19 01:05:16 +01:00
|
|
|
if (getId() == null) {
|
2016-09-19 05:47:52 +02:00
|
|
|
int sep = path.lastIndexOf('/');
|
2017-02-19 01:05:16 +01:00
|
|
|
setId(path.substring(sep + 1));
|
2016-09-19 05:47:52 +02:00
|
|
|
}
|
2016-08-24 23:58:15 +02:00
|
|
|
|
2017-02-20 20:30:37 +01:00
|
|
|
if (getName() == null) {
|
2017-02-19 01:05:16 +01:00
|
|
|
setName(getId());
|
2017-02-20 20:30:37 +01:00
|
|
|
}
|
2016-09-06 23:54:08 +02:00
|
|
|
|
2018-02-12 16:07:35 +01:00
|
|
|
mEnable = !mDisableFile.exists();
|
|
|
|
mRemove = mRemoveFile.exists();
|
|
|
|
mUpdated = mUpdateFile.exists();
|
2016-08-17 13:00:55 +02:00
|
|
|
}
|
|
|
|
|
2017-10-15 17:02:44 +02:00
|
|
|
public void createDisableFile() {
|
2017-06-05 21:06:23 +02:00
|
|
|
mEnable = false;
|
2018-06-19 22:43:03 +02:00
|
|
|
mDisableFile.createNewFile();
|
2016-08-22 12:30:13 +02:00
|
|
|
}
|
|
|
|
|
2017-10-15 17:02:44 +02:00
|
|
|
public void removeDisableFile() {
|
2017-06-05 21:06:23 +02:00
|
|
|
mEnable = true;
|
2018-02-12 16:07:35 +01:00
|
|
|
mDisableFile.delete();
|
2016-08-22 12:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isEnabled() {
|
2016-08-24 23:58:15 +02:00
|
|
|
return mEnable;
|
2016-08-22 12:30:13 +02:00
|
|
|
}
|
|
|
|
|
2017-10-15 17:02:44 +02:00
|
|
|
public void createRemoveFile() {
|
2017-06-05 21:06:23 +02:00
|
|
|
mRemove = true;
|
2018-06-19 22:43:03 +02:00
|
|
|
mRemoveFile.createNewFile();
|
2016-08-21 16:08:45 +02:00
|
|
|
}
|
|
|
|
|
2017-10-15 17:02:44 +02:00
|
|
|
public void deleteRemoveFile() {
|
2017-06-05 21:06:23 +02:00
|
|
|
mRemove = false;
|
2018-02-12 16:07:35 +01:00
|
|
|
mRemoveFile.delete();
|
2016-08-22 12:30:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean willBeRemoved() {
|
2016-08-24 23:58:15 +02:00
|
|
|
return mRemove;
|
2016-08-21 16:08:45 +02:00
|
|
|
}
|
|
|
|
|
2016-09-28 21:37:57 +02:00
|
|
|
public boolean isUpdated() {
|
|
|
|
return mUpdated;
|
|
|
|
}
|
|
|
|
|
2016-08-17 13:00:55 +02:00
|
|
|
}
|