• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

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

変更サマリ

差分

--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -54,6 +54,7 @@
5454
5555 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
5656 <uses-permission android:name="android.permission.INTERNET" />
57+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5758
5859 <uses-permission android:name="com.noshufou.android.su.RESPOND" />
5960
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -16,6 +16,7 @@
1616 <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>
1717 <string name="su_up_to_date">su is up to date</string>
1818 <string name="checking">Checking...</string>
19+ <string name="no_connection">No network connection. Could not check for updates</string>
1920
2021 <string name="tab_apps">Apps</string>
2122 <string name="tab_log">Log</string>
--- a/src/com/noshufou/android/su/Updater.java
+++ b/src/com/noshufou/android/su/Updater.java
@@ -20,6 +20,8 @@ import org.json.JSONObject;
2020 import android.app.AlertDialog;
2121 import android.content.Context;
2222 import android.content.DialogInterface;
23+import android.net.ConnectivityManager;
24+import android.net.NetworkInfo;
2325 import android.os.AsyncTask;
2426 import android.os.Environment;
2527 import android.os.Build.VERSION;
@@ -40,8 +42,15 @@ public class Updater {
4042 }
4143
4244 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+ }
4554 }
4655
4756 private void postManifest() {