Merge "Add factory test feature to shut off on long press power." into jb-mr1-dev
This commit is contained in:
35
core/java/android/os/FactoryTest.java
Normal file
35
core/java/android/os/FactoryTest.java
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user