Merge "Make more system dialogs could receive CLOSE_SYSTEM_DIALOGS" into sc-dev
This commit is contained in:
@@ -18,10 +18,7 @@ package com.android.server.am;
|
||||
|
||||
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -138,19 +135,6 @@ final class AppErrorDialog extends BaseErrorDialog implements View.OnClickListen
|
||||
findViewById(com.android.internal.R.id.customPanel).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getContext().registerReceiver(mReceiver,
|
||||
new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getContext().unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
setResult(msg.what);
|
||||
@@ -204,15 +188,6 @@ final class AppErrorDialog extends BaseErrorDialog implements View.OnClickListen
|
||||
}
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static class Data {
|
||||
AppErrorResult result;
|
||||
int taskId;
|
||||
|
||||
@@ -181,6 +181,11 @@ final class AppNotRespondingDialog extends BaseErrorDialog implements View.OnCli
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void closeDialog() {
|
||||
mHandler.obtainMessage(FORCE_CLOSE).sendToTarget();
|
||||
}
|
||||
|
||||
static class Data {
|
||||
final ProcessRecord proc;
|
||||
final ApplicationInfo aInfo;
|
||||
|
||||
@@ -61,6 +61,11 @@ final class AppWaitingForDebuggerDialog extends BaseErrorDialog {
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void closeDialog() {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
|
||||
@@ -16,16 +16,19 @@
|
||||
|
||||
package com.android.server.am;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
public class BaseErrorDialog extends AlertDialog {
|
||||
private static final int ENABLE_BUTTONS = 0;
|
||||
private static final int DISABLE_BUTTONS = 1;
|
||||
@@ -44,10 +47,19 @@ public class BaseErrorDialog extends AlertDialog {
|
||||
getWindow().setAttributes(attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mHandler.sendEmptyMessage(DISABLE_BUTTONS);
|
||||
mHandler.sendMessageDelayed(mHandler.obtainMessage(ENABLE_BUTTONS), 1000);
|
||||
getContext().registerReceiver(mReceiver,
|
||||
new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
getContext().unregisterReceiver(mReceiver);
|
||||
}
|
||||
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
@@ -84,4 +96,24 @@ public class BaseErrorDialog extends AlertDialog {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called when received ACTION_CLOSE_SYSTEM_DIALOGS.
|
||||
*/
|
||||
protected void closeDialog() {
|
||||
if (mCancelable) {
|
||||
cancel();
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
|
||||
closeDialog();
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -82,6 +82,11 @@ final class StrictModeViolationDialog extends BaseErrorDialog {
|
||||
DISMISS_TIMEOUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void closeDialog() {
|
||||
mHandler.obtainMessage(ACTION_OK).sendToTarget();
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
synchronized (mService.mProcLock) {
|
||||
|
||||
@@ -41,6 +41,11 @@ final class FactoryErrorDialog extends BaseErrorDialog {
|
||||
public void onStop() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void closeDialog() {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
private final Handler mHandler = new Handler() {
|
||||
public void handleMessage(Message msg) {
|
||||
throw new RuntimeException("Rebooting from failed factory test");
|
||||
|
||||
Reference in New Issue
Block a user