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

Commit c26aa7cf authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

Themes: Watch all app crashes for problematic themes

Only watching for exceptions that occur during an apps launch may
not be sufficient to catch possible bad themes causing issues.
This patch monitors all app crashes and broadcasts that there was
a crash if either Resources.NotFoundException or InflateException
are thrown.  The remaining logic is the same as when an app launch
failure occurred.

We also display a notification to the user so that they know why
their theme was reset to the system theme.

Change-Id: I0761d02587b5b81deee4a31a89f515dbc7cc5fe6
parent a4ee5697
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -2428,13 +2428,6 @@ public final class ActivityThread {

        } catch (Exception e) {
            if (!mInstrumentation.onException(activity, e)) {
                if (e instanceof InflateException) {
                    Log.e(TAG, "Failed to inflate", e);
                    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
                    + ": " + e.toString(), e);
@@ -2449,7 +2442,7 @@ public final class ActivityThread {
        if (r.packageInfo != null && !TextUtils.isEmpty(r.packageInfo.getPackageName())) {
            pkg = r.packageInfo.getPackageName();
        }
        Intent intent = new Intent(Intent.ACTION_APP_LAUNCH_FAILURE,
        Intent intent = new Intent(Intent.ACTION_APP_FAILURE,
                (pkg != null)? Uri.fromParts("package", pkg, null) : null);
        getSystemContext().sendBroadcast(intent);
    }
+4 −2
Original line number Diff line number Diff line
@@ -2846,13 +2846,15 @@ public class Intent implements Parcelable, Cloneable {
     * Could indicate that curently applied theme is malicious.
     * @hide
     */
    public static final String ACTION_APP_LAUNCH_FAILURE = "com.tmobile.intent.action.APP_LAUNCH_FAILURE";
    public static final String ACTION_APP_FAILURE =
            "com.tmobile.intent.action.APP_FAILURE";

    /**
     * Broadcast Action: Request to reset the unrecoverable errors count to 0.
     * @hide
     */
    public static final String ACTION_APP_LAUNCH_FAILURE_RESET = "com.tmobile.intent.action.APP_LAUNCH_FAILURE_RESET";
    public static final String ACTION_APP_FAILURE_RESET =
            "com.tmobile.intent.action.APP_FAILURE_RESET";

    /**
     * Activity Action: Shows the brightness setting dialog.
+3 −3
Original line number Diff line number Diff line
@@ -2954,10 +2954,10 @@
            </intent-filter>
        </receiver>

        <receiver android:name="com.android.server.AppsLaunchFailureReceiver" >
        <receiver android:name="com.android.server.AppsFailureReceiver" >
            <intent-filter>
                <action android:name="com.tmobile.intent.action.APP_LAUNCH_FAILURE" />
                <action android:name="com.tmobile.intent.action.APP_LAUNCH_FAILURE_RESET" />
                <action android:name="com.tmobile.intent.action.APP_FAILURE" />
                <action android:name="com.tmobile.intent.action.APP_FAILURE_RESET" />
                <action android:name="android.intent.action.PACKAGE_ADDED" />
                <action android:name="android.intent.action.PACKAGE_REMOVED" />
                <action android:name="org.cyanogenmod.intent.action.THEME_CHANGED" />
+2 −0
Original line number Diff line number Diff line
@@ -133,4 +133,6 @@
    <!-- stylus gestures support -->
    <string name="stylus_app_not_installed">%s is not installed</string>

    <string name="theme_reset_notification_title">Theme reset</string>
    <string name="theme_reset_notification_body">System theme restored due to multiple app crashes.</string>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -71,4 +71,7 @@
    <java-symbol type="bool" name="config_stylusGestures" />
    <java-symbol type="string" name="stylus_app_not_installed" />

    <!-- Theme reset notification -->
    <java-symbol type="string" name="theme_reset_notification_title" />
    <java-symbol type="string" name="theme_reset_notification_body" />
</resources>
Loading