[MOD][XPOSED][TASKER][4.4+] - (2014/03/05) - Dismiss Alarm Tasker Plugin

Search This thread

mikefero

Member
Aug 30, 2010
7
6
ic_plugin.png

Dismiss Alarm Tasker Plugin
DATP is an Xposed Module and Tasker plugin for handling dismissed alarms
originating from the KitKat Desk Clock (Alarm Clock) on Nexus 5 devices. DATP
uses the Xposed findAndHookMethod to intercept the
AlarmStateManager::setDismissState and creates an intent to initiate the Tasker
plugin event mechanism. The Tasker plugin portion of DATP allows you to set an
alarm label of interest to isolate named alarm events; blank (empty string)
alarm labels will result in all dismissed alarms events for that configuration.

Installation Requirements
[Xposed Framework] v2.4+ (FREE)
Home URL - [Will Post Links When Authorized]

Xposed is a framework for modules that can change the behavior of the
system and apps without touching any APKs. That's great because it means
that modules can work for different versions and even ROMs without any
changes (as long as the original code was not changed too much). It's also
easy to undo. As all changes are done in the memory, you just need to
deactivate the module and reboot to get your original system back. There
are many other advantages, but here is just one more: Multiple modules can
do changes to the same part of the system or app. With modified APKs, you
to decide for one. No way to combine them, unless the author builds
multiple APKs with different combinations.

[Tasker] v4.3b5+ (Purchase Required)
Home URL - [Will Post Links When Authorized]
Beta URL - [Will Post Links When Authorized]

Tasker is an application for Android which performs tasks (sets of
actions) based on contexts (application, time, date, location, event,
gesture) in user-defined profiles or in clickable or timer home screen
widgets.

This simple concept profoundly extends your control of your Android device
and it's capabilities, without the need for 'root' or a special home
screen.

NOTE: As of 2014/03/05 the current version available on the Google Play
Store is v4.2u3. The beta edition is required due to the addition
of support for developer event plugins.

Action - net.dinglisch.android.tasker.ACTION_EDIT_EVENT

See [Will Post Links When Authorized] for the
changelog in the upcoming version of Tasker.


Version/Change Log
1.0 - 2014/03/05 - Initial release

Source
Source URL - [Will Post Links When Authorized]
Hint: It's on GitHub and my GitHub repository is the same as my XDA member name

Build Requirement
[Locale API]
Home URL - [Will Post Links When Authorized]

The Locale Developer Platform exposes APIs for plug-in conditions and
settings. Interaction with Locale occurs via Intents which are
documented in the following sections, along with the
[Will Post Links When Authorized]

Thanks
rovo89 - Xposed Framework
Tungstwenty - Xposed Framework
Pent - Tasker
Two Forty Four AM - Locale API
 

Attachments

  • DismissAlarmTaskerPlugin-1.0.apk
    369 KB · Views: 306
  • configure_event.png
    configure_event.png
    142 KB · Views: 1,868
  • configured_event.png
    configured_event.png
    78.6 KB · Views: 1,695
Last edited:

cramu

Senior Member
Mar 12, 2012
187
52
Berlin
Also works on N4.
Would you consider to add actions to create, change and delete alarms by label?
 
Last edited:

mikefero

Member
Aug 30, 2010
7
6
Thanks for letting me know this works on Nexus 4 devices. Are you running KitKat v4.4+? The reason I am asking is I recently updated the title of this thread as I had a typo as to what version of android devices this is targeting. It's very well possible this would work on older android versions; however I targeted the build of the APK for SDK version 19 which is the KitKat release. When I get a moment I may go back into the AOSP repository and see if this will work on older Android Alarm Clock (Desk Clock) versions, but for now I am forcing KitKat requirement in the build.

Would you consider to add actions to create, change and delete alarms by label?
It is already possible to create alarms with alarm labels using Tasker; App->Set Alarm action. The Set Alarm App Action contains the following configuration elements:
  • Hours - Hour of day for alarm
  • Minutes - Minute of day for alarm
  • Message - Required on some devices [Not Nexus devices]
  • Confirm - If you want to confirm the creation of the alarm
  • If - Conditional expression that must be met to perform action
  • Label - Alarm label
The above would handle the creating of alarms with alarm labels. I use this App Action in Tasker to create an alarm Sunday - Thursday in a "Sleeping" task that is initiated from an NFC tag that I have on my nightstand. DATP was created so that I could perform my "End Sleeping" task when the alarm is dismissed and not snoozed as Tasker's event Alarm Done would get fired for any action of the Alarm Clock.

