Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d064785f authored by Philip Junker's avatar Philip Junker
Browse files

Make parsing of global_keys.xml more robust.

Test: manually verified with an ill-formatted global_keys.xml file.
Change-Id: I0a02093101b8d58f7d3773a4f9fdbd63b9b2f5cf
parent c25ef470
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -137,20 +137,27 @@ final class GlobalKeyManager {
                        String componentName = parser.getAttributeValue(null, ATTR_COMPONENT);
                        String dispatchWhenNonInteractive =
                                parser.getAttributeValue(null, ATTR_DISPATCH_WHEN_NON_INTERACTIVE);
                        if (keyCodeName == null || componentName == null) {
                            Log.wtf(TAG, "Failed to parse global keys entry: " + parser.getText());
                            continue;
                        }
                        int keyCode = KeyEvent.keyCodeFromString(keyCodeName);
                        if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
                            mKeyMapping.put(keyCode, new GlobalKeyAction(
                                    componentName, dispatchWhenNonInteractive));
                        } else {
                            Log.wtf(TAG, "Global keys entry does not map to a valid key code: "
                                    + keyCodeName);
                        }
                    }
                }
            }
        } catch (Resources.NotFoundException e) {
            Log.w(TAG, "global keys file not found", e);
            Log.wtf(TAG, "global keys file not found", e);
        } catch (XmlPullParserException e) {
            Log.w(TAG, "XML parser exception reading global keys file", e);
            Log.wtf(TAG, "XML parser exception reading global keys file", e);
        } catch (IOException e) {
            Log.w(TAG, "I/O exception reading global keys file", e);
            Log.e(TAG, "I/O exception reading global keys file", e);
        }
    }