parent
887bb171aa
commit
1abbedc4ab
@ -121,7 +121,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
||||||
assertEquals("com.example", apk.packageName);
|
assertEquals("com.example", apk.packageName);
|
||||||
assertEquals(10, apk.vercode);
|
assertEquals(10, apk.versionCode);
|
||||||
|
|
||||||
assertNull(apk.features);
|
assertNull(apk.features);
|
||||||
assertNull(apk.added);
|
assertNull(apk.added);
|
||||||
@ -147,7 +147,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
updatedCursor.close();
|
updatedCursor.close();
|
||||||
|
|
||||||
assertEquals("com.example", updatedApk.packageName);
|
assertEquals("com.example", updatedApk.packageName);
|
||||||
assertEquals(10, updatedApk.vercode);
|
assertEquals(10, updatedApk.versionCode);
|
||||||
|
|
||||||
assertNotNull(updatedApk.features);
|
assertNotNull(updatedApk.features);
|
||||||
assertNotNull(updatedApk.added);
|
assertNotNull(updatedApk.added);
|
||||||
@ -187,7 +187,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
// The find() method populates ALL fields if you don't specify any,
|
// The find() method populates ALL fields if you don't specify any,
|
||||||
// so we expect to find each of the ones we inserted above...
|
// so we expect to find each of the ones we inserted above...
|
||||||
assertEquals("com.example", apk.packageName);
|
assertEquals("com.example", apk.packageName);
|
||||||
assertEquals(11, apk.vercode);
|
assertEquals(11, apk.versionCode);
|
||||||
assertEquals("v1.1", apk.version);
|
assertEquals("v1.1", apk.version);
|
||||||
assertEquals("xxxxyyyy", apk.hash);
|
assertEquals("xxxxyyyy", apk.hash);
|
||||||
assertEquals("a hash type", apk.hashType);
|
assertEquals("a hash type", apk.hashType);
|
||||||
@ -207,7 +207,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
// Didn't ask for these fields, so should be their default values...
|
// Didn't ask for these fields, so should be their default values...
|
||||||
assertNull(apkLessFields.hashType);
|
assertNull(apkLessFields.hashType);
|
||||||
assertNull(apkLessFields.version);
|
assertNull(apkLessFields.version);
|
||||||
assertEquals(0, apkLessFields.vercode);
|
assertEquals(0, apkLessFields.versionCode);
|
||||||
|
|
||||||
Apk notFound = ApkProvider.Helper.find(getMockContext(), "com.doesnt.exist", 1000);
|
Apk notFound = ApkProvider.Helper.find(getMockContext(), "com.doesnt.exist", 1000);
|
||||||
assertNull(notFound);
|
assertNull(notFound);
|
||||||
|
@ -233,7 +233,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
Apk apk = new MockApk("org.fdroid.fdroid", 13);
|
Apk apk = new MockApk("org.fdroid.fdroid", 13);
|
||||||
|
|
||||||
// Insert a new record...
|
// Insert a new record...
|
||||||
Uri newUri = TestUtils.insertApk(this, apk.packageName, apk.vercode);
|
Uri newUri = TestUtils.insertApk(this, apk.packageName, apk.versionCode);
|
||||||
assertEquals(ApkProvider.getContentUri(apk).toString(), newUri.toString());
|
assertEquals(ApkProvider.getContentUri(apk).toString(), newUri.toString());
|
||||||
cursor = queryAllApks();
|
cursor = queryAllApks();
|
||||||
assertNotNull(cursor);
|
assertNotNull(cursor);
|
||||||
@ -257,7 +257,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
Apk toCheck = new Apk(cursor);
|
Apk toCheck = new Apk(cursor);
|
||||||
cursor.close();
|
cursor.close();
|
||||||
assertEquals("org.fdroid.fdroid", toCheck.packageName);
|
assertEquals("org.fdroid.fdroid", toCheck.packageName);
|
||||||
assertEquals(13, toCheck.vercode);
|
assertEquals(13, toCheck.versionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCount() {
|
public void testCount() {
|
||||||
@ -330,7 +330,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
// But this should have saved correctly...
|
// But this should have saved correctly...
|
||||||
assertEquals("Some features", apk.features.toString());
|
assertEquals("Some features", apk.features.toString());
|
||||||
assertEquals("com.example.com", apk.packageName);
|
assertEquals("com.example.com", apk.packageName);
|
||||||
assertEquals(1, apk.vercode);
|
assertEquals(1, apk.versionCode);
|
||||||
assertEquals(10, apk.repo);
|
assertEquals(10, apk.repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ abstract class BaseApkProviderTest extends FDroidProviderTest<ApkProvider> {
|
|||||||
protected void assertContains(List<Apk> apks, Apk apk) {
|
protected void assertContains(List<Apk> apks, Apk apk) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Apk a : apks) {
|
for (Apk a : apks) {
|
||||||
if (a.vercode == apk.vercode && a.packageName.equals(apk.packageName)) {
|
if (a.versionCode == apk.versionCode && a.packageName.equals(apk.packageName)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ public class MultiRepoUpdaterTest extends InstrumentationTestCase {
|
|||||||
for (int versionCode : versionCodes) {
|
for (int versionCode : versionCodes) {
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (Apk apk : apksToCheck) {
|
for (Apk apk : apksToCheck) {
|
||||||
if (apk.vercode == versionCode && apk.packageName.equals(appId)) {
|
if (apk.versionCode == versionCode && apk.packageName.equals(appId)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ public class MockApk extends Apk {
|
|||||||
|
|
||||||
public MockApk(String id, int versionCode) {
|
public MockApk(String id, int versionCode) {
|
||||||
this.packageName = id;
|
this.packageName = id;
|
||||||
this.vercode = versionCode;
|
this.versionCode = versionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class AppDetails extends AppCompatActivity {
|
|||||||
|
|
||||||
private String getInstalledStatus(final Apk apk) {
|
private String getInstalledStatus(final Apk apk) {
|
||||||
// Definitely not installed.
|
// Definitely not installed.
|
||||||
if (apk.vercode != app.installedVersionCode) {
|
if (apk.versionCode != app.installedVersionCode) {
|
||||||
return getString(R.string.app_not_installed);
|
return getString(R.string.app_not_installed);
|
||||||
}
|
}
|
||||||
// Definitely installed this version.
|
// Definitely installed this version.
|
||||||
@ -211,7 +211,7 @@ public class AppDetails extends AppCompatActivity {
|
|||||||
|
|
||||||
holder.version.setText(getString(R.string.version)
|
holder.version.setText(getString(R.string.version)
|
||||||
+ " " + apk.version
|
+ " " + apk.version
|
||||||
+ (apk.vercode == app.suggestedVercode ? " ☆" : ""));
|
+ (apk.versionCode == app.suggestedVercode ? " ☆" : ""));
|
||||||
|
|
||||||
holder.status.setText(getInstalledStatus(apk));
|
holder.status.setText(getInstalledStatus(apk));
|
||||||
|
|
||||||
@ -1246,7 +1246,7 @@ public class AppDetails extends AppCompatActivity {
|
|||||||
Apk curApk = null;
|
Apk curApk = null;
|
||||||
for (int i = 0; i < appDetails.getApks().getCount(); i++) {
|
for (int i = 0; i < appDetails.getApks().getCount(); i++) {
|
||||||
final Apk apk = appDetails.getApks().getItem(i);
|
final Apk apk = appDetails.getApks().getItem(i);
|
||||||
if (apk.vercode == app.suggestedVercode) {
|
if (apk.versionCode == app.suggestedVercode) {
|
||||||
curApk = apk;
|
curApk = apk;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1619,9 +1619,9 @@ public class AppDetails extends AppCompatActivity {
|
|||||||
public void onListItemClick(ListView l, View v, int position, long id) {
|
public void onListItemClick(ListView l, View v, int position, long id) {
|
||||||
App app = appDetails.getApp();
|
App app = appDetails.getApp();
|
||||||
final Apk apk = appDetails.getApks().getItem(position - l.getHeaderViewsCount());
|
final Apk apk = appDetails.getApks().getItem(position - l.getHeaderViewsCount());
|
||||||
if (app.installedVersionCode == apk.vercode) {
|
if (app.installedVersionCode == apk.versionCode) {
|
||||||
remove();
|
remove();
|
||||||
} else if (app.installedVersionCode > apk.vercode) {
|
} else if (app.installedVersionCode > apk.versionCode) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
builder.setMessage(R.string.installDowngrade);
|
builder.setMessage(R.string.installDowngrade);
|
||||||
builder.setPositiveButton(R.string.yes,
|
builder.setPositiveButton(R.string.yes,
|
||||||
|
@ -102,7 +102,7 @@ public class CompatibilityChecker {
|
|||||||
}
|
}
|
||||||
if (!features.contains(feat)) {
|
if (!features.contains(feat)) {
|
||||||
Collections.addAll(incompatibleReasons, feat.split(","));
|
Collections.addAll(incompatibleReasons, feat.split(","));
|
||||||
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.vercode
|
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.versionCode
|
||||||
+ " is incompatible based on lack of " + feat);
|
+ " is incompatible based on lack of " + feat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,7 +111,7 @@ public class CompatibilityChecker {
|
|||||||
for (final String code : apk.nativecode) {
|
for (final String code : apk.nativecode) {
|
||||||
incompatibleReasons.add(code);
|
incompatibleReasons.add(code);
|
||||||
}
|
}
|
||||||
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.vercode
|
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.versionCode
|
||||||
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
|
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
|
||||||
+ " while your architectures are " + cpuAbisDesc);
|
+ " while your architectures are " + cpuAbisDesc);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapk.version = str;
|
curapk.version = str;
|
||||||
break;
|
break;
|
||||||
case "versioncode":
|
case "versioncode":
|
||||||
curapk.vercode = Utils.parseInt(str, -1);
|
curapk.versionCode = Utils.parseInt(str, -1);
|
||||||
break;
|
break;
|
||||||
case "size":
|
case "size":
|
||||||
curapk.size = Utils.parseInt(str, 0);
|
curapk.size = Utils.parseInt(str, 0);
|
||||||
|
@ -16,7 +16,7 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
|
|
||||||
public String packageName;
|
public String packageName;
|
||||||
public String version;
|
public String version;
|
||||||
public int vercode;
|
public int versionCode;
|
||||||
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 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;
|
||||||
@ -109,7 +109,7 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
version = cursor.getString(i);
|
version = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.VERSION_CODE:
|
case ApkProvider.DataColumns.VERSION_CODE:
|
||||||
vercode = cursor.getInt(i);
|
versionCode = cursor.getInt(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.REPO_VERSION:
|
case ApkProvider.DataColumns.REPO_VERSION:
|
||||||
repoVersion = cursor.getInt(i);
|
repoVersion = cursor.getInt(i);
|
||||||
@ -123,14 +123,14 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return packageName + " (version " + vercode + ")";
|
return packageName + " (version " + versionCode + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentValues toContentValues() {
|
public ContentValues toContentValues() {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(ApkProvider.DataColumns.PACKAGE_NAME, packageName);
|
values.put(ApkProvider.DataColumns.PACKAGE_NAME, packageName);
|
||||||
values.put(ApkProvider.DataColumns.VERSION, version);
|
values.put(ApkProvider.DataColumns.VERSION, version);
|
||||||
values.put(ApkProvider.DataColumns.VERSION_CODE, vercode);
|
values.put(ApkProvider.DataColumns.VERSION_CODE, versionCode);
|
||||||
values.put(ApkProvider.DataColumns.REPO_ID, repo);
|
values.put(ApkProvider.DataColumns.REPO_ID, repo);
|
||||||
values.put(ApkProvider.DataColumns.HASH, hash);
|
values.put(ApkProvider.DataColumns.HASH, hash);
|
||||||
values.put(ApkProvider.DataColumns.HASH_TYPE, hashType);
|
values.put(ApkProvider.DataColumns.HASH_TYPE, hashType);
|
||||||
@ -153,9 +153,9 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
@TargetApi(19)
|
@TargetApi(19)
|
||||||
public int compareTo(Apk apk) {
|
public int compareTo(Apk apk) {
|
||||||
if (Build.VERSION.SDK_INT < 19) {
|
if (Build.VERSION.SDK_INT < 19) {
|
||||||
return Integer.valueOf(vercode).compareTo(apk.vercode);
|
return Integer.valueOf(versionCode).compareTo(apk.versionCode);
|
||||||
}
|
}
|
||||||
return Integer.compare(vercode, apk.vercode);
|
return Integer.compare(versionCode, apk.versionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
|
|
||||||
public static void update(Context context, Apk apk) {
|
public static void update(Context context, Apk apk) {
|
||||||
ContentResolver resolver = context.getContentResolver();
|
ContentResolver resolver = context.getContentResolver();
|
||||||
Uri uri = getContentUri(apk.packageName, apk.vercode);
|
Uri uri = getContentUri(apk.packageName, apk.versionCode);
|
||||||
resolver.update(uri, apk.toContentValues(), null, null);
|
resolver.update(uri, apk.toContentValues(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Uri getContentUri(Apk apk) {
|
public static Uri getContentUri(Apk apk) {
|
||||||
return getContentUri(apk.packageName, apk.vercode);
|
return getContentUri(apk.packageName, apk.versionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Uri getContentUri(String packageName, int versionCode) {
|
public static Uri getContentUri(String packageName, int versionCode) {
|
||||||
@ -328,8 +328,8 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
builder.append(',');
|
builder.append(',');
|
||||||
}
|
}
|
||||||
final Apk a = apks.get(i);
|
final Apk apk = apks.get(i);
|
||||||
builder.append(a.packageName).append(':').append(a.vercode);
|
builder.append(apk.packageName).append(':').append(apk.versionCode);
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ public class App extends ValueObject implements Comparable<App> {
|
|||||||
final SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
|
final SanitizedFile apkFile = SanitizedFile.knownSanitized(appInfo.publicSourceDir);
|
||||||
final Apk apk = new Apk();
|
final Apk apk = new Apk();
|
||||||
apk.version = packageInfo.versionName;
|
apk.version = packageInfo.versionName;
|
||||||
apk.vercode = packageInfo.versionCode;
|
apk.versionCode = packageInfo.versionCode;
|
||||||
apk.hashType = "sha256";
|
apk.hashType = "sha256";
|
||||||
apk.hash = Utils.getBinaryHash(apkFile, apk.hashType);
|
apk.hash = Utils.getBinaryHash(apkFile, apk.hashType);
|
||||||
apk.added = this.added;
|
apk.added = this.added;
|
||||||
@ -285,7 +285,7 @@ public class App extends ValueObject implements Comparable<App> {
|
|||||||
apk.packageName = this.packageName;
|
apk.packageName = this.packageName;
|
||||||
apk.installedFile = apkFile;
|
apk.installedFile = apkFile;
|
||||||
apk.permissions = Utils.CommaSeparatedList.make(packageInfo.requestedPermissions);
|
apk.permissions = Utils.CommaSeparatedList.make(packageInfo.requestedPermissions);
|
||||||
apk.apkName = apk.packageName + "_" + apk.vercode + ".apk";
|
apk.apkName = apk.packageName + "_" + apk.versionCode + ".apk";
|
||||||
|
|
||||||
final FeatureInfo[] features = packageInfo.reqFeatures;
|
final FeatureInfo[] features = packageInfo.reqFeatures;
|
||||||
if (features != null && features.length > 0) {
|
if (features != null && features.length > 0) {
|
||||||
|
@ -169,7 +169,7 @@ public class RepoPersister {
|
|||||||
for (Apk apk : packages) {
|
for (Apk apk : packages) {
|
||||||
boolean exists = false;
|
boolean exists = false;
|
||||||
for (Apk existing : existingApks) {
|
for (Apk existing : existingApks) {
|
||||||
if (existing.packageName.equals(apk.packageName) && existing.vercode == apk.vercode) {
|
if (existing.packageName.equals(apk.packageName) && existing.versionCode == apk.versionCode) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -256,7 +256,7 @@ public class RepoPersister {
|
|||||||
|
|
||||||
if (packages.containsKey(existingApk.packageName)) {
|
if (packages.containsKey(existingApk.packageName)) {
|
||||||
for (Apk newApk : packages.get(existingApk.packageName)) {
|
for (Apk newApk : packages.get(existingApk.packageName)) {
|
||||||
if (newApk.vercode == existingApk.vercode) {
|
if (newApk.versionCode == existingApk.versionCode) {
|
||||||
shouldStay = true;
|
shouldStay = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class TempApkProvider extends ApkProvider {
|
|||||||
return getContentUri()
|
return getContentUri()
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
.appendPath(PATH_APK)
|
.appendPath(PATH_APK)
|
||||||
.appendPath(Integer.toString(apk.vercode))
|
.appendPath(Integer.toString(apk.versionCode))
|
||||||
.appendPath(apk.packageName)
|
.appendPath(apk.packageName)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ public final class LocalRepoManager {
|
|||||||
if (app.installedApk != null) {
|
if (app.installedApk != null) {
|
||||||
try {
|
try {
|
||||||
appInfo = pm.getApplicationInfo(app.packageName, PackageManager.GET_META_DATA);
|
appInfo = pm.getApplicationInfo(app.packageName, PackageManager.GET_META_DATA);
|
||||||
copyIconToRepo(appInfo.loadIcon(pm), app.packageName, app.installedApk.vercode);
|
copyIconToRepo(appInfo.loadIcon(pm), app.packageName, app.installedApk.versionCode);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
Log.e(TAG, "Error getting app icon", e);
|
Log.e(TAG, "Error getting app icon", e);
|
||||||
}
|
}
|
||||||
@ -439,7 +439,7 @@ public final class LocalRepoManager {
|
|||||||
tag("source", "source");
|
tag("source", "source");
|
||||||
tag("tracker", "tracker");
|
tag("tracker", "tracker");
|
||||||
tag("marketversion", app.installedApk.version);
|
tag("marketversion", app.installedApk.version);
|
||||||
tag("marketvercode", app.installedApk.vercode);
|
tag("marketvercode", app.installedApk.versionCode);
|
||||||
|
|
||||||
tagPackage(app);
|
tagPackage(app);
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ public final class LocalRepoManager {
|
|||||||
serializer.startTag("", "package");
|
serializer.startTag("", "package");
|
||||||
|
|
||||||
tag("version", app.installedApk.version);
|
tag("version", app.installedApk.version);
|
||||||
tag("versioncode", app.installedApk.vercode);
|
tag("versioncode", app.installedApk.versionCode);
|
||||||
tag("apkname", app.installedApk.apkName);
|
tag("apkname", app.installedApk.apkName);
|
||||||
tagHash(app);
|
tagHash(app);
|
||||||
tag("sig", app.installedApk.sig.toLowerCase(Locale.US));
|
tag("sig", app.installedApk.sig.toLowerCase(Locale.US));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user