diff options
| author | Dianne Hackborn <hackbod@google.com> | 2015-01-05 23:15:10 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2015-01-05 23:15:10 +0000 |
| commit | d17218e7df24da8a2bcf6e7714dc0151155c3286 (patch) | |
| tree | c1db669055f3561b9dc5d01dec37697c8301e28e /core/java | |
| parent | 62ab1caa384fb17329891fbc24c959c7850e16c3 (diff) | |
| parent | 24bc8d761ae525f82dcaeee576ae238ab3a2de03 (diff) | |
am 24bc8d76: am 29807195: Merge "Fix issue #18901214: APR: Frequent crash in android" into lmp-mr1-dev
* commit '24bc8d761ae525f82dcaeee576ae238ab3a2de03':
Fix issue #18901214: APR: Frequent crash in android
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/com/android/internal/app/ShutdownActivity.java | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/core/java/com/android/internal/app/ShutdownActivity.java b/core/java/com/android/internal/app/ShutdownActivity.java new file mode 100644 index 000000000000..97521cf68dd4 --- /dev/null +++ b/core/java/com/android/internal/app/ShutdownActivity.java @@ -0,0 +1,66 @@ +/* + * 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.internal.app; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.IPowerManager; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.util.Slog; + +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); + + Intent intent = getIntent(); + mReboot = Intent.ACTION_REBOOT.equals(intent.getAction()); + mConfirm = intent.getBooleanExtra(Intent.EXTRA_KEY_CONFIRM, false); + Slog.i(TAG, "onCreate(): confirm=" + mConfirm); + + Thread thr = new Thread("ShutdownActivity") { + @Override + public void run() { + IPowerManager pm = IPowerManager.Stub.asInterface( + ServiceManager.getService(Context.POWER_SERVICE)); + try { + if (mReboot) { + pm.reboot(mConfirm, null, false); + } else { + pm.shutdown(mConfirm, false); + } + } catch (RemoteException e) { + } + } + }; + thr.start(); + finish(); + // Wait for us to tell the power manager to shutdown. + try { + thr.join(); + } catch (InterruptedException e) { + } + } +} |
