limit GeneralActivity to non-Uri Intents or file:// Uri Intents, now handling key imports as well
This commit is contained in:
@@ -108,6 +108,7 @@ public class Apg {
|
||||
public static final String ENCRYPT_AND_RETURN = "org.thialfihar.android.apg.intent.ENCRYPT_AND_RETURN";
|
||||
public static final String SELECT_PUBLIC_KEYS = "org.thialfihar.android.apg.intent.SELECT_PUBLIC_KEYS";
|
||||
public static final String SELECT_SECRET_KEY = "org.thialfihar.android.apg.intent.SELECT_SECRET_KEY";
|
||||
public static final String IMPORT = "org.thialfihar.android.apg.intent.IMPORT";
|
||||
}
|
||||
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
@@ -573,7 +574,8 @@ public class Apg {
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
}
|
||||
|
||||
public static Bundle importKeyRings(Activity context, int type, String filename,
|
||||
public static Bundle importKeyRings(Activity context, int type,
|
||||
InputStream inStream, long dataLength,
|
||||
ProgressDialogUpdater progress)
|
||||
throws GeneralException, FileNotFoundException, PGPException, IOException {
|
||||
Bundle returnData = new Bundle();
|
||||
@@ -588,9 +590,7 @@ public class Apg {
|
||||
throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
|
||||
}
|
||||
|
||||
FileInputStream fileIn = new FileInputStream(filename);
|
||||
long fileSize = new File(filename).length();
|
||||
PositionAwareInputStream progressIn = new PositionAwareInputStream(fileIn);
|
||||
PositionAwareInputStream progressIn = new PositionAwareInputStream(inStream);
|
||||
// need to have access to the bufferedInput, so we can reuse it for the possible
|
||||
// PGPObject chunks after the first one, e.g. files with several consecutive ASCII
|
||||
// armour blocks
|
||||
@@ -636,7 +636,7 @@ public class Apg {
|
||||
} else if (retValue == Id.return_value.ok) {
|
||||
++newKeys;
|
||||
}
|
||||
progress.setProgress((int)(100 * progressIn.position() / fileSize), 100);
|
||||
progress.setProgress((int)(100 * progressIn.position() / dataLength), 100);
|
||||
obj = objectFactory.nextObject();
|
||||
}
|
||||
}
|
||||
@@ -653,7 +653,7 @@ public class Apg {
|
||||
}
|
||||
|
||||
public static Bundle exportKeyRings(Activity context, Vector<Integer> keyRingIds,
|
||||
String filename,
|
||||
OutputStream outStream,
|
||||
ProgressDialogUpdater progress)
|
||||
throws GeneralException, FileNotFoundException, PGPException, IOException {
|
||||
Bundle returnData = new Bundle();
|
||||
@@ -667,8 +667,7 @@ public class Apg {
|
||||
if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
|
||||
throw new GeneralException(context.getString(R.string.error_externalStorageNotReady));
|
||||
}
|
||||
FileOutputStream fileOut = new FileOutputStream(new File(filename), false);
|
||||
ArmoredOutputStream out = new ArmoredOutputStream(fileOut);
|
||||
ArmoredOutputStream out = new ArmoredOutputStream(outStream);
|
||||
|
||||
int numKeys = 0;
|
||||
for (int i = 0; i < keyRingIds.size(); ++i) {
|
||||
@@ -689,7 +688,6 @@ public class Apg {
|
||||
++numKeys;
|
||||
}
|
||||
out.close();
|
||||
fileOut.close();
|
||||
returnData.putInt("exported", numKeys);
|
||||
|
||||
progress.setProgress(R.string.progress_done, 100, 100);
|
||||
|
||||
Reference in New Issue
Block a user