am a727db86: Update LockPatternUtils to new alarm API

* commit 'a727db864c3e555c073d908a85d4c6ebc6eb2303':
  Update LockPatternUtils to new alarm API
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index cc481e1..d60f787 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -18,6 +18,8 @@
 
 import android.Manifest;
 import android.app.ActivityManagerNative;
+import android.app.AlarmClockInfo;
+import android.app.AlarmManager;
 import android.app.admin.DevicePolicyManager;
 import android.app.trust.TrustManager;
 import android.appwidget.AppWidgetManager;
@@ -1170,13 +1172,9 @@
      * @return A formatted string of the next alarm (for showing on the lock screen),
      *   or null if there is no next alarm.
      */
-    public String getNextAlarm() {
-        String nextAlarm = Settings.System.getStringForUser(mContentResolver,
-                Settings.System.NEXT_ALARM_FORMATTED, UserHandle.USER_CURRENT);
-        if (nextAlarm == null || TextUtils.isEmpty(nextAlarm)) {
-            return null;
-        }
-        return nextAlarm;
+    public AlarmClockInfo getNextAlarm() {
+        AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+        return alarmManager.getNextAlarmClock(UserHandle.USER_CURRENT);
     }
 
     private boolean getBoolean(String secureSettingKey, boolean defaultValue, int userId) {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
index 150ab74..02a441b 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
@@ -16,9 +16,11 @@
 
 package com.android.keyguard;
 
+import android.app.AlarmClockInfo;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.res.Resources;
+import android.provider.AlarmClock;
 import android.text.TextUtils;
 import android.text.format.DateFormat;
 import android.util.AttributeSet;
@@ -121,15 +123,24 @@
 
     void refreshAlarmStatus() {
         // Update Alarm status
-        String nextAlarm = mLockPatternUtils.getNextAlarm();
-        if (!TextUtils.isEmpty(nextAlarm)) {
-            mAlarmStatusView.setText(nextAlarm);
+        AlarmClockInfo nextAlarm = mLockPatternUtils.getNextAlarm();
+        if (nextAlarm != null) {
+            mAlarmStatusView.setText(formatNextAlarm(nextAlarm));
             mAlarmStatusView.setVisibility(View.VISIBLE);
         } else {
             mAlarmStatusView.setVisibility(View.GONE);
         }
     }
 
+    String formatNextAlarm(AlarmClockInfo info) {
+        if (info == null) {
+            return "";
+        }
+        String skeleton = DateFormat.is24HourFormat(mContext) ? "EHm" : "Ehma";
+        String pattern = DateFormat.getBestDateTimePattern(Locale.getDefault(), skeleton);
+        return DateFormat.format(pattern, info.getTriggerTime()).toString();
+    }
+
     private void updateOwnerInfo() {
         if (mOwnerInfo == null) return;
         String ownerInfo = getOwnerInfo();