OSDN Git Service

auto import from //branches/cupcake_rel/...@140373
[android-x86/packages-apps-AlarmClock.git] / src / com / android / alarmclock / AlarmAlert.java
index 2464c96..6a9a718 100644 (file)
@@ -48,7 +48,7 @@ public class AlarmAlert extends Activity {
     private static final int KILLED = 3;
 
     private KeyguardManager mKeyguardManager;
-    private KeyguardManager.KeyguardLock mKeyguardLock = null;
+    private KeyguardManager.KeyguardLock mKeyguardLock;
     private Button mSnoozeButton;
     private int mState = UNKNOWN;
 
@@ -60,12 +60,15 @@ public class AlarmAlert extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        // Maintain a lock during the playback of the alarm. This lock may have
+        // already been acquired in AlarmReceiver. If the process was killed,
+        // the global wake lock is gone. Acquire again just to be sure.
+        AlarmAlertWakeLock.acquire(this);
+
         /* FIXME Intentionally verbose: always log this until we've
            fully debugged the app failing to start up */
         Log.v("AlarmAlert.onCreate()");
 
-        mKlaxon = AlarmKlaxon.getInstance();
-
         // Popup alert over black screen
         WindowManager.LayoutParams lp = getWindow().getAttributes();
         lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
@@ -85,6 +88,9 @@ public class AlarmAlert extends Activity {
         Intent i = getIntent();
         mAlarmId = i.getIntExtra(Alarms.ID, -1);
 
+        mKlaxon = new AlarmKlaxon();
+        mKlaxon.postPlay(this, mAlarmId);
+
         /* Set the title from the passed in label */
         setTitleFromIntent(i);
 
@@ -232,6 +238,9 @@ public class AlarmAlert extends Activity {
         disableKeyguard();
 
         mAlarmId = intent.getIntExtra(Alarms.ID, -1);
+        // Play the new alarm sound.
+        mKlaxon.postPlay(this, mAlarmId);
+
         setTitleFromIntent(intent);
 
         /* unset silenced message */