| Index: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Engine.java | 
| =================================================================== | 
| --- a/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Engine.java | 
| +++ b/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Engine.java | 
| @@ -38,32 +38,34 @@ import java.util.List; | 
| import java.util.Map; | 
| import java.util.Set; | 
| import java.util.TreeSet; | 
| import java.util.concurrent.LinkedBlockingQueue; | 
| import java.util.concurrent.TimeUnit; | 
| import java.util.concurrent.locks.ReentrantLock; | 
|  | 
| import org.adblockplus.adblockplussbrowser.R; | 
| +import org.adblockplus.sbrowser.contentblocker.util.ConnectivityUtils; | 
| import org.adblockplus.sbrowser.contentblocker.util.SharedPrefsUtils; | 
| import org.adblockplus.sbrowser.contentblocker.util.SubscriptionUtils; | 
|  | 
| import android.content.Context; | 
| import android.content.Intent; | 
| import android.content.pm.PackageInfo; | 
| import android.content.pm.PackageManager; | 
| import android.content.pm.ResolveInfo; | 
| import android.net.ConnectivityManager; | 
| import android.net.NetworkInfo; | 
| import android.net.Uri; | 
| import android.os.Handler; | 
| import android.os.Looper; | 
| import android.text.TextUtils; | 
| import android.text.format.DateUtils; | 
| import android.util.Log; | 
| +import android.widget.Toast; | 
|  | 
| public final class Engine | 
| { | 
| private static final String TAG = Engine.class.getSimpleName(); | 
|  | 
| public static final String USER_FILTERS_TITLE = "__filters"; | 
| public static final String USER_EXCEPTIONS_TITLE = "__exceptions"; | 
|  | 
| @@ -191,52 +193,34 @@ public final class Engine | 
| final Intent intent = new Intent(); | 
| intent.setAction(ACTION_UPDATE); | 
| intent.setData(Uri.parse("package:" + Engine.this.serviceContext.getPackageName())); | 
| Engine.this.serviceContext.sendBroadcast(intent); | 
| } | 
| }); | 
| } | 
|  | 
| -  boolean canUseInternet() | 
| +  boolean canUseInternet(final boolean allowMetered) | 
| { | 
| -    final ConnectivityManager connManager = (ConnectivityManager) this.serviceContext | 
| -        .getSystemService(Context.CONNECTIVITY_SERVICE); | 
| -    final NetworkInfo current = connManager.getActiveNetworkInfo(); | 
| -    if (current == null) | 
| -    { | 
| -      return false; | 
| -    } | 
| - | 
| -    if (wasFirstRun()) | 
| -    { | 
| -      return true; | 
| -    } | 
| - | 
| -    final boolean wifiOnly = "1".equals(SharedPrefsUtils.getString( | 
| -        this.serviceContext, R.string.key_automatic_updates , "1")); | 
| +    // allow a metered connection to update default subscriptions at the first run. | 
| +    // See https://issues.adblockplus.org/ticket/5237 | 
| +    return ConnectivityUtils.canUseInternet(serviceContext, allowMetered || wasFirstRun()); | 
| +  } | 
|  | 
| -    if (wifiOnly) | 
| +  public void forceUpdateSubscriptions(final boolean allowMetered) | 
| +  { | 
| +    try | 
| { | 
| -      if (current.isConnected() && !current.isRoaming()) | 
| -      { | 
| -        switch (current.getType()) | 
| -        { | 
| -          case ConnectivityManager.TYPE_BLUETOOTH: | 
| -          case ConnectivityManager.TYPE_ETHERNET: | 
| -          case ConnectivityManager.TYPE_WIFI: | 
| -          case ConnectivityManager.TYPE_WIMAX: | 
| -            return true; | 
| -          default: | 
| -            return false; | 
| -        } | 
| -      } | 
| -      return false; | 
| +      subscriptions.checkForUpdates(true, allowMetered); | 
| +      Toast.makeText(serviceContext, serviceContext.getText(R.string.updating_subscriptions), Toast.LENGTH_LONG).show(); | 
| } | 
| -    return current.isConnected(); | 
| +    catch (IOException e) | 
| +    { | 
| +      Log.e(TAG, "Failed checking for updates", e); | 
| +    } | 
| } | 
|  | 
| public List<SubscriptionInfo> getListedSubscriptions() | 
| { | 
| return this.subscriptions.getSubscriptions(this); | 
| } | 
|  | 
| public void changeSubscriptionState(final String id, final boolean enabled) | 
| @@ -684,17 +668,17 @@ public final class Engine | 
| } | 
| } | 
|  | 
| final long currentTime = System.currentTimeMillis(); | 
| if (currentTime > nextUpdateCheck) | 
| { | 
| nextUpdateCheck = currentTime + UPDATE_CHECK_INTERVAL; | 
|  | 
| -              this.engine.subscriptions.checkForUpdates(); | 
| +              this.engine.subscriptions.checkForUpdates(false, false); | 
| } | 
|  | 
| if (currentTime > this.engine.nextUpdateBroadcast) | 
| { | 
| this.engine.nextUpdateBroadcast = Long.MAX_VALUE; | 
| Log.d(TAG, "Sending update broadcast"); | 
| this.engine.writeFileAndSendUpdateBroadcast(); | 
| } | 
| @@ -771,17 +755,18 @@ public final class Engine | 
| this.response = response; | 
| if (headers != null) | 
| { | 
| this.headers.putAll(headers); | 
| } | 
| } | 
| } | 
|  | 
| -  public void enqueueDownload(final Subscription sub, final boolean forced) throws IOException | 
| +  public void enqueueDownload(final Subscription sub, final boolean forced, | 
| +      final boolean allowMetered) throws IOException | 
| { | 
| if (sub.getURL() != null && sub.shouldUpdate(forced)) | 
| { | 
| final HashMap<String, String> headers = new HashMap<>(); | 
| if (sub.isMetaDataValid() && sub.isFiltersValid()) | 
| { | 
| final String lastModified = sub.getMeta(Subscription.KEY_HTTP_LAST_MODIFIED); | 
| if (!TextUtils.isEmpty(lastModified)) | 
| @@ -790,17 +775,17 @@ public final class Engine | 
| } | 
| final String etag = sub.getMeta(Subscription.KEY_HTTP_ETAG); | 
| if (!TextUtils.isEmpty(etag)) | 
| { | 
| headers.put("If-None-Match", etag); | 
| } | 
| } | 
| Log.d(TAG, headers.toString()); | 
| -      this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers); | 
| +      this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers, allowMetered); | 
| } | 
| } | 
|  | 
| public void connectivityChanged() | 
| { | 
| this.downloader.connectivityChanged(); | 
| } | 
|  | 
|  |