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

Commit 12f6557f authored by d34d's avatar d34d Committed by Gerrit Code Review
Browse files

Themes: Track NotFoundException on app launch failure

We should probably keep an eye on NotFoundExceptions too since they
are a common exception thrown when a bad theme is applied.

Change-Id: I2ccaed0349a90ab99b99fb83cef0c9183d598088
parent 672181df
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -2204,13 +2204,10 @@ public final class ActivityThread {
            if (!mInstrumentation.onException(activity, e)) {
                if (e instanceof InflateException) {
                    Log.e(TAG, "Failed to inflate", e);
                    String pkg = null;
                    if (r.packageInfo != null && !TextUtils.isEmpty(r.packageInfo.getPackageName())) {
                        pkg = r.packageInfo.getPackageName();
                    }
                    Intent intent = new Intent(Intent.ACTION_APP_LAUNCH_FAILURE,
                            (pkg != null)? Uri.fromParts("package", pkg, null) : null);
                    getSystemContext().sendBroadcast(intent);
                    sendAppLaunchFailureBroadcast(r);
                } else if (e instanceof Resources.NotFoundException) {
                    Log.e(TAG, "Failed to find resource", e);
                    sendAppLaunchFailureBroadcast(r);
                }
                throw new RuntimeException(
                    "Unable to start activity " + component
@@ -2221,6 +2218,16 @@ public final class ActivityThread {
        return activity;
    }

    private void sendAppLaunchFailureBroadcast(ActivityClientRecord r) {
        String pkg = null;
        if (r.packageInfo != null && !TextUtils.isEmpty(r.packageInfo.getPackageName())) {
            pkg = r.packageInfo.getPackageName();
        }
        Intent intent = new Intent(Intent.ACTION_APP_LAUNCH_FAILURE,
                (pkg != null)? Uri.fromParts("package", pkg, null) : null);
        getSystemContext().sendBroadcast(intent);
    }

    private Context createBaseContextForActivity(ActivityClientRecord r,
            final Activity activity) {
        ContextImpl appContext = ContextImpl.createActivityContext(this, r.packageInfo, r.token);