summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMao Jinlong <c_jmao@codeaurora.org>2015-10-30 15:22:17 +0800
committerSteve Kondik <steve@cyngn.com>2015-11-30 19:31:23 -0800
commit5b04546a88e50094793ffa3a059840249d07ea7e (patch)
tree4b38d49bb72fb94afecccaeed9ab5cf49cae962a
parent54face314b90390826abbb75e1a0c55c30239a4c (diff)
downloadframeworks_base-5b04546a88e50094793ffa3a059840249d07ea7e.zip
frameworks_base-5b04546a88e50094793ffa3a059840249d07ea7e.tar.gz
frameworks_base-5b04546a88e50094793ffa3a059840249d07ea7e.tar.bz2
Alarm: add support for power off alarm
When phone is in Power-Off Alarm boot mode: 1. At the correct booting place to trigger the Power-Off Alarm UI 2. At the Power-Off Alarm alert UI, don't dispatch related physical key, such as home, search, etc Change-Id: I60ede3bde21d26eafb0610946f6d8bf884c85ddb
-rw-r--r--core/java/android/app/AlarmManager.java3
-rw-r--r--core/java/android/provider/Settings.java11
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java20
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java13
-rw-r--r--services/core/jni/com_android_server_AlarmManagerService.cpp1
5 files changed, 47 insertions, 1 deletions
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index af7a912..b0afe7c 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -104,8 +104,9 @@ public class AlarmManager {
* Alarm time in {@link System#currentTimeMillis System.currentTimeMillis()}
* (wall clock time in UTC), which will wake up the device when
* it goes off. And it will power on the devices when it shuts down.
+ * Set as 5 to make it be compatible with android_alarm_type.
*/
- public static final int RTC_POWEROFF_WAKEUP = 4;
+ public static final int RTC_POWEROFF_WAKEUP = 5;
/**
* Broadcast Action: Sent after the value returned by
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index e677b3e..8182855 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -2865,6 +2865,15 @@ public final class Settings {
private static final Validator TEXT_AUTO_CAPS_VALIDATOR = sBooleanValidator;
/**
+ * Setting to show if system is in power off alarm mode. 1 = true, 0 = false
+ * @hide
+ */
+ public static final String POWER_OFF_ALARM_MODE = "power_off_alarm_mode";
+
+ /** Validator for POWER_OFF_ALARM_MODE */
+ private static final Validator POWER_OFF_ALARM_MODE_VALIDATOR = sBooleanValidator;
+
+ /**
* Setting to enable Auto Punctuate in text editors. 1 = On, 0 = Off. This
* feature converts two spaces to a "." and space.
*/
@@ -3579,6 +3588,7 @@ public final class Settings {
PUBLIC_SETTINGS.add(SOUND_EFFECTS_ENABLED);
PUBLIC_SETTINGS.add(HAPTIC_FEEDBACK_ENABLED);
PUBLIC_SETTINGS.add(SHOW_WEB_SUGGESTIONS);
+ PUBLIC_SETTINGS.add(POWER_OFF_ALARM_MODE);
}
/**
@@ -3704,6 +3714,7 @@ public final class Settings {
VALIDATORS.put(WIFI_STATIC_NETMASK, WIFI_STATIC_NETMASK_VALIDATOR);
VALIDATORS.put(WIFI_STATIC_DNS1, WIFI_STATIC_DNS1_VALIDATOR);
VALIDATORS.put(WIFI_STATIC_DNS2, WIFI_STATIC_DNS2_VALIDATOR);
+ VALIDATORS.put(POWER_OFF_ALARM_MODE, POWER_OFF_ALARM_MODE_VALIDATOR);
}
/**
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 8872781..1bf7931 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -300,6 +300,11 @@ public final class ActivityManagerService extends ActivityManagerNative
private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY;
private static final String TAG_VISIBLE_BEHIND = TAG + POSTFIX_VISIBLE_BEHIND;
+ private static final String ACTION_POWER_OFF_ALARM =
+ "org.codeaurora.alarm.action.POWER_OFF_ALARM";
+
+ private static final String POWER_OFF_ALARM = "powerOffAlarm";
+
/** Control over CPU and battery monitoring */
// write battery stats every 30 minutes.
static final long BATTERY_STATS_TIME = 30 * 60 * 1000;
@@ -3608,6 +3613,15 @@ public final class ActivityManagerService extends ActivityManagerNative
return true;
}
+ /**
+ * If system is power off alarm boot mode, we need to start alarm UI.
+ */
+ void startAlarmActivityLocked() {
+ Intent intent = new Intent(ACTION_POWER_OFF_ALARM);
+ intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
+ mContext.startActivityAsUser(intent, UserHandle.CURRENT);
+ }
+
private ActivityInfo resolveActivityInfo(Intent intent, int flags, int userId) {
ActivityInfo ai = null;
ComponentName comp = intent.getComponent();
@@ -12062,6 +12076,12 @@ public final class ActivityManagerService extends ActivityManagerNative
mBooting = true;
startHomeActivityLocked(mCurrentUserId, "systemReady");
+ // start the power off alarm by boot mode
+ boolean isAlarmBoot = SystemProperties.getBoolean("ro.alarm_boot", false);
+ if (isAlarmBoot) {
+ startAlarmActivityLocked();
+ }
+
try {
if (AppGlobals.getPackageManager().hasSystemUidErrors()) {
Slog.e(TAG, "UIDs on the system are inconsistent, you need to wipe your"
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 1cb337b..e86b5a5 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -3137,6 +3137,19 @@ public class PhoneWindowManager implements WindowManagerPolicy {
+ " canceled=" + canceled);
}
+ // If the boot mode is power off alarm, we should not dispatch the several physical keys
+ // in power off alarm UI to avoid pausing power off alarm UI.
+ int isPowerOffAlarmMode = Settings.System.getInt(mContext.getContentResolver(),
+ Settings.System.POWER_OFF_ALARM_MODE, 0);
+ if (DEBUG_INPUT) { Log.d(TAG, "intercept Dispatching isPowerOffAlarmMode = " +
+ isPowerOffAlarmMode); }
+
+ if (isPowerOffAlarmMode == 1 && (keyCode == KeyEvent.KEYCODE_HOME
+ || keyCode == KeyEvent.KEYCODE_SEARCH
+ || keyCode == KeyEvent.KEYCODE_MENU)) {
+ return -1; // ignore the physical key here
+ }
+
// If we think we might have a volume down & power key chord on the way
// but we're not sure, then tell the dispatcher to wait a little while and
// try again later before dispatching.
diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp
index 4025988..5d1e7af 100644
--- a/services/core/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/core/jni/com_android_server_AlarmManagerService.cpp
@@ -55,6 +55,7 @@ static const clockid_t android_alarm_to_clockid[N_ANDROID_TIMERFDS] = {
CLOCK_BOOTTIME_ALARM,
CLOCK_BOOTTIME,
CLOCK_MONOTONIC,
+ CLOCK_POWEROFF_ALARM,
CLOCK_REALTIME,
};
/* to match the legacy alarm driver implementation, we need an extra