anongit / mytracks

Automatically exported from code.google.com/p/mytracks
0 stars 0 forks source link

NPE when using announcements #214

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Set the announcement frequency.
2. Start recording.
3. Crash

What is the expected output? What do you see instead?
From the logs
11-10 07:56:10.804 E/AndroidRuntime( 1195): java.lang.RuntimeException: Unable 
to create service 
com.google.android.apps.mytracks.services.TrackRecordingService: 
java.lang.NullPointerException
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.app.ActivityThread.handleCreateService(ActivityThread.java:1930)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.app.ActivityThread.access$2500(ActivityThread.java:117)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:982)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.os.Handler.dispatchMessage(Handler.java:99)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.os.Looper.loop(Looper.java:123)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.app.ActivityThread.main(ActivityThread.java:3647)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
java.lang.reflect.Method.invokeNative(Native Method)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
java.lang.reflect.Method.invoke(Method.java:507)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
dalvik.system.NativeStart.main(Native Method)
11-10 07:56:10.804 E/AndroidRuntime( 1195): Caused by: 
java.lang.NullPointerException
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.getTripStatistic
s(TrackRecordingService.java:1023)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.PeriodicTaskExecuter.scheduleTask(Peri
odicTaskExecuter.java:63)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.setUpAnnouncer(T
rackRecordingService.java:689)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.setAnnouncementF
requency(TrackRecordingService.java:1050)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.PreferenceManager.onSharedPreferenceCh
anged(PreferenceManager.java:134)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
com.google.android.apps.mytracks.services.TrackRecordingService.onCreate(TrackRe
cordingService.java:650)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     at 
android.app.ActivityThread.handleCreateService(ActivityThread.java:1920)
11-10 07:56:10.804 E/AndroidRuntime( 1195):     ... 10 more

Please use labels and text to provide additional information.

Original issue reported on code.google.com by sandordo...@google.com on 10 Nov 2010 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
I have not tried to debug this but what I think is happening is that we try to 
schedule the announcer before starting recording.  I think that we should 
change the following line:

  private void setUpAnnouncer() {
    if (announcementFrequency != -1) {
to
    if (announcementFrequency != -1 && recordingTrackId != -1) {

Original comment by sandordo...@google.com on 10 Nov 2010 at 5:03

GoogleCodeExporter commented 9 years ago
Ah, this bug is related to a clean up I did before.  In the past, TripStats 
would be set in constructor, and would have some stale data.  We always call 
setUpAnnouncer, regardless if we are recording or not.

Let me take on this bug.  As discussed offline, I would like to create a more 
sophisticated functional unit test for the service in general.

Basically, for each shared preference, we will use 3 values (default, not set, 
and an arbitrary value).  Then, we will end up with 3*N combinations.  For each 
combination, I want to run a simple test that starts/stops and calls a few 
methods on the service while running.

Original comment by ba...@google.com on 10 Nov 2010 at 6:54

GoogleCodeExporter commented 9 years ago
Please review: 
http://code.google.com/r/bartn-mytracks/source/detail?r=1846c7fa79f2328c4a300b36
5b354a1e3f3301c6

Original comment by ba...@google.com on 11 Nov 2010 at 8:34

GoogleCodeExporter commented 9 years ago
Please review: 
http://code.google.com/r/bartn-mytracks/source/detail?r=8a4e3630f002c9ce8f3bd21c
4857c4ea076158c2

Original comment by ba...@google.com on 11 Nov 2010 at 6:56

GoogleCodeExporter commented 9 years ago

Original comment by sandordo...@google.com on 16 Nov 2010 at 5:38