Remove most of old API
This commit is contained in:
@@ -66,11 +66,10 @@ public class KeychainContract {
|
||||
public static final int SECRET = 1;
|
||||
}
|
||||
|
||||
public static final String CONTENT_AUTHORITY_EXTERNAL = Constants.PACKAGE_NAME;
|
||||
public static final String CONTENT_AUTHORITY_INTERNAL = Constants.PACKAGE_NAME + ".internal";
|
||||
public static final String CONTENT_AUTHORITY = Constants.PACKAGE_NAME + ".provider";
|
||||
|
||||
private static final Uri BASE_CONTENT_URI_INTERNAL = Uri.parse("content://"
|
||||
+ CONTENT_AUTHORITY_INTERNAL);
|
||||
+ CONTENT_AUTHORITY);
|
||||
|
||||
public static final String BASE_KEY_RINGS = "key_rings";
|
||||
public static final String BASE_DATA = "data";
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Intent;
|
||||
import android.content.UriMatcher;
|
||||
import android.database.Cursor;
|
||||
import android.database.DatabaseUtils;
|
||||
@@ -46,11 +45,11 @@ import android.provider.BaseColumns;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class KeychainProvider extends ContentProvider {
|
||||
public static final String ACTION_BROADCAST_DATABASE_CHANGE = Constants.PACKAGE_NAME
|
||||
+ ".action.DATABASE_CHANGE";
|
||||
|
||||
public static final String EXTRA_BROADCAST_KEY_TYPE = "keyType";
|
||||
public static final String EXTRA_BROADCAST_CONTENT_ITEM_TYPE = "contentItemType";
|
||||
// public static final String ACTION_BROADCAST_DATABASE_CHANGE = Constants.PACKAGE_NAME
|
||||
// + ".action.DATABASE_CHANGE";
|
||||
//
|
||||
// public static final String EXTRA_BROADCAST_KEY_TYPE = "key_type";
|
||||
// public static final String EXTRA_BROADCAST_CONTENT_ITEM_TYPE = "contentItemType";
|
||||
|
||||
private static final int PUBLIC_KEY_RING = 101;
|
||||
private static final int PUBLIC_KEY_RING_BY_ROW_ID = 102;
|
||||
@@ -84,22 +83,16 @@ public class KeychainProvider extends ContentProvider {
|
||||
|
||||
// private static final int DATA_STREAM = 401;
|
||||
|
||||
protected boolean mInternalProvider;
|
||||
protected UriMatcher mUriMatcher;
|
||||
|
||||
/**
|
||||
* Build and return a {@link UriMatcher} that catches all {@link Uri} variations supported by
|
||||
* this {@link ContentProvider}.
|
||||
*/
|
||||
protected UriMatcher buildUriMatcher(boolean internalProvider) {
|
||||
protected UriMatcher buildUriMatcher() {
|
||||
final UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
|
||||
|
||||
String authority;
|
||||
if (internalProvider) {
|
||||
authority = KeychainContract.CONTENT_AUTHORITY_INTERNAL;
|
||||
} else {
|
||||
authority = KeychainContract.CONTENT_AUTHORITY_EXTERNAL;
|
||||
}
|
||||
String authority = KeychainContract.CONTENT_AUTHORITY;
|
||||
|
||||
/**
|
||||
* public key rings
|
||||
@@ -250,7 +243,7 @@ public class KeychainProvider extends ContentProvider {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
mUriMatcher = buildUriMatcher(mInternalProvider);
|
||||
mUriMatcher = buildUriMatcher();
|
||||
mApgDatabase = new KeychainDatabase(getContext());
|
||||
return true;
|
||||
}
|
||||
@@ -359,11 +352,8 @@ public class KeychainProvider extends ContentProvider {
|
||||
projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID);
|
||||
projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEY_RINGS + "."
|
||||
+ KeyRingsColumns.MASTER_KEY_ID);
|
||||
// only give out keyRing blob when we are using the internal content provider
|
||||
if (mInternalProvider) {
|
||||
projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "."
|
||||
+ KeyRingsColumns.KEY_RING_DATA);
|
||||
}
|
||||
projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "."
|
||||
+ KeyRingsColumns.KEY_RING_DATA);
|
||||
projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID);
|
||||
|
||||
return projectionMap;
|
||||
@@ -389,10 +379,7 @@ public class KeychainProvider extends ContentProvider {
|
||||
projectionMap.put(KeysColumns.CREATION, KeysColumns.CREATION);
|
||||
projectionMap.put(KeysColumns.EXPIRY, KeysColumns.EXPIRY);
|
||||
projectionMap.put(KeysColumns.KEY_RING_ROW_ID, KeysColumns.KEY_RING_ROW_ID);
|
||||
// only give out keyRing blob when we are using the internal content provider
|
||||
if (mInternalProvider) {
|
||||
projectionMap.put(KeysColumns.KEY_DATA, KeysColumns.KEY_DATA);
|
||||
}
|
||||
projectionMap.put(KeysColumns.KEY_DATA, KeysColumns.KEY_DATA);
|
||||
projectionMap.put(KeysColumns.RANK, KeysColumns.RANK);
|
||||
|
||||
return projectionMap;
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.provider;
|
||||
|
||||
/**
|
||||
* The same content provider as ApgProviderInternal except that it does not give out keyRing and key
|
||||
* blob data when querying.
|
||||
*
|
||||
* This provider is exported with a readPermission in AndroidManifest.xml
|
||||
*/
|
||||
public class KeychainProviderExternal extends KeychainProvider {
|
||||
|
||||
public KeychainProviderExternal() {
|
||||
mInternalProvider = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012-2013 Dominik Schürmann <dominik@dominikschuermann.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.sufficientlysecure.keychain.provider;
|
||||
|
||||
/**
|
||||
* This provider is NOT exported in AndroidManifest.xml as it also return the actual secret keys
|
||||
* from the database
|
||||
*/
|
||||
public class KeychainProviderInternal extends KeychainProvider {
|
||||
|
||||
public KeychainProviderInternal() {
|
||||
mInternalProvider = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -239,7 +239,7 @@ public class ProviderHelper {
|
||||
}
|
||||
|
||||
try {
|
||||
context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY_INTERNAL,
|
||||
context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY,
|
||||
operations);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(Constants.TAG, "applyBatch failed!", e);
|
||||
@@ -296,7 +296,7 @@ public class ProviderHelper {
|
||||
}
|
||||
|
||||
try {
|
||||
context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY_INTERNAL,
|
||||
context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY,
|
||||
operations);
|
||||
} catch (RemoteException e) {
|
||||
Log.e(Constants.TAG, "applyBatch failed!", e);
|
||||
|
||||
Reference in New Issue
Block a user