From d7232a8da636073189a41b42c6ff389b562a86f3 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 5 May 2013 18:28:25 +0300 Subject: [PATCH] wpadebug: Add exception handling for missing resources These errors should not really happen, but apparently they can if the build dependencies get messed up somehow. Signed-hostap: Jouni Malinen --- wpadebug/src/w1/fi/wpadebug/CommandListActivity.java | 10 ++++++++-- .../src/w1/fi/wpadebug/WpaCommandListActivity.java | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java b/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java index fb4268ecf..6d7ad4dd6 100644 --- a/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java +++ b/wpadebug/src/w1/fi/wpadebug/CommandListActivity.java @@ -77,8 +77,14 @@ public class CommandListActivity extends ListActivity Toast.LENGTH_SHORT).show(); } - InputStream inres = getResources().openRawResource(R.raw.shell_commands); - read_commands(list, new Scanner(inres)); + InputStream inres; + try { + inres = getResources().openRawResource(R.raw.shell_commands); + read_commands(list, new Scanner(inres)); + } catch (android.content.res.Resources.NotFoundException e) { + Toast.makeText(this, "Could not read internal resource", + Toast.LENGTH_SHORT).show(); + } ArrayAdapter listAdapter; listAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list); diff --git a/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java b/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java index 4ad9b2d1b..e08917934 100644 --- a/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java +++ b/wpadebug/src/w1/fi/wpadebug/WpaCommandListActivity.java @@ -59,8 +59,14 @@ public class WpaCommandListActivity extends ListActivity Toast.LENGTH_SHORT).show(); } - InputStream inres = getResources().openRawResource(R.raw.wpa_commands); - read_commands(list, new Scanner(inres)); + InputStream inres; + try { + inres = getResources().openRawResource(R.raw.wpa_commands); + read_commands(list, new Scanner(inres)); + } catch (android.content.res.Resources.NotFoundException e) { + Toast.makeText(this, "Could not read internal resource", + Toast.LENGTH_SHORT).show(); + } ArrayAdapter listAdapter; listAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, list);