Fix NPE when removing widgets
The issue happened when removing a user-selected widget, as `deleteWidget()` handles removing from both DB and AppWidgetHost. Then `onAppWidgetRemoved()` callback repetitively calls `deleteWidget()` trying to remove from DB and widget host again. - Separate the call to delete a widget from widget host and DB. Let CommunalAppWidgetHost manages deleting from DB for both uninstalled or user-selected widget, following the deletion from widget host. - In CommunalWidgetDAO#deleteWidgetById, added a null check on the entry that is queried. Returns false if no entry exists to be deleted. Bug: b/323057545 Test: atest CommunalWidgetRepositoryImplTest Test: atest CommunalWidgetDaoTest Test: atest CommunalEditModeViewModelTest Flag: ACONFIG com.android.systemui.communal_hub DEVELOPMENT Change-Id: I6a9b8f8605f22b08a447acf8d7747519fc6e3f81
Loading
Please register or sign in to comment