Added the ability to have the actual apk file sourced from elsewhere
This commit is contained in:
parent
a2c1b3da17
commit
55c06a203e
@ -401,8 +401,13 @@ public class AppDetails extends ListActivity {
|
|||||||
// it...
|
// it...
|
||||||
if (apk_file == null) {
|
if (apk_file == null) {
|
||||||
|
|
||||||
String remotefile = curapk.server + "/"
|
String remotefile;
|
||||||
|
if (curapk.apkSource == null) {
|
||||||
|
remotefile = curapk.server + "/"
|
||||||
+ apkname.replace(" ", "%20");
|
+ apkname.replace(" ", "%20");
|
||||||
|
} else {
|
||||||
|
remotefile = curapk.apkSource;
|
||||||
|
}
|
||||||
Log.d("FDroid", "Downloading apk from " + remotefile);
|
Log.d("FDroid", "Downloading apk from " + remotefile);
|
||||||
|
|
||||||
Message msg = new Message();
|
Message msg = new Message();
|
||||||
|
@ -31,7 +31,6 @@ import android.content.pm.PackageManager;
|
|||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.database.sqlite.SQLiteOpenHelper;
|
import android.database.sqlite.SQLiteOpenHelper;
|
||||||
import android.database.sqlite.SQLiteDatabase.CursorFactory;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class DB {
|
public class DB {
|
||||||
@ -121,8 +120,7 @@ public class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The TABLE_APK table stores details of all the application versions we
|
// The TABLE_APK table stores details of all the application versions we
|
||||||
// know
|
// know about. Each relates directly back to an entry in TABLE_APP.
|
||||||
// about. Each relates directly back to an entry in TABLE_APP.
|
|
||||||
// This information is retrieved from the repositories.
|
// This information is retrieved from the repositories.
|
||||||
private static final String TABLE_APK = "fdroid_apk";
|
private static final String TABLE_APK = "fdroid_apk";
|
||||||
private static final String CREATE_TABLE_APK = "create table " + TABLE_APK
|
private static final String CREATE_TABLE_APK = "create table " + TABLE_APK
|
||||||
@ -136,6 +134,7 @@ public class DB {
|
|||||||
public Apk() {
|
public Apk() {
|
||||||
updated = false;
|
updated = false;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
apkSource = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String id;
|
public String id;
|
||||||
@ -146,6 +145,11 @@ public class DB {
|
|||||||
public String hash;
|
public String hash;
|
||||||
public String apkName;
|
public String apkName;
|
||||||
|
|
||||||
|
// If null, the apk comes from the same server as the repo index.
|
||||||
|
// Otherwise
|
||||||
|
// this is the complete URL to download the apk from.
|
||||||
|
public String apkSource;
|
||||||
|
|
||||||
// Used internally for tracking during repo updates.
|
// Used internally for tracking during repo updates.
|
||||||
public boolean updated;
|
public boolean updated;
|
||||||
|
|
||||||
@ -186,7 +190,10 @@ public class DB {
|
|||||||
|
|
||||||
// Version 2...
|
// Version 2...
|
||||||
{ "alter table " + TABLE_APP + " add marketVersion text",
|
{ "alter table " + TABLE_APP + " add marketVersion text",
|
||||||
"alter table " + TABLE_APP + " add marketVercode integer" }
|
"alter table " + TABLE_APP + " add marketVercode integer" },
|
||||||
|
|
||||||
|
// Version 3...
|
||||||
|
{ "alter table " + TABLE_APK + " add apkSource text" }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -211,7 +218,7 @@ public class DB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||||
for(int v=oldVersion+1;v<=newVersion;v++)
|
for (int v = oldVersion + 1; v <= newVersion; v++)
|
||||||
for (int i = 0; i < DB_UPGRADES[v - 2].length; i++)
|
for (int i = 0; i < DB_UPGRADES[v - 2].length; i++)
|
||||||
db.execSQL(DB_UPGRADES[v - 2][i]);
|
db.execSQL(DB_UPGRADES[v - 2][i]);
|
||||||
}
|
}
|
||||||
@ -226,7 +233,7 @@ public class DB {
|
|||||||
|
|
||||||
public DB(Context ctx) {
|
public DB(Context ctx) {
|
||||||
|
|
||||||
DBHelper h=new DBHelper(ctx);
|
DBHelper h = new DBHelper(ctx);
|
||||||
db = h.getWritableDatabase();
|
db = h.getWritableDatabase();
|
||||||
mPm = ctx.getPackageManager();
|
mPm = ctx.getPackageManager();
|
||||||
}
|
}
|
||||||
@ -236,15 +243,15 @@ public class DB {
|
|||||||
db = null;
|
db = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the database, which should cause it to be re-created next time it's
|
// Delete the database, which should cause it to be re-created next time
|
||||||
// used.
|
// it's used.
|
||||||
public static void delete(Context ctx) {
|
public static void delete(Context ctx) {
|
||||||
try {
|
try {
|
||||||
ctx.deleteDatabase(DATABASE_NAME);
|
ctx.deleteDatabase(DATABASE_NAME);
|
||||||
// Also try and delete the old one, from versions 0.13 and earlier.
|
// Also try and delete the old one, from versions 0.13 and earlier.
|
||||||
ctx.deleteDatabase("fdroid_db");
|
ctx.deleteDatabase("fdroid_db");
|
||||||
} catch(Exception ex) {
|
} catch (Exception ex) {
|
||||||
Log.d("FDroid","Exception in DB.delete: "+ex.getMessage());
|
Log.d("FDroid", "Exception in DB.delete: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,6 +308,7 @@ public class DB {
|
|||||||
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
apk.hash = c2.getString(c2.getColumnIndex("hash"));
|
||||||
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
apk.size = c2.getInt(c2.getColumnIndex("size"));
|
||||||
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
|
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
|
||||||
|
apk.apkSource = c2.getString(c2.getColumnIndex("apkSource"));
|
||||||
app.apks.add(apk);
|
app.apks.add(apk);
|
||||||
c2.moveToNext();
|
c2.moveToNext();
|
||||||
}
|
}
|
||||||
@ -522,6 +530,7 @@ public class DB {
|
|||||||
values.put("hash", upapk.hash);
|
values.put("hash", upapk.hash);
|
||||||
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);
|
||||||
if (oldapk != null) {
|
if (oldapk != null) {
|
||||||
db.update(TABLE_APK, values, "id = '" + oldapk.id
|
db.update(TABLE_APK, values, "id = '" + oldapk.id
|
||||||
+ "' and version = '" + oldapk.version + "'", null);
|
+ "' and version = '" + oldapk.version + "'", null);
|
||||||
|
@ -104,6 +104,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapk.hash = str;
|
curapk.hash = str;
|
||||||
} else if (curel == "apkname") {
|
} else if (curel == "apkname") {
|
||||||
curapk.apkName = str;
|
curapk.apkName = str;
|
||||||
|
} else if (curel == "apksource") {
|
||||||
|
curapk.apkSource = str;
|
||||||
}
|
}
|
||||||
} else if (curapp != null && str != null) {
|
} else if (curapp != null && str != null) {
|
||||||
if (curel == "id") {
|
if (curel == "id") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user