StartingAlertService Wakelock...

Search This thread

hlb3

Senior Member
Jul 29, 2011
261
29
So it appears the calendar app has some sort of a bug in it. I have noticed it a few times now, before a reminder in the calendar goes off, a wakelock pops up in betterbatterystats that says 'StartingAlertService' (Calendar). This most recent time it kept my phone awake for over an hour before I killed the calendar. Anybody else notice this? And more important, have a way to fix it?

Sent from my Galaxy S II using Tapatalk
 

marnel47

Senior Member
Aug 29, 2007
79
19
Hagerstown, MD
I actually noticed this on mine for a couple days in a row not to long ago. Haven't seen it again but i've been keeping an eye out. Curious to know why?

Sent from my SAMSUNG-SGH-I777 using XDA App
 

wltklah

Senior Member
Jul 29, 2011
94
5
Urbana
I found the source code that call the wakelock of StartingAlertService here.
I am not a dev, but I can see that in order for the wakelock to be released, there are 2 IF statements that have to be satisfied. I think the problem might be there. Any Devs here would like to share any insights??
 

Entropy512

Senior Recognized Developer
Aug 31, 2007
14,088
25,086
Owego, NY
Had it happen to me once too... I'll look at the code if I can find some time.

Looks like the first if is a simple "is there a wakelock"

The second one appears to be "is something done with doing stuff".
 
Last edited:

claimui

Senior Member
Sep 11, 2011
173
105
Taipei
We've had this problem on the international Galaxy S II for a while now. There is a thread on it here: http://xdaforums.com/showthread.php?t=1192696

One problem I see is that the source is for the Android AOSP calendar, which is probably different from the Samsung calendar (just like the Email app is different). I haven't tried the AOSP calendar but typically the Samsung apps have more features. You would have to edit the smali files to fix the Samsung app (or do a crude replacement hack like my Exchange wakelock hack, and pray that it works).

In the meantime, my solution was to just uninstall Calendar. Works great, but now I have no calendar. ;) Other users have uninstalled Calendar and used replacement calendar apps without the wakelock issue, so you could try that.

EDIT: I also noticed that one user mentioned that this bug only happens when Calendar notifications are set to "Off." Kinda counterintuitive, but try setting Calendar notifications to something other than "Off" and see if that fixes the problem.
 
Last edited:
  • Like
Reactions: Simba501

hlb3

Senior Member
Jul 29, 2011
261
29
Came across this earlier today: http://xdaforums.com/showthread.php?p=16699746

I pushed that Calender.apk and froze the TW Calender in Titanium, I set a number of events like normal and so far I have not see the StartingAlertService Wakelock pop up at all, I'll continue to test for a few days and see what happens.

Sent from my Toshiba THRiVE using Tapatalk
 

mbze430

Senior Member
Feb 28, 2007
1,556
180
Southeast Missouri
I am surprised this was caught so late. I actually seen this problem 2 days after I bought the ATT SGS2... but I read over in the Intl forum, and decided it was best to get a more "complete" calendar replacement.
 

claimui

Senior Member
Sep 11, 2011
173
105
Taipei
EDIT: I also noticed that one user mentioned that this bug only happens when Calendar notifications are set to "Off." Kinda counterintuitive, but try setting Calendar notifications to something other than "Off" and see if that fixes the problem.

UPDATE: I think setting the Calendar notification setting to "Alert" avoids the wakelock issue. When I set it to "Status bar notification" or "Off", I get the wakelock. Give it a try and see if it helps.

Personally I'd rather just have the status bar notifications though. Having to dismiss the popup alert is a pain.

Using the original Android Calendar might be one solution, but I actually like the Samsung apps. Maybe we can just replace the relevant smali file, like I did with my Samsung Email app "fix".

UPDATE 2: Setting the Calendar notification setting to "Alert" seemed to help, but I eventually got another wakelock. So we still need a more reliable solution to this issue.
 
Last edited:

hlb3

Senior Member
Jul 29, 2011
261
29
Ill give that a shot also, I like the Samsung app better as well.


Sent from my Toshiba THRiVE using Tapatalk
 

Simba501

