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

Side by Side Diff: src/org/adblockplus/android/ABPEngine.java

Issue 5336189238247424: Populate AppInfo properly (Closed)
Patch Set: Created Nov. 15, 2013, 1:41 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
« no previous file with comments | « jni/abpEngine.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 org.adblockplus.android.updater.UpdaterActivity; 20 import org.adblockplus.android.updater.UpdaterActivity;
21 21
22 import android.app.Notification; 22 import android.app.Notification;
23 import android.app.NotificationManager; 23 import android.app.NotificationManager;
24 import android.app.PendingIntent; 24 import android.app.PendingIntent;
25 import android.content.Context; 25 import android.content.Context;
26 import android.content.Intent; 26 import android.content.Intent;
27 import android.content.pm.PackageInfo;
28 import android.content.pm.PackageManager.NameNotFoundException;
29 import android.os.Build.VERSION;
27 import android.support.v4.app.NotificationCompat; 30 import android.support.v4.app.NotificationCompat;
31 import android.util.Log;
28 32
29 public class ABPEngine 33 public class ABPEngine
30 { 34 {
31 private final static String TAG = "ABPEngine"; 35 private final static String TAG = "ABPEngine";
32 private static final int NOTIFICATION_ID = R.string.app_name + 1; 36 private static final int NOTIFICATION_ID = R.string.app_name + 1;
33 37
34 private Context context; 38 private Context context;
35 39
36 public ABPEngine(Context context, String basePath) 40 public ABPEngine(Context context, String basePath)
37 { 41 {
38 this.context = context; 42 this.context = context;
39 initialize(basePath); 43 String version;
44 try
45 {
46 final PackageInfo info = context.getPackageManager().getPackageInfo(contex t.getPackageName(), 0);
47 version = info.versionName + "." + info.versionCode;
48 } catch (NameNotFoundException e)
49 {
50 Log.e(TAG, "Failed to get the application version number", e);
51 version = "0";
52 }
53 final String applicationVersion = String.valueOf(VERSION.SDK_INT);
Wladimir Palant 2013/11/17 06:31:06 Shouldn't this be called sdkVersion?
Felix Dahlke 2013/11/18 15:42:35 Done.
54 final String locale = context.getResources().getConfiguration().locale.toStr ing();
55 final boolean developmentBuild = !context.getResources().getBoolean(R.bool.d ef_release);
56 initialize(basePath, version, applicationVersion, locale, developmentBuild);
40 } 57 }
41 58
42 public void onFilterChanged(String url, String status, long time) 59 public void onFilterChanged(String url, String status, long time)
43 { 60 {
44 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS). putExtra("url", url).putExtra("status", status).putExtra("time", time)); 61 context.sendBroadcast(new Intent(AdblockPlus.BROADCAST_SUBSCRIPTION_STATUS). putExtra("url", url).putExtra("status", status).putExtra("time", time));
45 } 62 }
46 63
47 /** 64 /**
48 * Called when update event occurred. 65 * Called when update event occurred.
49 * @param url Update download address 66 * @param url Update download address
50 */ 67 */
51 public void onUpdateEvent(String url, String error) 68 public void onUpdateEvent(String url, String error)
52 { 69 {
53 Notification notification = getNotification(url, error); 70 Notification notification = getNotification(url, error);
54 NotificationManager notificationManager = (NotificationManager) context.getS ystemService(Context.NOTIFICATION_SERVICE); 71 NotificationManager notificationManager = (NotificationManager) context.getS ystemService(Context.NOTIFICATION_SERVICE);
55 notificationManager.notify(NOTIFICATION_ID, notification); 72 notificationManager.notify(NOTIFICATION_ID, notification);
56 } 73 }
57 74
58 private native void initialize(String basePath); 75 private native void initialize(String basePath, String version, String sdkVers ion, String locale, boolean developmentBuild);
59 76
60 public native void release(); 77 public native void release();
61 78
62 public native boolean isFirstRun(); 79 public native boolean isFirstRun();
63 80
64 public native Subscription[] getListedSubscriptions(); 81 public native Subscription[] getListedSubscriptions();
65 82
66 public native Subscription[] getRecommendedSubscriptions(); 83 public native Subscription[] getRecommendedSubscriptions();
67 84
68 public native void addSubscription(String url); 85 public native void addSubscription(String url);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 132
116 Notification notification = builder.getNotification(); 133 Notification notification = builder.getNotification();
117 return notification; 134 return notification;
118 } 135 }
119 136
120 static 137 static
121 { 138 {
122 System.loadLibrary("abpEngine"); 139 System.loadLibrary("abpEngine");
123 } 140 }
124 } 141 }
OLDNEW
« no previous file with comments | « jni/abpEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld