consolidate: use KeychainProvider for deletion operation

This commit is contained in:
Vincent Breitmoser 2014-08-20 19:31:51 +02:00
parent 70426041df
commit 9aaaac068e
4 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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);

View File

@ -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");