mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-24 16:08:49 -05:00
consolidate: use KeychainProvider for deletion operation
This commit is contained in:
parent
70426041df
commit
9aaaac068e
@ -103,8 +103,6 @@ public class KeychainApplication extends Application {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void setupAccountAsNeeded(Context context) {
|
||||
AccountManager manager = AccountManager.get(context);
|
||||
Account[] accounts = manager.getAccountsByType(Constants.PACKAGE_NAME);
|
||||
|
@ -349,7 +349,7 @@ public class KeychainDatabase extends SQLiteOpenHelper {
|
||||
copy(in, out);
|
||||
}
|
||||
|
||||
// DANGEROUS
|
||||
// DANGEROUS, use in test code ONLY!
|
||||
public void clearDatabase() {
|
||||
getWritableDatabase().execSQL("delete from " + Tables.KEY_RINGS_PUBLIC);
|
||||
}
|
||||
|
@ -685,6 +685,11 @@ public class KeychainProvider extends ContentProvider {
|
||||
final int match = mUriMatcher.match(uri);
|
||||
|
||||
switch (match) {
|
||||
// dangerous
|
||||
case KEY_RINGS_UNIFIED: {
|
||||
count = db.delete(Tables.KEY_RINGS_PUBLIC, null, null);
|
||||
break;
|
||||
}
|
||||
case KEY_RING_PUBLIC: {
|
||||
@SuppressWarnings("ConstantConditions") // ensured by uriMatcher above
|
||||
String selection = KeyRings.MASTER_KEY_ID + " = " + uri.getPathSegments().get(1);
|
||||
|
@ -963,7 +963,6 @@ public class ProviderHelper {
|
||||
|
||||
private ConsolidateResult consolidateDatabaseStep2(Progressable progress, boolean recovery) {
|
||||
|
||||
|
||||
Preferences prefs = Preferences.getPreferences(mContext);
|
||||
|
||||
// Set flag that we have a cached consolidation here
|
||||
@ -986,7 +985,7 @@ public class ProviderHelper {
|
||||
|
||||
// 2. wipe database (IT'S DANGEROUS)
|
||||
log(LogLevel.DEBUG, LogType.MSG_CON_DB_CLEAR);
|
||||
new KeychainDatabase(mContext).clearDatabase();
|
||||
mContentResolver.delete(KeyRings.buildUnifiedKeyRingsUri(), null, null);
|
||||
|
||||
FileImportCache<ParcelableKeyRing> cacheSecret =
|
||||
new FileImportCache<ParcelableKeyRing>(mContext, "consolidate_secret.pcl");
|
||||
|
Loading…
Reference in New Issue
Block a user