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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 25 matching lines...) Expand all
36 import java.util.List; 36 import java.util.List;
37 import java.util.Map; 37 import java.util.Map;
38 import java.util.Set; 38 import java.util.Set;
39 import java.util.TreeSet; 39 import java.util.TreeSet;
40 import java.util.concurrent.LinkedBlockingQueue; 40 import java.util.concurrent.LinkedBlockingQueue;
41 import java.util.concurrent.TimeUnit; 41 import java.util.concurrent.TimeUnit;
42 import java.util.concurrent.locks.ReentrantLock; 42 import java.util.concurrent.locks.ReentrantLock;
43 import java.util.regex.Pattern; 43 import java.util.regex.Pattern;
44 44
45 import org.adblockplus.adblockplussbrowser.R; 45 import org.adblockplus.adblockplussbrowser.R;
46 import org.adblockplus.sbrowser.contentblocker.MainPreferences;
46 47
47 import android.content.Context; 48 import android.content.Context;
48 import android.content.Intent; 49 import android.content.Intent;
49 import android.content.SharedPreferences; 50 import android.content.SharedPreferences;
51 import android.content.pm.PackageInfo;
52 import android.content.pm.PackageManager;
50 import android.content.pm.ResolveInfo; 53 import android.content.pm.ResolveInfo;
51 import android.net.ConnectivityManager; 54 import android.net.ConnectivityManager;
52 import android.net.NetworkInfo; 55 import android.net.NetworkInfo;
53 import android.net.Uri; 56 import android.net.Uri;
54 import android.os.Handler; 57 import android.os.Handler;
55 import android.os.Looper; 58 import android.os.Looper;
56 import android.preference.PreferenceManager; 59 import android.preference.PreferenceManager;
57 import android.text.TextUtils; 60 import android.text.TextUtils;
58 import android.util.Log; 61 import android.util.Log;
59 62
(...skipping 30 matching lines...) Expand all
90 // INITIAL_UPDATE_CHECK_DELAY_SECONDS 93 // INITIAL_UPDATE_CHECK_DELAY_SECONDS
91 private static final long INITIAL_UPDATE_CHECK_DELAY_SECONDS = 5; 94 private static final long INITIAL_UPDATE_CHECK_DELAY_SECONDS = 5;
92 private static final long UPDATE_CHECK_INTERVAL_MINUTES = 30; 95 private static final long UPDATE_CHECK_INTERVAL_MINUTES = 30;
93 private static final long BROADCAST_COMBINATION_DELAY_MILLIS = 2500; 96 private static final long BROADCAST_COMBINATION_DELAY_MILLIS = 2500;
94 97
95 public static final long MILLIS_PER_SECOND = 1000; 98 public static final long MILLIS_PER_SECOND = 1000;
96 public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND; 99 public static final long MILLIS_PER_MINUTE = 60 * MILLIS_PER_SECOND;
97 public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE; 100 public static final long MILLIS_PER_HOUR = 60 * MILLIS_PER_MINUTE;
98 public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR; 101 public static final long MILLIS_PER_DAY = 24 * MILLIS_PER_HOUR;
99 102
103 private static final int NO_FLAG = 0;
104 private static final int OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE = 500000000;
105
100 private final ReentrantLock accessLock = new ReentrantLock(); 106 private final ReentrantLock accessLock = new ReentrantLock();
101 private DefaultSubscriptions defaultSubscriptions; 107 private DefaultSubscriptions defaultSubscriptions;
102 private Subscriptions subscriptions; 108 private Subscriptions subscriptions;
103 private JSONPrefs jsonPrefs; 109 private JSONPrefs jsonPrefs;
104 private AppInfo appInfo; 110 private AppInfo appInfo;
105 private LinkedBlockingQueue<EngineEvent> engineEvents = new LinkedBlockingQueu e<EngineEvent>(); 111 private LinkedBlockingQueue<EngineEvent> engineEvents = new LinkedBlockingQueu e<EngineEvent>();
106 private Thread handlerThread; 112 private Thread handlerThread;
107 private Downloader downloader; 113 private Downloader downloader;
108 private final Context serviceContext; 114 private final Context serviceContext;
109 private boolean wasFirstRun = false; 115 private boolean wasFirstRun = false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 { 158 {
153 return activityContext.getPackageManager() 159 return activityContext.getPackageManager()
154 .queryIntentActivities(new Intent(ACTION_OPEN_SETTINGS), 0).size() > 0 ; 160 .queryIntentActivities(new Intent(ACTION_OPEN_SETTINGS), 0).size() > 0 ;
155 } 161 }
156 catch (final Throwable t) 162 catch (final Throwable t)
157 { 163 {
158 return false; 164 return false;
159 } 165 }
160 } 166 }
161 167
168 /**
169 * Starting with Samsung Internet 5.0, the way to enable ad blocking has chang ed. As a result, we
170 * need to check for the version of Samsung Internet and apply text changes to the first run slide.
171 *
172 * @param activityContext
173 * @return a boolean that indicates, if the user has Samsung Internet version 5.x
174 */
175 public static boolean hasSamsungInternetVersion5OrNewer(final Context activity Context)
176 {
177 try
178 {
179 PackageInfo packageInfo = activityContext.getPackageManager().getPackageIn fo(MainPreferences.SBROWSER_APP_ID, NO_FLAG);
180 return packageInfo.versionCode >= OLDEST_SAMSUNG_INTERNET_5_VERSIONCODE;
181 }
182 catch (PackageManager.NameNotFoundException e)
183 {
184 // Should never happen, as checkAAStatusAndProceed() should not be called if the user
185 // has no compatible SBrowser installed. Nevertheless we have to handle th e Exception.
186 Log.d(TAG, "No compatible Samsung Browser found.", e);
187 return false;
188 }
189 }
190
162 public void requestUpdateBroadcast() 191 public void requestUpdateBroadcast()
163 { 192 {
164 this.lock(); 193 this.lock();
165 try 194 try
166 { 195 {
167 this.nextUpdateBroadcast = System.currentTimeMillis() + BROADCAST_COMBINAT ION_DELAY_MILLIS; 196 this.nextUpdateBroadcast = System.currentTimeMillis() + BROADCAST_COMBINAT ION_DELAY_MILLIS;
168 } 197 }
169 finally 198 finally
170 { 199 {
171 this.unlock(); 200 this.unlock();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 Log.d(TAG, headers.toString()); 799 Log.d(TAG, headers.toString());
771 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers); 800 this.downloader.enqueueDownload(this.createDownloadURL(sub), sub.getId(), headers);
772 } 801 }
773 } 802 }
774 803
775 public void connectivityChanged() 804 public void connectivityChanged()
776 { 805 {
777 this.downloader.connectivityChanged(); 806 this.downloader.connectivityChanged();
778 } 807 }
779 } 808 }
OLDNEW

Powered by Google App Engine
This is Rietveld