Could you elaborate on the enhancement request regarding "change and delete alarms by label?" I do not fully understand what you are looking for in this instance and once I have a better understanding I will look at adding this functionality.
 

cramu

Senior Member
Mar 12, 2012
187
52
Berlin
Yes I'm running 4.4.2.

Just digging through my old profiles and you're right, I already managed to set an alarm with label through tasker.
The problem was, that tasker is not able to edit or delete alarms.
If you try to change an alarm that has been set before, Tasker will create a new alarm with the same label.
 

mikefero

Member
Aug 30, 2010
7
6
The problem was, that tasker is not able to edit or delete alarms.
If you try to change an alarm that has been set before, Tasker will create a new alarm with the same label.

OK I think I understand what you are looking as far as additional actions for Tasker. When I get a chance I will look into adding the ability to change and delete alarms via two new Tasker actions. I will make it so that if the alarm label is matched then update the alarm with a new time or delete the alarm. If it makes sense I may package them into one Tasker action with a check box for delete actions; we'll see though what looks better.

Not sure when I am going to get to adding this functionality, but it should be within the next week or so.
 

vali_ics

Senior Member
Jul 28, 2010
1,303
222
Bucharest
When i try to install the apk this is what appear : There was a problem while parsing the package...
I tried another xposed plugin and it work. Can someone upload it in another place?
 

Pkt_Lnt

Inactive Recognized Contributor
Dec 26, 2011
7,894
5,804
SLO
When i try to install the apk this is what appear : There was a problem while parsing the package...
I tried another xposed plugin and it work. Can someone upload it in another place?

It only installs on KitKat. You get that message if you try to install on anything less than 4.4 KitKat.
 
  • Like
Reactions: mikefero

mikefero

Member
Aug 30, 2010
7
6
Will be this available for 4.3 ?

Sent from my GT-N7100 using Tapatalk
I will investigate at some point and see if the functionality is available for older versions of Android in the com.google.android.deskclock package. I targeted and tested only KitKat and that is why I forced that restriction on the installation. Feel free to download the source from github and make any modifications. If you do make any changes and want them committed just send me a patch and I will more than likely incorporate in a future release.

Source can be obtained here: github.com/mikefero/DismissAlarmTaskerPlugin

NOTE: I noticed a build issue when I recently checked out a clean copy of the source and have already updated the project locally; will commit sometime soon with some other fixes. The issue is with the pathing for the locale-api which I may just rip out this requirement at some point as well in order to make the building simpler with less setup on any other developers end.
 

cramu

Senior Member
Mar 12, 2012
187
52
Berlin
OK I think I understand what you are looking as far as additional actions for Tasker. When I get a chance I will look into adding the ability to change and delete alarms via two new Tasker actions. I will make it so that if the alarm label is matched then update the alarm with a new time or delete the alarm. If it makes sense I may package them into one Tasker action with a check box for delete actions; we'll see though what looks better.

Not sure when I am going to get to adding this functionality, but it should be within the next week or so.

Any progress with this feature?
 

XlAfbk

