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

Commit a925f189 authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Allow disabling of crash dialog.

Bug: 22007110

Change-Id: I78cd234715c740347dda34e23617b22ae1d8d0a6
parent 7f8eec09
Loading
Loading
Loading
Loading
+40 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2015, 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="wrap_content"
        android:layout_height="wrap_content"
        android:paddingStart="14dp"
        android:paddingEnd="10dp"
        android:gravity="center_vertical"
        >
    <CheckBox
            android:id="@+id/checkbox"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            />
    <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            />

</LinearLayout>
+3 −0
Original line number Diff line number Diff line
@@ -2555,6 +2555,9 @@
    <!-- Text of the alert that is displayed when an application has crashed. -->
    <string name="aerr_process">Unfortunately, the process <xliff:g id="process">%1$s</xliff:g> has
        stopped.</string>
    <!-- Text of the alert that is displayed when an application has crashed. -->
    <string name="aerr_process_silence">Silence crashes from <xliff:g id="process">%1$s</xliff:g>
        until reboot.</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. -->
+2 −0
Original line number Diff line number Diff line
@@ -1714,6 +1714,7 @@
  <java-symbol type="layout" name="launch_warning" />
  <java-symbol type="layout" name="safe_mode" />
  <java-symbol type="layout" name="simple_list_item_2_single_choice" />
  <java-symbol type="layout" name="app_error_dialog_dont_show_again" />
  <java-symbol type="plurals" name="wifi_available" />
  <java-symbol type="plurals" name="wifi_available_detailed" />
  <java-symbol type="string" name="accessibility_binding_label" />
@@ -1721,6 +1722,7 @@
  <java-symbol type="string" name="adb_active_notification_title" />
  <java-symbol type="string" name="aerr_application" />
  <java-symbol type="string" name="aerr_process" />
  <java-symbol type="string" name="aerr_process_silence" />
  <java-symbol type="string" name="aerr_title" />
  <java-symbol type="string" name="android_upgrading_fstrim" />
  <java-symbol type="string" name="android_upgrading_apk" />
+12 −1
Original line number Diff line number Diff line
@@ -1232,6 +1232,8 @@ public final class ActivityManagerService extends ActivityManagerNative
    final ArrayList<UidRecord.ChangeItem> mPendingUidChanges = new ArrayList<>();
    final ArrayList<UidRecord.ChangeItem> mAvailUidChanges = new ArrayList<>();
    ArraySet<String> mAppsNotReportingCrashes;
    /**
     * Runtime CPU use collection thread.  This object's lock is used to
     * perform synchronization with the thread (notifying it to run).
@@ -1420,7 +1422,9 @@ public final class ActivityManagerService extends ActivityManagerNative
                        }
                        return;
                    }
                    if (mShowDialogs && !mSleeping && !mShuttingDown) {
                    final boolean crashSilenced = mAppsNotReportingCrashes != null &&
                            mAppsNotReportingCrashes.contains(proc.info.packageName);
                    if (mShowDialogs && !mSleeping && !mShuttingDown && !crashSilenced) {
                        Dialog d = new AppErrorDialog(mContext,
                                ActivityManagerService.this, res, proc);
                        d.show();
@@ -20573,6 +20577,13 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    void stopReportingCrashesLocked(ProcessRecord proc) {
        if (mAppsNotReportingCrashes == null) {
            mAppsNotReportingCrashes = new ArraySet<>();
        }
        mAppsNotReportingCrashes.add(proc.info.packageName);
    }
    private final class LocalService extends ActivityManagerInternal {
        @Override
        public void onWakefulnessChanged(int wakefulness) {
+35 −7
Original line number Diff line number Diff line
@@ -19,14 +19,22 @@ package com.android.server.am;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.CheckBox;
import android.widget.FrameLayout;
import android.widget.TextView;

final class AppErrorDialog extends BaseErrorDialog {
    private final ActivityManagerService mService;
    private final AppErrorResult mResult;
    private final ProcessRecord mProc;
    private CharSequence mName;

    // Event 'what' codes
    static final int FORCE_QUIT = 0;
@@ -44,17 +52,16 @@ final class AppErrorDialog extends BaseErrorDialog {
        mService = service;
        mProc = app;
        mResult = result;
        CharSequence name;
        if ((app.pkgList.size() == 1) &&
                (name=context.getPackageManager().getApplicationLabel(app.info)) != null) {
                (mName = context.getPackageManager().getApplicationLabel(app.info)) != null) {
            setMessage(res.getString(
                    com.android.internal.R.string.aerr_application,
                    name.toString(), app.info.processName));
                    mName.toString(), app.info.processName));
        } else {
            name = app.processName;
            mName = app.processName;
            setMessage(res.getString(
                    com.android.internal.R.string.aerr_process,
                    name.toString()));
                    mName.toString()));
        }

        setCancelable(false);
@@ -85,12 +92,33 @@ final class AppErrorDialog extends BaseErrorDialog {
                DISMISS_TIMEOUT);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (!ActivityManagerService.IS_USER_BUILD) {
            FrameLayout frame = (FrameLayout) findViewById(android.R.id.custom);
            Context context = getContext();
            LayoutInflater.from(context).inflate(
                    com.android.internal.R.layout.app_error_dialog_dont_show_again, frame, true);
            ((TextView) frame.findViewById(com.android.internal.R.id.text)).setText(
                    context.getResources().getString(
                            com.android.internal.R.string.aerr_process_silence,
                            mName.toString()));
            findViewById(com.android.internal.R.id.customPanel).setVisibility(View.VISIBLE);
        }
    }

    private final Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            View view = findViewById(com.android.internal.R.id.checkbox);
            final boolean stopReporting = view != null && ((CheckBox) view).isChecked();
            synchronized (mService) {
                if (mProc != null && mProc.crashDialog == AppErrorDialog.this) {
                    mProc.crashDialog = null;
                }
                if (stopReporting) {
                    mService.stopReportingCrashesLocked(mProc);
                }
            }
            mResult.set(msg.what);