[Bugfix] Don't crash when MIME type is unknown.
When user tries to open a file of unknown MIME type through CertInstaller,
it just goes back and file manager is shown again. So we give user a
toast to let he or she knows what happened just now.
Bug: 218161567
Test: Manual
Change-Id: I2ff479343ea3c045eb6e3da7890b16c37b6c0212
diff --git a/src/com/android/certinstaller/CertInstallerMain.java b/src/com/android/certinstaller/CertInstallerMain.java
index 17b5649..61f3000 100644
--- a/src/com/android/certinstaller/CertInstallerMain.java
+++ b/src/com/android/certinstaller/CertInstallerMain.java
@@ -204,7 +204,10 @@
String target = MIME_MAPPINGS.get(mimeType);
if (target == null) {
- throw new IllegalArgumentException("Unknown MIME type: " + mimeType);
+ Log.e(TAG, "Unknown MIME type: " + mimeType + ". "
+ + Log.getStackTraceString(new Throwable()));
+ Toast.makeText(this, R.string.invalid_certificate_title, Toast.LENGTH_LONG).show();
+ return;
}
if (WIFI_CONFIG.equals(target)) {