From 2ecdec95f6f0fad91c100eb83af62d46053edd23 Mon Sep 17 00:00:00 2001 From: ChainsDD Date: Tue, 24 Aug 2010 17:24:55 -0500 Subject: [PATCH] Check for network connectivity before attempting to check for updates --- AndroidManifest.xml | 1 + res/values/strings.xml | 1 + src/com/noshufou/android/su/Updater.java | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index a3dbd29..16733e5 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -54,6 +54,7 @@ + diff --git a/res/values/strings.xml b/res/values/strings.xml index 386bebd..0080962 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -16,6 +16,7 @@ An error occurred and su was not updated. A zip file (su-2.3.1-bin-signed.zip) has been placed on your sdcard, please reboot into recovery mode and flash it to update your su binary. su is up to date Checking... + No network connection. Could not check for updates Apps Log diff --git a/src/com/noshufou/android/su/Updater.java b/src/com/noshufou/android/su/Updater.java index 6f4a18d..e8f7422 100644 --- a/src/com/noshufou/android/su/Updater.java +++ b/src/com/noshufou/android/su/Updater.java @@ -20,6 +20,8 @@ import org.json.JSONObject; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.os.AsyncTask; import android.os.Environment; import android.os.Build.VERSION; @@ -40,8 +42,15 @@ public class Updater { } public void doUpdate() { - // Get the process started, it all goes from here. - new DownloadFileTask().execute("http://dl.dropbox.com/u/6408470/Superuser/manifest.json"); + ConnectivityManager cm = + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); + if (cm.getActiveNetworkInfo() == null + || cm.getActiveNetworkInfo().getState() == NetworkInfo.State.DISCONNECTED) { + Toast.makeText(mContext, R.string.no_connection, Toast.LENGTH_SHORT).show(); + } else { + // Get the process started, it all goes from here. + new DownloadFileTask().execute("http://dl.dropbox.com/u/6408470/Superuser/manifest.json"); + } } private void postManifest() { -- 2.11.0