From 6bea62d3521a02190096ab7034b03a48e5a28b2d Mon Sep 17 00:00:00 2001 From: Mark Dietz Date: Thu, 15 Nov 2012 16:56:40 -0500 Subject: [PATCH] Reboot options Change-Id: I5e01fe261f079a424c68fccb98230cad13e9614d --- .../android/view/WindowManagerPolicy.java | 1 + core/res/res/drawable-hdpi/ic_lock_reboot.png | Bin 0 -> 3689 bytes core/res/res/drawable-mdpi/ic_lock_reboot.png | Bin 0 -> 3374 bytes .../res/res/drawable-xhdpi/ic_lock_reboot.png | Bin 0 -> 2221 bytes core/res/res/values/arrays.xml | 17 ++++ core/res/res/values/public.xml | 1 + core/res/res/values/strings.xml | 27 ++++++ core/res/res/values/symbols.xml | 9 ++ .../internal/policy/impl/GlobalActions.java | 20 +++++ .../server/power/PowerManagerService.java | 2 +- .../android/server/power/ShutdownThread.java | 80 ++++++++++++++---- .../server/wm/WindowManagerService.java | 6 ++ 12 files changed, 145 insertions(+), 18 deletions(-) create mode 100644 core/res/res/drawable-hdpi/ic_lock_reboot.png create mode 100644 core/res/res/drawable-mdpi/ic_lock_reboot.png create mode 100644 core/res/res/drawable-xhdpi/ic_lock_reboot.png diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index 26739b3d50..660b452ba1 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -398,6 +398,7 @@ public FakeWindow addFakeWindow(Looper looper, public void switchKeyboardLayout(int deviceId, int direction); public void shutdown(boolean confirm); + public void reboot(boolean confirm); public void rebootSafeMode(boolean confirm); } diff --git a/core/res/res/drawable-hdpi/ic_lock_reboot.png b/core/res/res/drawable-hdpi/ic_lock_reboot.png new file mode 100644 index 0000000000000000000000000000000000000000..4beeb8778062d0accda10c0a852f73cb4b8f9abc GIT binary patch literal 3689 zcmV-v4wmtWP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*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lE$KC?a~XsD~g2=|V+B^jaA` zM1@e4kknI`m+1D;g$N2PP@)ovGzgh6%5El#U1vm#oUfNPaFDh3*?XV0j~(cT1&9Bf z{r~^B_PYK5I&)NdS^DU4X%gUeV6>M3?g6#~>v|Pn3K#)i16~D|^cujimd_Kw4&Yv3 z;J*wo1grqoM#ldcz%#)6z=gRS&dIQh&IPUnZUR;U%Ygni&rAbP0h_|-`l8lt{pv01 zXV#aU>UHWs-8kw7f06p3dE`xXxSIfXsefb$e4l!U+SkD-s0^?%Q?I|MjwF2C7T$1n zfJaLNc0heYy<7b<^8KWGeZu~z`g-`?UiG}30C%bLV!Kbh zIoN2G&()K10IX1_3W9$nF&sV)-+!X6F0j9;%~0zIU_jkg;NancXWvmDQRlbuaf!OS zz{jHy3Q8%<2!3L6<2+bZ=)!rw$4fNKgS>`3O| zXWL^5pIcM=MbTkyBB9?5>}%)*yBYW~qQ4YaUgb2p0JuD&KLotg;1T=~@Nz^yKO7iK z1B?S_NAw>7`y0*@-##vvn3dI40M1P$9^1N*r+)?Pjp&!g;!Oc8PUv@c0bmOFDWYE( zhIZ*WaJENmETZ2J94QO%ZDPV+ox83Rk;{NnBKnLu_+YZ{Gx+8HKeY$Q!^IXE< zuT?4sC0i=BJghFO3$RrEJz;n5#miUNQKq)K3fS9#hxmstb*VA!D1~+8C+~3let5)OG56VKFF@4P|1hQeHnF zc(>$D%bt)L9t=zJaM)qTfm2I7|0HmK6Xo^g1(k{%@{jsZ)79yP>I)47|6M`dH2eJk z>J6FR#-CxMT2v>FPOq4TfE$7Jz{MrUcWZjO1$Z8qJdt-~voZ#(3Kx9m1eoD)hc+GB z!BE-Q0(=oW9-l~nSXMOz%xeKSn%hZ}06qU-iT?r0$iD*sSE1;}{k|=e00000NkvXX Hu0mjfG&JZE literal 0 HcmV?d00001 diff --git a/core/res/res/drawable-mdpi/ic_lock_reboot.png b/core/res/res/drawable-mdpi/ic_lock_reboot.png new file mode 100644 index 0000000000000000000000000000000000000000..2b125b98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_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00076NkljWmtP5VKM=HRUg`ktCU&G#0Y4 zA~v$IoGe%2mpk*ZdF7qQJLlf>V;bK&i|3s8`#j&yIq&m* z-W;H%L_P(#D5-lX1$0V!Ch3f%Wr?!@Nv|&cVhrd>k|#;w?Z7eMCi77PE&{EKC1416 z=n6&QwOd=rO29VY9`SG$SdoQ*1Hk7Pg3fhkkC3Je3Q+?sB8zYOd$`~je1_=9l-+%V)BV82<@4V(h<0sbc7k;(A^ zXlq8mPT;3UtOG|9Y}d8GxDj!-83C6K=~{|rHQ@e%KbSQC$v*;GfOj6@2T)2OK(2TA znD;5I7j#J~dGQlTQz`xCmWg|#%&1dR!Hb_~;J7bMyg5q18WT@vAYevP&5Kt@379qU z@(ctN%v+s}5>PR5DFXo;&Ad>F67XJ9)r` ze7}GljT+Huvv0>1Xt&K=!+~76MgrP_X+yk}pm@J)WIl$PHKP*&8@>?ZO&kKg8vcV2 zf1w0<;7&k988{d*ZfymwI0N(X1=tee)05-pzS>qJxkpKVy07*qoM6N<$ Ef|(^cwg3PC literal 0 HcmV?d00001 diff --git a/core/res/res/drawable-xhdpi/ic_lock_reboot.png b/core/res/res/drawable-xhdpi/ic_lock_reboot.png new file mode 100644 index 0000000000000000000000000000000000000000..f27e5e40c22e7bdc13764ead0347674a9041ec24 GIT binary patch literal 2221 zcmV;e2vYZnP)U8P*7-ZbZ>KLZ*U+lnSp_Ufq@}0xwybFAi#%#fq@|}KQEO56)-X|e7nZL z$iTqBa9P*U#mSX{G{Bl%P*lRez;J+pfx##xwK$o9f#C}S14DXwNkIt%17i#W1A|CX zc0maP17iUL1A|C*NRTrF17iyV0~1e4YDEbH0|SF|enDkXW_m`6f}y3QrGjHhep0GJ zaAk2xYHqQDXI^rCQ9*uDVo7QW0|Nup4h9AW240u^5(W3f%sd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1?+7NzMm3;01 z0$QbCj3xTDT_s7s31+;0e5%lQHiQo~#vMRJdz3I1_(BU@-ElsxQL8ckj86tR>s zmVA+2G^Q z(s_YDP5O~%9KiuPkY|7v!+Ieim*^gWYly0=%;{)VU3P-=P4aPvjGrhiihH5Fy*J1fZ@*V&H!RuFkC0b zLb5#qOyGLMnHy;{&cqM^1DxfuB^9uU0#E9*SxB)FmQK*>ED&9!fjVmwe3UZBlNUs& zV7%c0$7yi}AX?dP*kBBgGR1=f-oPD3;A!G$`jDRP-MabMxJt9Rk6R6AayBNj-td4P zzBR(KgUTqZowkhdkZy975rwo?oyPp%v?5aGV+=txQ}c}UBK zw%O1vn(NrWQz@6|WlnL1I?mGx1Sn(*)0n}Glv|^g4eT{;77q=IiQ1B6g?~%cX4R`+ z=WGYg96xIHm0J{7_UiH4Xe-m4jRAe8l}>u7P7YR%s`O&Zurf~J#DfMfX zUeF13C$(i#N53xVQ&kOBkh^h0Gr0&ela*9ZMubqBG;M%hE>Xj~d_$x2OxjJS)JKd- zOlCGqD5H=Fetab8qla@GriRlr&_M6CYt{a9KbA0#C@~_0=%R&AnyEADplb{Oe*A>U vCx;+CbkIY;r~1(|!05kbqX7RWfWHO+*vAYXO7uX300000NkvXXu0mjf&VvK2 literal 0 HcmV?d00001 diff --git a/core/res/res/values/arrays.xml b/core/res/res/values/arrays.xml index 1e966f7cc5..227d7b8ec9 100644 --- a/core/res/res/values/arrays.xml +++ b/core/res/res/values/arrays.xml @@ -419,4 +419,21 @@ TUV WXYZ + + + + @string/global_action_reboot + @string/global_action_reboot_recovery + @string/global_action_reboot_bootloader + @string/global_action_reboot_download + + + + + + recovery + bootloader + download + diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml index a5dae7ed7a..5f1042825c 100644 --- a/core/res/res/values/public.xml +++ b/core/res/res/values/public.xml @@ -894,6 +894,7 @@ + diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 9932d1e169..1d3db27796 100755 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -315,6 +315,16 @@ power off dialog instead of the global actions menu. --> Do you want to shut down? + + Rebooting\u2026 + + + Your tablet will reboot. + + Your phone will reboot. + Reboot to safe mode @@ -345,7 +355,24 @@ Power off + + + Reboot + + + Recovery + + + Download + + + Bootloader + + Reboot tablet + Reboot phone + + Bug report diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 68a0289756..d224e0ff43 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -1813,4 +1813,13 @@ + + + + + + + + + diff --git a/policy/src/com/android/internal/policy/impl/GlobalActions.java b/policy/src/com/android/internal/policy/impl/GlobalActions.java index d1f8ef15b7..ef7cd6b2a2 100644 --- a/policy/src/com/android/internal/policy/impl/GlobalActions.java +++ b/policy/src/com/android/internal/policy/impl/GlobalActions.java @@ -242,6 +242,26 @@ public void onPress() { mWindowManagerFuncs.shutdown(true); } + public boolean showDuringKeyguard() { + return true; + } + + public boolean showBeforeProvisioning() { + return true; + } + }); + + // next: reboot + mItems.add( + new SinglePressAction( + com.android.internal.R.drawable.ic_lock_reboot, + R.string.global_action_reboot) { + + public void onPress() { + // shutdown by making sure radio and power are handled accordingly. + mWindowManagerFuncs.reboot(true); + } + public boolean onLongPress() { mWindowManagerFuncs.rebootSafeMode(true); return true; diff --git a/services/java/com/android/server/power/PowerManagerService.java b/services/java/com/android/server/power/PowerManagerService.java index 8650192f1f..747fd83f52 100644 --- a/services/java/com/android/server/power/PowerManagerService.java +++ b/services/java/com/android/server/power/PowerManagerService.java @@ -1827,7 +1827,7 @@ public void run() { if (shutdown) { ShutdownThread.shutdown(mContext, confirm); } else { - ShutdownThread.reboot(mContext, reason, confirm); + ShutdownThread.reboot(mContext, confirm); } } } diff --git a/services/java/com/android/server/power/ShutdownThread.java b/services/java/com/android/server/power/ShutdownThread.java index c7f7390fcb..62c616652a 100644 --- a/services/java/com/android/server/power/ShutdownThread.java +++ b/services/java/com/android/server/power/ShutdownThread.java @@ -46,6 +46,7 @@ import com.android.internal.telephony.ITelephony; import android.util.Log; +import android.view.KeyEvent; import android.view.WindowManager; public final class ShutdownThread extends Thread { @@ -126,21 +127,62 @@ static void shutdownInner(final Context context, boolean confirm) { if (confirm) { final CloseDialogReceiver closer = new CloseDialogReceiver(context); + if (mReboot && !mRebootSafeMode){ + sConfirmDialog = new AlertDialog.Builder(context) + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(com.android.internal.R.string.reboot_system) + .setSingleChoiceItems(com.android.internal.R.array.reboot_options, 0, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + if (which < 0) + return; + + String actions[] = context.getResources().getStringArray(com.android.internal.R.array.reboot_actions); + + if (actions != null && which < actions.length) + mRebootReason = actions[which]; + } + }) + .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + mReboot = true; + beginShutdownSequence(context); + } + }) + .setNegativeButton(com.android.internal.R.string.no, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + mReboot = false; + sConfirmDialog.cancel(); + } + }) + .create(); + sConfirmDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { + public boolean onKey (DialogInterface dialog, int keyCode, KeyEvent event) { + if (keyCode == KeyEvent.KEYCODE_BACK) { + mReboot = false; + sConfirmDialog.cancel(); + } + return true; + } + }); + } else { + sConfirmDialog = new AlertDialog.Builder(context) + .setTitle(mRebootSafeMode + ? com.android.internal.R.string.reboot_safemode_title + : com.android.internal.R.string.power_off) + .setMessage(resourceId) + .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + beginShutdownSequence(context); + } + }) + .setNegativeButton(com.android.internal.R.string.no, null) + .create(); + } + if (sConfirmDialog != null) { sConfirmDialog.dismiss(); } - sConfirmDialog = new AlertDialog.Builder(context) - .setTitle(mRebootSafeMode - ? com.android.internal.R.string.reboot_safemode_title - : com.android.internal.R.string.power_off) - .setMessage(resourceId) - .setPositiveButton(com.android.internal.R.string.yes, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - beginShutdownSequence(context); - } - }) - .setNegativeButton(com.android.internal.R.string.no, null) - .create(); + closer.dialog = sConfirmDialog; sConfirmDialog.setOnDismissListener(closer); sConfirmDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); @@ -180,10 +222,10 @@ public void onDismiss(DialogInterface unused) { * @param reason code to pass to the kernel (e.g. "recovery"), or null. * @param confirm true if user confirmation is needed before shutting down. */ - public static void reboot(final Context context, String reason, boolean confirm) { + public static void reboot(final Context context, boolean confirm) { mReboot = true; mRebootSafeMode = false; - mRebootReason = reason; + mRebootReason = null; shutdownInner(context, confirm); } @@ -213,9 +255,13 @@ private static void beginShutdownSequence(Context context) { // throw up an indeterminate system dialog to indicate radio is // shutting down. ProgressDialog pd = new ProgressDialog(context); - pd.setTitle(context.getText(com.android.internal.R.string.power_off)); - pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress)); - pd.setIndeterminate(true); + if (mReboot) { + pd.setTitle(context.getText(com.android.internal.R.string.reboot_system)); + pd.setMessage(context.getText(com.android.internal.R.string.reboot_progress)); + } else { + pd.setTitle(context.getText(com.android.internal.R.string.power_off)); + pd.setMessage(context.getText(com.android.internal.R.string.shutdown_progress)); + } pd.setIndeterminate(true); pd.setCancelable(false); pd.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG); diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 51edb44f2d..bf766ab67b 100755 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -5417,6 +5417,12 @@ public void shutdown(boolean confirm) { ShutdownThread.shutdown(mContext, confirm); } + // Called by window manager policy. Not exposed externally. + @Override + public void reboot(boolean confirm) { + ShutdownThread.reboot(mContext, confirm); + } + // Called by window manager policy. Not exposed externally. @Override public void rebootSafeMode(boolean confirm) {