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

Commit 23d28cec authored by Shibin George's avatar Shibin George
Browse files

Synchronize access of mSubscriptions

Introduction of setConfigAsync to set Zen mode config
asynchronously leads to synchronization issues like
ArrayIndexOutOfBoundsException while accessing mSubscriptions.

Change-Id: I6f72d894605498e0a4b48eb58af19851be53b9dc
parent 9f2a1979
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -76,6 +76,8 @@ public class ZenModeConditions implements ConditionProviders.Callback {
            evaluateRule(automaticRule, current, processSubscriptions);
            updateSnoozing(automaticRule);
        }

        synchronized (mSubscriptions) {
            final int N = mSubscriptions.size();
            for (int i = N - 1; i >= 0; i--) {
                final Uri id = mSubscriptions.keyAt(i);
@@ -87,6 +89,7 @@ public class ZenModeConditions implements ConditionProviders.Callback {
                    }
                }
            }
        }
        mFirstEvaluation = false;
    }

@@ -152,7 +155,9 @@ public class ZenModeConditions implements ConditionProviders.Callback {
        }
        if (processSubscriptions) {
            if (mConditionProviders.subscribeIfNecessary(rule.component, rule.conditionId)) {
                synchronized (mSubscriptions) {
                    mSubscriptions.put(rule.conditionId, rule.component);
                }
            } else {
                if (DEBUG) Log.d(TAG, "zmc failed to subscribe");
            }