Fix Intent.ACTION_REBOOT

Turns out this would be useful for automated testing.

Change-Id: Idd5e35a8d4a354447b17a77fe0b606f78df844d0
Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-09-08 07:21:07 -04:00
parent 582deec1f3
commit b8a8a578c2
2 changed files with 13 additions and 2 deletions

View File

@@ -1311,6 +1311,10 @@
<action android:name="android.intent.action.ACTION_REQUEST_SHUTDOWN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.REBOOT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.android.internal.app.NetInitiatedActivity"
android:theme="@style/Theme.Dialog.Alert"

View File

@@ -27,19 +27,26 @@ import com.android.internal.app.ShutdownThread;
public class ShutdownActivity extends Activity {
private static final String TAG = "ShutdownActivity";
private boolean mReboot;
private boolean mConfirm;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mConfirm = getIntent().getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
Intent intent = getIntent();
mReboot = Intent.ACTION_REBOOT.equals(intent.getAction());
mConfirm = intent.getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
Slog.i(TAG, "onCreate(): confirm=" + mConfirm);
Handler h = new Handler();
h.post(new Runnable() {
public void run() {
ShutdownThread.shutdown(ShutdownActivity.this, mConfirm);
if (mReboot) {
ShutdownThread.reboot(ShutdownActivity.this, null, mConfirm);
} else {
ShutdownThread.shutdown(ShutdownActivity.this, mConfirm);
}
}
});
}