Make use of sdkver, permissions and features
This commit is contained in:
parent
17d6916e95
commit
08816e4bc8
@ -312,7 +312,33 @@ public class AppDetails extends ListActivity {
|
||||
installed = app.installedVersion;
|
||||
}
|
||||
}
|
||||
p.setMessage(getString(R.string.isinst) + " " + installed);
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(getString(R.string.isinst));
|
||||
msg.append(" ");
|
||||
msg.append(installed);
|
||||
if (caninstall && curapk.minSdkVersion > 0) {
|
||||
msg.append("\nMinimum API level: ");
|
||||
msg.append(curapk.minSdkVersion);
|
||||
}
|
||||
if (caninstall && curapk.permissions != null) {
|
||||
msg.append("\nPermissions required:");
|
||||
for (String perm : curapk.permissions) {
|
||||
msg.append("\n ");
|
||||
msg.append(perm);
|
||||
}
|
||||
}
|
||||
if (caninstall && curapk.features != null) {
|
||||
msg.append("\nFeatures required:");
|
||||
for (String feat : curapk.features) {
|
||||
msg.append("\n ");
|
||||
if (feat.matches("android\\.(hard|soft)ware\\..*"))
|
||||
msg.append(feat.substring(17));
|
||||
else
|
||||
msg.append(feat);
|
||||
}
|
||||
}
|
||||
p.setMessage(msg.toString());
|
||||
|
||||
if (caninstall) {
|
||||
p.setButton(getString(R.string.install),
|
||||
|
@ -90,9 +90,9 @@ public class DB {
|
||||
public String marketVersion;
|
||||
public int marketVercode;
|
||||
|
||||
// Comma-separated list of anti-features (as defined in the metadata
|
||||
// Array of anti-features (as defined in the metadata
|
||||
// documentation) or null if there aren't any.
|
||||
public String antiFeatures;
|
||||
public String[] antiFeatures;
|
||||
|
||||
// True if there are new versions (apks) that the user hasn't
|
||||
// explicitly ignored. (We're currently not using the database
|
||||
@ -158,6 +158,9 @@ public class DB {
|
||||
public int size; // Size in bytes - 0 means we don't know!
|
||||
public String server;
|
||||
public String hash;
|
||||
public int minSdkVersion; // 0 if unknown
|
||||
public String[] permissions; // null if empty or unknown
|
||||
public String[] features; // null if empty or unknown
|
||||
|
||||
// ID (md5 sum of public key) of signature. Might be null, in the
|
||||
// transition to this field existing.
|
||||
@ -236,7 +239,12 @@ public class DB {
|
||||
{ "alter table " + TABLE_APP + " add donateURL string" },
|
||||
|
||||
// Version 9...
|
||||
{ "alter table " + TABLE_APK + " add srcname string" } };
|
||||
{ "alter table " + TABLE_APK + " add srcname string" },
|
||||
|
||||
// Version 10...
|
||||
{ "alter table " + TABLE_APK + " add minSdkVersion integer",
|
||||
"alter table " + TABLE_APK + " add permissions string",
|
||||
"alter table " + TABLE_APK + " add features string" }};
|
||||
|
||||
private class DBHelper extends SQLiteOpenHelper {
|
||||
|
||||
@ -360,12 +368,11 @@ public class DB {
|
||||
while (!c.isAfterLast()) {
|
||||
|
||||
App app = new App();
|
||||
app.antiFeatures = c
|
||||
.getString(c.getColumnIndex("antiFeatures"));
|
||||
app.antiFeatures = decodeList(c
|
||||
.getString(c.getColumnIndex("antiFeatures")));
|
||||
boolean include = true;
|
||||
if (app.antiFeatures != null && app.antiFeatures.length() > 0) {
|
||||
String[] afs = app.antiFeatures.split(",");
|
||||
for (String af : afs) {
|
||||
if (app.antiFeatures != null) {
|
||||
for (String af : app.antiFeatures) {
|
||||
if (af.equals("Ads") && !pref_antiAds)
|
||||
include = false;
|
||||
else if (af.equals("Tracking") && !pref_antiTracking)
|
||||
@ -421,6 +428,12 @@ public class DB {
|
||||
.getString(c2.getColumnIndex("apkName"));
|
||||
apk.apkSource = c2.getString(c2
|
||||
.getColumnIndex("apkSource"));
|
||||
apk.minSdkVersion = c2.getInt(c2
|
||||
.getColumnIndex("minSdkVersion"));
|
||||
apk.permissions = decodeList(c2.getString(c2
|
||||
.getColumnIndex("permissions")));
|
||||
apk.features = decodeList(c2.getString(c2
|
||||
.getColumnIndex("features")));
|
||||
app.apks.add(apk);
|
||||
c2.moveToNext();
|
||||
}
|
||||
@ -497,6 +510,25 @@ public class DB {
|
||||
}
|
||||
}
|
||||
|
||||
// Join the elements of a String array with commas. An empty array
|
||||
// or a null value both result in null as the return value.
|
||||
public static String encodeList(String[] array) {
|
||||
if (array == null || array.length == 0)
|
||||
return null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String e : array) {
|
||||
sb.append(e);
|
||||
sb.append(",");
|
||||
}
|
||||
return sb.substring(0, sb.length() - 1);
|
||||
}
|
||||
|
||||
public static String[] decodeList(String string) {
|
||||
if (string == null || string.length() == 0)
|
||||
return null;
|
||||
return string.split(",");
|
||||
}
|
||||
|
||||
private Vector<App> updateApps = null;
|
||||
|
||||
// Called before a repo update starts.
|
||||
@ -637,7 +669,7 @@ public class DB {
|
||||
values.put("installedVerCode", upapp.installedVerCode);
|
||||
values.put("marketVersion", upapp.marketVersion);
|
||||
values.put("marketVercode", upapp.marketVercode);
|
||||
values.put("antiFeatures", upapp.antiFeatures);
|
||||
values.put("antiFeatures", encodeList(upapp.antiFeatures));
|
||||
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
|
||||
if (oldapp != null) {
|
||||
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
||||
@ -664,6 +696,9 @@ public class DB {
|
||||
values.put("size", upapk.size);
|
||||
values.put("apkName", upapk.apkName);
|
||||
values.put("apkSource", upapk.apkSource);
|
||||
values.put("minSdkVersion", upapk.minSdkVersion);
|
||||
values.put("permissions", encodeList(upapk.permissions));
|
||||
values.put("features", encodeList(upapk.features));
|
||||
if (oldapk != null) {
|
||||
db.update(TABLE_APK, values, "id = ? and version =?", new String[] {
|
||||
oldapk.id, oldapk.version });
|
||||
|
@ -119,6 +119,16 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
curapk.apkName = str;
|
||||
} else if (curel.equals("apksource")) {
|
||||
curapk.apkSource = str;
|
||||
} else if (curel.equals("sdkver")) {
|
||||
try {
|
||||
curapk.minSdkVersion = Integer.parseInt(str);
|
||||
} catch (NumberFormatException ex) {
|
||||
curapk.minSdkVersion = 0;
|
||||
}
|
||||
} else if (curel.equals("permissions")) {
|
||||
curapk.permissions = DB.decodeList(str);
|
||||
} else if (curel.equals("features")) {
|
||||
curapk.features = DB.decodeList(str);
|
||||
}
|
||||
} else if (curapp != null && str != null) {
|
||||
if (curel.equals("id")) {
|
||||
@ -151,7 +161,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
curapp.marketVercode = 0;
|
||||
}
|
||||
} else if (curel.equals("antifeatures")) {
|
||||
curapp.antiFeatures = str;
|
||||
curapp.antiFeatures = DB.decodeList(str);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user