From 67430f3d25a103cf87ba72d4034e703107b715ee Mon Sep 17 00:00:00 2001 From: Patrick Scott Date: Wed, 19 Aug 2009 16:19:15 -0400 Subject: [PATCH] Fix some copy-paste errors and acquire locks before launching the Activity. Acquiring the locks before launching the Activity prevents some strange pausing behavior in ActivityManager. If the screen is off, the ActivityManager attempts to pause the Activity before resuming it. --- src/com/android/alarmclock/AlarmAlert.java | 7 +++---- src/com/android/alarmclock/AlarmReceiver.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/com/android/alarmclock/AlarmAlert.java b/src/com/android/alarmclock/AlarmAlert.java index 038521b..e78112d 100644 --- a/src/com/android/alarmclock/AlarmAlert.java +++ b/src/com/android/alarmclock/AlarmAlert.java @@ -218,16 +218,15 @@ public class AlarmAlert extends Activity { @Override protected void onStart() { - super.onResume(); + super.onStart(); if (Log.LOGV) Log.v("AlarmAlert.onStart()"); - // Acquire a separate lock for the screen to stay on. This is necessary - // to avoid flashing the keyguard when the screen is locked. + // Acquire a separate lock for the screen to stay on. AlarmAlertWakeLock.acquireScreenWakeLock(this); } @Override protected void onStop() { - super.onPause(); + super.onStop(); if (Log.LOGV) Log.v("AlarmAlert.onStop()"); AlarmAlertWakeLock.releaseScreenLock(); } diff --git a/src/com/android/alarmclock/AlarmReceiver.java b/src/com/android/alarmclock/AlarmReceiver.java index 7844283..7fc5b35 100644 --- a/src/com/android/alarmclock/AlarmReceiver.java +++ b/src/com/android/alarmclock/AlarmReceiver.java @@ -88,6 +88,14 @@ public class AlarmReceiver extends BroadcastReceiver { return; } + // Maintain a cpu wake lock until the AlarmAlert and AlarmKlaxon can + // pick it up. Also acquire the screen lock so the screen is on before + // starting the AlarmAlert activity. Do this before launching the + // AlarmAlert so that the ActivityManager does not try to pause the + // activity due to the screen being off. + AlarmAlertWakeLock.acquireCpuWakeLock(context); + AlarmAlertWakeLock.acquireScreenWakeLock(context); + /* Close dialogs and window shade */ Intent closeDialogs = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.sendBroadcast(closeDialogs); @@ -154,10 +162,6 @@ public class AlarmReceiver extends BroadcastReceiver { // correct notification. NotificationManager nm = getNotificationManager(context); nm.notify(alarm.id, n); - - // Maintain a cpu wake lock until the AlarmAlert and AlarmKlaxon can - // pick it up. - AlarmAlertWakeLock.acquireCpuWakeLock(context); } private NotificationManager getNotificationManager(Context context) { -- 2.11.0