Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a85a2c63 authored by Adrian Roos's avatar Adrian Roos
Browse files

Improve ANR dialog

Bug: 22692162
Change-Id: Ie1f0ca54216f123ae26df51d42f88b0fa2d65941
parent 9fa3cd3d
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2016 The Android Open Source Project
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="@dimen/dialog_list_padding_vertical_material"
        android:paddingBottom="@dimen/dialog_list_padding_vertical_material"
>


    <TextView
            android:id="@+id/aerr_close"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/aerr_close_app"
            style="@style/aerr_list_item"
    />

    <TextView
            android:id="@+id/aerr_wait"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/aerr_wait"
            style="@style/aerr_list_item"
    />

    <TextView
            android:id="@+id/aerr_report"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/aerr_report"
            style="@style/aerr_list_item"
    />

</LinearLayout>
+10 −7
Original line number Diff line number Diff line
@@ -2597,10 +2597,9 @@
    <string name="aerr_process"><xliff:g id="process">%1$s</xliff:g> has
        stopped</string>
    <!-- Text of the alert that is displayed when an application has crashed repeatedly. -->
    <string name="aerr_application_repeated"><xliff:g id="application">%1$s</xliff:g> is repeatedly stopping</string>
    <string name="aerr_application_repeated"><xliff:g id="application">%1$s</xliff:g> keeps stopping</string>
    <!-- Text of the alert that is displayed when a process has crashed repeatedly. -->
    <string name="aerr_process_repeated"><xliff:g id="process">%1$s</xliff:g> is
        repeatedly stopping</string>
    <string name="aerr_process_repeated"><xliff:g id="process">%1$s</xliff:g> keeps stopping</string>
    <!-- Button that restarts a crashed application -->
    <string name="aerr_restart">Restart app</string>
    <!-- Button that clears cache and restarts a crashed application -->
@@ -2611,17 +2610,21 @@
    <string name="aerr_close">Close</string>
    <!-- Button that mutes further crashes of the crashed application-->
    <string name="aerr_mute">Mute</string>
    <!-- Button that waits a bit more for an unresponsive app -->
    <string name="aerr_wait">Wait</string>
    <!-- Button that closes an unresponsive application -->
    <string name="aerr_close_app">Close app</string>

    <!-- Title of the alert when an application is not responding. -->
    <string name="anr_title"></string>
    <!-- Text of the alert that is displayed when an application is not responding. -->
    <string name="anr_activity_application"><xliff:g id="application">%2$s</xliff:g> isn\'t responding.\n\nDo you want to close it?</string>
    <string name="anr_activity_application"><xliff:g id="application">%2$s</xliff:g> isn\'t responding</string>
    <!-- Text of the alert that is displayed when an application is not responding. -->
    <string name="anr_activity_process">Activity <xliff:g id="activity">%1$s</xliff:g> isn\'t responding.\n\nDo you want to close it?</string>
    <string name="anr_activity_process"><xliff:g id="activity">%1$s</xliff:g> isn\'t responding</string>
    <!-- Text of the alert that is displayed when an application is not responding. -->
    <string name="anr_application_process"><xliff:g id="application">%1$s</xliff:g> isn\'t responding. Do you want to close it?</string>
    <string name="anr_application_process"><xliff:g id="application">%1$s</xliff:g> isn\'t responding</string>
    <!-- Text of the alert that is displayed when an application is not responding. -->
    <string name="anr_process">Process <xliff:g id="process">%1$s</xliff:g> isn\'t responding.\n\nDo you want to close it?</string>
    <string name="anr_process">Process <xliff:g id="process">%1$s</xliff:g> isn\'t responding</string>
    <!-- Button allowing the user to close an application that is not responding. This will kill the application. -->
    <string name="force_close">OK</string>
    <!-- Button allowing the user to send a bug report for application which has encountered an error. -->
