Check for -1 id before modifying alarms.
Bug: 2898729
Change-Id: I9f70ee40fbcebeae2028c19a3b355e5d1cc433d4
diff --git a/src/com/android/deskclock/AlarmClock.java b/src/com/android/deskclock/AlarmClock.java
index 5ade787..5ecf5c4 100644
--- a/src/com/android/deskclock/AlarmClock.java
+++ b/src/com/android/deskclock/AlarmClock.java
@@ -154,6 +154,10 @@
final AdapterContextMenuInfo info =
(AdapterContextMenuInfo) item.getMenuInfo();
final int id = (int) info.id;
+ // Error check just in case.
+ if (id == -1) {
+ return super.onContextItemSelected(item);
+ }
switch (item.getItemId()) {
case R.id.delete_alarm:
// Confirm that the alarm will be deleted.
diff --git a/src/com/android/deskclock/Alarms.java b/src/com/android/deskclock/Alarms.java
index 4c90753..e0e17d0 100644
--- a/src/com/android/deskclock/Alarms.java
+++ b/src/com/android/deskclock/Alarms.java
@@ -115,8 +115,8 @@
* Removes an existing Alarm. If this alarm is snoozing, disables
* snooze. Sets next alert.
*/
- public static void deleteAlarm(
- Context context, int alarmId) {
+ public static void deleteAlarm(Context context, int alarmId) {
+ if (alarmId == -1) return;
ContentResolver contentResolver = context.getContentResolver();
/* If alarm is snoozing, lose it */