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

Commit 791f8774 authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Logging to help find the cause of widget crash in clock widget.

This will continue to crash as before, but will show some useful
information in the exception.

Bug: 7450247

Change-Id: Ib3160a5f64154517791d165973c12294ecd09901
parent 18bbcf7f
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -336,6 +336,7 @@ class AppWidgetServiceImpl {
                pw.print(info.autoAdvanceViewId);
                pw.print(" initialLayout=#");
                pw.print(Integer.toHexString(info.initialLayout));
                pw.print(" uid="); pw.print(p.uid);
                pw.print(" zombie="); pw.println(p.zombie);
    }

@@ -699,6 +700,10 @@ class AppWidgetServiceImpl {
            }

            int userId = UserHandle.getUserId(id.provider.uid);
            if (userId != mUserId) {
                Slog.w(TAG, "AppWidgetServiceImpl of user " + mUserId
                        + " binding to provider on user " + userId);
            }
            // Bind to the RemoteViewsService (which will trigger a callback to the
            // RemoteViewsAdapter.onServiceConnected())
            final long token = Binder.clearCallingIdentity();
@@ -966,6 +971,13 @@ class AppWidgetServiceImpl {
            ensureStateLoadedLocked();
            for (int i = 0; i < N; i++) {
                AppWidgetId id = lookupAppWidgetIdLocked(appWidgetIds[i]);
                if (id == null) {
                    String message = "AppWidgetId NPE: mUserId=" + mUserId
                            + ", callingUid=" + Binder.getCallingUid()
                            + ", appWidgetIds[i]=" + appWidgetIds[i]
                            + "\n  mAppWidgets:\n" + getUserWidgets();
                    throw new NullPointerException(message);
                }
                if (id.views != null) {
                    // Only trigger a partial update for a widget if it has received a full update
                    updateAppWidgetInstanceLocked(id, views, true);
@@ -974,6 +986,18 @@ class AppWidgetServiceImpl {
        }
    }

    private String getUserWidgets() {
        StringBuffer sb = new StringBuffer();
        for (AppWidgetId widget: mAppWidgetIds) {
            sb.append("    id="); sb.append(widget.appWidgetId);
            sb.append(", hostUid="); sb.append(widget.host.uid);
            sb.append(", provider="); sb.append(widget.provider.info.provider.toString());
            sb.append("\n");
        }
        sb.append("\n");
        return sb.toString();
    }

    public void notifyAppWidgetViewDataChanged(int[] appWidgetIds, int viewId) {
        if (appWidgetIds == null) {
            return;