X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=src%2Fro%2Fieval%2Ffonbot%2FUtils.java;h=e2e0dab2319ed86e085e98c52c91972ca8a8bcf7;hb=251aceaaa3379c65d66a975ff9e7524f7d2f1d73;hp=5c54f86e89b8ca38cfc5572eca732918fe05db90;hpb=1443a92948e04e18b32a49e3f60fb1a31f6fa871;p=fonbot.git diff --git a/src/ro/ieval/fonbot/Utils.java b/src/ro/ieval/fonbot/Utils.java index 5c54f86..e2e0dab 100644 --- a/src/ro/ieval/fonbot/Utils.java +++ b/src/ro/ieval/fonbot/Utils.java @@ -4,6 +4,7 @@ import static ro.ieval.fonbot.R.string.*; import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; @@ -18,6 +19,8 @@ import android.database.Cursor; import android.location.LocationManager; import android.media.AudioManager; import android.net.Uri; +import android.os.Handler; +import android.os.Looper; import android.preference.PreferenceManager; import android.provider.ContactsContract.PhoneLookup; import android.telephony.SmsManager; @@ -65,7 +68,7 @@ public final class Utils { LS, RM, CONTACTS, DISABLE, ENABLE, POLL, HANGUP, ANSWER, LAUNCH, DATA, GPS, GLOCATION, REBOOT, NOTIFY, SCREENCAP, - TORCH, GETFILE + TORCH, GETFILE, SH, ROOTSH } /** @@ -188,10 +191,8 @@ public final class Utils { * @throws AssertionError if the given object is null */ public static T toNonNull(@Nullable T object) throws AssertionError{ - if(object==null){ - Log.wtf(Utils.class.getName(), "toNonNull called with null"); - throw new AssertionError("Log.wtf did not terminate the process"); - } + if(object==null) + throw new NullPointerException(); return object; } @@ -299,7 +300,13 @@ public final class Utils { break; case SMS: - SmsManager.getDefault().sendTextMessage(address.data, null, message, null, null); + new Handler(Looper.getMainLooper()).post(new Runnable(){ + @Override + public void run(){ + final ArrayList parts = SmsManager.getDefault().divideMessage(message); + SmsManager.getDefault().sendMultipartTextMessage(address.data, null, parts, null, null); + } + }); break; case LOCAL: @@ -1002,6 +1009,24 @@ public final class Utils { } Heavy.getfile(context, replyTo, toNonNull(args[0]), toNonNull(args[1]), getfilePort); break; + + case SH: + if(args.length == 0){ + Heavy.help(context, replyTo, toNonNull(Command.SH)); + return; + } + + Heavy.execute(context, replyTo, "sh", join(" ", args)); + break; + + case ROOTSH: + if(args.length == 0){ + Heavy.help(context, replyTo, toNonNull(Command.ROOTSH)); + return; + } + + Heavy.execute(context, replyTo, "su", join(" ", args)); + break; } }