Merge tag 'v3.2.1' into linked-identities
Version 3.2.1 Conflicts: OpenKeychain/build.gradle OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyAdapter.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/EncryptKeyCompletionView.java OpenKeychain/src/main/res/layout/decrypt_text_fragment.xml OpenKeychain/src/main/res/values/strings.xml
This commit is contained in:
@@ -73,7 +73,7 @@ public class KeychainContract {
|
||||
|
||||
interface ApiAppsColumns {
|
||||
String PACKAGE_NAME = "package_name";
|
||||
String PACKAGE_SIGNATURE = "package_signature";
|
||||
String PACKAGE_CERTIFICATE = "package_signature";
|
||||
}
|
||||
|
||||
interface ApiAppsAccountsColumns {
|
||||
|
||||
@@ -148,7 +148,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
||||
"CREATE TABLE IF NOT EXISTS " + Tables.API_APPS + " ("
|
||||
+ BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
+ ApiAppsColumns.PACKAGE_NAME + " TEXT NOT NULL UNIQUE, "
|
||||
+ ApiAppsColumns.PACKAGE_SIGNATURE + " BLOB"
|
||||
+ ApiAppsColumns.PACKAGE_CERTIFICATE + " BLOB"
|
||||
+ ")";
|
||||
|
||||
private static final String CREATE_API_APPS_ACCOUNTS =
|
||||
|
||||
@@ -50,7 +50,6 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
|
||||
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpConstants;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
||||
import org.sufficientlysecure.keychain.pgp.Progressable;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
|
||||
import org.sufficientlysecure.keychain.pgp.UncachedPublicKey;
|
||||
@@ -1415,7 +1414,7 @@ public class ProviderHelper {
|
||||
private ContentValues contentValueForApiApps(AppSettings appSettings) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(ApiApps.PACKAGE_NAME, appSettings.getPackageName());
|
||||
values.put(ApiApps.PACKAGE_SIGNATURE, appSettings.getPackageSignature());
|
||||
values.put(ApiApps.PACKAGE_CERTIFICATE, appSettings.getPackageSignature());
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -1462,7 +1461,7 @@ public class ProviderHelper {
|
||||
settings.setPackageName(cursor.getString(
|
||||
cursor.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME)));
|
||||
settings.setPackageSignature(cursor.getBlob(
|
||||
cursor.getColumnIndex(KeychainContract.ApiApps.PACKAGE_SIGNATURE)));
|
||||
cursor.getColumnIndex(KeychainContract.ApiApps.PACKAGE_CERTIFICATE)));
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
@@ -1554,31 +1553,10 @@ public class ProviderHelper {
|
||||
mContentResolver.insert(uri, values);
|
||||
}
|
||||
|
||||
public Set<String> getAllFingerprints(Uri uri) {
|
||||
Set<String> fingerprints = new HashSet<>();
|
||||
String[] projection = new String[]{KeyRings.FINGERPRINT};
|
||||
Cursor cursor = mContentResolver.query(uri, projection, null, null, null);
|
||||
try {
|
||||
if (cursor != null) {
|
||||
int fingerprintColumn = cursor.getColumnIndex(KeyRings.FINGERPRINT);
|
||||
while (cursor.moveToNext()) {
|
||||
fingerprints.add(
|
||||
KeyFormattingUtils.convertFingerprintToHex(cursor.getBlob(fingerprintColumn))
|
||||
);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (cursor != null) {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
return fingerprints;
|
||||
}
|
||||
|
||||
public byte[] getApiAppSignature(String packageName) {
|
||||
public byte[] getApiAppCertificate(String packageName) {
|
||||
Uri queryUri = ApiApps.buildByPackageNameUri(packageName);
|
||||
|
||||
String[] projection = new String[]{ApiApps.PACKAGE_SIGNATURE};
|
||||
String[] projection = new String[]{ApiApps.PACKAGE_CERTIFICATE};
|
||||
|
||||
Cursor cursor = mContentResolver.query(queryUri, projection, null, null, null);
|
||||
try {
|
||||
|
||||
@@ -31,10 +31,12 @@ import android.provider.OpenableColumns;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.util.DatabaseUtil;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TemporaryStorageProvider extends ContentProvider {
|
||||
|
||||
@@ -44,7 +46,9 @@ public class TemporaryStorageProvider extends ContentProvider {
|
||||
private static final String COLUMN_NAME = "name";
|
||||
private static final String COLUMN_TIME = "time";
|
||||
private static final Uri BASE_URI = Uri.parse("content://org.sufficientlysecure.keychain.tempstorage/");
|
||||
private static final int DB_VERSION = 1;
|
||||
private static final int DB_VERSION = 2;
|
||||
|
||||
private static File cacheDir;
|
||||
|
||||
public static Uri createFile(Context context, String targetName) {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
@@ -66,7 +70,7 @@ public class TemporaryStorageProvider extends ContentProvider {
|
||||
@Override
|
||||
public void onCreate(SQLiteDatabase db) {
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_FILES + " (" +
|
||||
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
|
||||
COLUMN_ID + " TEXT PRIMARY KEY, " +
|
||||
COLUMN_NAME + " TEXT, " +
|
||||
COLUMN_TIME + " INTEGER" +
|
||||
");");
|
||||
@@ -74,28 +78,39 @@ public class TemporaryStorageProvider extends ContentProvider {
|
||||
|
||||
@Override
|
||||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
|
||||
Log.d(Constants.TAG, "Upgrading files db from " + oldVersion + " to " + newVersion);
|
||||
|
||||
switch (oldVersion) {
|
||||
case 1:
|
||||
db.execSQL("DROP TABLE IF EXISTS files");
|
||||
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_FILES + " (" +
|
||||
COLUMN_ID + " TEXT PRIMARY KEY, " +
|
||||
COLUMN_NAME + " TEXT, " +
|
||||
COLUMN_TIME + " INTEGER" +
|
||||
");");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TemporaryStorageDatabase db;
|
||||
private static TemporaryStorageDatabase db;
|
||||
|
||||
private File getFile(Uri uri) throws FileNotFoundException {
|
||||
try {
|
||||
return getFile(Integer.parseInt(uri.getLastPathSegment()));
|
||||
return getFile(uri.getLastPathSegment());
|
||||
} catch (NumberFormatException e) {
|
||||
throw new FileNotFoundException();
|
||||
}
|
||||
}
|
||||
|
||||
private File getFile(int id) {
|
||||
return new File(getContext().getCacheDir(), "temp/" + id);
|
||||
private File getFile(String id) {
|
||||
return new File(cacheDir, "temp/" + id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
db = new TemporaryStorageDatabase(getContext());
|
||||
return new File(getContext().getCacheDir(), "temp").mkdirs();
|
||||
cacheDir = getContext().getCacheDir();
|
||||
return new File(cacheDir, "temp").mkdirs();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,13 +148,15 @@ public class TemporaryStorageProvider extends ContentProvider {
|
||||
if (!values.containsKey(COLUMN_TIME)) {
|
||||
values.put(COLUMN_TIME, System.currentTimeMillis());
|
||||
}
|
||||
String uuid = UUID.randomUUID().toString();
|
||||
values.put(COLUMN_ID, uuid);
|
||||
int insert = (int) db.getWritableDatabase().insert(TABLE_FILES, null, values);
|
||||
try {
|
||||
getFile(insert).createNewFile();
|
||||
getFile(uuid).createNewFile();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
return Uri.withAppendedPath(BASE_URI, Long.toString(insert));
|
||||
return Uri.withAppendedPath(BASE_URI, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,7 +169,7 @@ public class TemporaryStorageProvider extends ContentProvider {
|
||||
selectionArgs, null, null, null);
|
||||
if (files != null) {
|
||||
while (files.moveToNext()) {
|
||||
getFile(files.getInt(0)).delete();
|
||||
getFile(files.getString(0)).delete();
|
||||
}
|
||||
files.close();
|
||||
return db.getWritableDatabase().delete(TABLE_FILES, selection, selectionArgs);
|
||||
|
||||
Reference in New Issue
Block a user