The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
| 17 | package com.android.server.am; |
| 18 | |
| 19 | import android.content.Context; |
Christian Mehlmauer | 7664e20 | 2010-07-20 08:46:17 +0200 | [diff] [blame] | 20 | import android.content.DialogInterface; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.os.Handler; |
| 22 | import android.os.Message; |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 23 | import android.view.WindowManager; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
| 25 | class AppWaitingForDebuggerDialog extends BaseErrorDialog { |
| 26 | final ActivityManagerService mService; |
| 27 | final ProcessRecord mProc; |
| 28 | private CharSequence mAppName; |
| 29 | |
| 30 | public AppWaitingForDebuggerDialog(ActivityManagerService service, |
| 31 | Context context, ProcessRecord app) { |
| 32 | super(context); |
| 33 | mService = service; |
| 34 | mProc = app; |
| 35 | mAppName = context.getPackageManager().getApplicationLabel(app.info); |
| 36 | |
| 37 | setCancelable(false); |
| 38 | |
| 39 | StringBuilder text = new StringBuilder(); |
| 40 | if (mAppName != null && mAppName.length() > 0) { |
| 41 | text.append("Application "); |
| 42 | text.append(mAppName); |
| 43 | text.append(" (process "); |
| 44 | text.append(app.processName); |
| 45 | text.append(")"); |
| 46 | } else { |
| 47 | text.append("Process "); |
| 48 | text.append(app.processName); |
| 49 | } |
| 50 | |
| 51 | text.append(" is waiting for the debugger to attach."); |
| 52 | |
| 53 | setMessage(text.toString()); |
Christian Mehlmauer | 7664e20 | 2010-07-20 08:46:17 +0200 | [diff] [blame] | 54 | setButton(DialogInterface.BUTTON_POSITIVE, "Force Close", mHandler.obtainMessage(1, app)); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | setTitle("Waiting For Debugger"); |
Dianne Hackborn | 5fe7e2a | 2012-10-04 11:58:16 -0700 | [diff] [blame] | 56 | WindowManager.LayoutParams attrs = getWindow().getAttributes(); |
| 57 | attrs.setTitle("Waiting For Debugger: " + app.info.processName); |
| 58 | getWindow().setAttributes(attrs); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | public void onStop() { |
| 62 | } |
| 63 | |
| 64 | private final Handler mHandler = new Handler() { |
| 65 | public void handleMessage(Message msg) { |
| 66 | switch (msg.what) { |
| 67 | case 1: |
| 68 | // Kill the application. |
Dan Egnor | 42471dd | 2010-01-07 17:25:22 -0800 | [diff] [blame] | 69 | mService.killAppAtUsersRequest(mProc, AppWaitingForDebuggerDialog.this); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | break; |
| 71 | } |
| 72 | } |
| 73 | }; |
| 74 | } |