Merge pull request #2161 from Redirion/patch-1
Fixed CheckForNewAppVersionTask being executed when it shouldn't
This commit is contained in:
commit
554ebf7ab9
1 changed files with 12 additions and 0 deletions
|
@ -2,11 +2,13 @@ package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.Signature;
|
import android.content.pm.Signature;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
|
@ -69,6 +71,8 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(Void... voids) {
|
protected String doInBackground(Void... voids) {
|
||||||
|
|
||||||
|
if(isCancelled() || !isConnected()) return null;
|
||||||
|
|
||||||
// Make a network request to get latest NewPipe data.
|
// Make a network request to get latest NewPipe data.
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
|
|
||||||
|
@ -227,4 +231,12 @@ public class CheckForNewAppVersionTask extends AsyncTask<Void, Void, String> {
|
||||||
|
|
||||||
return getCertificateSHA1Fingerprint().equals(GITHUB_APK_SHA1);
|
return getCertificateSHA1Fingerprint().equals(GITHUB_APK_SHA1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isConnected() {
|
||||||
|
|
||||||
|
ConnectivityManager cm =
|
||||||
|
(ConnectivityManager) app.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
return cm.getActiveNetworkInfo() != null
|
||||||
|
&& cm.getActiveNetworkInfo().isConnected();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue