Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java

Issue 29430610: Issue 5193 - Apply Samsung Internet UI changes to the frist run slide (Closed)
Patch Set: Changes according to Diegos comments Created May 9, 2017, 9:44 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java
===================================================================
--- a/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java
+++ b/adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/engine/Engine.java
@@ -38,20 +38,23 @@
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 java.util.regex.Pattern;
import org.adblockplus.adblockplussbrowser.R;
+import org.adblockplus.sbrowser.contentblocker.MainPreferences;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+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.preference.PreferenceManager;
import android.text.TextUtils;
@@ -72,16 +75,17 @@
public static final Pattern RE_FILTER_OPTIONS = Pattern
.compile("\\$(~?[\\w\\-]+(?:=[^,\\s]+)?(?:,~?[\\w\\-]+(?:=[^,\\s]+)?)*)$");
public static final Pattern RE_FILTER_CSSPROPERTY = Pattern
.compile("\\[\\-abp\\-properties=([\"'])([^\"']+)\\1\\]");
public static final String USER_FILTERS_TITLE = "__filters";
public static final String USER_EXCEPTIONS_TITLE = "__exceptions";
+ public static final String SBROWSER_APP_ID = "com.sec.android.app.sbrowser";
public static final String ACTION_OPEN_SETTINGS = "com.samsung.android.sbrowser.contentBlocker.ACTION_SETTING";
public static final String ACTION_UPDATE = "com.samsung.android.sbrowser.contentBlocker.ACTION_UPDATE";
public static final String EASYLIST_URL = "https://easylist-downloads.adblockplus.org/easylist.txt";
public static final String SUBSCRIPTIONS_EXCEPTIONSURL = "subscriptions_exceptionsurl";
public static final String CHARSET_UTF_8 = "UTF-8";
private static final String PREFS_KEY_PREVIOUS_VERSION = "key_previous_version";
@@ -92,16 +96,19 @@
private static final long UPDATE_CHECK_INTERVAL_MINUTES = 30;
private static final long BROADCAST_COMBINATION_DELAY_MILLIS = 2500;
public static final long MILLIS_PER_SECOND = 1000;
public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND;
public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE;
public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR;
+ private static final int NO_FLAG = 0;
+ private static final int OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE = 500000000;
+
private final ReentrantLock accessLock = new ReentrantLock();
private DefaultSubscriptions defaultSubscriptions;
private Subscriptions subscriptions;
private JSONPrefs jsonPrefs;
private AppInfo appInfo;
private LinkedBlockingQueue<EngineEvent> engineEvents = new LinkedBlockingQueue<EngineEvent>();
private Thread handlerThread;
private Downloader downloader;
@@ -154,16 +161,39 @@
.queryIntentActivities(new Intent(ACTION_OPEN_SETTINGS), 0).size() > 0;
}
catch (final Throwable t)
{
return false;
}
}
+ /**
+ * Starting with Samsung Internet 5.0, the way to enable ad blocking has changed. As a result, we
+ * need to check for the version of Samsung Internet and apply text changes to the first run slide.
+ *
+ * @param activityContext
+ * @return a boolean that indicates, if the user has Samsung Internet version 5.x
+ */
+ public static boolean hasSamsungInternetVersion5OrNewer(final Context activityContext)
+ {
+ try
+ {
+ PackageInfo packageInfo = activityContext.getPackageManager().getPackageInfo(SBROWSER_APP_ID, NO_FLAG);
+ return packageInfo.versionCode >= OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE;
+ }
+ catch (PackageManager.NameNotFoundException e)
+ {
+ // Should never happen, as checkAAStatusAndProceed() should not be called if the user
+ // has no compatible SBrowser installed. Nevertheless we have to handle the Exception.
+ Log.d(TAG, "No compatible Samsung Browser found.", e);
+ return false;
+ }
+ }
+
public void requestUpdateBroadcast()
{
this.lock();
try
{
this.nextUpdateBroadcast = System.currentTimeMillis() + BROADCAST_COMBINATION_DELAY_MILLIS;
}
finally
« no previous file with comments | « adblockplussbrowser/src/org/adblockplus/sbrowser/contentblocker/MainPreferences.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld