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;
|
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) {
|
if (caninstall) {
|
||||||
p.setButton(getString(R.string.install),
|
p.setButton(getString(R.string.install),
|
||||||
|
@ -90,9 +90,9 @@ public class DB {
|
|||||||
public String marketVersion;
|
public String marketVersion;
|
||||||
public int marketVercode;
|
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.
|
// 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
|
// True if there are new versions (apks) that the user hasn't
|
||||||
// explicitly ignored. (We're currently not using the database
|
// 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 int size; // Size in bytes - 0 means we don't know!
|
||||||
public String server;
|
public String server;
|
||||||
public String hash;
|
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
|
// ID (md5 sum of public key) of signature. Might be null, in the
|
||||||
// transition to this field existing.
|
// transition to this field existing.
|
||||||
@ -236,7 +239,12 @@ public class DB {
|
|||||||
{ "alter table " + TABLE_APP + " add donateURL string" },
|
{ "alter table " + TABLE_APP + " add donateURL string" },
|
||||||
|
|
||||||
// Version 9...
|
// 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 {
|
private class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
@ -360,12 +368,11 @@ public class DB {
|
|||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
|
|
||||||
App app = new App();
|
App app = new App();
|
||||||
app.antiFeatures = c
|
app.antiFeatures = decodeList(c
|
||||||
.getString(c.getColumnIndex("antiFeatures"));
|
.getString(c.getColumnIndex("antiFeatures")));
|
||||||
boolean include = true;
|
boolean include = true;
|
||||||
if (app.antiFeatures != null && app.antiFeatures.length() > 0) {
|
if (app.antiFeatures != null) {
|
||||||
String[] afs = app.antiFeatures.split(",");
|
for (String af : app.antiFeatures) {
|
||||||
for (String af : afs) {
|
|
||||||
if (af.equals("Ads") && !pref_antiAds)
|
if (af.equals("Ads") && !pref_antiAds)
|
||||||
include = false;
|
include = false;
|
||||||
else if (af.equals("Tracking") && !pref_antiTracking)
|
else if (af.equals("Tracking") && !pref_antiTracking)
|
||||||
@ -421,6 +428,12 @@ public class DB {
|
|||||||
.getString(c2.getColumnIndex("apkName"));
|
.getString(c2.getColumnIndex("apkName"));
|
||||||
apk.apkSource = c2.getString(c2
|
apk.apkSource = c2.getString(c2
|
||||||
.getColumnIndex("apkSource"));
|
.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);
|
app.apks.add(apk);
|
||||||
c2.moveToNext();
|
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;
|
private Vector<App> updateApps = null;
|
||||||
|
|
||||||
// Called before a repo update starts.
|
// Called before a repo update starts.
|
||||||
@ -637,7 +669,7 @@ public class DB {
|
|||||||
values.put("installedVerCode", upapp.installedVerCode);
|
values.put("installedVerCode", upapp.installedVerCode);
|
||||||
values.put("marketVersion", upapp.marketVersion);
|
values.put("marketVersion", upapp.marketVersion);
|
||||||
values.put("marketVercode", upapp.marketVercode);
|
values.put("marketVercode", upapp.marketVercode);
|
||||||
values.put("antiFeatures", upapp.antiFeatures);
|
values.put("antiFeatures", encodeList(upapp.antiFeatures));
|
||||||
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
|
values.put("hasUpdates", upapp.hasUpdates ? 1 : 0);
|
||||||
if (oldapp != null) {
|
if (oldapp != null) {
|
||||||
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
db.update(TABLE_APP, values, "id = ?", new String[] { oldapp.id });
|
||||||
@ -664,6 +696,9 @@ public class DB {
|
|||||||
values.put("size", upapk.size);
|
values.put("size", upapk.size);
|
||||||
values.put("apkName", upapk.apkName);
|
values.put("apkName", upapk.apkName);
|
||||||
values.put("apkSource", upapk.apkSource);
|
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) {
|
if (oldapk != null) {
|
||||||
db.update(TABLE_APK, values, "id = ? and version =?", new String[] {
|
db.update(TABLE_APK, values, "id = ? and version =?", new String[] {
|
||||||
oldapk.id, oldapk.version });
|
oldapk.id, oldapk.version });
|
||||||
|
@ -119,6 +119,16 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapk.apkName = str;
|
curapk.apkName = str;
|
||||||
} else if (curel.equals("apksource")) {
|
} else if (curel.equals("apksource")) {
|
||||||
curapk.apkSource = str;
|
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) {
|
} else if (curapp != null && str != null) {
|
||||||
if (curel.equals("id")) {
|
if (curel.equals("id")) {
|
||||||
@ -151,7 +161,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapp.marketVercode = 0;
|
curapp.marketVercode = 0;
|
||||||
}
|
}
|
||||||
} else if (curel.equals("antifeatures")) {
|
} else if (curel.equals("antifeatures")) {
|
||||||
curapp.antiFeatures = str;
|
curapp.antiFeatures = DB.decodeList(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user