• Introducing XDA Computing: Discussion zones for Hardware, Software, and more!    Check it out!
  • Fill out your device list and let everyone know which phones you have!    Edit Your Device Inventory

[FIX] StartingAlertService Wakelock (TouchWizCalendar.apk)

Search This thread

mgmate

Senior Member
May 14, 2011
210
27
Rodries,

I am now playing with XWLA4, last version provided by intratech where also CF-root is ready and provided.

Could you please patch it?

Regards,

Mgmate
 

Attachments

  • TouchWizCalendar.rar
    387 KB · Views: 1

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Rodries,

I am now playing with XWLA4, last version provided by intratech where also CF-root is ready and provided.

Could you please patch it?

Regards,

Mgmate
It's a odexed apk and you haven't provided the odex file, so I can't patch it
Anyway try to use cwm from first post, I think must work it's an apk, I don't think that sammy has touch calendar code

Edit:
Anyway I've download LA4 and I've patched it (attached only apk, you can replace the apk inside cwm file), but I think it's the same apk. Remember to delete the calendar odex file to be sure odexed calendar is used
 

Attachments

  • TouchWizCalendar.apk
    783 KB · Views: 40
Last edited:

crsnwby

Senior Member
Jul 16, 2010
119
14
Yes, but you can make a backup of apk & odex file, the cwm file rename the original files adding .bak extension, so you can revert it if doesn't work

I have the same ROM but I dont understand post 1. There is no odex file in the archive i downloaded, can someone tell me what im supposed to do?

I replaced my apk with the one in the zip file but it does not work.
 

mgmate

Senior Member
May 14, 2011
210
27
It's a odexed apk and you haven't provided the odex file, so I can't patch it
Anyway try to use cwm from first post, I think must work it's an apk, I don't think that sammy has touch calendar code

Edit:
Anyway I've download LA4 and I've patched it (attached only apk, you can replace the apk inside cwm file), but I think it's the same apk. Remember to delete the calendar odex file to be sure odexed calendar is used

Rodries,

I am not sure I fully understand. If I replace in the provided ZIP the apk you sent me (the modified one for LA4), What is the reason to delete the calendar.odex? Does your installable ZIP do not rename it?

And by the way many thanks for your support!!

MGMATE
 

arabcamel

Senior Member
Oct 19, 2010
477
62
Can't figure it out

I'm trying to figure out how to do this myself and still no luck. I will be doing more research today. In the meantime, can you please patch this themed calendar for me. thank you in advance.
 

Attachments

  • TouchWizCalendar.apk
    1.2 MB · Views: 1

stevenh

Member
Feb 14, 2006
12
0
I've tried to patch this myself with no luck. Any help? I get "Application not installed" after making the changes and recompiling using APK Manager.
 

Attachments

  • TouchWizCalendar.apk
    946.3 KB · Views: 2

rodries

Senior Member
Jul 2, 2011
410
183
Alicante
Rodries,

I am not sure I fully understand. If I replace in the provided ZIP the apk you sent me (the modified one for LA4), What is the reason to delete the calendar.odex? Does your installable ZIP do not rename it?

And by the way many thanks for your support!!

MGMATE

If you replace in the provided ZIP(first post) the apk I sent you, the script will rename the original apk & odex, no need to delete calendar.odex
 

kmilof

Senior Member
Aug 19, 2010
253
18
Linares
Hey! I've been trying to make this work, but i cant, i'm working with apktool under ubuntu, decompiling and building after making the changes, but the calendar wont appear in my app drawer.

any thoughts?


thanks :D
 

