|
|
@ -22,6 +22,7 @@ import com.fox2code.mmm.R;
|
|
|
|
import com.fox2code.mmm.compat.CompatActivity;
|
|
|
|
import com.fox2code.mmm.compat.CompatActivity;
|
|
|
|
import com.fox2code.mmm.utils.FastException;
|
|
|
|
import com.fox2code.mmm.utils.FastException;
|
|
|
|
import com.fox2code.mmm.utils.Files;
|
|
|
|
import com.fox2code.mmm.utils.Files;
|
|
|
|
|
|
|
|
import com.fox2code.mmm.utils.Hashes;
|
|
|
|
import com.fox2code.mmm.utils.Http;
|
|
|
|
import com.fox2code.mmm.utils.Http;
|
|
|
|
import com.fox2code.mmm.utils.IntentHelper;
|
|
|
|
import com.fox2code.mmm.utils.IntentHelper;
|
|
|
|
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
|
|
|
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
|
|
@ -54,6 +55,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
final Intent intent = this.getIntent();
|
|
|
|
final Intent intent = this.getIntent();
|
|
|
|
final String target;
|
|
|
|
final String target;
|
|
|
|
final String name;
|
|
|
|
final String name;
|
|
|
|
|
|
|
|
final String checksum;
|
|
|
|
final boolean noPatch;
|
|
|
|
final boolean noPatch;
|
|
|
|
final boolean noExtensions;
|
|
|
|
final boolean noExtensions;
|
|
|
|
final boolean rootless;
|
|
|
|
final boolean rootless;
|
|
|
@ -66,6 +68,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
target = intent.getStringExtra(Constants.EXTRA_INSTALL_PATH);
|
|
|
|
target = intent.getStringExtra(Constants.EXTRA_INSTALL_PATH);
|
|
|
|
name = intent.getStringExtra(Constants.EXTRA_INSTALL_NAME);
|
|
|
|
name = intent.getStringExtra(Constants.EXTRA_INSTALL_NAME);
|
|
|
|
|
|
|
|
checksum = intent.getStringExtra(Constants.EXTRA_INSTALL_CHECKSUM);
|
|
|
|
noPatch = intent.getBooleanExtra(Constants.EXTRA_INSTALL_NO_PATCH, false);
|
|
|
|
noPatch = intent.getBooleanExtra(Constants.EXTRA_INSTALL_NO_PATCH, false);
|
|
|
|
noExtensions = intent.getBooleanExtra(// Allow intent to disable extensions
|
|
|
|
noExtensions = intent.getBooleanExtra(// Allow intent to disable extensions
|
|
|
|
Constants.EXTRA_INSTALL_NO_EXTENSIONS, false);
|
|
|
|
Constants.EXTRA_INSTALL_NO_EXTENSIONS, false);
|
|
|
@ -122,6 +125,15 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
this.progressIndicator.setProgressCompat(progress, true);
|
|
|
|
this.progressIndicator.setProgressCompat(progress, true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
if (checksum != null && !checksum.isEmpty()) {
|
|
|
|
|
|
|
|
Log.d(TAG, "Checking for checksum: " + checksum);
|
|
|
|
|
|
|
|
this.installerTerminal.addLine("- Checking file integrity");
|
|
|
|
|
|
|
|
if (!Hashes.checkSumMatch(rawModule, checksum)) {
|
|
|
|
|
|
|
|
this.setInstallStateFinished(false,
|
|
|
|
|
|
|
|
"! File integrity check failed", "");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (noPatch) {
|
|
|
|
if (noPatch) {
|
|
|
|
try (OutputStream outputStream = new FileOutputStream(moduleCache)) {
|
|
|
|
try (OutputStream outputStream = new FileOutputStream(moduleCache)) {
|
|
|
|
outputStream.write(rawModule);
|
|
|
|
outputStream.write(rawModule);
|
|
|
@ -152,13 +164,31 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, "Module download Thread").start();
|
|
|
|
}, "Module download Thread").start();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
final File moduleFile = new File(target);
|
|
|
|
|
|
|
|
if (checksum != null && !checksum.isEmpty()) {
|
|
|
|
|
|
|
|
Log.d(TAG, "Checking for checksum: " + checksum);
|
|
|
|
|
|
|
|
this.installerTerminal.addLine("- Checking file integrity");
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
if (!Hashes.checkSumMatch(Files.readSU(moduleFile), checksum)) {
|
|
|
|
|
|
|
|
this.setInstallStateFinished(false,
|
|
|
|
|
|
|
|
"! File integrity check failed", "");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
Log.e(TAG, "Failed to read file for checksum check", e);
|
|
|
|
|
|
|
|
this.setInstallStateFinished(false,
|
|
|
|
|
|
|
|
"! File integrity check failed", "");
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
this.installerTerminal.addLine("- Installing " + name);
|
|
|
|
this.installerTerminal.addLine("- Installing " + name);
|
|
|
|
new Thread(() -> this.doInstall(
|
|
|
|
new Thread(() -> this.doInstall(
|
|
|
|
this.toDelete = new File(target), noExtensions, rootless),
|
|
|
|
this.toDelete = moduleFile, noExtensions, rootless),
|
|
|
|
"Install Thread").start();
|
|
|
|
"Install Thread").start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doInstall(File file,boolean noExtensions,boolean rootless) {
|
|
|
|
private void doInstall(File file,boolean noExtensions,boolean rootless) {
|
|
|
|
Log.i(TAG, "Installing: " + moduleCache.getName());
|
|
|
|
Log.i(TAG, "Installing: " + moduleCache.getName());
|
|
|
|
InstallerController installerController = new InstallerController(
|
|
|
|
InstallerController installerController = new InstallerController(
|
|
|
|