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

Commit 323ef915 authored by Julia Tuttle's avatar Julia Tuttle
Browse files

PeopleSpaceWidgetManager: log slightly more

We're seeing a weird probelm where Conversation widgets are still
showing content even though the relevant notifications have been
dismissed.

I'm currently assuming that the widget is failing to update for some
reason when the notification is dismissed.

This change logs all the warnings and errors in PeopleSpaceWidgetManager
unconditionally, and includes the widget ID in all of them. Hopefully
this will give us a clue what's going wrong when the notification is
dismissed.

Bug: 230268718
Test: manual; errors logged trying to add widget with no convo notifs
Change-Id: Ie7fdf91dccbb4b02ba4b9ffa9e20ec758abb96b9
parent 48bab40d
Loading
Loading
Loading
Loading
+14 −16
Original line number Original line Diff line number Diff line
@@ -289,7 +289,7 @@ public class PeopleSpaceWidgetManager {
            if (DEBUG) Log.d(TAG, "Updating widget: " + appWidgetId);
            if (DEBUG) Log.d(TAG, "Updating widget: " + appWidgetId);
            PeopleSpaceTile tile = getTileForExistingWidget(appWidgetId);
            PeopleSpaceTile tile = getTileForExistingWidget(appWidgetId);
            if (tile == null) {
            if (tile == null) {
                Log.e(TAG, "Matching conversation not found for shortcut ID");
                Log.e(TAG, "Matching conversation not found for widget " + appWidgetId);
            }
            }
            updateAppWidgetOptionsAndView(appWidgetId, tile);
            updateAppWidgetOptionsAndView(appWidgetId, tile);
            widgetIdToTile.put(appWidgetId, tile);
            widgetIdToTile.put(appWidgetId, tile);
@@ -308,7 +308,7 @@ public class PeopleSpaceWidgetManager {
        if (DEBUG) Log.d(TAG, "Widget: " + appWidgetId + " for: " + key.toString());
        if (DEBUG) Log.d(TAG, "Widget: " + appWidgetId + " for: " + key.toString());


        if (!PeopleTileKey.isValid(key)) {
        if (!PeopleTileKey.isValid(key)) {
            Log.e(TAG, "Cannot update invalid widget");
            Log.e(TAG, "Invalid tile key updating widget " + appWidgetId);
            return;
            return;
        }
        }
        RemoteViews views = PeopleTileViewHelper.createRemoteViews(mContext, tile, appWidgetId,
        RemoteViews views = PeopleTileViewHelper.createRemoteViews(mContext, tile, appWidgetId,
@@ -330,7 +330,7 @@ public class PeopleSpaceWidgetManager {
    /** Updates tile in app widget options and the current view. */
    /** Updates tile in app widget options and the current view. */
    public void updateAppWidgetOptionsAndView(int appWidgetId, PeopleSpaceTile tile) {
    public void updateAppWidgetOptionsAndView(int appWidgetId, PeopleSpaceTile tile) {
        if (tile == null) {
        if (tile == null) {
            if (DEBUG) Log.w(TAG, "Storing null tile");
            Log.w(TAG, "Storing null tile for widget " + appWidgetId);
        }
        }
        synchronized (mTiles) {
        synchronized (mTiles) {
            mTiles.put(appWidgetId, tile);
            mTiles.put(appWidgetId, tile);
@@ -348,7 +348,7 @@ public class PeopleSpaceWidgetManager {
        try {
        try {
            return getTileForExistingWidgetThrowing(appWidgetId);
            return getTileForExistingWidgetThrowing(appWidgetId);
        } catch (Exception e) {
        } catch (Exception e) {
            Log.e(TAG, "failed to retrieve tile for widget ID " + appWidgetId, e);
            Log.e(TAG, "failed to retrieve tile for existing widget " + appWidgetId, e);
            return null;
            return null;
        }
        }
    }
    }
@@ -388,7 +388,7 @@ public class PeopleSpaceWidgetManager {
            boolean supplementFromStorage) throws
            boolean supplementFromStorage) throws
            PackageManager.NameNotFoundException {
            PackageManager.NameNotFoundException {
        if (!PeopleTileKey.isValid(key)) {
        if (!PeopleTileKey.isValid(key)) {
            Log.e(TAG, "PeopleTileKey invalid: " + key.toString());
            Log.e(TAG, "Invalid tile key finding tile for existing widget " + appWidgetId);
            return null;
            return null;
        }
        }


@@ -423,7 +423,7 @@ public class PeopleSpaceWidgetManager {
            // Add current state.
            // Add current state.
            return getTileWithCurrentState(storedTile.build(), ACTION_BOOT_COMPLETED);
            return getTileWithCurrentState(storedTile.build(), ACTION_BOOT_COMPLETED);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            Log.e(TAG, "getTileFromPersistentStorage failing", e);
            Log.e(TAG, "getTileFromPersistentStorage failing for widget " + appWidgetId, e);
            return null;
            return null;
        }
        }
    }
    }
@@ -591,10 +591,7 @@ public class PeopleSpaceWidgetManager {
        if (DEBUG) Log.d(TAG, "Augmenting tile for existing widget: " + widgetId);
        if (DEBUG) Log.d(TAG, "Augmenting tile for existing widget: " + widgetId);
        PeopleSpaceTile tile = getTileForExistingWidget(widgetId);
        PeopleSpaceTile tile = getTileForExistingWidget(widgetId);
        if (tile == null) {
        if (tile == null) {
            if (DEBUG) {
            Log.w(TAG, "Null tile for existing widget " + widgetId + ", skipping update.");
                Log.w(TAG, "Widget: " + widgetId
                        + ". Null tile for existing widget, skipping update.");
            }
            return Optional.empty();
            return Optional.empty();
        }
        }
        String contactUriString = mSharedPrefs.getString(String.valueOf(widgetId), null);
        String contactUriString = mSharedPrefs.getString(String.valueOf(widgetId), null);
@@ -816,7 +813,7 @@ public class PeopleSpaceWidgetManager {
            tile = getTileFromPersistentStorage(key, appWidgetId,  /* supplementFromStorage= */
            tile = getTileFromPersistentStorage(key, appWidgetId,  /* supplementFromStorage= */
                    false);
                    false);
        } catch (PackageManager.NameNotFoundException e) {
        } catch (PackageManager.NameNotFoundException e) {
            Log.e(TAG, "Cannot add widget since app was uninstalled");
            Log.e(TAG, "Cannot add widget " + appWidgetId + " since app was uninstalled");
            return;
            return;
        }
        }
        if (tile == null) {
        if (tile == null) {
@@ -851,7 +848,7 @@ public class PeopleSpaceWidgetManager {
                    Collections.singletonList(tile.getId()),
                    Collections.singletonList(tile.getId()),
                    tile.getUserHandle(), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS);
                    tile.getUserHandle(), LauncherApps.FLAG_CACHE_PEOPLE_TILE_SHORTCUTS);
        } catch (Exception e) {
        } catch (Exception e) {
            Log.w(TAG, "failed to cache shortcut", e);
            Log.w(TAG, "failed to cache shortcut for widget " + appWidgetId, e);
        }
        }
        PeopleSpaceTile finalTile = tile;
        PeopleSpaceTile finalTile = tile;
        mBgExecutor.execute(
        mBgExecutor.execute(
@@ -862,7 +859,7 @@ public class PeopleSpaceWidgetManager {
    public void registerConversationListenerIfNeeded(int widgetId, PeopleTileKey key) {
    public void registerConversationListenerIfNeeded(int widgetId, PeopleTileKey key) {
        // Retrieve storage needed for registration.
        // Retrieve storage needed for registration.
        if (!PeopleTileKey.isValid(key)) {
        if (!PeopleTileKey.isValid(key)) {
            if (DEBUG) Log.w(TAG, "Could not register listener for widget: " + widgetId);
            Log.w(TAG, "Invalid tile key registering listener for widget " + widgetId);
            return;
            return;
        }
        }
        TileConversationListener newListener = new TileConversationListener();
        TileConversationListener newListener = new TileConversationListener();
@@ -911,7 +908,7 @@ public class PeopleSpaceWidgetManager {
                        widgetSp.getInt(USER_ID, INVALID_USER_ID),
                        widgetSp.getInt(USER_ID, INVALID_USER_ID),
                        widgetSp.getString(PACKAGE_NAME, null));
                        widgetSp.getString(PACKAGE_NAME, null));
                if (!PeopleTileKey.isValid(key)) {
                if (!PeopleTileKey.isValid(key)) {
                    if (DEBUG) Log.e(TAG, "Could not delete " + widgetId);
                    Log.e(TAG, "Invalid tile key trying to remove widget " + widgetId);
                    return;
                    return;
                }
                }
                storedWidgetIdsForKey = new HashSet<>(
                storedWidgetIdsForKey = new HashSet<>(
@@ -1083,7 +1080,8 @@ public class PeopleSpaceWidgetManager {
                synchronized (mLock) {
                synchronized (mLock) {
                    existingTile = getTileForExistingWidgetThrowing(appWidgetId);
                    existingTile = getTileForExistingWidgetThrowing(appWidgetId);
                    if (existingTile == null) {
                    if (existingTile == null) {
                        Log.e(TAG, "Matching conversation not found for shortcut ID");
                        Log.e(TAG, "Matching conversation not found for widget "
                                + appWidgetId);
                        continue;
                        continue;
                    }
                    }
                    updatedTile = getTileWithCurrentState(existingTile, entryPoint);
                    updatedTile = getTileWithCurrentState(existingTile, entryPoint);
@@ -1091,7 +1089,7 @@ public class PeopleSpaceWidgetManager {
                }
                }
            } catch (PackageManager.NameNotFoundException e) {
            } catch (PackageManager.NameNotFoundException e) {
                // Delete data for uninstalled widgets.
                // Delete data for uninstalled widgets.
                Log.e(TAG, "package no longer found for tile", e);
                Log.e(TAG, "Package no longer found for widget " + appWidgetId, e);
                JobScheduler jobScheduler = mContext.getSystemService(JobScheduler.class);
                JobScheduler jobScheduler = mContext.getSystemService(JobScheduler.class);
                if (jobScheduler != null
                if (jobScheduler != null
                        && jobScheduler.getPendingJob(PeopleBackupFollowUpJob.JOB_ID) != null) {
                        && jobScheduler.getPendingJob(PeopleBackupFollowUpJob.JOB_ID) != null) {