summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2009-07-30 01:21:08 -0700
committerMike Lockwood <lockwood@android.com>2009-07-30 10:16:28 -0700
commitbad80e0dccdeaeea97991f7d092678ff0df1bc84 (patch)
tree16f00b4fb6d548c3b7023c87416bc2f55024c759 /services
parentd2fb98006054f94753d8c58cf6a809840964db2e (diff)
downloadframeworks_base-bad80e0dccdeaeea97991f7d092678ff0df1bc84.zip
frameworks_base-bad80e0dccdeaeea97991f7d092678ff0df1bc84.tar.gz
frameworks_base-bad80e0dccdeaeea97991f7d092678ff0df1bc84.tar.bz2
Add Activity Intent.ACTION_REQUEST_SHUTDOWN for requesting a system shutdown.
The Intent.EXTRA_KEY_CONFIRM extra can be set to require user confirmation before shutting down. The ACTION_REQUEST_SHUTDOWN Intent is protected by android.permission.SHUTDOWN. Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/ShutdownActivity.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/services/java/com/android/server/ShutdownActivity.java b/services/java/com/android/server/ShutdownActivity.java
new file mode 100644
index 0000000..7f0e90d
--- /dev/null
+++ b/services/java/com/android/server/ShutdownActivity.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009 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 com.android.server;
+
+import android.app.Activity;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.Handler;
+import android.util.Log;
+import com.android.internal.app.ShutdownThread;
+
+public class ShutdownActivity extends Activity {
+
+ private static final String TAG = "ShutdownActivity";
+ private boolean mConfirm;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mConfirm = getIntent().getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false);
+ Log.i(TAG, "onCreate(): confirm=" + mConfirm);
+
+ Handler h = new Handler();
+ h.post(new Runnable() {
+ public void run() {
+ ShutdownThread.shutdown(ShutdownActivity.this, mConfirm);
+ }
+ });
+ }
+}