Our URLSpan2.onClick is almost the same as the overridden method, and if our method crashed, the platform method would have probably crashed as well. In any case, Context.startActivity is only supposed to throw ActivityNotFoundException, so I just don't see how we can be at fault. Leaving this here for the record.
java.lang.NullPointerException: Attempt to read from field 'java.lang.String android.content.pm.PackageItemInfo.packageName' on a null object reference in method 'java.util.List com.android.server.pm.PackageManagerService$ComputerEngine.applyPostResolutionFilter(java.util.List, java.lang.String, boolean, int, boolean, int, android.content.Intent)'
at android.os.Parcel.createExceptionOrNull(Parcel.java:2432)
at android.os.Parcel.createException(Parcel.java:2410)
at android.os.Parcel.readException(Parcel.java:2393)
at android.os.Parcel.readException(Parcel.java:2335)
at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:2626)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1743)
at android.app.Activity.startActivityForResult(Activity.java:5532)
at androidx.activity.ComponentActivity.startActivityForResult(Unknown Source:0)
at android.app.Activity.startActivityForResult(Activity.java:5485)
at androidx.activity.ComponentActivity.startActivityForResult(Unknown Source:0)
at android.app.Activity.startActivity(Activity.java:5891)
at android.app.Activity.startActivity(Activity.java:5844)
at com.ubergeek42.WeechatAndroid.utils.URLSpan2.onClick(Unknown Source:24)
at com.ubergeek42.WeechatAndroid.views.LineView$gestureDetector$1.onSingleTapUp(SourceFile:111)
at android.view.GestureDetector.onTouchEvent(GestureDetector.java:748)
at com.ubergeek42.WeechatAndroid.views.LineView.onTouchEvent(Unknown Source:2)
at android.view.View.dispatchTouchEvent(View.java:14860)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3131)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2812)
at com.android.internal.policy.DecorView.superDispatchTouchEvent(DecorView.java:569)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1895)
at android.app.Activity.dispatchTouchEvent(Activity.java:4319)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchTouchEvent$androidx$appcompat$view$WindowCallbackWrapper(Unknown Source:2)
at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchTouchEvent(Unknown Source:0)
at com.android.internal.policy.DecorView.dispatchTouchEvent(DecorView.java:527)
at android.view.View.dispatchPointerEvent(View.java:15133)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:6671)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:6459)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5900)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5957)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5923)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:6088)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5931)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:6145)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5904)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5957)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5923)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5931)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5904)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8932)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8883)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8851)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:9065)
at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:280)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:337)
at android.os.Looper.loopOnce(Looper.java:168)
at android.os.Looper.loop(Looper.java:299)
at android.app.ActivityThread.main(ActivityThread.java:8261)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:556)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: android.os.RemoteException: Remote stack trace:
at com.android.server.pm.PackageManagerService$ComputerEngine.applyPostResolutionFilter(PackageManagerService.java:3096)
at com.android.server.pm.PackageManagerService$ComputerEngine.queryIntentActivitiesInternal(PackageManagerService.java:2376)
at com.android.server.pm.PackageManagerService$ComputerTracker.queryIntentActivitiesInternal(PackageManagerService.java:5126)
at com.android.server.pm.PackageManagerService.queryIntentActivitiesInternal(PackageManagerService.java:10925)
at com.android.server.pm.PackageManagerService.resolveIntentInternal(PackageManagerService.java:10278)
User reported a crash after tapping on this URL: https://www.cbc.ca/news/canada/nova-scotia/battery-power-laptop-phone-research-dalhousie-university-1.6724175. Crash was reproducible. After removing the
www.
part, the page opened fine, and the crash stopped occurring.Our
URLSpan2.onClick
is almost the same as the overridden method, and if our method crashed, the platform method would have probably crashed as well. In any case,Context.startActivity
is only supposed to throwActivityNotFoundException
, so I just don't see how we can be at fault. Leaving this here for the record.