Senior Member
Aug 11, 2010
1,484
440
Doesn't work on Lollipop for me. Would be greatly appreciated if you could add support.
Logcats:
Alarm dismissed from alarm screen:
Code:
V/AlarmClock(21153): Setting dismissed state to instance 1
V/AlarmClock(21153): Clearing notifications for alarm instance: 1
V/AlarmClock(21153): Canceling instance 1 timers
I/AlarmClock(21153): Disabling parent alarm: 1
V/AlarmClock(21153): *** notifyChange() id: 1 url content://com.android.deskclock/alarms/1
V/AlarmClock(21153): AlarmService.onStartCommand() with intent: Intent { act=STOP_ALARM dat=content://com.android.deskclock/instances/1 cmp=com.android.deskclock/.alarms.AlarmService }
V/AlarmClock(21153): AlarmService.onDestroy() called
V/AlarmClock(21153): AlarmService.stop with instance: 1
V/AlarmClock(21153): AlarmKlaxon.stop()
V/AlarmClock/AlarmActivity(21153): Received broadcast: com.android.deskclock.ALARM_DONE
V/AlarmClock/AlarmActivity(21153): Ignored broadcast: com.android.deskclock.ALARM_DONE
Alarm snoozed:
Code:
V/AlarmClock(21153): Setting snoozed state to instance 1 for Tue 20:58
V/AlarmClock(21153): *** notifyChange() id: 1 url content://com.android.deskclock/instances/1
V/AlarmClock(21153): Displaying snoozed notification for alarm instance: 1
V/AlarmClock(21153): Scheduling state change 5 to instance 1 at Tue 20:58 (1425412680000)
V/AlarmClock(21153): AlarmService.onStartCommand() with intent: Intent { act=STOP_ALARM dat=content://com.android.deskclock/instances/1 cmp=com.android.deskclock/.alarms.AlarmService }
V/AlarmClock(21153): AlarmService.onDestroy() called
V/AlarmClock(21153): AlarmService.stop with instance: 1
V/AlarmClock(21153): AlarmKlaxon.stop()
V/AlarmClock/AlarmActivity(21153): Received broadcast: com.android.deskclock.ALARM_DONE
V/AlarmClock/AlarmActivity(21153): Ignored broadcast: com.android.deskclock.ALARM_DONE
Alarm dismissed from notification:
Code:
V/AlarmClock(21153): AlarmStateManager received intent Intent { act=change_state cat=[DISMISS_TAG] dat=content://com.android.deskclock/instances/1 flg=0x10000010 cmp=com.android.deskclock/.alarms.AlarmStateManager bnds=[97,208][756,280] (has extras) }
V/AlarmClock(21153): Setting dismissed state to instance 1
V/AlarmClock(21153): AlarmService.onStartCommand() with intent: Intent { act=STOP_ALARM dat=content://com.android.deskclock/instances/1 cmp=com.android.deskclock/.alarms.AlarmService }
V/AlarmClock(21153): AlarmService.onDestroy() called
V/AlarmClock(21153): There is no current alarm to stop
V/AlarmClock(21153): Clearing notifications for alarm instance: 1
V/AlarmClock(21153): Canceling instance 1 timers
W/AlarmManager( 5742): Clear alarm type=4,alarmSeconds=1425412680
I/AlarmClock(21153): Disabling parent alarm: 1
V/AlarmClock(21153): *** notifyChange() id: 1 url content://com.android.deskclock/alarms/1
 

mikefero

Member
Aug 30, 2010
7
6
Doesn't work on Lollipop for me. Would be greatly appreciated if you could add support.

Thanks for the logs and the heads up.; I didn't even realize rovo89 updated Xposed to work with ART on Lollipop back in February. With that good news discovered and your test using the module I will dust off the code and look into adding support when I have some free time. Might be a few weeks so if you don't hear anything from me give me a ping.
 

XlAfbk

Senior Member
Aug 11, 2010
1,484
440
Thanks for the logs and the heads up.; I didn't even realize rovo89 updated Xposed to work with ART on Lollipop back in February. With that good news discovered and your test using the module I will dust off the code and look into adding support when I have some free time. Might be a few weeks so if you don't hear anything from me give me a ping.
The fix for Lollipop is actually quite trivial:
\fero\xposed\dismissalarm\DismissAlarm.java, line51: com.google.android.deskclock -> com.android.deskclock
I'm not sure whether Google-provided roms still have google in the package name, but Cyanogenmod/AOSP don't. Maybe just look for either to be on the safe side?

Attached is a .apk patched to work with CM12 until there's an official update. Apk is signed with my own keys so you'll have to uninstall the old one first.
@mikefero: If you have a problem with this apk / updated yours then please ping me and I'll remove it.
 

Attachments

  • DismissAlarmTaskerPlugin-1.0-CM12.apk
    368.4 KB · Views: 43

mikefero

Member
Aug 30, 2010
7
6
If you have a problem with this apk / updated yours then please ping me and I'll remove it.

@XlAfbk Thanks for providing an updated APK; I have no problem with it. Would it be possible for you to provide a diff patch or create a fork and initiate a pull request so I can merge it in when I get my setup going?
 

XlAfbk

Senior Member
Aug 11, 2010
1,484
440
@XlAfbk Thanks for providing an updated APK; I have no problem with it. Would it be possible for you to provide a diff patch or create a fork and initiate a pull request so I can merge it in when I get my setup going?
I actually modded it in .smali as I was too lazy to set up the build environment properly.
Here's what I'm proposing as the change for the java code (quick and dirty):
Code:
--- DismissAlarm.java	2015-04-06 23:12:56.827140600 +0200
+++ DismissAlarm.java	2015-04-06 23:14:04.962882800 +0200
@@ -89,7 +89,7 @@
 		 * Ensure that we are only handling customizations for the alarm/desk
 		 * clock package
 		 */
-		if (loadPackageParam.packageName.equals(ALARM_CLOCK_PACKAGE_NAME)) {
+		if (loadPackageParam.packageName.equals("com.google.android.deskclock") || loadPackageParam.packageName.equals("com.android.deskclock")) {
 			//Find the AlarmStateManager and AlarmInstance classes
 			final Class<?> alarmStateManager = XposedHelpers.findClass(ALARM_STATE_MANAGER_CLASS_NAME, loadPackageParam.classLoader);
 			final Class<?> alarmInstance = XposedHelpers.findClass(ALARM_INSTANCE_CLASS_NAME, loadPackageParam.classLoader);
 

Top Liked Posts

  • There are no posts matching your filters.
  • 5
    ic_plugin.png

    Dismiss Alarm Tasker Plugin
    DATP is an Xposed Module and Tasker plugin for handling dismissed alarms
    originating from the KitKat Desk Clock (Alarm Clock) on Nexus 5 devices. DATP
    uses the Xposed findAndHookMethod to intercept the
    AlarmStateManager::setDismissState and creates an intent to initiate the Tasker
    plugin event mechanism. The Tasker plugin portion of DATP allows you to set an
    alarm label of interest to isolate named alarm events; blank (empty string)
    alarm labels will result in all dismissed alarms events for that configuration.

    Installation Requirements
    [Xposed Framework] v2.4+ (FREE)
    Home URL - [Will Post Links When Authorized]

    Xposed is a framework for modules that can change the behavior of the
    system and apps without touching any APKs. That's great because it means
    that modules can work for different versions and even ROMs without any
    changes (as long as the original code was not changed too much). It's also
    easy to undo. As all changes are done in the memory, you just need to
    deactivate the module and reboot to get your original system back. There
    are many other advantages, but here is just one more: Multiple modules can
    do changes to the same part of the system or app. With modified APKs, you
    to decide for one. No way to combine them, unless the author builds
    multiple APKs with different combinations.

    [Tasker] v4.3b5+ (Purchase Required)
    Home URL - [Will Post Links When Authorized]
    Beta URL - [Will Post Links When Authorized]

    Tasker is an application for Android which performs tasks (sets of
    actions) based on contexts (application, time, date, location, event,
    gesture) in user-defined profiles or in clickable or timer home screen
    widgets.

    This simple concept profoundly extends your control of your Android device
    and it's capabilities, without the need for 'root' or a special home
    screen.

    NOTE: As of 2014/03/05 the current version available on the Google Play
    Store is v4.2u3. The beta edition is required due to the addition
    of support for developer event plugins.

    Action - net.dinglisch.android.tasker.ACTION_EDIT_EVENT

    See [Will Post Links When Authorized] for the
    changelog in the upcoming version of Tasker.


    Version/Change Log
    1.0 - 2014/03/05 - Initial release

    Source
    Source URL - [Will Post Links When Authorized]
    Hint: It's on GitHub and my GitHub repository is the same as my XDA member name

    Build Requirement
    [Locale API]
    Home URL - [Will Post Links When Authorized]

    The Locale Developer Platform exposes APIs for plug-in conditions and
    settings. Interaction with Locale occurs via Intents which are
    documented in the following sections, along with the
    [Will Post Links When Authorized]

    Thanks
    rovo89 - Xposed Framework
    Tungstwenty - Xposed Framework
    Pent - Tasker
    Two Forty Four AM - Locale API
    1
    When i try to install the apk this is what appear : There was a problem while parsing the package...
    I tried another xposed plugin and it work. Can someone upload it in another place?

    It only installs on KitKat. You get that message if you try to install on anything less than 4.4 KitKat.
    1
    Maybe MikeFero has advanced with his?
    Sadly I have not, but the recent pings and inquiries are giving me the motivation to finally upgrade from Lollipop v5.0 to 5.1.1 and get things going again with the Unofficial Xposed that works with ART.

    I think i misunderstood the whole intention of this module.
    I thought, it would be possible to delete alarms in stock clock app (as a task).
    Nevertheless, could this be possible through Xposed especially using the intents implemented recently (see above)?
    Never got around to finishing that feature; however the UI was added to the tasker portion of the app. All you currently get for the delete action is a log message. The main intention I had when writing this plugin was so that I could perform actions with Tasker given a specific alarm (which is performed via the alarm label that can be set). The original deskclock (nor does the current one AFAIK) did not send the alarm label in the intention, so I used Xposed to hook into that portion of the deskclock to get the information required in order to pass off to Tasker.

    As far as those intents added to CM12.1; at a quick scan it doesn't appear to allow for the deleting of alarms (but I may be mistaken). Please use @XlAfbk module that is provided in this post. This is a great contribution and I still need to push it to the repo and start branching off and refactoring a bit for a 1.1 sometime (sometimes I wish sleep was optional).