Renamed Apk.id to Apk.packageName
This commit is contained in:
parent
5779736913
commit
038816e32a
@ -101,7 +101,7 @@ public class CompatibilityChecker extends Compatibility {
|
|||||||
}
|
}
|
||||||
if (!features.contains(feat)) {
|
if (!features.contains(feat)) {
|
||||||
Collections.addAll(incompatibleReasons, feat.split(","));
|
Collections.addAll(incompatibleReasons, feat.split(","));
|
||||||
Utils.debugLog(TAG, apk.id + " vercode " + apk.vercode
|
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.vercode
|
||||||
+ " is incompatible based on lack of " + feat);
|
+ " is incompatible based on lack of " + feat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public class CompatibilityChecker extends Compatibility {
|
|||||||
for (final String code : apk.nativecode) {
|
for (final String code : apk.nativecode) {
|
||||||
incompatibleReasons.add(code);
|
incompatibleReasons.add(code);
|
||||||
}
|
}
|
||||||
Utils.debugLog(TAG, apk.id + " vercode " + apk.vercode
|
Utils.debugLog(TAG, apk.packageName + " vercode " + apk.vercode
|
||||||
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
|
+ " only supports " + Utils.CommaSeparatedList.str(apk.nativecode)
|
||||||
+ " while your architectures are " + cpuAbisDesc);
|
+ " while your architectures are " + cpuAbisDesc);
|
||||||
}
|
}
|
||||||
|
@ -252,7 +252,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
curapp.packageName = attributes.getValue("", "id");
|
curapp.packageName = attributes.getValue("", "id");
|
||||||
} else if ("package".equals(localName) && curapp != null && curapk == null) {
|
} else if ("package".equals(localName) && curapp != null && curapk == null) {
|
||||||
curapk = new Apk();
|
curapk = new Apk();
|
||||||
curapk.id = curapp.packageName;
|
curapk.packageName = curapp.packageName;
|
||||||
curapk.repo = repo.getId();
|
curapk.repo = repo.getId();
|
||||||
currentApkHashType = null;
|
currentApkHashType = null;
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import java.util.Date;
|
|||||||
|
|
||||||
public class Apk extends ValueObject implements Comparable<Apk> {
|
public class Apk extends ValueObject implements Comparable<Apk> {
|
||||||
|
|
||||||
public String id;
|
public String packageName;
|
||||||
public String version;
|
public String version;
|
||||||
public int vercode;
|
public int vercode;
|
||||||
public int size; // Size in bytes - 0 means we don't know!
|
public int size; // Size in bytes - 0 means we don't know!
|
||||||
@ -65,7 +65,7 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
features = Utils.CommaSeparatedList.make(cursor.getString(i));
|
features = Utils.CommaSeparatedList.make(cursor.getString(i));
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.PACKAGE_NAME:
|
case ApkProvider.DataColumns.PACKAGE_NAME:
|
||||||
id = cursor.getString(i);
|
packageName = cursor.getString(i);
|
||||||
break;
|
break;
|
||||||
case ApkProvider.DataColumns.IS_COMPATIBLE:
|
case ApkProvider.DataColumns.IS_COMPATIBLE:
|
||||||
compatible = cursor.getInt(i) == 1;
|
compatible = cursor.getInt(i) == 1;
|
||||||
@ -118,12 +118,12 @@ public class Apk extends ValueObject implements Comparable<Apk> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id + " (version " + vercode + ")";
|
return packageName + " (version " + vercode + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentValues toContentValues() {
|
public ContentValues toContentValues() {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put(ApkProvider.DataColumns.PACKAGE_NAME, id);
|
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, vercode);
|
||||||
values.put(ApkProvider.DataColumns.REPO_ID, repo);
|
values.put(ApkProvider.DataColumns.REPO_ID, repo);
|
||||||
|
@ -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.id, apk.vercode);
|
Uri uri = getContentUri(apk.packageName, apk.vercode);
|
||||||
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.id, apk.vercode);
|
return getContentUri(apk.packageName, apk.vercode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Uri getContentUri(String id, int versionCode) {
|
public static Uri getContentUri(String id, int versionCode) {
|
||||||
@ -329,7 +329,7 @@ public class ApkProvider extends FDroidProvider {
|
|||||||
builder.append(',');
|
builder.append(',');
|
||||||
}
|
}
|
||||||
final Apk a = apks.get(i);
|
final Apk a = apks.get(i);
|
||||||
builder.append(a.id).append(':').append(a.vercode);
|
builder.append(a.packageName).append(':').append(a.vercode);
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
@ -273,10 +273,10 @@ public class App extends ValueObject implements Comparable<App> {
|
|||||||
apk.added = this.added;
|
apk.added = this.added;
|
||||||
apk.minSdkVersion = Utils.getMinSdkVersion(context, packageName);
|
apk.minSdkVersion = Utils.getMinSdkVersion(context, packageName);
|
||||||
apk.maxSdkVersion = Utils.getMaxSdkVersion(context, packageName);
|
apk.maxSdkVersion = Utils.getMaxSdkVersion(context, packageName);
|
||||||
apk.id = 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.id + "_" + apk.vercode + ".apk";
|
apk.apkName = apk.packageName + "_" + apk.vercode + ".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.id.equals(apk.id) && existing.vercode == apk.vercode) {
|
if (existing.packageName.equals(apk.packageName) && existing.vercode == apk.vercode) {
|
||||||
exists = true;
|
exists = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -254,8 +254,8 @@ public class RepoPersister {
|
|||||||
for (Apk existingApk : existing) {
|
for (Apk existingApk : existing) {
|
||||||
boolean shouldStay = false;
|
boolean shouldStay = false;
|
||||||
|
|
||||||
if (packages.containsKey(existingApk.id)) {
|
if (packages.containsKey(existingApk.packageName)) {
|
||||||
for (Apk newApk : packages.get(existingApk.id)) {
|
for (Apk newApk : packages.get(existingApk.packageName)) {
|
||||||
if (newApk.vercode == existingApk.vercode) {
|
if (newApk.vercode == existingApk.vercode) {
|
||||||
shouldStay = true;
|
shouldStay = true;
|
||||||
break;
|
break;
|
||||||
|
@ -49,7 +49,7 @@ public class TempApkProvider extends ApkProvider {
|
|||||||
.buildUpon()
|
.buildUpon()
|
||||||
.appendPath(PATH_APK)
|
.appendPath(PATH_APK)
|
||||||
.appendPath(Integer.toString(apk.vercode))
|
.appendPath(Integer.toString(apk.vercode))
|
||||||
.appendPath(apk.id)
|
.appendPath(apk.packageName)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ public class ApkDownloader implements AsyncDownloader.Listener {
|
|||||||
Utils.debugLog(TAG, "Downloading apk from " + remoteAddress + " to " + localFile);
|
Utils.debugLog(TAG, "Downloading apk from " + remoteAddress + " to " + localFile);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dlWrapper = DownloaderFactory.createAsync(context, remoteAddress, localFile, app.name + " " + curApk.version, curApk.id, credentials, this);
|
dlWrapper = DownloaderFactory.createAsync(context, remoteAddress, localFile, app.name + " " + curApk.version, curApk.packageName, credentials, this);
|
||||||
dlWrapper.download();
|
dlWrapper.download();
|
||||||
return true;
|
return true;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -112,7 +112,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
Apk apk = new Apk(cursor);
|
Apk apk = new Apk(cursor);
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
||||||
assertEquals("com.example", apk.id);
|
assertEquals("com.example", apk.packageName);
|
||||||
assertEquals(10, apk.vercode);
|
assertEquals(10, apk.vercode);
|
||||||
|
|
||||||
assertNull(apk.features);
|
assertNull(apk.features);
|
||||||
@ -138,7 +138,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
Apk updatedApk = new Apk(updatedCursor);
|
Apk updatedApk = new Apk(updatedCursor);
|
||||||
updatedCursor.close();
|
updatedCursor.close();
|
||||||
|
|
||||||
assertEquals("com.example", updatedApk.id);
|
assertEquals("com.example", updatedApk.packageName);
|
||||||
assertEquals(10, updatedApk.vercode);
|
assertEquals(10, updatedApk.vercode);
|
||||||
|
|
||||||
assertNotNull(updatedApk.features);
|
assertNotNull(updatedApk.features);
|
||||||
@ -176,7 +176,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.id);
|
assertEquals("com.example", apk.packageName);
|
||||||
assertEquals(11, apk.vercode);
|
assertEquals(11, apk.vercode);
|
||||||
assertEquals("v1.1", apk.version);
|
assertEquals("v1.1", apk.version);
|
||||||
assertEquals("xxxxyyyy", apk.hash);
|
assertEquals("xxxxyyyy", apk.hash);
|
||||||
@ -191,7 +191,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
|
|||||||
|
|
||||||
assertNotNull(apkLessFields);
|
assertNotNull(apkLessFields);
|
||||||
|
|
||||||
assertEquals("com.example", apkLessFields.id);
|
assertEquals("com.example", apkLessFields.packageName);
|
||||||
assertEquals("xxxxyyyy", apkLessFields.hash);
|
assertEquals("xxxxyyyy", apkLessFields.hash);
|
||||||
|
|
||||||
// Didn't ask for these fields, so should be their default values...
|
// Didn't ask for these fields, so should be their default values...
|
||||||
|
@ -127,9 +127,9 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
|
|
||||||
assertTotalApkCount(5);
|
assertTotalApkCount(5);
|
||||||
|
|
||||||
assertEquals("com.example.one", one.id);
|
assertEquals("com.example.one", one.packageName);
|
||||||
assertEquals("com.example.two", two.id);
|
assertEquals("com.example.two", two.packageName);
|
||||||
assertEquals("com.example.five", five.id);
|
assertEquals("com.example.five", five.packageName);
|
||||||
|
|
||||||
String[] expectedIds = {
|
String[] expectedIds = {
|
||||||
"com.example.one",
|
"com.example.one",
|
||||||
@ -142,7 +142,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
List<Apk> all = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
|
List<Apk> all = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
|
||||||
List<String> actualIds = new ArrayList<>();
|
List<String> actualIds = new ArrayList<>();
|
||||||
for (Apk apk : all) {
|
for (Apk apk : all) {
|
||||||
actualIds.add(apk.id);
|
actualIds.add(apk.packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestUtils.assertContainsOnly(actualIds, expectedIds);
|
TestUtils.assertContainsOnly(actualIds, expectedIds);
|
||||||
@ -158,7 +158,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
List<Apk> allRemaining = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
|
List<Apk> allRemaining = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
|
||||||
List<String> actualRemainingIds = new ArrayList<>();
|
List<String> actualRemainingIds = new ArrayList<>();
|
||||||
for (Apk apk : allRemaining) {
|
for (Apk apk : allRemaining) {
|
||||||
actualRemainingIds.add(apk.id);
|
actualRemainingIds.add(apk.packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] expectedRemainingIds = {
|
String[] expectedRemainingIds = {
|
||||||
@ -232,7 +232,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.id, apk.vercode);
|
Uri newUri = TestUtils.insertApk(this, apk.packageName, apk.vercode);
|
||||||
assertEquals(ApkProvider.getContentUri(apk).toString(), newUri.toString());
|
assertEquals(ApkProvider.getContentUri(apk).toString(), newUri.toString());
|
||||||
cursor = queryAllApks();
|
cursor = queryAllApks();
|
||||||
assertNotNull(cursor);
|
assertNotNull(cursor);
|
||||||
@ -255,7 +255,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
|
|||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
Apk toCheck = new Apk(cursor);
|
Apk toCheck = new Apk(cursor);
|
||||||
cursor.close();
|
cursor.close();
|
||||||
assertEquals("org.fdroid.fdroid", toCheck.id);
|
assertEquals("org.fdroid.fdroid", toCheck.packageName);
|
||||||
assertEquals(13, toCheck.vercode);
|
assertEquals(13, toCheck.vercode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +328,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.id);
|
assertEquals("com.example.com", apk.packageName);
|
||||||
assertEquals(1, apk.vercode);
|
assertEquals(1, apk.vercode);
|
||||||
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.id.equals(apk.id)) {
|
if (a.vercode == apk.vercode && a.packageName.equals(apk.packageName)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -56,7 +56,7 @@ abstract class BaseApkProviderTest extends FDroidProviderTest<ApkProvider> {
|
|||||||
|
|
||||||
protected void assertBelongsToApp(List<Apk> apks, String appId) {
|
protected void assertBelongsToApp(List<Apk> apks, String appId) {
|
||||||
for (Apk apk : apks) {
|
for (Apk apk : apks) {
|
||||||
assertEquals(appId, apk.id);
|
assertEquals(appId, apk.packageName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,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.id.equals(appId)) {
|
if (apk.vercode == versionCode && apk.packageName.equals(appId)) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import org.fdroid.fdroid.data.Apk;
|
|||||||
public class MockApk extends Apk {
|
public class MockApk extends Apk {
|
||||||
|
|
||||||
public MockApk(String id, int versionCode) {
|
public MockApk(String id, int versionCode) {
|
||||||
this.id = id;
|
this.packageName = id;
|
||||||
this.vercode = versionCode;
|
this.vercode = versionCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user