standardize on lowercase SHA-256 hashes
fdroidserver produces lowercase hashes, so its easiest to just mimic that. This makes hash comparisons easy.
This commit is contained in:
parent
fdec402837
commit
e77bde2cfa
@ -386,7 +386,7 @@ public final class Utils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] mdbytes = md.digest();
|
byte[] mdbytes = md.digest();
|
||||||
return toHexString(mdbytes);
|
return toHexString(mdbytes).toLowerCase(Locale.ENGLISH);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.e(TAG, "Error reading \"" + apk.getAbsolutePath()
|
Log.e(TAG, "Error reading \"" + apk.getAbsolutePath()
|
||||||
+ "\" to compute " + algo + " hash.", e);
|
+ "\" to compute " + algo + " hash.", e);
|
||||||
|
@ -25,7 +25,7 @@ public class Apk extends ValueObject implements Comparable<Apk>, Parcelable {
|
|||||||
public int versionCode;
|
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; // checksum of the APK, in lowercase hex
|
||||||
public String hashType;
|
public String hashType;
|
||||||
public int minSdkVersion = SDK_VERSION_MIN_VALUE; // 0 if unknown
|
public int minSdkVersion = SDK_VERSION_MIN_VALUE; // 0 if unknown
|
||||||
public int targetSdkVersion = SDK_VERSION_MIN_VALUE; // 0 if unknown
|
public int targetSdkVersion = SDK_VERSION_MIN_VALUE; // 0 if unknown
|
||||||
|
@ -120,7 +120,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
+ " );";
|
+ " );";
|
||||||
private static final String DROP_TABLE_INSTALLED_APP = "DROP TABLE " + InstalledAppTable.NAME + ";";
|
private static final String DROP_TABLE_INSTALLED_APP = "DROP TABLE " + InstalledAppTable.NAME + ";";
|
||||||
|
|
||||||
private static final int DB_VERSION = 60;
|
private static final int DB_VERSION = 61;
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
|
|
||||||
@ -327,6 +327,16 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
migrateAppPrimaryKeyToRowId(db, oldVersion);
|
migrateAppPrimaryKeyToRowId(db, oldVersion);
|
||||||
removeApkPackageNameColumn(db, oldVersion);
|
removeApkPackageNameColumn(db, oldVersion);
|
||||||
addAppPrefsTable(db, oldVersion);
|
addAppPrefsTable(db, oldVersion);
|
||||||
|
lowerCaseApkHashes(db, oldVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void lowerCaseApkHashes(SQLiteDatabase db, int oldVersion) {
|
||||||
|
if (oldVersion >= 61) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Utils.debugLog(TAG, "Lowercasing all APK hashes");
|
||||||
|
db.execSQL("UPDATE " + InstalledAppTable.NAME + " SET " + InstalledAppTable.Cols.HASH
|
||||||
|
+ " = lower(" + InstalledAppTable.Cols.HASH + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAppPrefsTable(SQLiteDatabase db, int oldVersion) {
|
private void addAppPrefsTable(SQLiteDatabase db, int oldVersion) {
|
||||||
|
@ -470,7 +470,7 @@ public final class LocalRepoManager {
|
|||||||
private void tagHash(App app) throws IOException {
|
private void tagHash(App app) throws IOException {
|
||||||
serializer.startTag("", "hash");
|
serializer.startTag("", "hash");
|
||||||
serializer.attribute("", "type", app.installedApk.hashType);
|
serializer.attribute("", "type", app.installedApk.hashType);
|
||||||
serializer.text(app.installedApk.hash.toLowerCase(Locale.US));
|
serializer.text(app.installedApk.hash);
|
||||||
serializer.endTag("", "hash");
|
serializer.endTag("", "hash");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user