Allow to pass large blobs and a new content provider to simplify this

Since AIDL is not for passing large data, a blob can be passed to APG by
a Uri. This Uri is opened as a file by APG and read/written to. Note the
file is overwritten by APG, so make sure it is a copy if you want to
keep the original.

With the ApgServiceBlobProvider, Apg has an own ContentProvider that can
be used like mentioned above. For now the data is stored in the dir
where APG stores other files and NOT DELETED after en/decryption. This
is tbd. It can only be accessed by an application with the permission
"org.thialfihar.android.apg.permission.STORE_BLOBS".

ApgCon has been updated accordingly and can handle blobs with `setBlob`
and `getBlobResult`. That is a really easy way to en/decrypt large data.

Note that encrypting by blob should only be used for large files (1MB+).
On all other cases, the data should be passed as as String through the
AIDl-Interface, so no temporary file must be created.

See ApgCon for a complete example of how to connect to the AIDL and use
it. Or use it in your own project!
This commit is contained in:
Markus Doits
2011-11-04 21:22:49 +01:00
parent a7294d50b1
commit ad16574657
10 changed files with 422 additions and 35 deletions

View File

@@ -30,6 +30,7 @@ import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.text.ClipboardManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AnimationUtils;
@@ -189,19 +190,28 @@ public class DecryptActivity extends BaseActivity {
// ignore, then
}
} else if (Apg.Intent.DECRYPT.equals(mIntent.getAction())) {
Log.d(Constants.tag, "Apg Intent DECRYPT startet");
Bundle extras = mIntent.getExtras();
if (extras == null) {
Log.d(Constants.tag, "extra bundle was null");
extras = new Bundle();
} else {
Log.d(Constants.tag, "got extras");
}
mData = extras.getByteArray(Apg.EXTRA_DATA);
String textData = null;
if (mData == null) {
Log.d(Constants.tag, "EXTRA_DATA was null");
textData = extras.getString(Apg.EXTRA_TEXT);
} else {
Log.d(Constants.tag, "Got data from EXTRA_DATA");
}
if (textData != null) {
Log.d(Constants.tag, "textData null, matching text ...");
Matcher matcher = Apg.PGP_MESSAGE.matcher(textData);
if (matcher.matches()) {
Log.d(Constants.tag, "PGP_MESSAGE matched");
textData = matcher.group(1);
// replace non breakable spaces
textData = textData.replaceAll("\\xa0", " ");
@@ -209,11 +219,14 @@ public class DecryptActivity extends BaseActivity {
} else {
matcher = Apg.PGP_SIGNED_MESSAGE.matcher(textData);
if (matcher.matches()) {
Log.d(Constants.tag, "PGP_SIGNED_MESSAGE matched");
textData = matcher.group(1);
// replace non breakable spaces
textData = textData.replaceAll("\\xa0", " ");
mMessage.setText(textData);
mDecryptButton.setText(R.string.btn_verify);
} else {
Log.d(Constants.tag, "Nothing matched!");
}
}
}