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

Unified Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29399749: Issue 5081 - Make libadblockplus-android users supply the application and applicationVersion parame… (Closed)
Patch Set: Created March 31, 2017, 1:28 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: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
diff --git a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
index 3cabbbbb58d298a782cc47809d45970b6cce7d26..9f4e981b89aa4eb788acaff233f9f14abffbcba9 100644
--- a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
@@ -79,29 +79,35 @@ public final class AdblockEngine
private volatile boolean enabled = true;
private volatile List<String> whitelistedDomains;
- public static AppInfo generateAppInfo(final Context context, boolean developmentBuild)
+ public static AppInfo generateAppInfo(final Context context, boolean developmentBuild,
+ String application, String applicationVersion)
{
- String version = "0";
- try
- {
- final PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
- version = info.versionName;
- if (developmentBuild)
- version += "." + info.versionCode;
anton 2017/03/31 13:30:27 addonVersion is generated, but we need hardcoded v
sergei 2017/03/31 13:49:09 I'm not sure that we should use a hard coded value
anton 2017/03/31 13:52:26 it's not clear from the task. i think the intentio
sergei 2017/03/31 14:01:52 I thought we control this version because it's our
anton 2017/03/31 14:05:27 no, it's app package, not library
- }
- catch (final NameNotFoundException e)
- {
- Log.e(TAG, "Failed to get the application version number", e);
- }
final String sdkVersion = String.valueOf(VERSION.SDK_INT);
final String locale = Locale.getDefault().toString().replace('_', '-');
- return AppInfo.builder()
- .setVersion(version)
+ AppInfo.Builder builder =
+ AppInfo
+ .builder()
.setApplicationVersion(sdkVersion)
.setLocale(locale)
- .setDevelopmentBuild(developmentBuild)
- .build();
+ .setDevelopmentBuild(developmentBuild);
+
+ if (application != null)
+ {
+ builder.setApplication(application);
+ }
+
+ if (applicationVersion != null)
+ {
+ builder.setApplicationVersion(applicationVersion);
+ }
+
+ return builder.build();
+ }
+
+ public static AppInfo generateAppInfo(final Context context, boolean developmentBuild)
sergei 2017/03/31 13:49:09 So, currently application and applicationVersion a
anton 2017/03/31 13:52:26 there will be no compilation errors here
sergei 2017/03/31 14:01:52 Then I think it should be removed.
anton 2017/03/31 14:05:27 not clear what you've meant. if the user(app devel
sergei 2017/03/31 14:08:33 That was the idea to don't allow to use this metho
+ {
+ return generateAppInfo(context, developmentBuild, null, null);
}
/**

Powered by Google App Engine
This is Rietveld