when parsing APKs for the local repo, correctly set maxSdkVersion
The original logic had maxSdkVersion=0 meaning infinity. That was changed to be a very large value SDK_VERSION_MAX_VALUE, but getMinMaxSdkVersion() was still returning 0 for APKs where maxSdkVersion was not set. This is a follow up on fc0df0dcf4dd0d5f13de82d7cd9254b2b48cb62d
This commit is contained in:
parent
d54748ff39
commit
02d98826a9
@ -126,10 +126,14 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapk.apkName = str;
|
curapk.apkName = str;
|
||||||
break;
|
break;
|
||||||
case "sdkver":
|
case "sdkver":
|
||||||
curapk.minSdkVersion = Utils.parseInt(str, 0);
|
curapk.minSdkVersion = Utils.parseInt(str, Apk.SDK_VERSION_MIN_VALUE);
|
||||||
break;
|
break;
|
||||||
case "maxsdkver":
|
case "maxsdkver":
|
||||||
curapk.maxSdkVersion = Utils.parseInt(str, 0);
|
curapk.maxSdkVersion = Utils.parseInt(str, Apk.SDK_VERSION_MAX_VALUE);
|
||||||
|
if (curapk.maxSdkVersion == 0) {
|
||||||
|
// before fc0df0dcf4dd0d5f13de82d7cd9254b2b48cb62d, this could be 0
|
||||||
|
curapk.maxSdkVersion = Apk.SDK_VERSION_MAX_VALUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "added":
|
case "added":
|
||||||
curapk.added = Utils.parseDate(str, null);
|
curapk.added = Utils.parseDate(str, null);
|
||||||
|
@ -39,6 +39,7 @@ import com.nostra13.universalimageloader.utils.StorageUtils;
|
|||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.fdroid.fdroid.compat.FileCompat;
|
import org.fdroid.fdroid.compat.FileCompat;
|
||||||
|
import org.fdroid.fdroid.data.Apk;
|
||||||
import org.fdroid.fdroid.data.Repo;
|
import org.fdroid.fdroid.data.Repo;
|
||||||
import org.fdroid.fdroid.data.SanitizedFile;
|
import org.fdroid.fdroid.data.SanitizedFile;
|
||||||
import org.xml.sax.XMLReader;
|
import org.xml.sax.XMLReader;
|
||||||
@ -226,8 +227,8 @@ public final class Utils {
|
|||||||
|
|
||||||
/* PackageManager doesn't give us the min and max sdk versions, so we have
|
/* PackageManager doesn't give us the min and max sdk versions, so we have
|
||||||
* to parse it */
|
* to parse it */
|
||||||
private static int getMinMaxSdkVersion(Context context, String packageName,
|
private static int getSdkVersion(Context context, String packageName,
|
||||||
String attrName) {
|
String attrName, final int defaultValue) {
|
||||||
try {
|
try {
|
||||||
AssetManager am = context.createPackageContext(packageName, 0).getAssets();
|
AssetManager am = context.createPackageContext(packageName, 0).getAssets();
|
||||||
XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
|
XmlResourceParser xml = am.openXmlResourceParser("AndroidManifest.xml");
|
||||||
@ -245,15 +246,15 @@ public final class Utils {
|
|||||||
} catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
|
} catch (PackageManager.NameNotFoundException | IOException | XmlPullParserException e) {
|
||||||
Log.e(TAG, "Could not get min/max sdk version", e);
|
Log.e(TAG, "Could not get min/max sdk version", e);
|
||||||
}
|
}
|
||||||
return 0;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMinSdkVersion(Context context, String packageName) {
|
public static int getMinSdkVersion(Context context, String packageName) {
|
||||||
return getMinMaxSdkVersion(context, packageName, "minSdkVersion");
|
return getSdkVersion(context, packageName, "minSdkVersion", Apk.SDK_VERSION_MIN_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getMaxSdkVersion(Context context, String packageName) {
|
public static int getMaxSdkVersion(Context context, String packageName) {
|
||||||
return getMinMaxSdkVersion(context, packageName, "maxSdkVersion");
|
return getSdkVersion(context, packageName, "maxSdkVersion", Apk.SDK_VERSION_MAX_VALUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return a fingerprint formatted for display
|
// return a fingerprint formatted for display
|
||||||
|
@ -14,6 +14,7 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
|
|
||||||
// Using only byte-range keeps it only 8-bits in the SQLite database
|
// Using only byte-range keeps it only 8-bits in the SQLite database
|
||||||
public static final int SDK_VERSION_MAX_VALUE = Byte.MAX_VALUE;
|
public static final int SDK_VERSION_MAX_VALUE = Byte.MAX_VALUE;
|
||||||
|
public static final int SDK_VERSION_MIN_VALUE = 0;
|
||||||
|
|
||||||
public String packageName;
|
public String packageName;
|
||||||
public String versionName;
|
public String versionName;
|
||||||
@ -22,7 +23,7 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
public long repo; // ID of the repo it comes from
|
public long repo; // ID of the repo it comes from
|
||||||
public String hash;
|
public String hash;
|
||||||
public String hashType;
|
public String hashType;
|
||||||
public int minSdkVersion; // 0 if unknown
|
public int minSdkVersion = SDK_VERSION_MIN_VALUE; // 0 if unknown
|
||||||
public int maxSdkVersion = SDK_VERSION_MAX_VALUE; // "infinity" if not set
|
public int maxSdkVersion = SDK_VERSION_MAX_VALUE; // "infinity" if not set
|
||||||
public Date added;
|
public Date added;
|
||||||
public Utils.CommaSeparatedList permissions; // null if empty or
|
public Utils.CommaSeparatedList permissions; // null if empty or
|
||||||
|
@ -23,6 +23,7 @@ import org.fdroid.fdroid.Hasher;
|
|||||||
import org.fdroid.fdroid.Preferences;
|
import org.fdroid.fdroid.Preferences;
|
||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
|
import org.fdroid.fdroid.data.Apk;
|
||||||
import org.fdroid.fdroid.data.App;
|
import org.fdroid.fdroid.data.App;
|
||||||
import org.fdroid.fdroid.data.SanitizedFile;
|
import org.fdroid.fdroid.data.SanitizedFile;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
@ -452,9 +453,13 @@ public final class LocalRepoManager {
|
|||||||
tagHash(app);
|
tagHash(app);
|
||||||
tag("sig", app.installedApk.sig.toLowerCase(Locale.US));
|
tag("sig", app.installedApk.sig.toLowerCase(Locale.US));
|
||||||
tag("size", app.installedApk.installedFile.length());
|
tag("size", app.installedApk.installedFile.length());
|
||||||
tag("sdkver", app.installedApk.minSdkVersion);
|
|
||||||
tag("maxsdkver", app.installedApk.maxSdkVersion);
|
|
||||||
tag("added", app.installedApk.added);
|
tag("added", app.installedApk.added);
|
||||||
|
if (app.installedApk.minSdkVersion > Apk.SDK_VERSION_MIN_VALUE) {
|
||||||
|
tag("sdkver", app.installedApk.minSdkVersion);
|
||||||
|
}
|
||||||
|
if (app.installedApk.maxSdkVersion < Apk.SDK_VERSION_MAX_VALUE) {
|
||||||
|
tag("maxsdkver", app.installedApk.maxSdkVersion);
|
||||||
|
}
|
||||||
tagFeatures(app);
|
tagFeatures(app);
|
||||||
tagPermissions(app);
|
tagPermissions(app);
|
||||||
tagNativecode(app);
|
tagNativecode(app);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user