Top Liked Posts

  • There are no posts matching your filters.
  • 33
    Hi

    This is the solution to fix the StartingAlertService Wakelock
    To reproduce the problem (or the fix) modify calendar settings to notify events in status bar, create a an event and add a reminder inmediatly, so a notificantion is triggered and you can see it in status bar, open BetterBatteryStats and you can check in partial wakelocks if you have the StartingAlertService Wakelock. You will see that the wakelock is always working, you only need to refresh data and the wakelock time is increased, the wakelock is not released until you close to notification.

    The problem is in TouchWizCalendar.apk not releasing the wakelock properly in class ServiceHandler inside class AlertService
    The actual code is:
    Code:
    private final class ServiceHandler extends Handler {
            public ServiceHandler(Looper looper) {
                super(looper);
            }
    
            @Override
            public void handleMessage(Message msg) {
                processMessage(msg);
                AlertService.this.stopSelf();
            }
        }

    If you check the new android sources you can see the next code:
    Code:
     private final class ServiceHandler extends Handler {
            public ServiceHandler(Looper looper) {
                super(looper);
            }
    
            @Override
            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);
            }
        }

    So the next change will fix the problem. You have to decompile TouchWizCalendar.apk locate com/android/calendar/AlertService$ServiceHandler.smali and search & replace next code.
    Search (the last method):
    Code:
    # virtual methods
    .method public handleMessage(Landroid/os/Message;)V
        .registers 3
        .parameter "msg"
    
        .prologue
        .line 594
        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
    
        .line 598
        iget-object v0, p0, Lcom/android/calendar/AlertService$ServiceHandler;->this$0:Lcom/android/calendar/AlertService;
    
        invoke-virtual {v0}, Lcom/android/calendar/AlertService;->stopSelf()V
    
        .line 601
        return-void
    .end method
    Replace by:
    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

    Now recompile TouchWizCalendar.apk and replace it.

    I've attached a cwm zip file to create a backup (TouchWizCalendar.apk.bak), replace the apk, and clear battery stats to reset wakelocks counters (reset battery stats doesn't affect to SGS2 battery, the battery chip doesn't need that info). The apk is based on kk5 rom.
    If you don't want to use the cwm file you can extract TouchWizCalendar.apk from the zip and use root explorer (or similar) to replace the file, don't forget to make a backup of your original apk.

    Edit:
    If you get:

    Code:
    # virtual methods
    .method public handleMessage(Landroid/os/Message;)V
        .locals 1
        .parameter "msg"
    ...
    ...
    ...
    when decompile then replace with
    Code:
    # virtual methods
    .method public handleMessage(Landroid/os/Message;)V
        .locals 2
        .parameter "msg"
    ...
    ...
    ...

    Edit2:
    If you use odexed rom delete or rename the odex file (maybe com.android.calendar.odex or TouchWizCalendar.odex, I'm not sure) to be sure classes.dex is used from deodexed apk

    Edit3:
    I've updated the zip to be sure odex file is not used in odexed roms
    2
    Hello rodies

    i uploaded the whole cmw file from the GingerMod Rom. I didn't extract the apk because there is another file in it. The dev. didn't named it TouchWizCalender.apk but Calendar.apk.

    I think it's the same Programm though because i get the same Wakelock and also battery drain with it.

    Many thanks in advance. :):):)
    Sure thing. Perhaps when rodies agrees, we can give the mod to the GingerMod dev.

    I hope rodies can fix the nasty Bug for us.

    I'm a bit busy now, I'll patch your calendar tomorrow.
    Also I think there is more bugs in calendar code I'll try to fix them also.
    Samsung is using an old and bugged calendar version, S is not upgrading his modified apks with last android version.

    About Maps I'm not using it so I don't know nothing about maps wakelocks, tell me the wakelock name and I'll try to find the problem, but maps is a big apk, so it will be very hard to find the problem, and how to reproduce the problem.
    In calendar I know how to reproduce the problem so I can debug it and find the bug.

    The calendar fix is public so any dev can use it freely.
    If I find more bugs I'll publish how to fix them.
    2
    @rodries.

    After replacing the original TouchWizCalendar.apk by yours from the first post, I'm still getting wakelocks from Agenda (Dutch for Calendar). See the first picture. Batterylife is OK though (see the second picture). Also, I noticed that the APK's (my original and yours) differ almost 200 KB in size (see the third picture). Therefore my kind request: would you be so kind to modify my original TouchWizCalendar.apk (attached to this post)?

    My current firmware versions are (Android 2.3.6):
    - PDA : I9100XWKK2
    - PHONE : I9100XXKI4
    - CSC : I9100XENKJ1
    Build Info : Fri Nov 11 18:05:58 KST 2011

    Try to use this apk and comment
    Remember to reset battery stats to be sure problem is fixed
    The size is not important I've compressed the apk with 9
    1
    hi
    it will work on xwkk5 stock rom odexed?
    1
    I've attached my calendar. Thanks.

    Your apk is fixed
    You haven't the wakelock problem
    If you have the problem try to clean cache & dalvik-cache from recovery, then reboot, the first time you will have to wait a lot (about 5 mins), because you have to wait to recreate cache.