OLD | NEW |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 24 matching lines...) Expand all Loading... |
35 import org.adblockplus.libadblockplus.JsEngine; | 35 import org.adblockplus.libadblockplus.JsEngine; |
36 import org.adblockplus.libadblockplus.JsValue; | 36 import org.adblockplus.libadblockplus.JsValue; |
37 import org.adblockplus.libadblockplus.LogSystem; | 37 import org.adblockplus.libadblockplus.LogSystem; |
38 import org.adblockplus.libadblockplus.ShowNotificationCallback; | 38 import org.adblockplus.libadblockplus.ShowNotificationCallback; |
39 import org.adblockplus.libadblockplus.Subscription; | 39 import org.adblockplus.libadblockplus.Subscription; |
40 import org.adblockplus.libadblockplus.UpdateAvailableCallback; | 40 import org.adblockplus.libadblockplus.UpdateAvailableCallback; |
41 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 41 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
42 import org.adblockplus.libadblockplus.WebRequest; | 42 import org.adblockplus.libadblockplus.WebRequest; |
43 | 43 |
44 import android.content.Context; | 44 import android.content.Context; |
| 45 import android.content.pm.PackageInfo; |
| 46 import android.content.pm.PackageManager; |
45 import android.os.Build.VERSION; | 47 import android.os.Build.VERSION; |
46 import android.os.Handler; | 48 import android.os.Handler; |
47 import android.os.Looper; | 49 import android.os.Looper; |
48 import android.util.Log; | 50 import android.util.Log; |
49 | 51 |
50 public final class AdblockEngine | 52 public final class AdblockEngine |
51 { | 53 { |
52 // default base path to store subscription files in android app | 54 // default base path to store subscription files in android app |
53 public static final String BASE_PATH_DIRECTORY = "adblock"; | 55 public static final String BASE_PATH_DIRECTORY = "adblock"; |
54 | 56 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (applicationVersion != null) | 100 if (applicationVersion != null) |
99 { | 101 { |
100 builder.setApplicationVersion(applicationVersion); | 102 builder.setApplicationVersion(applicationVersion); |
101 } | 103 } |
102 | 104 |
103 return builder.build(); | 105 return builder.build(); |
104 } | 106 } |
105 | 107 |
106 public static AppInfo generateAppInfo(final Context context, boolean developme
ntBuild) | 108 public static AppInfo generateAppInfo(final Context context, boolean developme
ntBuild) |
107 { | 109 { |
108 return generateAppInfo(context, developmentBuild, null, null); | 110 try |
| 111 { |
| 112 PackageInfo packageInfo = context.getPackageManager().getPackageInfo(conte
xt.getPackageName(), 0); |
| 113 String application = context.getPackageName(); |
| 114 String applicationVersion = packageInfo.versionName; |
| 115 |
| 116 return generateAppInfo(context, developmentBuild, application, application
Version); |
| 117 } |
| 118 catch (PackageManager.NameNotFoundException e) |
| 119 { |
| 120 throw new RuntimeException(e); |
| 121 } |
109 } | 122 } |
110 | 123 |
111 /** | 124 /** |
112 * Builds Adblock engine | 125 * Builds Adblock engine |
113 */ | 126 */ |
114 public static class Builder | 127 public static class Builder |
115 { | 128 { |
116 private Context context; | 129 private Context context; |
117 private Map<String, Integer> urlToResourceIdMap; | 130 private Map<String, Integer> urlToResourceIdMap; |
118 private AndroidWebRequestResourceWrapper.Storage resourceStorage; | 131 private AndroidWebRequestResourceWrapper.Storage resourceStorage; |
(...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 public void setWhitelistedDomains(List<String> domains) | 670 public void setWhitelistedDomains(List<String> domains) |
658 { | 671 { |
659 this.whitelistedDomains = domains; | 672 this.whitelistedDomains = domains; |
660 } | 673 } |
661 | 674 |
662 public List<String> getWhitelistedDomains() | 675 public List<String> getWhitelistedDomains() |
663 { | 676 { |
664 return whitelistedDomains; | 677 return whitelistedDomains; |
665 } | 678 } |
666 } | 679 } |
OLD | NEW |