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
17package com.android.server.am;
18
19import android.content.Context;
20import android.os.Handler;
21import android.os.Message;
22
23class AppWaitingForDebuggerDialog extends BaseErrorDialog {
24    final ActivityManagerService mService;
25    final ProcessRecord mProc;
26    private CharSequence mAppName;
27
28    public AppWaitingForDebuggerDialog(ActivityManagerService service,
29            Context context, ProcessRecord app) {
30        super(context);
31        mService = service;
32        mProc = app;
33        mAppName = context.getPackageManager().getApplicationLabel(app.info);
34
35        setCancelable(false);
36
37        StringBuilder text = new StringBuilder();
38        if (mAppName != null && mAppName.length() > 0) {
39            text.append("Application ");
40            text.append(mAppName);
41            text.append(" (process ");
42            text.append(app.processName);
43            text.append(")");
44        } else {
45            text.append("Process ");
46            text.append(app.processName);
47        }
48
49        text.append(" is waiting for the debugger to attach.");
50
51        setMessage(text.toString());
52        setButton("Force Close", mHandler.obtainMessage(1, app));
53        setTitle("Waiting For Debugger");
54        getWindow().setTitle("Waiting For Debugger: " + app.info.processName);
55    }
56
57    public void onStop() {
58    }
59
60    private final Handler mHandler = new Handler() {
61        public void handleMessage(Message msg) {
62            switch (msg.what) {
63                case 1:
64                    // Kill the application.
65                    mService.killAppAtUsersRequest(mProc, AppWaitingForDebuggerDialog.this);
66                    break;
67            }
68        }
69    };
70}
71