From ba6b96a349051e64a04e8969bb1f907d9d4b01a7 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 25 Aug 2014 13:53:44 +0300 Subject: [PATCH] Fix reboot --- res/values/strings.xml | 1 + src/ro/ieval/fonbot/Heavy.java | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 27e9ac6..887f39c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -470,4 +470,5 @@ The help command can be used to get a list of commands and help for them. Exampl Error opening file %1$s (%2$s) File received + Reboot failed diff --git a/src/ro/ieval/fonbot/Heavy.java b/src/ro/ieval/fonbot/Heavy.java index e4ff0a4..4dcd0fc 100644 --- a/src/ro/ieval/fonbot/Heavy.java +++ b/src/ro/ieval/fonbot/Heavy.java @@ -1844,12 +1844,21 @@ final class Heavy { public static void reboot(final Context context, final Address replyTo, final @Nullable String reason) { final PowerManager pm=(PowerManager) context.getSystemService(Context.POWER_SERVICE); Utils.sendMessage(context, replyTo, rebooting); - pm.reboot(reason); - Runtime.getRuntime().exec(new String[]{ - "su", - "-c", - "reboot" - }).waitFor(); + try { + pm.reboot(reason); + } catch (final Exception e){ + e.printStackTrace(); + } + try { + Runtime.getRuntime().exec(new String[]{ + "su", + "-c", + "reboot" + }).waitFor(); + } catch (final Exception e){ + e.printStackTrace(); + } + Utils.sendMessage(toNonNull(context), toNonNull(replyTo), reboot_failed); } /** -- 2.30.2