diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-09-25 00:24:48 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-09-25 00:24:48 +0200 |
commit | 4918d377fed75a24a339bcf71581717dc3706ceb (patch) | |
tree | c0a923ab5d12f261a3307f16842906373899bdfe /src/main | |
parent | 4a2df58165c83a7b800b4bf8c1beb2b6ee5a2513 (diff) |
simplify updater a bit and only search for updates in wifi or mobile networks
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/UpdaterActivity.java | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java index bed5ed26b..3893f7b7b 100644 --- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java +++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java @@ -11,8 +11,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -30,6 +28,7 @@ import java.io.File; import de.pixart.messenger.Config; import de.pixart.messenger.R; import de.pixart.messenger.services.UpdaterWebService; +import de.pixart.messenger.services.XmppConnectionService; public class UpdaterActivity extends Activity { @@ -39,6 +38,7 @@ public class UpdaterActivity extends Activity { private DownloadManager downloadManager; private long downloadReference; private String FileName = "update.apk"; + private XmppConnectionService mXmppConnectionService; BroadcastReceiver downloadReceiver = new BroadcastReceiver() { @@ -79,7 +79,7 @@ public class UpdaterActivity extends Activity { registerReceiver(downloadReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); //check of internet is available before making a web service request - if (isNetworkAvailable(this)) { + if (isNetworkAvailable()) { Intent msgIntent = new Intent(this, UpdaterWebService.class); msgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); msgIntent.putExtra(UpdaterWebService.REQUEST_STRING, Config.UPDATE_URL); @@ -112,16 +112,10 @@ public class UpdaterActivity extends Activity { } //check for internet connection - private boolean isNetworkAvailable(Context context) { - ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - if (connectivity != null) { - NetworkInfo[] info = connectivity.getAllNetworkInfo(); - if (info != null) { - for (int i = 0; i < info.length; i++) { - if (info[i].getState() == NetworkInfo.State.CONNECTED) { - return true; - } - } + private boolean isNetworkAvailable() { + if (mXmppConnectionService.hasInternetConnection()) { + if (mXmppConnectionService.isWIFI() || mXmppConnectionService.isMobile()) { + return true; } } return false; |