blob: c9d4d0117c563b66bd6b522be36b6cfa390b9242 [file] [log] [blame]
Mike Lockwoodbad80e02009-07-30 01:21:08 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.server;
18
19import android.app.Activity;
20import android.content.BroadcastReceiver;
21import android.content.Intent;
22import android.os.Bundle;
23import android.os.Handler;
Joe Onorato8a9b2202010-02-26 18:56:32 -080024import android.util.Slog;
Mike Lockwoodbad80e02009-07-30 01:21:08 -070025import com.android.internal.app.ShutdownThread;
26
27public class ShutdownActivity extends Activity {
28
29 private static final String TAG = "ShutdownActivity";
Mike Lockwoodb8a8a572010-09-08 07:21:07 -040030 private boolean mReboot;
Mike Lockwoodbad80e02009-07-30 01:21:08 -070031 private boolean mConfirm;
32
33 @Override
34 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState);
36
Mike Lockwoodb8a8a572010-09-08 07:21:07 -040037 Intent intent = getIntent();
38 mReboot = Intent.ACTION_REBOOT.equals(intent.getAction());
39 mConfirm = intent.getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
Joe Onorato8a9b2202010-02-26 18:56:32 -080040 Slog.i(TAG, "onCreate(): confirm=" + mConfirm);
Mike Lockwoodbad80e02009-07-30 01:21:08 -070041
42 Handler h = new Handler();
43 h.post(new Runnable() {
44 public void run() {
Mike Lockwoodb8a8a572010-09-08 07:21:07 -040045 if (mReboot) {
46 ShutdownThread.reboot(ShutdownActivity.this, null, mConfirm);
47 } else {
48 ShutdownThread.shutdown(ShutdownActivity.this, mConfirm);
49 }
Mike Lockwoodbad80e02009-07-30 01:21:08 -070050 }
51 });
52 }
53}