Check for null URIs

This commit is contained in:
M66B
2021-08-07 08:11:34 +02:00
parent 1f449c9e58
commit 8f46bdebd1
6 changed files with 43 additions and 8 deletions

View File

@@ -19,6 +19,8 @@ package eu.faircode.email;
Copyright 2018-2021 by Marcel Bokhorst (M66B)
*/
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
import android.Manifest;
import android.app.Dialog;
import android.app.NotificationChannel;
@@ -107,8 +109,6 @@ import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_GMAIL;
public class ActivitySetup extends ActivityBase implements FragmentManager.OnBackStackChangedListener {
private View view;
private DrawerLayout drawerLayout;
@@ -571,6 +571,10 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
if (uri == null)
throw new FileNotFoundException();
String password = args.getString("password");
EntityLog.log(context, "Exporting " + uri);
@@ -799,6 +803,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
" answers=" + import_answers +
" settings=" + import_settings);
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme()) &&
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.w("Import uri=" + uri);
@@ -1403,6 +1410,9 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
Uri uri = args.getParcelable("uri");
Log.i("Import certificate uri=" + uri);
if (uri == null)
throw new FileNotFoundException();
boolean der = false;
String extension = Helper.getExtension(uri.getLastPathSegment());
Log.i("Extension=" + extension);