]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Crudely catch exception if no file browser is available
authorTobias Brunner <tobias@strongswan.org>
Thu, 21 Jun 2018 17:05:33 +0000 (19:05 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 3 Jul 2018 09:31:43 +0000 (11:31 +0200)
Seen on Android TV in the emulator.

src/frontends/android/app/src/main/java/org/strongswan/android/ui/TrustedCertificateImportActivity.java
src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileImportActivity.java

index ed950cd11f18971a5f6231d9073a5e6547458cf7..f61db05b0fe7c77ba38ce7b7a2d8ffaf615463eb 100644 (file)
@@ -18,6 +18,7 @@ package org.strongswan.android.ui;
 import android.annotation.TargetApi;
 import android.app.Activity;
 import android.app.Dialog;
+import android.content.ActivityNotFoundException;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.net.Uri;
@@ -76,7 +77,15 @@ public class TrustedCertificateImportActivity extends AppCompatActivity
                        Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                        openIntent.setType("*/*");
                        openIntent.putExtra(Intent.EXTRA_MIME_TYPES, ACCEPTED_MIME_TYPES);
-                       startActivityForResult(openIntent, OPEN_DOCUMENT);
+                       try
+                       {
+                               startActivityForResult(openIntent, OPEN_DOCUMENT);
+                       }
+                       catch (ActivityNotFoundException e)
+                       {       /* some devices are unable to browse for files */
+                               finish();
+                               return;
+                       }
                }
        }
 
index fd6ccd9c7598298610f85dc846385905f29cc988..1d8b677eed0473ff67154065f8a30308cb4d3dcf 100644 (file)
@@ -17,6 +17,7 @@ package org.strongswan.android.ui;
 
 import android.app.Activity;
 import android.app.LoaderManager;
+import android.content.ActivityNotFoundException;
 import android.content.AsyncTaskLoader;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -64,7 +65,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.lang.OutOfMemoryError;
 import java.net.URL;
 import java.net.UnknownHostException;
 import java.security.KeyStore;
@@ -212,7 +212,15 @@ public class VpnProfileImportActivity extends AppCompatActivity
                {
                        Intent openIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                        openIntent.setType("*/*");
-                       startActivityForResult(openIntent, OPEN_DOCUMENT);
+                       try
+                       {
+                               startActivityForResult(openIntent, OPEN_DOCUMENT);
+                       }
+                       catch (ActivityNotFoundException e)
+                       {       /* some devices are unable to browse for files */
+                               finish();
+                               return;
+                       }
                }
 
                if (savedInstanceState != null)