Add recommended KEEPVERITY and KEEPFORCEENCRYPT flags

This commit is contained in:
topjohnwu 2017-12-21 15:41:34 +08:00
parent 9a6d1bd700
commit 75532ef591
34 changed files with 66 additions and 69 deletions

View File

@ -109,19 +109,16 @@ public class FlashActivity extends Activity {
Intent intent = getIntent();
Uri uri = intent.getData();
boolean keepEnc = intent.getBooleanExtra(Const.Key.FLASH_SET_ENC, false);
boolean keepVerity = intent.getBooleanExtra(Const.Key.FLASH_SET_VERITY, false);
switch (intent.getStringExtra(Const.Key.FLASH_ACTION)) {
case Const.Value.FLASH_ZIP:
new FlashZip(this, uri, console, logs).exec();
break;
case Const.Value.PATCH_BOOT:
new InstallMagisk(this, console, logs, uri, keepEnc, keepVerity, (Uri) intent.getParcelableExtra(Const.Key.FLASH_SET_BOOT))
new InstallMagisk(this, console, logs, uri, (Uri) intent.getParcelableExtra(Const.Key.FLASH_SET_BOOT))
.exec();
break;
case Const.Value.FLASH_MAGISK:
new InstallMagisk(this, console, logs, uri, keepEnc, keepVerity, intent.getStringExtra(Const.Key.FLASH_SET_BOOT))
new InstallMagisk(this, console, logs, uri, intent.getStringExtra(Const.Key.FLASH_SET_BOOT))
.exec();
break;
}

View File

@ -117,8 +117,7 @@ public class MagiskFragment extends Fragment
}
((NotificationManager) mm.getSystemService(Context.NOTIFICATION_SERVICE)).cancelAll();
ShowUI.magiskInstallDialog(getActivity(),
keepEncChkbox.isChecked(), keepVerityChkbox.isChecked());
ShowUI.magiskInstallDialog(getActivity());
}
@OnClick(R.id.uninstall_button)
@ -139,7 +138,13 @@ public class MagiskFragment extends Fragment
setupExpandable();
keepVerityChkbox.setChecked(mm.keepVerity);
keepVerityChkbox.setOnCheckedChangeListener((view, isChecked) -> {
mm.keepVerity = isChecked;
});
keepEncChkbox.setChecked(mm.keepEnc);
keepEncChkbox.setOnCheckedChangeListener((view, isChecked) -> {
mm.keepEnc = isChecked;
});
mSwipeRefreshLayout.setOnRefreshListener(this);
updateUI();

View File

