Home | History | Annotate | Download | only in am
      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;
     20 import android.content.DialogInterface;
     21 import android.os.Handler;
     22 import android.os.Message;
     23 import android.view.WindowManager;
     24 
     25 final 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());
     54         setButton(DialogInterface.BUTTON_POSITIVE, "Force Close", mHandler.obtainMessage(1, app));
     55         setTitle("Waiting For Debugger");
     56         WindowManager.LayoutParams attrs = getWindow().getAttributes();
     57         attrs.setTitle("Waiting For Debugger: " + app.info.processName);
     58         getWindow().setAttributes(attrs);
     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.
     69                     mService.killAppAtUsersRequest(mProc, AppWaitingForDebuggerDialog.this);
     70                     break;
     71             }
     72         }
     73     };
     74 }
     75