Senior Member
Feb 2, 2010
3,206
1,137
I experienced this issue. Here's the thread. It has happened since that thread died, but oddly hasn't occurred in the last week or so. I haven't seen any type of consistent behavior. Sometimes it happens, and other times it'll completely stop for a while.


UPDATE: I think setting the Calendar notification setting to "Alert" avoids the wakelock issue. When I set it to "Status bar notification" or "Off", I get the wakelock. Give it a try and see if it helps.

Personally I'd rather just have the status bar notifications though. Having to dismiss the popup alert is a pain.

Using the original Android Calendar might be one solution, but I actually like the Samsung apps. Maybe we can just replace the relevant smali file, like I did with my Samsung Email app "fix".

This wouldn't be an option for me. I keep my calendar notifications in my status bar for a while and dismiss them when I don't need them.
 
Last edited:

hlb3

Senior Member
Jul 29, 2011
261
29
Changing to alert didn't seem to work for me, had a 36 min wakelock last night. Back to testing the stock Android calendar.

Sent from my Galaxy S II using Tapatalk
 

Kadin

Senior Member
Sep 23, 2007
706
98
California
Well my battery life was plummeting today and I couldn't figure out why. I had an alert for a meeting today at 11AM (it's 5:41PM right now). I just looked in BBS and showed this under partial wakelocks for 1hr 39mins. I went in and deleted the appointment and the service was still increasing. I pulled the battery and now it only shows 37mins under BBS. The time is no longer increasing after a few mins.

I did have notification set to Status Bar Notification, now changed to Alert and will see how it goes from here.
 

Simba501

Senior Member
Feb 2, 2010
3,206
1,137
Well my battery life was plummeting today and I couldn't figure out why. I had an alert for a meeting today at 11AM (it's 5:41PM right now). I just looked in BBS and showed this under partial wakelocks for 1hr 39mins. I went in and deleted the appointment and the service was still increasing. I pulled the battery and now it only shows 37mins under BBS. The time is no longer increasing after a few mins.

I did have notification set to Status Bar Notification, now changed to Alert and will see how it goes from here.

That's peculiar. It didn't really affect my battery.
 

Kadin

Senior Member
Sep 23, 2007
706
98
California
That's peculiar. It didn't really affect my battery.

Yeah "plummeting" might have been an exaggeration but I definitely noticed a faster battery drain than normal. Usually get around 1-2% loss per hour but was getting close to 5% today. All in sleep as I was working all afternoon.

Sent from my SAMSUNG-SGH-I777 using xda premium
 

hlb3

Senior Member
Jul 29, 2011
261
29
When I get them it puts a big drain on my battery like that as well.


Sent from my Toshiba THRiVE using Tapatalk
 

claimui

Senior Member
Sep 11, 2011
173
105
Taipei
Today I got a wakelock even though my Calendar notification was set to "Alert" (same thing as what hlb3 reported earlier). So it seems this is not a reliable solution after all. Hope somebody is able to make some progress on this.
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I've modified TouchWizCalendar.apk with backsmali to force the wakelock release
something like:
Original:
Code:
if (mStartingService != null) {
   if (service.stopSelfResult(startId)) {
     mStartingService.release();
  }
}
Now:
Code:
if (mStartingService != null) {
  service.stopSelfResult(startId);
  mStartingService.release();              
}

In finishStartingService function in AlertReceiver.smali I've commented (#) the if
Code:
    invoke-virtual {p0, p1}, Landroid/app/Service;->stopSelfResult(I)Z

    move-result v1

#    if-eqz v1, :cond_12

    .line 125
    sget-object v1, Lcom/android/calendar/AlertReceiver;->mStartingService:Landroid/os/PowerManager$WakeLock;

