packages/apps/Superuser
リビジョン | 2ecdec95f6f0fad91c100eb83af62d46053edd23 (tree) |
---|---|
日時 | 2010-08-25 07:24:55 |
作者 | ChainsDD <chainsdd@gmai...> |
コミッター | ChainsDD |
Check for network connectivity before attempting to check for updates
@@ -54,6 +54,7 @@ | ||
54 | 54 | |
55 | 55 | <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> |
56 | 56 | <uses-permission android:name="android.permission.INTERNET" /> |
57 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | |
57 | 58 | |
58 | 59 | <uses-permission android:name="com.noshufou.android.su.RESPOND" /> |
59 | 60 |
@@ -16,6 +16,7 @@ | ||
16 | 16 | <string name="su_not_updated">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.</string> |
17 | 17 | <string name="su_up_to_date">su is up to date</string> |
18 | 18 | <string name="checking">Checking...</string> |
19 | + <string name="no_connection">No network connection. Could not check for updates</string> | |
19 | 20 | |
20 | 21 | <string name="tab_apps">Apps</string> |
21 | 22 | <string name="tab_log">Log</string> |
@@ -20,6 +20,8 @@ import org.json.JSONObject; | ||
20 | 20 | import android.app.AlertDialog; |
21 | 21 | import android.content.Context; |
22 | 22 | import android.content.DialogInterface; |
23 | +import android.net.ConnectivityManager; | |
24 | +import android.net.NetworkInfo; | |
23 | 25 | import android.os.AsyncTask; |
24 | 26 | import android.os.Environment; |
25 | 27 | import android.os.Build.VERSION; |
@@ -40,8 +42,15 @@ public class Updater { | ||
40 | 42 | } |
41 | 43 | |
42 | 44 | public void doUpdate() { |
43 | - // Get the process started, it all goes from here. | |
44 | - new DownloadFileTask().execute("http://dl.dropbox.com/u/6408470/Superuser/manifest.json"); | |
45 | + ConnectivityManager cm = | |
46 | + (ConnectivityManager)mContext.getSystemService(Context.CONNECTIVITY_SERVICE); | |
47 | + if (cm.getActiveNetworkInfo() == null | |
48 | + || cm.getActiveNetworkInfo().getState() == NetworkInfo.State.DISCONNECTED) { | |
49 | + Toast.makeText(mContext, R.string.no_connection, Toast.LENGTH_SHORT).show(); | |
50 | + } else { | |
51 | + // Get the process started, it all goes from here. | |
52 | + new DownloadFileTask().execute("http://dl.dropbox.com/u/6408470/Superuser/manifest.json"); | |
53 | + } | |
45 | 54 | } |
46 | 55 | |
47 | 56 | private void postManifest() { |