 Issue 4705284891082752:
  Proxy configurators  (Closed)
    
  
    Issue 4705284891082752:
  Proxy configurators  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 
| 3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 | 
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. | 
| 13 * | 13 * | 
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License | 
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 
| 16 */ | 16 */ | 
| 17 | 17 | 
| 18 package org.adblockplus.android; | 18 package org.adblockplus.android; | 
| 19 | 19 | 
| 20 import java.util.concurrent.locks.ReentrantLock; | |
| 21 | |
| 22 import org.adblockplus.android.configurators.NativeProxyConfigurator; | |
| 20 import org.adblockplus.android.updater.UpdaterActivity; | 23 import org.adblockplus.android.updater.UpdaterActivity; | 
| 21 import org.adblockplus.libadblockplus.JsValue; | 24 import org.adblockplus.libadblockplus.JsValue; | 
| 22 import org.adblockplus.libadblockplus.Subscription; | 25 import org.adblockplus.libadblockplus.Subscription; | 
| 23 import org.apache.commons.lang.StringUtils; | 26 import org.apache.commons.lang.StringUtils; | 
| 24 | 27 | 
| 25 import android.app.Notification; | 28 import android.app.Notification; | 
| 26 import android.app.PendingIntent; | 29 import android.app.PendingIntent; | 
| 27 import android.content.Context; | 30 import android.content.Context; | 
| 28 import android.content.Intent; | 31 import android.content.Intent; | 
| 29 import android.support.v4.app.NotificationCompat; | 32 import android.support.v4.app.NotificationCompat; | 
| 30 | 33 | 
| 31 public final class Utils | 34 public final class Utils | 
| 32 { | 35 { | 
| 36 private static final ReentrantLock LOCK = new ReentrantLock(); | |
| 37 private static boolean nativeProxySupportChecked = false; | |
| 38 private static boolean nativeProxySupported = false; | |
| 39 | |
| 33 private Utils() | 40 private Utils() | 
| 34 { | 41 { | 
| 35 // | 42 // | 
| 36 } | 43 } | 
| 37 | 44 | 
| 45 public static boolean isNativeProxySupported(final Context context) | |
| 46 { | |
| 47 LOCK.lock(); | |
| 
Felix Dahlke
2014/08/19 16:14:46
Wouldn't a synchronize method have the same effect
 
René Jeschke
2014/08/19 16:33:24
Yeah, right, somehow I used a lock before, that me
 | |
| 48 try | |
| 49 { | |
| 50 if (!nativeProxySupportChecked) | |
| 51 { | |
| 52 nativeProxySupported = NativeProxyConfigurator.canUse(context); | |
| 53 nativeProxySupportChecked = true; | |
| 54 } | |
| 55 | |
| 56 return nativeProxySupported; | |
| 57 } | |
| 58 finally | |
| 59 { | |
| 60 LOCK.unlock(); | |
| 61 } | |
| 62 } | |
| 63 | |
| 38 public static String getTag(final Class<?> clazz) | 64 public static String getTag(final Class<?> clazz) | 
| 39 { | 65 { | 
| 40 return clazz.getSimpleName(); | 66 return clazz.getSimpleName(); | 
| 41 } | 67 } | 
| 42 | 68 | 
| 43 public static String capitalizeString(final String s) | 69 public static String capitalizeString(final String s) | 
| 44 { | 70 { | 
| 45 if (s == null || s.length() == 0) | 71 if (s == null || s.length() == 0) | 
| 46 { | 72 { | 
| 47 return ""; | 73 return ""; | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 time = lastDownload; | 137 time = lastDownload; | 
| 112 status = "synchronize_last_at"; | 138 status = "synchronize_last_at"; | 
| 113 } | 139 } | 
| 114 | 140 | 
| 115 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS) | 141 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS) | 
| 116 .putExtra("url", sub.getProperty("url").toString()) | 142 .putExtra("url", sub.getProperty("url").toString()) | 
| 117 .putExtra("status", status) | 143 .putExtra("status", status) | 
| 118 .putExtra("time", time * 1000L)); | 144 .putExtra("time", time * 1000L)); | 
| 119 } | 145 } | 
| 120 } | 146 } | 
| OLD | NEW |