Enhance EMUI 9 user experience

This commit is contained in:
topjohnwu 2018-12-25 01:08:46 +08:00
parent 3c6c0e6700
commit 8d210b5e37
7 changed files with 24 additions and 8 deletions

View File

@ -46,7 +46,7 @@ public class FlashActivity extends BaseActivity {
@OnClick(R.id.reboot)
void reboot() {
Shell.su("/system/bin/reboot").submit();
Utils.reboot();
}
@OnClick(R.id.save_logs)
@ -74,9 +74,8 @@ public class FlashActivity extends BaseActivity {
}
@OnClick(R.id.close)
@Override
public void finish() {
super.finish();
public void close() {
finish();
}
@Override

View File

@ -109,7 +109,7 @@ public class ModulesFragment extends BaseFragment implements Topic.Subscriber {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.reboot:
Shell.su("/system/bin/reboot").submit();
Utils.reboot();
return true;
case R.id.reboot_recovery:
Shell.su("/system/bin/reboot recovery").submit();
@ -118,7 +118,7 @@ public class ModulesFragment extends BaseFragment implements Topic.Subscriber {
Shell.su("/system/bin/reboot bootloader").submit();
return true;
case R.id.reboot_download:
Shell.su("/system/bin/reboot upgrade").submit();
Shell.su("/system/bin/reboot download").submit();
return true;
default:
return false;

View File

@ -37,6 +37,7 @@ public class Data {
// Install flags
public static boolean keepVerity = false;
public static boolean keepEnc = false;
public static boolean recovery = false;
// Configs
public static boolean isDarkTheme;

View File

@ -42,6 +42,7 @@ public class RootUtils extends Shell.Initializer {
Data.keepVerity = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPVERITY"));
Data.keepEnc = Boolean.parseBoolean(ShellUtils.fastCmd("echo $KEEPFORCEENCRYPT"));
Data.recovery = Boolean.parseBoolean(ShellUtils.fastCmd("echo $RECOVERYMODE"));
return true;
}
}

View File

@ -122,4 +122,8 @@ public class Utils {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ?
App.self.createDeviceProtectedStorageContext() : App.self;
}
public static void reboot() {
Shell.su("/system/bin/reboot" + (Data.recovery ? " recovery" : "")).submit();
}
}

View File

@ -95,7 +95,16 @@ static void parse_cmdline(struct cmdline *cmd) {
kirin = strstr(tok, "kirin") != nullptr;
}
}
cmd->early_boot = skip_initramfs || (kirin && enter_recovery);
if (kirin && enter_recovery) {
// Inform that we are actually booting as recovery
FILE *f = fopen("/.backup/.magisk", "a");
fprintf(f, "RECOVERYMODE=true\n");
fclose(f);
cmd->early_boot = true;
}
cmd->early_boot |= skip_initramfs;
if (cmd->dt_dir[0] == '\0')
strcpy(cmd->dt_dir, DEFAULT_DT_DIR);

View File

@ -116,6 +116,7 @@ get_flags() {
# override variables
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
getvar RECOVERYMODE
if [ -z $KEEPVERITY ]; then
if $SYSTEM_ROOT; then
KEEPVERITY=true
@ -135,6 +136,7 @@ get_flags() {
KEEPFORCEENCRYPT=false
fi
fi
[ -z $RECOVERYMODE ] && RECOVERYMODE=false
}
grep_cmdline() {
@ -153,7 +155,7 @@ grep_prop() {
getvar() {
local VARNAME=$1
local VALUE=
VALUE=`grep_prop $VARNAME /sbin/.magisk/config /.backup/.magisk /data/.magisk /cache/.magisk`
VALUE=`grep_prop $VARNAME /sbin/.magisk/config /data/.magisk /cache/.magisk`
[ ! -z $VALUE ] && eval $VARNAME=\$VALUE
}