use of de.robv.android.xposed.installer.util.RootUtil in project XposedInstaller by rovo89.
the class StatusInstallerFragment method onOptionsItemSelected.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()) {
case R.id.reboot:
case R.id.soft_reboot:
case R.id.reboot_recovery:
final RootUtil.RebootMode mode = RootUtil.RebootMode.fromId(item.getItemId());
confirmReboot(mode.titleRes, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
RootUtil.reboot(mode, getActivity());
}
});
return true;
case R.id.dexopt_now:
new MaterialDialog.Builder(getActivity()).title(R.string.dexopt_now).content(R.string.this_may_take_a_while).progress(true, 0).cancelable(false).showListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(final DialogInterface dialog) {
new Thread("dexopt") {
@Override
public void run() {
RootUtil rootUtil = new RootUtil();
if (!rootUtil.startShell()) {
dialog.dismiss();
NavUtil.showMessage(getActivity(), getString(R.string.root_failed));
return;
}
rootUtil.execute("cmd package bg-dexopt-job", null);
dialog.dismiss();
XposedApp.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(getActivity(), R.string.done, Toast.LENGTH_LONG).show();
}
});
}
}.start();
}
}).show();
return true;
case R.id.show_outdated:
mShowOutdated = !item.isChecked();
XposedApp.getPreferences().edit().putBoolean("framework_download_show_outdated", mShowOutdated).apply();
item.setChecked(mShowOutdated);
refreshZipViews(getView());
return true;
}
return super.onOptionsItemSelected(item);
}
use of de.robv.android.xposed.installer.util.RootUtil in project XposedInstaller by rovo89.
the class FlashDirectly method flash.
public void flash(Context context, FlashCallback callback) {
ZipCheckResult zipCheck = openAndCheckZip(callback);
if (zipCheck == null) {
return;
}
// Do additional checks.
ZipFile zip = zipCheck.getZip();
if (!zipCheck.isFlashableInApp()) {
triggerError(callback, FlashCallback.ERROR_NOT_FLASHABLE_IN_APP);
closeSilently(zip);
return;
}
// Extract update-binary.
ZipEntry entry = zip.getEntry("META-INF/com/google/android/update-binary");
File updateBinaryFile = new File(XposedApp.getInstance().getCacheDir(), "update-binary");
try {
AssetUtil.writeStreamToFile(zip.getInputStream(entry), updateBinaryFile, 0700);
} catch (IOException e) {
Log.e(XposedApp.TAG, "Could not extract update-binary", e);
triggerError(callback, FlashCallback.ERROR_INVALID_ZIP);
return;
} finally {
closeSilently(zip);
}
// Execute the flash commands.
RootUtil rootUtil = new RootUtil();
if (!rootUtil.startShell(callback)) {
return;
}
callback.onStarted();
rootUtil.execute("export NO_UIPRINT=1", callback);
if (mSystemless) {
rootUtil.execute("export SYSTEMLESS=1", callback);
}
int result = rootUtil.execute(getShellPath(updateBinaryFile) + " 2 1 " + getShellPath(mZipPath), callback);
if (result != FlashCallback.OK) {
triggerError(callback, result);
return;
}
callback.onDone();
}
use of de.robv.android.xposed.installer.util.RootUtil in project XposedInstaller by rovo89.
the class FlashRecoveryAuto method flash.
@Override
public void flash(Context context, FlashCallback callback) {
ZipCheckResult zipCheck = openAndCheckZip(callback);
if (zipCheck == null) {
return;
} else {
closeSilently(zipCheck.getZip());
}
final String zipName = mZipPath.getName();
String cmd;
// Execute the flash commands.
RootUtil rootUtil = new RootUtil();
if (!rootUtil.startShell(callback)) {
return;
}
callback.onStarted();
// Make sure /cache/recovery/ exists.
if (rootUtil.execute("ls /cache/recovery", null) != 0) {
callback.onLine(context.getString(R.string.file_creating_directory, "/cache/recovery"));
if (rootUtil.executeWithBusybox("mkdir /cache/recovery", callback) != 0) {
callback.onError(FlashCallback.ERROR_GENERIC, context.getString(R.string.file_create_directory_failed, "/cache/recovery"));
return;
}
}
// Copy the ZIP to /cache/recovery/.
callback.onLine(context.getString(R.string.file_copying, zipName));
cmd = "cp -a " + RootUtil.getShellPath(mZipPath) + " /cache/recovery/" + zipName;
if (rootUtil.executeWithBusybox(cmd, callback) != 0) {
callback.onError(FlashCallback.ERROR_GENERIC, context.getString(R.string.file_copy_failed, zipName, "/cache/recovery"));
return;
}
// Write the flashing command to /cache/recovery/command.
callback.onLine(context.getString(R.string.file_writing_recovery_command));
cmd = "echo --update_package=/cache/recovery/" + zipName + " > /cache/recovery/command";
if (rootUtil.execute(cmd, callback) != 0) {
callback.onError(FlashCallback.ERROR_GENERIC, context.getString(R.string.file_writing_recovery_command_failed));
return;
}
callback.onLine(context.getString(R.string.auto_flash_note, zipName));
callback.onDone();
}
Aggregations