+3 −0
Original line number Diff line number Diff line
@@ -2511,6 +2511,9 @@

  <java-symbol type="bool" name="config_strongAuthRequiredOnBoot" />

  <java-symbol type="layout" name="app_anr_dialog" />
  <java-symbol type="id" name="aerr_wait" />

  <!-- Encryption notification while accounts are locked by credential encryption -->
  <java-symbol type="string" name="user_encrypted_title" />
  <java-symbol type="string" name="user_encrypted_message" />
+2 −1
Original line number Diff line number Diff line
@@ -745,7 +745,8 @@ class AppErrors {
        if (mService.mController != null) {
            try {
                // 0 == continue, -1 = kill process immediately
                int res = mService.mController.appEarlyNotResponding(app.processName, app.pid, annotation);
                int res = mService.mController.appEarlyNotResponding(
                        app.processName, app.pid, annotation);
                if (res < 0 && app.pid != MY_PID) {
                    app.kill("anr", true);
                }
+49 −20
Original line number Diff line number Diff line
@@ -21,12 +21,19 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Slog;
import android.view.LayoutInflater;
import android.view.View;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;

final class AppNotRespondingDialog extends BaseErrorDialog {
import static com.android.server.am.ActivityManagerService.IS_USER_BUILD;

final class AppNotRespondingDialog extends BaseErrorDialog implements View.OnClickListener {
    private static final String TAG = "AppNotRespondingDialog";

    // Event 'what' codes
@@ -71,24 +78,10 @@ final class AppNotRespondingDialog extends BaseErrorDialog {
            }
        }

        setMessage(name2 != null
        setTitle(name2 != null
                ? res.getString(resid, name1.toString(), name2.toString())
                : res.getString(resid, name1.toString()));

        setButton(DialogInterface.BUTTON_POSITIVE,
                res.getText(com.android.internal.R.string.force_close),
                mHandler.obtainMessage(FORCE_CLOSE));
        setButton(DialogInterface.BUTTON_NEGATIVE,
                res.getText(com.android.internal.R.string.wait),
                mHandler.obtainMessage(WAIT));

        if (app.errorReportReceiver != null) {
            setButton(DialogInterface.BUTTON_NEUTRAL,
                    res.getText(com.android.internal.R.string.report),
                    mHandler.obtainMessage(WAIT_AND_REPORT));
        }

        setTitle(res.getText(com.android.internal.R.string.anr_title));
        if (aboveSystem) {
            getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ERROR);
        }
@@ -99,7 +92,41 @@ final class AppNotRespondingDialog extends BaseErrorDialog {
        getWindow().setAttributes(attrs);
    }

    public void onStop() {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        final FrameLayout frame = (FrameLayout) findViewById(android.R.id.custom);
        final Context context = getContext();
        LayoutInflater.from(context).inflate(
                com.android.internal.R.layout.app_anr_dialog, frame, true);

        final TextView report = (TextView) findViewById(com.android.internal.R.id.aerr_report);
        report.setOnClickListener(this);
        final boolean hasReceiver = mProc.errorReportReceiver != null;
        report.setVisibility(hasReceiver ? View.VISIBLE : View.GONE);
        final TextView close = (TextView) findViewById(com.android.internal.R.id.aerr_close);
        close.setOnClickListener(this);
        final TextView wait = (TextView) findViewById(com.android.internal.R.id.aerr_wait);
        wait.setOnClickListener(this);

        findViewById(com.android.internal.R.id.customPanel).setVisibility(View.VISIBLE);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case com.android.internal.R.id.aerr_report:
                mHandler.obtainMessage(WAIT_AND_REPORT).sendToTarget();
                break;
            case com.android.internal.R.id.aerr_close:
                mHandler.obtainMessage(FORCE_CLOSE).sendToTarget();
                break;
            case com.android.internal.R.id.aerr_wait:
                mHandler.obtainMessage(WAIT).sendToTarget();
                break;
            default:
                break;
        }
    }

    private final Handler mHandler = new Handler() {
@@ -138,6 +165,8 @@ final class AppNotRespondingDialog extends BaseErrorDialog {
                    Slog.w(TAG, "bug report receiver dissappeared", e);
                }
            }

            dismiss();
        }
    };
}