aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-09-25 10:26:45 +0200
committerChristian Schneppe <christian@pix-art.de>2016-09-25 10:26:45 +0200
commit1637506552eb48ded7c230466dd178aa1ec6ea4b (patch)
tree94882a59079233b6efb4cb44cf6c47c7f9ec5d2e /src
parent66301c4961b99b1fc650bb99c3578453b5c17ba5 (diff)
Revert "simplify updater a bit and only search for updates in wifi or mobile networks"
This reverts commit 4918d377fed75a24a339bcf71581717dc3706ceb.
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/UpdaterActivity.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
index 3893f7b7b..bed5ed26b 100644
--- a/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/UpdaterActivity.java
@@ -11,6 +11,8 @@ 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;
@@ -28,7 +30,6 @@ 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 {
@@ -38,7 +39,6 @@ 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()) {
+ if (isNetworkAvailable(this)) {
Intent msgIntent = new Intent(this, UpdaterWebService.class);
msgIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
msgIntent.putExtra(UpdaterWebService.REQUEST_STRING, Config.UPDATE_URL);
@@ -112,10 +112,16 @@ public class UpdaterActivity extends Activity {
}
//check for internet connection
- private boolean isNetworkAvailable() {
- if (mXmppConnectionService.hasInternetConnection()) {
- if (mXmppConnectionService.isWIFI() || mXmppConnectionService.isMobile()) {
- return true;
+ 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;
+ }
+ }
}
}
return false;