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: Created May 5, 2017, 2:58 p.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
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;
@@ -92,16 +95,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 +160,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(MainPreferences.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

Powered by Google App Engine
This is Rietveld