Loading core/java/com/android/internal/app/ShutdownThread.java +35 −3 Original line number Diff line number Diff line Loading @@ -18,15 +18,17 @@ package com.android.internal.app; import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.Dialog; import android.app.IActivityManager; import android.app.ProgressDialog; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetooth; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Power; import android.os.PowerManager; Loading Loading @@ -91,13 +93,20 @@ public final class ShutdownThread extends Thread { } } Log.d(TAG, "Notifying thread to start radio shutdown"); final int longPressBehavior = context.getResources().getInteger( com.android.internal.R.integer.config_longPressOnPowerBehavior); final int resourceId = longPressBehavior == 2 ? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm; Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior); if (confirm) { final CloseDialogReceiver closer = new CloseDialogReceiver(context); final AlertDialog dialog = new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(com.android.internal.R.string.power_off) .setMessage(com.android.internal.R.string.shutdown_confirm) .setMessage(resourceId) .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { beginShutdownSequence(context); Loading @@ -105,6 +114,8 @@ public final class ShutdownThread extends Thread { }) .setNegativeButton(com.android.internal.R.string.no, null) .create(); closer.dialog = dialog; dialog.setOnDismissListener(closer); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); if (!context.getResources().getBoolean( com.android.internal.R.bool.config_sf_slowBlur)) { Loading @@ -116,6 +127,27 @@ public final class ShutdownThread extends Thread { } } private static class CloseDialogReceiver extends BroadcastReceiver implements DialogInterface.OnDismissListener { private Context mContext; public Dialog dialog; CloseDialogReceiver(Context context) { mContext = context; IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { dialog.cancel(); } public void onDismiss(DialogInterface unused) { mContext.unregisterReceiver(this); } } /** * Request a clean shutdown, waiting for subsystems to clean up their * state etc. Must be called from a Looper thread in which its UI Loading core/res/res/values-xlarge/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.tablet.TabletStatusBarService</string> <bool name="config_statusBarCanHide">false</bool> <!-- see comment in values/config.xml --> <integer name="config_longPressOnPowerBehavior">2</integer> <!-- Show sliding tab before lockscreen --> <bool name="config_enableSlidingTabFirst">false</bool> <!-- Enable lockscreen rotation --> Loading core/res/res/values/config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,13 @@ closed. The default is 0. --> <integer name="config_lidNavigationAccessibility">0</integer> <!-- Control the behavior when the user long presses the power button. 0 - Nothing 1 - Global actions menu 2 - Power off (with confirmation) --> <integer name="config_longPressOnPowerBehavior">1</integer> <!-- Indicate whether the SD card is accessible without removing the battery. --> <bool name="config_batterySdCardAccessibility">false</bool> Loading core/res/res/values/strings.xml +8 −1 Original line number Diff line number Diff line Loading @@ -280,9 +280,16 @@ <!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. --> <string name="shutdown_progress">Shutting down\u2026</string> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, there will be a confirmation dialog. This is the message. --> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, there will be a confirmation dialog. This is the message. --> <string name="shutdown_confirm">Your phone will shut down.</string> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, it asks the user if they'd like to shut down. This is the message. This is used instead of shutdown_confirm when the system is configured to use long press to go directly to the power off dialog instead of the global actions menu. --> <string name="shutdown_confirm_question">Would you like to shut down?</string> <!-- Recent Tasks dialog: title TODO: this should move to SystemUI.apk, but the code for the old recent dialog is still in the framework Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +27 −4 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.os.Vibrator; import android.provider.Settings; import com.android.internal.R; import com.android.internal.app.ShutdownThread; import com.android.internal.policy.PolicyManager; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.ITelephony; Loading Loading @@ -129,6 +130,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; 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; // wallpaper is at the bottom, though the window manager may move it. static final int WALLPAPER_LAYER = 2; static final int APPLICATION_LAYER = 2; Loading Loading @@ -224,6 +229,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mDeskDockEnablesAccelerometer; int mLidKeyboardAccessibility; int mLidNavigationAccessibility; int mLongPressOnPowerBehavior = -1; boolean mScreenOn = false; boolean mOrientationSensorEnabled = false; int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -467,10 +473,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { Runnable mPowerLongPress = new Runnable() { public void run() { // The context isn't read if (mLongPressOnPowerBehavior < 0) { mLongPressOnPowerBehavior = mContext.getResources().getInteger( com.android.internal.R.integer.config_longPressOnPowerBehavior); } switch (mLongPressOnPowerBehavior) { case LONG_PRESS_POWER_NOTHING: break; case LONG_PRESS_POWER_GLOBAL_ACTIONS: mShouldTurnOffOnKeyUp = false; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); showGlobalActionsDialog(); break; case LONG_PRESS_POWER_SHUT_OFF: mShouldTurnOffOnKeyUp = false; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); ShutdownThread.shutdown(mContext, true); break; } } }; Loading Loading
core/java/com/android/internal/app/ShutdownThread.java +35 −3 Original line number Diff line number Diff line Loading @@ -18,15 +18,17 @@ package com.android.internal.app; import android.app.ActivityManagerNative; import android.app.AlertDialog; import android.app.Dialog; import android.app.IActivityManager; import android.app.ProgressDialog; import android.app.AlertDialog; import android.bluetooth.BluetoothAdapter; import android.bluetooth.IBluetooth; import android.content.BroadcastReceiver; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.IntentFilter; import android.os.Handler; import android.os.Power; import android.os.PowerManager; Loading Loading @@ -91,13 +93,20 @@ public final class ShutdownThread extends Thread { } } Log.d(TAG, "Notifying thread to start radio shutdown"); final int longPressBehavior = context.getResources().getInteger( com.android.internal.R.integer.config_longPressOnPowerBehavior); final int resourceId = longPressBehavior == 2 ? com.android.internal.R.string.shutdown_confirm_question : com.android.internal.R.string.shutdown_confirm; Log.d(TAG, "Notifying thread to start shutdown longPressBehavior=" + longPressBehavior); if (confirm) { final CloseDialogReceiver closer = new CloseDialogReceiver(context); final AlertDialog dialog = new AlertDialog.Builder(context) .setIcon(android.R.drawable.ic_dialog_alert) .setTitle(com.android.internal.R.string.power_off) .setMessage(com.android.internal.R.string.shutdown_confirm) .setMessage(resourceId) .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { beginShutdownSequence(context); Loading @@ -105,6 +114,8 @@ public final class ShutdownThread extends Thread { }) .setNegativeButton(com.android.internal.R.string.no, null) .create(); closer.dialog = dialog; dialog.setOnDismissListener(closer); dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); if (!context.getResources().getBoolean( com.android.internal.R.bool.config_sf_slowBlur)) { Loading @@ -116,6 +127,27 @@ public final class ShutdownThread extends Thread { } } private static class CloseDialogReceiver extends BroadcastReceiver implements DialogInterface.OnDismissListener { private Context mContext; public Dialog dialog; CloseDialogReceiver(Context context) { mContext = context; IntentFilter filter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS); context.registerReceiver(this, filter); } @Override public void onReceive(Context context, Intent intent) { dialog.cancel(); } public void onDismiss(DialogInterface unused) { mContext.unregisterReceiver(this); } } /** * Request a clean shutdown, waiting for subsystems to clean up their * state etc. Must be called from a Looper thread in which its UI Loading
core/res/res/values-xlarge/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ <string name="config_statusBarComponent">com.android.systemui/com.android.systemui.statusbar.tablet.TabletStatusBarService</string> <bool name="config_statusBarCanHide">false</bool> <!-- see comment in values/config.xml --> <integer name="config_longPressOnPowerBehavior">2</integer> <!-- Show sliding tab before lockscreen --> <bool name="config_enableSlidingTabFirst">false</bool> <!-- Enable lockscreen rotation --> Loading
core/res/res/values/config.xml +7 −0 Original line number Diff line number Diff line Loading @@ -221,6 +221,13 @@ closed. The default is 0. --> <integer name="config_lidNavigationAccessibility">0</integer> <!-- Control the behavior when the user long presses the power button. 0 - Nothing 1 - Global actions menu 2 - Power off (with confirmation) --> <integer name="config_longPressOnPowerBehavior">1</integer> <!-- Indicate whether the SD card is accessible without removing the battery. --> <bool name="config_batterySdCardAccessibility">false</bool> Loading
core/res/res/values/strings.xml +8 −1 Original line number Diff line number Diff line Loading @@ -280,9 +280,16 @@ <!-- Shutdown Progress Dialog. This is shown if the user chooses to power off the phone. --> <string name="shutdown_progress">Shutting down\u2026</string> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, there will be a confirmation dialog. This is the message. --> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, there will be a confirmation dialog. This is the message. --> <string name="shutdown_confirm">Your phone will shut down.</string> <!-- Shutdown Confirmation Dialog. When the user chooses to power off the phone, it asks the user if they'd like to shut down. This is the message. This is used instead of shutdown_confirm when the system is configured to use long press to go directly to the power off dialog instead of the global actions menu. --> <string name="shutdown_confirm_question">Would you like to shut down?</string> <!-- Recent Tasks dialog: title TODO: this should move to SystemUI.apk, but the code for the old recent dialog is still in the framework Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +27 −4 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.os.Vibrator; import android.provider.Settings; import com.android.internal.R; import com.android.internal.app.ShutdownThread; import com.android.internal.policy.PolicyManager; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.telephony.ITelephony; Loading Loading @@ -129,6 +130,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final boolean SHOW_STARTING_ANIMATIONS = true; static final boolean SHOW_PROCESSES_ON_ALT_MENU = false; 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; // wallpaper is at the bottom, though the window manager may move it. static final int WALLPAPER_LAYER = 2; static final int APPLICATION_LAYER = 2; Loading Loading @@ -224,6 +229,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean mDeskDockEnablesAccelerometer; int mLidKeyboardAccessibility; int mLidNavigationAccessibility; int mLongPressOnPowerBehavior = -1; boolean mScreenOn = false; boolean mOrientationSensorEnabled = false; int mCurrentAppOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; Loading Loading @@ -467,10 +473,27 @@ public class PhoneWindowManager implements WindowManagerPolicy { Runnable mPowerLongPress = new Runnable() { public void run() { // The context isn't read if (mLongPressOnPowerBehavior < 0) { mLongPressOnPowerBehavior = mContext.getResources().getInteger( com.android.internal.R.integer.config_longPressOnPowerBehavior); } switch (mLongPressOnPowerBehavior) { case LONG_PRESS_POWER_NOTHING: break; case LONG_PRESS_POWER_GLOBAL_ACTIONS: mShouldTurnOffOnKeyUp = false; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); showGlobalActionsDialog(); break; case LONG_PRESS_POWER_SHUT_OFF: mShouldTurnOffOnKeyUp = false; performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false); sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS); ShutdownThread.shutdown(mContext, true); break; } } }; Loading