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