* limitations under the License.
*/
- package com.android.alarmclock;
+ package com.android.deskclock;
-import android.app.Activity;
-import android.app.Notification;
-import android.app.NotificationManager;
-import android.app.PendingIntent;
-import android.content.Context;
+import android.app.KeyguardManager;
import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
-import android.content.SharedPreferences;
-import android.content.res.Configuration;
import android.os.Bundle;
-import android.preference.PreferenceManager;
-import android.view.KeyEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.LayoutInflater;
-import android.view.Window;
+import android.os.Handler;
+import android.os.Message;
import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.Toast;
-import android.widget.TextView;
-
-import java.util.Calendar;
/**
- * Alarm Clock alarm alert: pops visible indicator and plays alarm
- * tone
+ * Full screen alarm alert: pops visible indicator and plays alarm tone. This
+ * activity shows the alert as a dialog.
*/
-public class AlarmAlert extends Activity {
-
- // These defaults must match the values in res/xml/settings.xml
- private static final String DEFAULT_SNOOZE = "10";
- private static final String DEFAULT_VOLUME_BEHAVIOR = "2";
+public class AlarmAlert extends AlarmAlertFullScreen {
- private Alarm mAlarm;
- private int mVolumeBehavior;
+ // If we try to check the keyguard more than 5 times, just launch the full
+ // screen activity.
+ private int mKeyguardRetryCount;
+ private final int MAX_KEYGUARD_CHECKS = 5;
- // Receives the ALARM_KILLED action from the AlarmKlaxon.
- private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ private final Handler mHandler = new Handler() {
@Override
- public void onReceive(Context context, Intent intent) {
- Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
- if (mAlarm.id == alarm.id) {
- dismiss(true);
- }
+ public void handleMessage(Message msg) {
+ handleScreenOff((KeyguardManager) msg.obj);
}
};
* limitations under the License.
*/
- package com.android.alarmclock;
+ package com.android.deskclock;
+import android.app.Activity;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.LayoutInflater;
+import android.view.Window;
import android.view.WindowManager;
+import android.widget.Button;
+import android.widget.Toast;
+import android.widget.TextView;
+
+import java.util.Calendar;
/**
- * Full screen alarm alert: pops visible indicator and plays alarm tone. This
- * activity displays the alert in full screen in order to be secure. The
- * background is the current wallpaper.
+ * Alarm Clock alarm alert: pops visible indicator and plays alarm
+ * tone. This activity is the full screen version which shows over the lock
+ * screen with the wallpaper as the background.
*/
-public class AlarmAlertFullScreen extends AlarmAlert {
+public class AlarmAlertFullScreen extends Activity {
+
+ // These defaults must match the values in res/xml/settings.xml
+ private static final String DEFAULT_SNOOZE = "10";
+ private static final String DEFAULT_VOLUME_BEHAVIOR = "2";
+ protected static final String SCREEN_OFF = "screen_off";
+
+ protected Alarm mAlarm;
+ private int mVolumeBehavior;
+
+ // Receives the ALARM_KILLED action from the AlarmKlaxon.
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Alarm alarm = intent.getParcelableExtra(Alarms.ALARM_INTENT_EXTRA);
+ if (alarm != null && mAlarm.id == alarm.id) {
+ dismiss(true);
+ }
+ }
+ };
+
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);