StartingAlertService Wakelock...

Search This thread

arabcamel

Senior Member
Oct 19, 2010
477
62
http://xdaforums.com/showpost.php?p=19173992&postcount=18

If you don't know how to decompile & apply patch upload your TouchWizCalendar.apk and I'll patch it for you

Can I just use the one from the link you posted? do the calendar apk's differ from ROM to ROM? If so, I'll definitely post mine if you would be so kind to patch it for me. I have never used APK Manager to decompile and modify apk's. I've only recently learned to modify some of the SQLite databases and whatnot...
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
Can I just use the one from the link you posted? do the calendar apk's differ from ROM to ROM? If so, I'll definitely post mine if you would be so kind to patch it for me. I have never used APK Manager to decompile and modify apk's. I've only recently learned to modify some of the SQLite databases and whatnot...

No
But that's not the real fix, the problem is in android 2.3.5, I think it's fixed in 2.3.6 I can see it fixed in 4.0 (ics)

the bug is in class ServiceHandler inside class AlertService, in 2.3.5 the service is stopped instead finished so the wakelock is not released

Code:
public void handleMessage(Message msg) {
            processMessage(msg);
            // NOTE: We MUST not call stopSelf() directly, since we need to
            // make sure the wake lock acquired by AlertReceiver is released.
            AlertReceiver.finishStartingService(AlertService.this, msg.arg1);
        }

I think I'm not going to fix it because 2.3.6 is out

Edit: seems that Samsung is using a very old modifed calendar code, because I can see this code fixed in old android 1.5.
Because Samsung is using a personal version of the calendar they are not upgrading the code and not applyng a lot of improvements
 
Last edited:

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
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
 

Attachments

  • TouchWizCalendar.apk
    783.1 KB · Views: 664
Last edited:

arabcamel

Senior Member
Oct 19, 2010
477
62
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
I just installed it on unnamed ROM. I'll let you know my findings in a couple days


Sent from my SAMSUNG-SGH-I777 using XDA App
 
  • Like
Reactions: gr8hairy1

arabcamel

Senior Member
Oct 19, 2010
477
62
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

my phone had been org the charger for a little over 5 hours and the startingalert wake lock has been on for 1hr 39 min. This doesn't seem to have worked for me. Any thoughts?

Sent from my SAMSUNG-SGH-I777 using XDA App
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
my phone had been org the charger for a little over 5 hours and the startingalert wake lock has been on for 1hr 39 min. This doesn't seem to have worked for me. Any thoughts?

Sent from my SAMSUNG-SGH-I777 using XDA App

Upload your apk, i'll patch it, this change fix the wakelock for sure, i'll create a cwm file to be sure you replace the apk and clear dalvikcache. Remember to clear battstats to be sure you have the problem.
 
Last edited:
  • Like
Reactions: arabcamel

arabcamel

Senior Member
Oct 19, 2010
477
62
Upload your apk, i'll patch it, this change fix the wakelock for sure, i'll create a cwm file to be sure you replace the apk and clear dalvikcache. Remember to clear battstats to be sure you have the problem.

I attached the TouchWiz calendar apk from ICScrewD 2.3.6 ROM which I am using right now. if you are saying 2.3.6 has the bug too, please send me the patched apk so I can use that going forward until ICS is available.

thanks for your help! Oh and how to you clear battstats?
 

Attachments

  • TouchWizCalendar.apk
    1.2 MB · Views: 4

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I attached the TouchWiz calendar apk from ICScrewD 2.3.6 ROM which I am using right now. if you are saying 2.3.6 has the bug too, please send me the patched apk so I can use that going forward until ICS is available.

thanks for your help! Oh and how to you clear battstats?

I'll patch it in 8hrs. You can clean battery stats in recovery mode, in advaned menu
 
  • Like
Reactions: arabcamel

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I attached the TouchWiz calendar apk from ICScrewD 2.3.6 ROM which I am using right now. if you are saying 2.3.6 has the bug too, please send me the patched apk so I can use that going forward until ICS is available.

thanks for your help! Oh and how to you clear battstats?

