From: Jouni Malinen Date: Sun, 5 May 2013 15:28:25 +0000 (+0300) Subject: wpadebug: Add exception handling for missing resources X-Git-Tag: aosp-kk-from-upstream~293 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d7232a8da636073189a41b42c6ff389b562a86f3;p=thirdparty%2Fhostap.git 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 --- 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);