summaryrefslogtreecommitdiff
path: root/src/com/android/deskclock/data/TimerModel.java
AgeCommit message (Collapse)Author
2022-04-18DeskClock: Remove compatibility to old APIsHEADsugisawa-mr1Michael W
* We never build on these, so the code and annotations are useless Change-Id: I791370b531ecadcbddb63ca04d5c4c51aafe1bc1
2022-04-18DeskClock: Add FLAG_IMMUTABLEMichael W
* As per recommendations Change-Id: I467c5eec9e7de1cb8084a173e942832c6ac44e27
2020-12-08DeskClock: Rework notification channel implementationMichael W
* Alarm notifications etc. are important and should be on high importance level. * On contrast, upcoming alarms etc. should not have sounds or vibrations attached to them. * In addition, we need to fix strings for notification channel. * In order to achieve this, we need to create some new channels because you can't change the priority for existing channels * Delete old channels on boot and update the names of existing channels if they already exist (they get created with the first notification requiring them) * Move creation of upcoming alarm notifications into one place Test: manual - Tested the DeskClock UI manually and tested that every possible notification behaves as expected. Co-authored-by: Wang Han <416810799@qq.com> Change-Id: I6d2e9abd6a822a62b3313c62b0617d8d9211948e
2019-11-13AOSP/DeskClock - Updated to sdkVersion 29.Raman Tenneti
+ Fixed all the comments from jplemieux@ in CL: https://android-review.googlesource.com/c/platform/packages/apps/DeskClock/+/1161143 + Incorporated changes from Luca Stefani (https://android-review.googlesource.com/c/platform/packages/apps/DeskClock/+/1162919) BUG: 133177396 BUG: 143990962 Test: manual - Tested the DeskClock UI manually and tested the alarm, stopwatch and timer. $ make -j 40 $ ls -l out/target/product/generic/system/product/app/DeskClock/DeskClock.apk -rw-r--r-- 1 rtenneti .... 6436375 Nov 11 16:09 out/target/product/generic/system/product/app/DeskClock/DeskClock.apk $ adb install -r out/target/product/generic/system/product/app/DeskClock/DeskClock.apk + Verified by setting up the alaram and waiting for the alarm to go off. "Clock has stopped" wasn't displayed. Noted there were no exceptions in the logs. (b/135587258) ++ The following are the results from logcat with manual alaram testing On x20web site in my home directory - ~rtenneti/android/ logcat.out.1111.1610 logcat.out.1112.1603 ++ Verified there were no java exceptions. $ grep -n -i 'exception' ~rtenneti/android/logcat.out.1111.1610 | wc -l 0 ++ Verified Alarm was firing (results are in x20web site) $ grep -n -i 'alarm' ~rtenneti/android/logcat.out.1111.1610 (for an alarm that was set to 19:12:00 at 19:11:19. Results from Alarm firing). 6880:11-11 19:11:19.403 8813 8863 I AlarmClock: Registering instance: 1 6881:11-11 19:11:19.405 8813 8863 I AlarmClock: Setting high notification state to instance 1 6882:11-11 19:11:19.406 8813 8863 V AlarmClock: *** notifyChange() id: 1 url content://com.android.deskclock/instances/1 6883:11-11 19:11:19.408 8813 8863 V AlarmClock: Displaying high priority notification for alarm instance: 1 6884:11-11 19:11:19.414 8813 8863 I AlarmClock: Scheduling state change 5 to instance 1 at Mon 7:12 PM (1573517520000) 6885:11-11 19:11:19.419 8813 8863 I AlarmClock: Setting upcoming AlarmClockInfo for alarm: 1 6887:11-11 19:11:19.423 1329 1329 V SettingsProvider: Notifying for 0: content://settings/system/next_alarm_formatted .... 7143:11-11 19:12:00.031 1329 1329 V SettingsProvider: Notifying for 0: content://settings/system/next_alarm_formatted 7144:11-11 19:12:00.032 1329 1329 D ConditionProviders.SCP: onReceive android.app.action.NEXT_ALARM_CLOCK_CHANGED .... 7152:11-11 19:12:00.055 8813 8813 I AlarmClock: Setting fire state to instance 1 7153:11-11 19:12:00.105 8813 8813 V AlarmClock: *** notifyChange() id: 1 url content://com.android.deskclock/instances/1 7154:11-11 19:12:00.112 8813 8813 D Events : [Alarm] [Fire] 7155:11-11 19:12:00.113 8813 8813 I AlarmClock: Scheduling state change 6 to instance 1 at Mon 7:22 PM (1573518120000) 7156:11-11 19:12:00.118 8813 8813 I AlarmClock: Canceling upcoming AlarmClockInfo 7157:11-11 19:12:00.123 8813 8813 V AlarmClock: AlarmService.start with instance: 1 7158:11-11 19:12:00.124 8813 8813 V AlarmClock: Displaying alarm notification for alarm instance: 1 7159:11-11 19:12:00.130 8813 8813 V AlarmClock: Clearing notifications for alarm instance: 1 7161:11-11 19:12:00.145 8813 8813 V AlarmClock: AlarmKlaxon.start() ... Change-Id: I005530d5d82568e028acb4cbad1f3212fc9c61a2
2019-11-08Revert submissionRaman Tenneti
Reason for revert: https://b.corp.google.com/issues/144125913 - DeskClock exits when alarm goes off. Change-Id: I55b1a95632c52235429365ca64c36840b23bb005
2019-11-07AOSP/DeskClock - Updated to sdkVersion 29.Raman Tenneti
BUG: 133177396 BUG: 143990962 Test: manual - Tested the DeskClock UI manually and tested the alarm, stopwatch and timer. $ make -j 40 $ ls -l out/target/product/generic/system/product/app/DeskClock/DeskClock.apk -rw-r--r-- 1 rtenneti primarygroup 6432279 Nov 6 19:07 out/target/product/generic/system/product/app/DeskClock/DeskClock.apk $ adb install -r out/target/product/generic/system/product/app/DeskClock/DeskClock.apk + Verified by setting up the alaram and waiting for the alarm to go off. "Clock has stopped" wasn't displayed. Noted there were no exceptions in the logs. (b/135587258) Change-Id: Ic946cb58ddc8430c034b73854080c586a1939d4a
2018-04-03Convert DeskClock to androidx.Aurimas Liutikas
Test: compile and open Bug: 76692459 Change-Id: Ibf8e95a917fbe3e364340ed1c5fba6e66f2d8afd
2017-11-17Handle ACTION_DISMISS_TIMER intentChristine Franks
Bug: 38475809 Test: adb shell am start -a android.intent.action.DISMISS_TIMER Change-Id: Ifa0b3caa9b021334d573f8d312acbb4236273e4e
2016-12-05Remove DataModel.getSharedPreferences()James Lemieux
Bug: 33251787 All access to SharedPreferences now occurs privately within DataModel and UiDataModel. This ensures SharedPreferences are created precisely once and cached in member variables (in the delegate models behind DataModel). Tests can now be isolated from each other by rebuilding those delegate models. Change-Id: Ie7bf69bed13be1604e73dca6058877bc05e8afea
2016-12-05Refactor where SharedPreferences are builtJames Lemieux
Bug: 33251787 To enable easier testing, build and migrate SharedPreferences once during Application creation and only store references to it in member variables. Change-Id: I562d2cbddeeff165304fc8844d2af4b765fe4861
2016-12-01Fix janky RepeatDays animationChristine Franks
Bug: 33039716 Test: manual - no apparent jank (or strict mode violations) during repeatdays expansion/contraction, and systrace reports no dropped frames during the animation itself. Change-Id: I923781f44a5db50534640ae605705f7437c805f4
2016-11-19Timer sound setting now updates on locale change.Sean Stout
Bug: 32916213 Test: manual - change locales to confirm "Timer Sound" string changes Change-Id: Ib8b4b5af37aa22e6e3dd68b45564df2dc47f1d8e
2016-10-27Implementing fullscreen ringtone pickerJames Lemieux
Bug: 27856432 Ringtone picker now looks more like the rest of the app. Also allows the user to pick a file chosen from their file system using the built-in file browser. Change-Id: I8ce9dbc28e414d188f52b3885960a475a16061d8
2016-10-04Timer no longer has Pre-N and N+ notification builders.Sean Stout
Bug: 30793112 Test: manual - Confirm notifications post correctly on Pre-N and N Change-Id: I7921707a021e98396cd8b5e586d9b9aefecc212a
2016-09-07Add support to reset timer without deletingJustin Klaassen
am: 12540ba3d8 Change-Id: Id7ae52b46cd1377c703503c07a79ad694b78635d
2016-09-07Add support to reset timer without deletingJustin Klaassen
Bug: 30076796 Change-Id: Ibe2e3728cbff6455cf4b944ea12bd5ae58adfe0b
2016-08-04Controller, DataModel and UiDataModel allow context to be replacedJames Lemieux
Bug: 29538369 Adjusting the context within those classes connotes that their delegates should be rebuilt using the new context. Change-Id: If11e4f8a5e6c4fe870d9eb16c0e3b65ed0a32624
2016-06-24Tapping on a timer notification takes you to the correct timer.Sean Stout
Bug: 29584816 Before if there were both missed timers and running/paused timers, tapping on the running or paused timers would instead take you to the same timer that tapping the missed timer would take you. Now it will take you to the correct timer. Change-Id: I700b56022097f98f58304117f0cc7ad7b66a4e51
2016-06-14Stopwatches and timers continue to work after device reboot.Sean Stout
Bug: 8101723 Upon device shutdown and reboot, the stopwatch will resume state. If the stopwatch was running, it will continue to run as well as account for the time that the device was off. Additionally, all timers that are on the device will resume state. If the timer was running, it will continue to run on device reboot. If the timer was missed by less than 1 minute, the timer will still go off. If the timer was missed by more than 1 minute, the timer will go to a new "missed" state and give the user a notification that a timer has been missed. Change-Id: Ib7f199ef5be4714b831450933c574f39824d15dc Stopwatches and timers continue to work after device reboot. Bug: 8101723 Upon device shutdown and reboot, the stopwatch will resume state. If the stopwatch was running, it will continue to run as well as account for the time that the device was off. Additionally, all timers that are on the device will resume state. If the timer was running, it will continue to run on device reboot. If the timer was missed by less than 1 minute, the timer will still go off. If the timer was missed by more than 1 minute, the timer will go to a new "missed" state and give the user a notification that a timer has been missed. Change-Id: I831d7a5172a3cede595db1b62e503ecc8c4c55c2
2016-06-08Provide stable order for alarm notificationsJames Lemieux
Bug: 28904591 - alarms, timers and stopwatch each use unique notification group keys - Upcoming/Snoozed alarms are sorted chronologically followed by Missed alarms (also sorted chronologically) Change-Id: I1b46af22c3ddc691ecfd4545b54db5ff06c5983e
2016-05-27Show chronometer in expired timer notificationJames Lemieux
Bug: 28985277 The chronometer time is always displayed as the top line. The second line may now be any of: - a single timer label - "Time's up" if no label was given - "N timers expired" if multiple timers are currently expired. Change-Id: Ibe57b03b4b308d89f11ba0d9f175d16bee2480eb
2016-05-19Style the timer notification properly for NJames Lemieux
Bug: 28817514 Makes use of countdown Chronometer in N+. Change-Id: I0a9aa57c47ec7655d7a29b44dc473e516b44cb0f
2016-05-19Custom ringtone picker v2Justin Klaassen
am: b2e7e16232 * commit 'b2e7e162327b1992aa74721a8847c7f7a579e049': Custom ringtone picker v2 Change-Id: I9327bab257156ccfc80c7ca369c9536068076493
2016-05-18Custom ringtone picker v2Justin Klaassen
Bug: 28667387 - Request the READ_EXTERNAL_STORAGE permission if it isn't already granted when launching the ringtone picker. This allows the listing of external ringtones stored in the alarms/ folder. - Allow the volume rockers to control the alarm stream volume while the ringtone picker is showing. - Load the RingtoneManager's cursor off the main thread to prevent potential ANRs and jank. - Use Theme.AppCompat.Dialog to more closely match the styling of the platform version. - Disable the "OK" button if the selection is invalid. Change-Id: I1ec6b0b744a3a19b3f289e33c24db982543862bc
2016-02-16Refactoring SharedPreferences to common location.Justin Klaassen
Bug: 25860525 Change-Id: I0c55d34b17a2aa5fb94d9d562bebdcc2e44af4d0 (cherry picked from commit 942b3a3956221969c77f9abc447444505eea6929)
2016-01-21Add timer vibrate option.Annie Chin
Bug: 23980150 User can en/disable vibration for all timers from the Settings page. Vibration is off by default. Change-Id: I0ae81583c73e54f44fca6262359ed2d46aaba498
2016-01-15Fix alarm not firing in memory-pressure situationsJames Lemieux
am: b76aa50f9e * commit 'b76aa50f9e13e71e81b9d02cc3ebebaa73188d3e': Fix alarm not firing in memory-pressure situations
2016-01-14Fix alarm not firing in memory-pressure situationsJames Lemieux
Bug: 25846551 The original form of the code that fires an alarm is: AlarmManager -> BroadcastReceiver -> Service. The new form of the code that fires an alarm is: AlarmManager -> Service. Evidence exists that the system lowmemorykiller may elect to kill the clock app after BroadcastReceiver.onReceive(...) completes but before Service.onStartCommand(...) begins. When this occurs, the results are disastrous as the clock fails to fire at the appropriate time. To remove this possibility, all alarm state changes are delivered to the Service. The methods that manipulate database state within BroadcastReceiver have been made public and static and are called directly from the Service to perform the same work as before. If the alarm state transition is to the FIRING state, the AlarmService also performs the work of posting the firing notification in the foreground. All of this occurs during the handling of a single Intent on the same thread within the service which should no longer provide lowmemorykiller with any opportunities to prevent the firing of an alarm by killing the clock app. Change-Id: I3629a5b725a758f680f41611939a5bbeec23238a
2016-01-13Promote TimerService to the foreground while expired timers existJames Lemieux
am: 0dd0cac610 * commit '0dd0cac610cd59762c8b604da6c437b18a29246b': Promote TimerService to the foreground while expired timers exist
2016-01-11Promote TimerService to the foreground while expired timers existJames Lemieux
Bug: 26471891 This makes the clock app unlikely to be killed in memory pressure situations while expired timers are ringing. Change-Id: I89f141a835e3de67a58671d6c5b381de52be5c18
2016-01-06Schedule alarm state callbacks to occur even when device is idleJames Lemieux
Bug: 26200446 Theoretically, the callback delivered by AlarmClock should ensure the device is awake for delivery of the second intent that changes the alarm state to FIRED. This CL removes that reliance and schedules the AlarmManager callback in a manner that will wake the device if it is dozing at the fire time. Change-Id: Idaf41309850bd4d072b1c84c28b038ee0197c145
2015-11-30Refactor DataModel.resetOrDeleteTimer(...)James Lemieux
By adding a return value from this method, callers that want to know whether the timer was reset or deleted can examine the return value rather that duplicating the logic found within DataModel. Change-Id: Id63ea1f56c35b21d5b3d8cd7188d28b87926bb45
2015-11-13Merge "Simplify HandleDeskClockApiCalls, TimerService and StopwatchService" ↵James Lemieux
into ub-deskclock-dazzle am: 8da3608e79 * commit '8da3608e7942518a3c33dc6be26160c02295259c': Simplify HandleDeskClockApiCalls, TimerService and StopwatchService
2015-11-12Simplify HandleDeskClockApiCalls, TimerService and StopwatchServiceJames Lemieux
HandleDeskClockApiCalls used to pass through all timer and stopwatch mutations to the corresponding Service to complete. This complicated the logging of the corresponding event unnecessarily. After this change: - StopwatchService is only invoked from stopwatch notifications and may now assume the event label - TimerService is only invoked from timer notifications and AlarmManager and may now assume the event label - HandleDeskClockApiCalls.EXTRA_FROM_NOTIFICATION has been replaced with HandleDeskClockApiCalls.EXTRA_EVENT_LABEL which explicitly identifies the label of the event Change-Id: Ic9796c43e826f82138ee431d3abb02524c0146ba
2015-11-11resolve merge conflicts of bca2b6924d to ub-deskclock-escargatoire.James Lemieux
Change-Id: I14346d1532cb65da0c4d35cd9ddde3edcc6570e1
2015-11-10Refactor Timers to use new unified DataModelJames Lemieux
Bug: 24816218 Bug: 25494722 This refactoring introduces a Timer domain object. Instances of these domain objects are fetched via a DataModel class that is the single point of reference for all timer data. This allows the data to be shared across the entire application. In particular, the timer notifications, TimerFragment and ExpiredTimersActivity all draw upon the same model to determine what the state of the timers are. IMPORTANT: The public intent com.android.deskclock.action.STOP_TIMER has been renamed to com.android.deskclock.action.PAUSE_TIMER to be more accurate. Change-Id: Ib904e80a25c6de1861de2b395bec27db16ff0e66
2015-11-02Implement custom ringtone picker for timers and alarms.Dylan Phan
Bug: 23996371 Change-Id: I6515da60f2811d7fd03b8a41d9bd724dc959fd0f
2015-09-01Simplify code that adds None as a valid timer ringtoneJames Lemieux
- None option is added to picker by default, remove code that manually added it - Replace NO_RINGTONE_URI constant in TimerRingtonePreference with test method: DataModel.isSilentTimerRingtoneUri(uri) Bug: 23499698 Change-Id: Id45a24bee607edd8295c2a31785e55d67b44e8b0
2015-08-25Allow "Silent" to be set as a Timer ringtone.Annie Chin
Bug: 23499698 Add "None" option to Timer ringtone selection. Summary will show up as "Silent." This is consistent with Alarm ringtone selection. Change-Id: I4dc87f3258a3223a2bcddcf29076944cd9637df4
2015-08-21Present Clock's timer beep as the default ringtoneJames Lemieux
A "settings" package was introduced as a byproduct of this CL. When choosing the preferred ringtone for timers, the default selection should play timer_expired.ogg which ships with the application. This is the only sound played on all prior version of the application. Known Issue: the dialog will label the default as "Default alarm sound". This will be fixed in a later CL. Change-Id: I4e9c6663c597038ec273b699cdda3a036b376350
2015-08-18remove requests for READ_EXTERNAL_STORAGE permissionJames Lemieux
Very late in the M release, a change was made to no longer require the READ_EXTERNAL_STORAGE permission to view the titles of external ring tones. Consequently, we no longer have a reason to acquire this permission in the application. As well, the storage of the ringtone to play for expired timers has been moved from Utils into the DataModel. Bug: 22919062 Change-Id: I9209cd3e6efaee1063c1c04bca15b0ea61ffc4d8