Ok, I've created a CMW zip file to install it in recovery mode, the script will install the new calendar, create a backup and clear battery stats.
Please test & report.
 

Attachments

  • calendar_wakelock_fix_CWM.zip
    836 KB · Views: 21
  • Like
Reactions: arabcamel

arabcamel

Senior Member
Oct 19, 2010
477
62
I'll patch it in 8hrs. You can clean battery stats in recovery mode, in advaned menu

Do I need to clear battery stats in recovery mode to reset the counters in the application BetterBatteryStats? That's what I originally thought you were referring to.

---------- Post added at 10:46 AM ---------- Previous post was at 10:39 AM ----------

Ok, I've created a CMW zip file to install it in recovery mode, the script will install the new calendar, create a backup and clear battery stats.
Please test & report.

THANKS SO MUCH!

I'd rather install it via root browser - so I'm assuming I can extract the apk from your zip file and do it that way. The reason I don't like to clear battery stats is I have to make sure my battery is fully charged to do so...

I'm just going to use this calendar apk from now on with any ROM and see if it works. I'm trying out Task650's ROM currently.
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I'd rather install it via root browser - so I'm assuming I can extract the apk from your zip file and do it that way. The reason I don't like to clear battery stats is I have to make sure my battery is fully charged to do so...

I'm just going to use this calendar apk from now on with any ROM and see if it works. I'm trying out Task650's ROM currently.

The zip is designed to be installed with CWM, deleting the battery stats file is not a problem in SGS2 because the battery chip has no problem when you remove that file. That file is used to perform some batts calculations but not the charge, Entropy512 explainned this in some posts, I think I read it in siyah kernel thread. So it's safe delete battery stats in SGS2.
If you install the apk manually I'm not sure if you need to clear dalvik cache, the script delete only the required files from dalvik-cache.
 
  • Like
Reactions: gaspx

arabcamel

Senior Member
Oct 19, 2010
477
62
The zip is designed to be installed with CWM, deleting the battery stats file is not a problem in SGS2 because the battery chip has no problem when you remove that file. That file is used to perform some batts calculations but not the charge, Entropy512 explainned this in some posts, I think I read it in siyah kernel thread. So it's safe delete battery stats in SGS2.
If you install the apk manually I'm not sure if you need to clear dalvik cache, the script delete only the required files from dalvik-cache.

I forgot about that. I still have some habits from the Samsung Captivate which the battery stats DID matter I beleieve. So, the battery does not need to be fully charged on the SGS2 to delete battery stats?

Maybe I'll just flash the zip as it might be quicker and easier. Will this remove my gmail sync - so I will need to log back in?
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I forgot about that. I still have some habits from the Samsung Captivate which the battery stats DID matter I beleieve. So, the battery does not need to be fully charged on the SGS2 to delete battery stats?

Maybe I'll just flash the zip as it might be quicker and easier. Will this remove my gmail sync - so I will need to log back in?

The script reset battery stats only. No problem with your data.
 
  • Like
Reactions: arabcamel

arabcamel

Senior Member
Oct 19, 2010
477
62
The script reset battery stats only. No problem with your data.

I flashed your zip file that you made for me and it seems to be working PERFECTLY! thank you so much. Since I used what seems to be a generic TouchWiz Calendar apk, I should be able to flash this zip file on any ROM, right? (I won't hold you liable)
 

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Xiaomi Mi 10T / 10T Pro
I flashed your zip file that you made for me and it seems to be working PERFECTLY! thank you so much. Since I used what seems to be a generic TouchWiz Calendar apk, I should be able to flash this zip file on any ROM, right? (I won't hold you liable)

I think you can use it in any ROM but i'm not sure you can test it if doesn't work you can upload new apk and I'll patch it for you, if you don't get any response here email me rodries@gmail.com
 
  • Like
Reactions: arabcamel

godsdragon

Member
Feb 16, 2010
5
0
TampaBay
Even though i know very little about messing with my phone, i set my calendar notifications to alert. Thanks for your research ...and expertise...:cool:
 

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.