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

Commit 3bea6d47 authored by Jonathan Klee's avatar Jonathan Klee
Browse files

refactor: make sure updateAppWidget is not called twice at the same time

Sentry has weird NullPointException & ArrayIndexOutOfBoundsException.

Since a lot of stuffs are done in the BroadcastReceiver.onReceived()
callback and it could be called twice quite fast, let's make sure it
is a least thread safe.
parent ebc25cf6
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ public class EDriveWidget extends AppWidgetProvider {
        return convertedData;
    }

    public void updateAppWidget(@NonNull final Context context) {
    public synchronized void updateAppWidget(@NonNull final Context context) {
        final AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        final ComponentName provider = new ComponentName(context, getClass());
        int[] appWidgetIds = appWidgetManager.getAppWidgetIds(provider);
@@ -113,7 +113,7 @@ public class EDriveWidget extends AppWidgetProvider {
        }
    }

    public void updateAppWidget(@NonNull final Context context, @NonNull final AppWidgetManager appWidgetManager,
    private void updateAppWidget(@NonNull final Context context, @NonNull final AppWidgetManager appWidgetManager,
                                final int appWidgetId) {
        final AccountManager accountManager = AccountManager.get(context);