From: Marius Gavrilescu Date: Mon, 25 Aug 2014 10:53:44 +0000 (+0300) Subject: Fix reboot X-Git-Tag: 0.000_002~8 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=ba6b96a349051e64a04e8969bb1f907d9d4b01a7;p=fonbot.git Fix reboot --- 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); } /**