Fix export crashes in Android 9
This fixes the following crashes in Android 9 (honor 9 lite):
Startup crash due to null mCalendars.get(i).mName:
2022-05-14 19:16:40.330 16853-16960/org.sufficientlysecure.ical E/AndroidRuntime: FATAL EXCEPTION: Thread-3
Process: org.sufficientlysecure.ical, PID: 16853
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.contentEquals(java.lang.CharSequence)' on a null object reference
at org.sufficientlysecure.ical.ui.MainActivity.initialiseCalendars(MainActivity.java:359)
at org.sufficientlysecure.ical.ui.MainActivity.access$1500(MainActivity.java:81)
at org.sufficientlysecure.ical.ui.MainActivity$9.run(MainActivity.java:442)
at java.lang.Thread.run(Thread.java:784)
2022-05-14 19:16:40.355 16853-16960/org.sufficientlysecure.ical I/Process: Sending signal. PID: 16853 SIG: 9
Export crash due to null cursor returned due to unsupported columns:
2022-05-14 19:18:25.015 17114-17181/org.sufficientlysecure.ical E/ICS_RunnableWithProgress: An exception occurred
java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getCount()' on a null object reference
at org.sufficientlysecure.ical.SaveCalendar.getEvents(SaveCalendar.java:255)
at org.sufficientlysecure.ical.SaveCalendar.run(SaveCalendar.java:193)
at org.sufficientlysecure.ical.ui.dialogs.RunnableWithProgress$1.run(RunnableWithProgress.java:44)
at java.lang.Thread.run(Thread.java:784)
Export working correctly after the fixes
Hi,
thanks for diving into this.
After having a look at it, I have the following remarks:
-
Since the changes address different breakdown reasons, the commit should be split into two.
-
I am not sure whether the second change is accurate. My impression is that the guard
mCalendars.get(i).mName != nullshould just go the corresponding clause, hence sth. like(calendarName == null || (mCalendars.get(i).mName != null && mCalendars.get(i).mName.contentEquals(calendarName)))which in turn could maybe be compactified to(calendarName == null || calendarName.contentEquals(mCalendars.get(i).mName). Or is there something I miss? -
Concerning the first change, a space should go between
ifand(. I would also prefer if the generous catch-all could be avoided totally, e. g. the documentation of the .query method suggests that catching OperationCanceledException is enough, but that is maybe too risky.
Please refactor as you wish. The traces above should be enough to pinpoint the issues. The query method returns null on my phone as the the stack trace shows.
I experienced "Export crash due to null cursor returned due to unsupported columns" problem, and I confirm that this pull request solves it.
A year has gone by since the problem and solution were spotted.
@fhaftmann or any other maintainer. Given that the changes are only a few lines, could you please consider just creating your own commits, separated as deemed necessary, with the repository-compatible formatting and with a more limited exception catching, and creating a new release?
That way this app will continue alive and working for the community.
Thanks for the app, and the attention.
This app is no longer in google play store. So its basically dead. I would like to add it again since the license here allows everything as far as i got it. I came across this issue because i want to port my phone´s data to a new one and wondered why this app cant be installed on other phones anymore. Its not available anymore.