openvehicles / Open-Vehicle-Android

Android App for OVMS
Other
54 stars 45 forks source link

Fix NullPointerException and IndexOutOfBoundsException #168

Closed francos closed 4 months ago

francos commented 5 months ago

@dexterbg This PR should fix 2 of the issues raised here: https://github.com/openvehicles/Open-Vehicle-Android/pull/166

FATAL EXCEPTION: main
Process: com.openvehicles.OVMS, PID: 10119
java.lang.NullPointerException: Parameter specified as non-null is null: method com.openvehicles.OVMS.ui.NotificationsFragment.onEditorAction, parameter keyEvent
    at com.openvehicles.OVMS.ui.NotificationsFragment.onEditorAction(Unknown Source:7)
    at android.widget.TextView.onEditorAction(TextView.java:7390)
    at com.android.internal.inputmethod.EditableInputConnection.performEditorAction(EditableInputConnection.java:156)
    at android.view.inputmethod.InputConnectionWrapper.performEditorAction(InputConnectionWrapper.java:246)
    at com.android.internal.inputmethod.RemoteInputConnectionImpl.lambda$performEditorAction$21$com-android-internal-inputmethod-RemoteInputConnectionImpl(RemoteInputConnectionImpl.java:654)
    at com.android.internal.inputmethod.RemoteInputConnectionImpl$$ExternalSyntheticLambda33.run(Unknown Source:6)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7946)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)
java.lang.IndexOutOfBoundsException: Index 572 out of bounds for length 572
    at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
    at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
    at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
    at java.util.Objects.checkIndex(Objects.java:359)
    at java.util.ArrayList.get(ArrayList.java:434)
    at com.openvehicles.OVMS.ui.MapFragment.updateMapDetails(MapFragment.kt:351)
    at com.openvehicles.OVMS.ui.MapFragment.onOptionsItemSelected(MapFragment.kt:279)
    at androidx.fragment.app.Fragment.performOptionsItemSelected(Fragment.java:3122)
    at androidx.fragment.app.FragmentManager.dispatchOptionsItemSelected(FragmentManager.java:3226)
    at androidx.fragment.app.FragmentController.dispatchOptionsItemSelected(FragmentController.java:416)
    at androidx.fragment.app.FragmentActivity.onMenuItemSelected(FragmentActivity.java:358)
    at androidx.appcompat.app.AppCompatActivity.onMenuItemSelected(AppCompatActivity.java:269)
    at androidx.appcompat.view.WindowCallbackWrapper.onMenuItemSelected(WindowCallbackWrapper.java:110)
    at androidx.appcompat.app.AppCompatDelegateImpl.onMenuItemSelected(AppCompatDelegateImpl.java:1259)
    at androidx.appcompat.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:836)
    at androidx.appcompat.view.menu.SubMenuBuilder.dispatchMenuItemSelected(SubMenuBuilder.java:91)
    at androidx.appcompat.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:159)
    at androidx.appcompat.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:987)
    at androidx.appcompat.view.menu.MenuPopup.onItemClick(MenuPopup.java:128)
    at android.widget.AdapterView.performItemClick(AdapterView.java:330)
    at android.widget.AbsListView.performItemClick(AbsListView.java:1197)
    at android.widget.AbsListView$PerformClick.run(AbsListView.java:3210)
    at android.widget.AbsListView.onTouchUp(AbsListView.java:4188)
    at android.widget.AbsListView.onTouchEvent(AbsListView.java:3929)
    at androidx.appcompat.widget.DropDownListView.onTouchEvent(DropDownListView.java:236)
    at androidx.appcompat.widget.MenuPopupWindow$MenuDropDownListView.onTouchEvent(MenuPopupWindow.java:140)
    at android.view.View.dispatchTouchEvent(View.java:15057)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3168)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2810)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3174)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2824)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3174)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2824)
    at android.widget.PopupWindow$PopupDecorView.dispatchTouchEvent(PopupWindow.java:2597)
    at android.view.View.dispatchPointerEvent(View.java:15321)
    at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6842)
    at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6623)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6075)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6132)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6098)
    at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6263)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6106)
    at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6320)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6079)
    at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:6132)
    at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:6098)
    at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:6106)
    at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:6079)
    at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:9233)
    at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:9184)

Regarding the other issue you mentioned in that PR:

At least some vehicle specific menus are missing, i.e. when switching to a Twizy, the battery tab no longer shows the battery cell & energy chart menus.

Not sure how to test that, if you provide me with step by step instructions and what you are expecting to see then I can try to reproduce and fix it when I have some time.