mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
much better version reading by directly looking for the APG package, rather than looping through all installed packages
This commit is contained in:
parent
dcce05f3df
commit
bda9745d8b
@ -37,7 +37,6 @@ import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.regex.Pattern;
|
||||
@ -90,6 +89,7 @@ import org.thialfihar.android.apg.utils.IterableIterator;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.net.Uri;
|
||||
@ -1836,19 +1836,14 @@ public class Apg {
|
||||
if (VERSION != null) {
|
||||
return VERSION;
|
||||
}
|
||||
List<PackageInfo> packs = context.getPackageManager().getInstalledPackages(0);
|
||||
for (int i = 0; i < packs.size(); ++i) {
|
||||
PackageInfo p = packs.get(i);
|
||||
if (!p.packageName.equals(mApgPackageName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VERSION = p.versionName;
|
||||
try {
|
||||
PackageInfo pi = context.getPackageManager().getPackageInfo(mApgPackageName, 0);
|
||||
VERSION = pi.versionName;
|
||||
return VERSION;
|
||||
} catch (NameNotFoundException e) {
|
||||
// unpossible!
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
// unpossible!
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
public static String getFullVersion(Context context) {
|
||||
|
Loading…
Reference in New Issue
Block a user