@ -50,8 +50,8 @@ public class MagiskManager extends Application {
public String managerLink;
public String bootBlock = null;
public int snetVersion;
public boolean keepVerity;
public boolean keepEnc;
public boolean keepVerity = false;
public boolean keepEnc = false;
// Data
public Map<String, Module> moduleMap;
@ -186,22 +186,33 @@ public class MagiskManager extends Application {
magiskHide = true;
}
ret = Shell.su("echo \"$BOOTIMAGE\"");
if (Utils.isValidShellResponse(ret))
bootBlock = ret.get(0);
ret = Shell.su("echo \"$DTBOIMAGE\"");
if (Utils.isValidShellResponse(ret))
keepVerity = true;
ret = Shell.su(
"getvar KEEPVERITY",
"echo $KEEPVERITY");
try {
keepVerity = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0));
} catch (NumberFormatException e) {
keepVerity = false;
}
if (Utils.isValidShellResponse(ret))
keepVerity = Boolean.parseBoolean(ret.get(0));
} catch (NumberFormatException ignored) {}
ret = Shell.sh("getprop ro.crypto.state");
if (Utils.isValidShellResponse(ret) && ret.get(0).equals("encrypted"))
keepEnc = true;
ret = Shell.su(
"getvar KEEPFORCEENCRYPT",
"echo $KEEPFORCEENCRYPT");
try {
keepEnc = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0));
} catch (NumberFormatException e) {
keepEnc = false;
}
if (Utils.isValidShellResponse(ret))
keepEnc = Boolean.parseBoolean(ret.get(0));
} catch (NumberFormatException ignored) {}
if (suDB != null && !SuDatabaseHelper.verified) {
suDB.close();

View File

@ -62,11 +62,6 @@ public class SplashActivity extends Activity {
// Magisk working as expected
if (Shell.rootAccess() && mm.magiskVersionCode > 0) {
List<String> ret = Shell.su("echo \"$BOOTIMAGE\"");
if (Utils.isValidShellResponse(ret)) {
mm.bootBlock = ret.get(0);
}
// Add update checking service
if (Const.Value.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) {
ComponentName service = new ComponentName(this, UpdateCheckService.class);

View File

@ -40,26 +40,23 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
private Uri mBootImg, mZip;
private List<String> console, logs;
private String mBootLocation;
private boolean mKeepEnc, mKeepVerity;
private int mode;
private InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity) {
private InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip) {
super(context);
this.console = console;
this.logs = logs;
mZip = zip;
mKeepEnc = enc;
mKeepVerity = verity;
}
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity, Uri boot) {
this(context, console, logs, zip, enc, verity);
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, Uri boot) {
this(context, console, logs, zip);
mBootImg = boot;
mode = PATCH_MODE;
}
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, boolean enc, boolean verity, String boot) {
this(context, console, logs, zip, enc, verity);
public InstallMagisk(Activity context, List<String> console, List<String> logs, Uri zip, String boot) {
this(context, console, logs, zip);
mBootLocation = boot;
mode = DIRECT_MODE;
}
@ -190,7 +187,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
"cd " + install,
Utils.fmt("KEEPFORCEENCRYPT=%b KEEPVERITY=%b HIGHCOMP=%b " +
"sh update-binary indep boot_patch.sh %s || echo 'Failed!'",
mKeepEnc, mKeepVerity, highCompression, boot));
mm.keepEnc, mm.keepVerity, highCompression, boot));
if (TextUtils.equals(console.get(console.size() - 1), "Failed!"))
return false;
@ -250,7 +247,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
Utils.fmt("cp -af %s/* %s; rm -rf %s", install, binPath, install),
Utils.fmt("flash_boot_image %s %s", patched_boot, mBootLocation),
mm.remoteMagiskVersionCode >= 1464 ? "[ -L /data/magisk.img ] || cp /data/magisk.img /data/adb/magisk.img" : "",
"patch_dtbo_image");
mm.keepVerity ? "" : "patch_dtbo_image");
break;
default:
return false;

View File

@ -112,9 +112,6 @@ public class Const {
public static final String INTENT_PERM = "perm_dialog";
public static final String FLASH_ACTION = "action";
public static final String FLASH_SET_BOOT = "boot";
public static final String FLASH_SET_ENC = "enc";
public static final String FLASH_SET_VERITY = "verity";
// others
public static final String UPDATE_NOTIFICATION = "notification";

View File

@ -94,6 +94,7 @@ public class Shell {
"export PATH=" + bbpath + ":$PATH",
"mount_partitions",
"find_boot_image",
"find_dtbo_image",
"migrate_boot_backup");
}
}

View File

@ -96,7 +96,7 @@ public class ShowUI {
notificationManager.notify(Const.ID.DTBO_NOTIFICATION_ID, builder.build());
}
public static void magiskInstallDialog(Activity activity, boolean enc, boolean verity) {
public static void magiskInstallDialog(Activity activity) {
MagiskManager mm = Utils.getMagiskManager(activity);
String filename = Utils.fmt("Magisk-v%s.zip", mm.remoteMagiskVersionString);
new AlertDialogBuilder(activity)
@ -145,8 +145,6 @@ public class ShowUI {
intent.setData(uri)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(Const.Key.FLASH_SET_BOOT, data.getData())
.putExtra(Const.Key.FLASH_SET_ENC, enc)
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
.putExtra(Const.Key.FLASH_ACTION, Const.Value.PATCH_BOOT);
mm.startActivity(intent);
}
@ -175,8 +173,6 @@ public class ShowUI {
Intent intent = new Intent(mm, FlashActivity.class);
intent.setData(uri)
.putExtra(Const.Key.FLASH_SET_BOOT, boot)
.putExtra(Const.Key.FLASH_SET_ENC, enc)
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_MAGISK);
activity.startActivity(intent);
}
@ -203,8 +199,6 @@ public class ShowUI {
Intent intent = new Intent(mm, FlashActivity.class);
intent.setData(uri)
.putExtra(Const.Key.FLASH_SET_BOOT, boot)
.putExtra(Const.Key.FLASH_SET_ENC, enc)
.putExtra(Const.Key.FLASH_SET_VERITY, verity)
.putExtra(Const.Key.FLASH_ACTION, Const.Value.FLASH_MAGISK);
activity.startActivity(intent);
}

View File

@ -24,7 +24,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">إعدادات متقدمة</string>
<string name="keep_force_encryption">الحفاظ علي قوه التشفير</string>
<string name="keep_dm_verity">إبقاء dm-verity</string>
<string name="keep_dm_verity">إبقاء AVB 2.0/dm-verity</string>
<string name="current_magisk_title">نسخة Magisk المثبته: %1$s</string>
<string name="install_magisk_title">آخر نسخة Magisk: %1$s</string>
<string name="uninstall">إلغاء التثبيت</string>

View File

@ -20,7 +20,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Pokročilá Nastavení</string>
<string name="keep_force_encryption">Udržet "force encryption"</string>
<string name="keep_dm_verity">Udržet dm-verity</string>
<string name="keep_dm_verity">Udržet AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Nainstalovaná verze: %1$s</string>
<string name="install_magisk_title">Poslední verze: %1$s</string>
<string name="uninstall">Odinstalovat</string>

View File

@ -28,7 +28,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Erweiterte Optionen</string>
<string name="keep_force_encryption">\"force encryption\" beibehalten</string>
<string name="keep_dm_verity">\"dm-verity\"-Test beibehalten</string>
<string name="keep_dm_verity">AVB 2.0/dm-verity beibehalten</string>
<string name="current_magisk_title">Installierte Version: %1$s</string>
<string name="install_magisk_title">Neueste Version: %1$s</string>
<string name="uninstall">Deinstallieren</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Προηγμένες ρυθμίσεις</string>
<string name="keep_force_encryption">Διατήρηση επιβεβλημένης κρυπτογράφησης</string>
<string name="keep_dm_verity">Διατήρηση dm-verity</string>
<string name="keep_dm_verity">Διατήρηση AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Εγκατεστημένη έκδοση: %1$s</string>
<string name="install_magisk_title">Τελευταία έκδοση: %1$s</string>
<string name="uninstall">Απεγκατάσταση</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Ajustes avanzados</string>
<string name="keep_force_encryption">Mantener cifrado forzado</string>
<string name="keep_dm_verity">Mantener dm-verity</string>
<string name="keep_dm_verity">Mantener AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versión instalada: %1$s</string>
<string name="install_magisk_title">Última versión: %1$s</string>
<string name="uninstall">Desinstalar</string>

View File

@ -26,7 +26,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Täpsemad seaded</string>
<string name="keep_force_encryption">Säilita sunnitud krüpteering</string>
<string name="keep_dm_verity">Säilita dm-verity</string>
<string name="keep_dm_verity">Säilita AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Installitud versioon: %1$s</string>
<string name="install_magisk_title">Viimane versioon: %1$s</string>
<string name="uninstall">Eemalda</string>

View File

@ -21,7 +21,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Paramètres avancés</string>
<string name="keep_force_encryption">Garder le chiffrement forcé</string>
<string name="keep_dm_verity">Garder dm-verity</string>
<string name="keep_dm_verity">Garder AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Version installée : %1$s</string>
<string name="install_magisk_title">Dernière Magisk : %1$s</string>
<string name="uninstall">Désinstaller</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Napredne postavke</string>
<string name="keep_force_encryption">Zadrži prisilno šifirannje</string>
<string name="keep_dm_verity">Zadrži dm-istinitost</string>
<string name="keep_dm_verity">Zadrži AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Instalirana inačica: %1$s</string>
<string name="install_magisk_title">Najnovija inačica: %1$s</string>
<string name="uninstall">Deinstaliraj</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Pengaturan Lanjutan</string>
<string name="keep_force_encryption">Biarkan enkripsi paksa</string>
<string name="keep_dm_verity">Biarkan dm-verity</string>
<string name="keep_dm_verity">Biarkan AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versi yang Terpasang: %1$s</string>
<string name="install_magisk_title">Versi Terbaru: %1$s</string>
<string name="uninstall">Copot</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Impostazioni avanzate</string>
<string name="keep_force_encryption">Mantieni crittografia forzata</string>
<string name="keep_dm_verity">Mantieni dm-verity</string>
<string name="keep_dm_verity">Mantieni AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versione installata: %1$s</string>
<string name="install_magisk_title">Ultima versione disponibile: %1$s</string>
<string name="uninstall">Disinstalla</string>

View File

@ -20,7 +20,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">高度な設定</string>
<string name="keep_force_encryption">強制的な暗号化を維持する</string>
<string name="keep_dm_verity">dm-verityを維持する</string>
<string name="keep_dm_verity">AVB 2.0/dm-verityを維持する</string>
<string name="current_magisk_title">インストール済: %1$s</string>
<string name="install_magisk_title">最新: %1$s</string>
<string name="uninstall">アンインストール</string>

View File

@ -20,7 +20,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">고급 설정</string>
<string name="keep_force_encryption">강제 암호화 유지</string>
<string name="keep_dm_verity">dm-verity 유지</string>
<string name="keep_dm_verity">AVB 2.0/dm-verity 유지</string>
<string name="current_magisk_title">설치된버전: %1$s</string>
<string name="install_magisk_title">최신버전: %1$s</string>
<string name="uninstall">제거</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Geavanceerde instellingen</string>
<string name="keep_force_encryption">Behoud afgedwongen versleuteling</string>
<string name="keep_dm_verity">Behoud dm-verity</string>
<string name="keep_dm_verity">Behoud AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Geïnstalleerde versie: %1$s</string>
<string name="install_magisk_title">Recentste versie: %1$s</string>
<string name="uninstall">Deïnstalleren</string>

View File

@ -28,7 +28,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Zaawansowane Ustawienia</string>
<string name="keep_force_encryption">Zachowaj Szyfrowanie</string>
<string name="keep_dm_verity">Zachowaj dm-verity</string>
<string name="keep_dm_verity">Zachowaj AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Zainstalowana Wersja: %1$s</string>
<string name="install_magisk_title">Ostatnia Wersja: %1$s</string>
<string name="uninstall">Odinstaluj</string>

View File

@ -28,7 +28,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Configurações avançadas</string>
<string name="keep_force_encryption">Keep force encryption</string>
<string name="keep_dm_verity">Keep dm-verity</string>
<string name="keep_dm_verity">Keep AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versão instalada: %1$s</string>
<string name="install_magisk_title">Última versão: %1$s</string>
<string name="uninstall">Desinstalar</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Definições avançadas</string>
<string name="keep_force_encryption">Manter encriptação forçada</string>
<string name="keep_dm_verity">Manter dm-verity</string>
<string name="keep_dm_verity">Manter AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versão instalada: %1$s</string>
<string name="install_magisk_title">Última versão: %1$s</string>
<string name="uninstall">Desinstalar</string>

View File

@ -22,7 +22,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Setări avansate</string>
<string name="keep_force_encryption">Păstrare criptare forţată</string>
<string name="keep_dm_verity">Păstrare dm-verity</string>
<string name="keep_dm_verity">Păstrare AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Versiune instalată: %1$s</string>
<string name="install_magisk_title">Ultima versiune: %1$s</string>
<string name="uninstall">Dezinstalare</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Расширенные настройки</string>
<string name="keep_force_encryption">Оставить шифрование</string>
<string name="keep_dm_verity">Оставить dm-verity</string>
<string name="keep_dm_verity">Оставить AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Установлена версия: %1$s</string>
<string name="install_magisk_title">Последняя версия: %1$s</string>
<string name="uninstall">Удаление</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Напредна Подешавања</string>
<string name="keep_force_encryption">Задржи форсирану енкрипцију</string>
<string name="keep_dm_verity">Задржи dm-verity</string>
<string name="keep_dm_verity">Задржи AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Инсталирана верзија: %1$s</string>
<string name="install_magisk_title">Најновија верзија: %1$s</string>
<string name="uninstall">Унинсталирај</string>

View File

@ -24,7 +24,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Advancerade inställningar</string>
<string name="keep_force_encryption">Fortsätt tvinga kryptering</string>
<string name="keep_dm_verity">Behåll dm-verity</string>
<string name="keep_dm_verity">Behåll AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Installerad: %1$s</string>
<string name="install_magisk_title">Senaste: %1$s</string>
<string name="uninstall">Avinstallera</string>

View File

@ -24,7 +24,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Gelişmiş Ayarlar</string>
<string name="keep_force_encryption">Şifrelemeyi zorlamayı sürdür</string>
<string name="keep_dm_verity">"Dm-verity\'yi koru"</string>
<string name="keep_dm_verity">AVB 2.0/dm-verity \'yi koru</string>
<string name="current_magisk_title">Yüklü Sürüm: %1$s</string>
<string name="install_magisk_title">Yeni Sürüm: %1$s</string>
<string name="uninstall">Kaldır</string>

View File

@ -24,7 +24,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Розширені налаштування</string>
<string name="keep_force_encryption">Залишити примусове шифрування</string>
<string name="keep_dm_verity">Залишити dm-verity</string>
<string name="keep_dm_verity">Залишити AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Поточна версія: %1$s</string>
<string name="install_magisk_title">Найновіша версія: %1$s</string>
<string name="uninstall">Видалити</string>

View File

@ -20,7 +20,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Thiết lập nâng cao</string>
<string name="keep_force_encryption">Giữ bắt buộc mã hoá</string>
<string name="keep_dm_verity">Giữ dm-verity</string>
<string name="keep_dm_verity">Giữ AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Đã cài đặt phiên bản: %1$s</string>
<string name="install_magisk_title">Phiên bản mới nhất: %1$s</string>
<string name="uninstall">Gỡ bỏ</string>

View File

@ -25,7 +25,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">高级设置</string>
<string name="keep_force_encryption">保持强制加密</string>
<string name="keep_dm_verity">保留 dm-verity</string>
<string name="keep_dm_verity">保留 AVB 2.0/dm-verity</string>
<string name="current_magisk_title">已安装版本:%1$s</string>
<string name="install_magisk_title">最新的版本:%1$s</string>
<string name="uninstall">卸载</string>

View File

@ -20,7 +20,7 @@
<!--Install Fragment-->
<string name="advanced_settings_title">高級設置</string>
<string name="keep_force_encryption">保持強制加密</string>
<string name="keep_dm_verity">保留 dm-verity</string>
<string name="keep_dm_verity">保留 AVB 2.0/dm-verity</string>
<string name="current_magisk_title">已安裝版本:%1$s</string>
<string name="install_magisk_title">最新的版本:%1$s</string>
<string name="uninstall">解除安裝</string>

View File

@ -27,8 +27,8 @@
<!--Install Fragment-->
<string name="advanced_settings_title">Advanced Settings</string>
<string name="keep_force_encryption">Keep force encryption</string>
<string name="keep_dm_verity">Keep dm-verity</string>
<string name="keep_force_encryption">Preserve force encryption</string>
<string name="keep_dm_verity">Preserve AVB 2.0/dm-verity</string>
<string name="current_magisk_title">Installed Version: %1$s</string>
<string name="install_magisk_title">Latest Version: %1$s</string>
<string name="uninstall">Uninstall</string>