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

Delta Between Two Patch Sets: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/AppInfo.java

Issue 29640558: Issue 6187 - Adjust query string parameters for Yandex (Closed)
Left Patch Set: Created Dec. 15, 2017, 3:53 p.m.
Right Patch Set: Renamed method to isPackageInstalled Created Dec. 18, 2017, 9:29 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 77 }
78 78
79 public static AppInfo create(final Context context) 79 public static AppInfo create(final Context context)
80 { 80 {
81 return new Builder().autoFill(context).build(); 81 return new Builder().autoFill(context).build();
82 } 82 }
83 83
84 public static class Builder 84 public static class Builder
85 { 85 {
86 private static final String SBROWSER_PACKAGE_NAME = "com.sec.android.app.sbr owser"; 86 private static final String SBROWSER_PACKAGE_NAME = "com.sec.android.app.sbr owser";
87 private static final String SBROWSER_BETA_PACKAGE_NAME = "com.sec.android.ap p.sbrowser.beta";
87 private static final String SBROWSER_APP_NAME = "sbrowser"; 88 private static final String SBROWSER_APP_NAME = "sbrowser";
88 private static final String YANDEX_PACKAGE_NAME = "com.yandex.browser"; 89 private static final String YANDEX_PACKAGE_NAME = "com.yandex.browser";
90 private static final String YANDEX_ALPHA_PACKAGE_NAME = "com.yandex.browser. alpha";
91 private static final String YANDEX_BETA_PACKAGE_NAME = "com.yandex.browser.b eta";
89 private static final String YANDEX_APP_NAME = "yandex"; 92 private static final String YANDEX_APP_NAME = "yandex";
90 93
91 private String addonName = "adblockplussbrowser"; 94 private String addonName = "adblockplussbrowser";
92 private String addonVersion = "0"; 95 private String addonVersion = "0";
93 private String application = ""; 96 private String application = "";
94 private String applicationVersion = "0"; 97 private String applicationVersion = "0";
95 private String platform = "android"; 98 private String platform = "android";
96 private String platformVersion = Integer.toString(Build.VERSION.SDK_INT); 99 private String platformVersion = Integer.toString(Build.VERSION.SDK_INT);
97 private String locale = "en-US"; 100 private String locale = "en-US";
98 101
(...skipping 25 matching lines...) Expand all
124 127
125 return this; 128 return this;
126 } 129 }
127 130
128 public AppInfo build() 131 public AppInfo build()
129 { 132 {
130 return new AppInfo(this.addonName, this.addonVersion, this.application, 133 return new AppInfo(this.addonName, this.addonVersion, this.application,
131 this.applicationVersion, this.platform, this.platformVersion, this.loc ale); 134 this.applicationVersion, this.platform, this.platformVersion, this.loc ale);
132 } 135 }
133 136
134 private String checkForCompatibleInstalledBrowser(final PackageManager packa geManager) 137 private String checkForCompatibleInstalledBrowser(final PackageManager packa geManager)
diegocarloslima 2017/12/15 16:13:43 I think that we should also consider all the alpha
jens 2017/12/18 08:41:34 Thats actually a good idea :)
135 { 138 {
136 StringBuilder installedCompatibleBrowser = new StringBuilder(); 139 StringBuilder installedCompatibleBrowser = new StringBuilder();
140
141 if (isPackageInstalled(packageManager, SBROWSER_PACKAGE_NAME)
142 || isPackageInstalled(packageManager, SBROWSER_BETA_PACKAGE_NAME))
143 {
144 installedCompatibleBrowser.append(SBROWSER_APP_NAME);
145 }
146
147 if (isPackageInstalled(packageManager, YANDEX_PACKAGE_NAME)
148 || isPackageInstalled(packageManager, YANDEX_ALPHA_PACKAGE_NAME)
149 || isPackageInstalled(packageManager, YANDEX_BETA_PACKAGE_NAME))
150 {
151 installedCompatibleBrowser.append(YANDEX_APP_NAME);
152 }
153
154 return installedCompatibleBrowser.toString();
155 }
156
157 private boolean isPackageInstalled(final PackageManager packageManager, fina l String packageName)
158 {
137 try 159 try
138 { 160 {
139 packageManager.getPackageInfo(SBROWSER_PACKAGE_NAME, 0); 161 packageManager.getPackageInfo(packageName, 0);
140 installedCompatibleBrowser.append(SBROWSER_APP_NAME); 162 return true;
141 } 163 }
142 catch (PackageManager.NameNotFoundException e) 164 catch (PackageManager.NameNotFoundException e)
143 { 165 {
144 // nothing 166 return false;
145 } 167 }
146 try
147 {
148 packageManager.getPackageInfo(YANDEX_PACKAGE_NAME, 0);
149 installedCompatibleBrowser.append(YANDEX_APP_NAME);
150 }
151 catch (PackageManager.NameNotFoundException e)
152 {
153 // nothing
154 }
155 return installedCompatibleBrowser.toString();
156 } 168 }
157 } 169 }
158 } 170 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld