blob: d08bb101c93f6c9443a69c7801222a2ae168837f [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package com.android.server.am;
18
19import android.content.Context;
Christian Mehlmauer7664e202010-07-20 08:46:17 +020020import android.content.DialogInterface;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.os.Handler;
22import android.os.Message;
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -070023import android.view.WindowManager;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080024
25class 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 Mehlmauer7664e202010-07-20 08:46:17 +020054 setButton(DialogInterface.BUTTON_POSITIVE, "Force Close", mHandler.obtainMessage(1, app));
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 setTitle("Waiting For Debugger");
Dianne Hackborn5fe7e2a2012-10-04 11:58:16 -070056 WindowManager.LayoutParams attrs = getWindow().getAttributes();
57 attrs.setTitle("Waiting For Debugger: " + app.info.processName);
58 getWindow().setAttributes(attrs);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080059 }
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 Egnor42471dd2010-01-07 17:25:22 -080069 mService.killAppAtUsersRequest(mProc, AppWaitingForDebuggerDialog.this);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070 break;
71 }
72 }
73 };
74}