My new TouchWizCalendar.apk (XXKI4 stock ROM) is attached but I've not tested it a lot
You only need to overwrite it in /system/app with rootexplorer for example (maybe you need to clear dalvik cache,also delete calendar data, I'm not sure). If works I can create CWM file.
Try TouchWizCalendarV2(notCWM).zip first (based on Serendipity), it's not a CWM file you will have to decompress it and replace.
 

Attachments

  • TouchWizCalendar.apk
    1.2 MB · Views: 60
  • TouchWizCalendarV2(notCWM).zip
    592.4 KB · Views: 27
Last edited:

hlb3

Senior Member
Jul 29, 2011
261
29
Awesome, I'll give it a try.


Sent from my Toshiba THRiVE using Tapatalk
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    ok, the real StartingAlertService Wakelock fix is replace the handleMessage function in AlertService$ServiceHandler.smali in TouchWizCalendar.apk with:

    Code:
    # virtual methods
    .method public handleMessage(Landroid/os/Message;)V
        .registers 4
        .parameter "msg"
    
        .prologue
    
        iget-object v0, p0, Lcom/android/calendar/AlertService$ServiceHandler;->this$0:Lcom/android/calendar/AlertService;
    
        invoke-virtual {v0, p1}, Lcom/android/calendar/AlertService;->processMessage(Landroid/os/Message;)V
    
        iget-object v0, p0, Lcom/android/calendar/AlertService$ServiceHandler;->this$0:Lcom/android/calendar/AlertService;
    
        iget v1, p1, Landroid/os/Message;->arg1:I
    
        invoke-static {v0, v1}, Lcom/android/calendar/AlertReceiver;->finishStartingService(Landroid/app/Service;I)V
    
        return-void
    .end method

    I'm posting the fix because seems that new samsung rom based in 2.3.6 has the bug
    So if anyone wants to test you can try to replace the attached TouchWizCalendar.apk (make a backup of the original) in this post, if doesn't work then upload the original apk and I'll patch it.
    The patched TouchWizCalendar.apk is from Checkrom RevoHD 3.1.1 not sue if all roms use the same apk
    3
    I've modified TouchWizCalendar.apk with backsmali to force the wakelock release
    something like:
    Original:
    Code:
    if (mStartingService != null) {
       if (service.stopSelfResult(startId)) {
         mStartingService.release();
      }
    }
    Now:
    Code:
    if (mStartingService != null) {
      service.stopSelfResult(startId);
      mStartingService.release();              
    }

    In finishStartingService function in AlertReceiver.smali I've commented (#) the if
    Code:
        invoke-virtual {p0, p1}, Landroid/app/Service;->stopSelfResult(I)Z
    
        move-result v1
    
    #    if-eqz v1, :cond_12
    
        .line 125
        sget-object v1, Lcom/android/calendar/AlertReceiver;->mStartingService:Landroid/os/PowerManager$WakeLock;

    My new TouchWizCalendar.apk (XXKI4 stock ROM) is attached but I've not tested it a lot
    You only need to overwrite it in /system/app with rootexplorer for example (maybe you need to clear dalvik cache,also delete calendar data, I'm not sure). If works I can create CWM file.
    Try TouchWizCalendarV2(notCWM).zip first (based on Serendipity), it's not a CWM file you will have to decompress it and replace.
    2
    I've created a thread explaining the problem and how to fix it

    http://xdaforums.com/showthread.php?p=20138812
    2
    Ok, did a littke testing and under normal situations it has taken care of the wakelock. I found if you create or edit an event with a reminder to go off in like 30 min or so it will wakelock until it notifies you, then it stops. That was the only time I could get it to do a wakelock, so far it is looking promising.

    Sent from my Toshiba THRiVE using Tapatalk
    1
    We've had this problem on the international Galaxy S II for a while now. There is a thread on it here: http://xdaforums.com/showthread.php?t=1192696

    One problem I see is that the source is for the Android AOSP calendar, which is probably different from the Samsung calendar (just like the Email app is different). I haven't tried the AOSP calendar but typically the Samsung apps have more features. You would have to edit the smali files to fix the Samsung app (or do a crude replacement hack like my Exchange wakelock hack, and pray that it works).

    In the meantime, my solution was to just uninstall Calendar. Works great, but now I have no calendar. ;) Other users have uninstalled Calendar and used replacement calendar apps without the wakelock issue, so you could try that.

    EDIT: I also noticed that one user mentioned that this bug only happens when Calendar notifications are set to "Off." Kinda counterintuitive, but try setting Calendar notifications to something other than "Off" and see if that fixes the problem.