summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-08-20 19:43:47 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-20 19:43:47 -0700
commit6fee1cba4f6ed7ab28f8d0e8dad823a3d900cf9a (patch)
tree8056269b755f5e65a4fad0456595df3b1b4d660e
parentd87fd2e136b69c0d3f0a5c9d7c923e604d0c576c (diff)
parent4b72463d7cb807912ca359f3b5a160f59d985c1d (diff)
downloadframeworks_base-6fee1cba4f6ed7ab28f8d0e8dad823a3d900cf9a.zip
frameworks_base-6fee1cba4f6ed7ab28f8d0e8dad823a3d900cf9a.tar.gz
frameworks_base-6fee1cba4f6ed7ab28f8d0e8dad823a3d900cf9a.tar.bz2
am 4b72463d: Merge "Add factory test feature to shut off on long press power." into jb-mr1-dev
* commit '4b72463d7cb807912ca359f3b5a160f59d985c1d': Add factory test feature to shut off on long press power.
-rw-r--r--core/java/android/os/FactoryTest.java35
-rw-r--r--core/java/android/view/WindowManagerPolicy.java4
-rw-r--r--policy/src/com/android/internal/policy/impl/GlobalActions.java4
-rwxr-xr-xpolicy/src/com/android/internal/policy/impl/PhoneWindowManager.java14
-rwxr-xr-xservices/java/com/android/server/wm/WindowManagerService.java8
5 files changed, 54 insertions, 11 deletions
diff --git a/core/java/android/os/FactoryTest.java b/core/java/android/os/FactoryTest.java
new file mode 100644
index 0000000..ec99697
--- /dev/null
+++ b/core/java/android/os/FactoryTest.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os;
+
+/**
+ * Provides support for in-place factory test functions.
+ *
+ * This class provides a few properties that alter the normal operation of the system
+ * during factory testing.
+ *
+ * {@hide}
+ */
+public final class FactoryTest {
+ /**
+ * When true, long-press on power should immediately cause the device to
+ * shut down, without prompting the user.
+ */
+ public static boolean isLongPressOnPowerOffEnabled() {
+ return SystemProperties.getInt("factory.long_press_power_off", 0) != 0;
+ }
+}
diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java
index c0a4a63..7173d1d 100644
--- a/core/java/android/view/WindowManagerPolicy.java
+++ b/core/java/android/view/WindowManagerPolicy.java
@@ -390,8 +390,8 @@ public interface WindowManagerPolicy {
*/
public void switchKeyboardLayout(int deviceId, int direction);
- public void shutdown();
- public void rebootSafeMode();
+ public void shutdown(boolean confirm);
+ public void rebootSafeMode(boolean confirm);
}
/**
diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java
index fe23bff..8d19f34 100644
--- a/policy/src/com/android/internal/policy/impl/GlobalActions.java
+++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java
@@ -209,11 +209,11 @@ class GlobalActions implements DialogInterface.OnDismissListener, DialogInterfac
public void onPress() {
// shutdown by making sure radio and power are handled accordingly.
- mWindowManagerFuncs.shutdown();
+ mWindowManagerFuncs.shutdown(true);
}
public boolean onLongPress() {
- mWindowManagerFuncs.rebootSafeMode();
+ mWindowManagerFuncs.rebootSafeMode(true);
return true;
}
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
index 95a202c..209ad38 100755
--- a/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
@@ -42,6 +42,7 @@ import android.media.AudioManager;
import android.media.IAudioService;
import android.os.BatteryManager;
import android.os.Bundle;
+import android.os.FactoryTest;
import android.os.Handler;
import android.os.IBinder;
import android.os.IRemoteCallback;
@@ -172,6 +173,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
static final int LONG_PRESS_POWER_NOTHING = 0;
static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1;
static final int LONG_PRESS_POWER_SHUT_OFF = 2;
+ static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3;
// These need to match the documentation/constant in
// core/res/res/values/config.xml
@@ -716,8 +718,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
public void run() {
// The context isn't read
if (mLongPressOnPowerBehavior < 0) {
- mLongPressOnPowerBehavior = mContext.getResources().getInteger(
- com.android.internal.R.integer.config_longPressOnPowerBehavior);
+ if (FactoryTest.isLongPressOnPowerOffEnabled()) {
+ mLongPressOnPowerBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
+ } else {
+ mLongPressOnPowerBehavior = mContext.getResources().getInteger(
+ com.android.internal.R.integer.config_longPressOnPowerBehavior);
+ }
}
switch (mLongPressOnPowerBehavior) {
case LONG_PRESS_POWER_NOTHING:
@@ -729,10 +735,12 @@ public class PhoneWindowManager implements WindowManagerPolicy {
showGlobalActionsDialog();
break;
case LONG_PRESS_POWER_SHUT_OFF:
+ case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
mPowerKeyHandled = true;
performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
- mWindowManagerFuncs.shutdown();
+ mWindowManagerFuncs.shutdown(
+ mLongPressOnPowerBehavior == LONG_PRESS_POWER_SHUT_OFF);
break;
}
}
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index b14955d..98adf38 100755
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5257,14 +5257,14 @@ public class WindowManagerService extends IWindowManager.Stub
// Called by window manager policy. Not exposed externally.
@Override
- public void shutdown() {
- ShutdownThread.shutdown(mContext, true);
+ public void shutdown(boolean confirm) {
+ ShutdownThread.shutdown(mContext, confirm);
}
// Called by window manager policy. Not exposed externally.
@Override
- public void rebootSafeMode() {
- ShutdownThread.rebootSafeMode(mContext, true);
+ public void rebootSafeMode(boolean confirm) {
+ ShutdownThread.rebootSafeMode(mContext, confirm);
}
public void setInputFilter(IInputFilter filter) {