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

Commit 283159d1 authored by Michael W's avatar Michael W
Browse files

SystemUI: KeyGuardMonitor: Prevent ConcurrentModificationException

* Instead of accessing the original ArrayList, which might be modified
  while processing the loop, create a copy of the list and work with that
  one
* This ensures that no exception is thrown when some other part unregisters
  its listener while the list is already being processed

BUGBASH-1289

Change-Id: Ie8404d88c7c87c4ec8fcd64fdd5218b25806f24f
parent 612b8472
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 * Copyright (C) 2017 The LineageOS Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
@@ -127,7 +128,8 @@ public final class KeyguardMonitor extends KeyguardUpdateMonitorCallback {
    }

    private void notifyKeyguardChanged() {
        for (Callback callback : mCallbacks) {
        ArrayList<Callback> callbacks = new ArrayList<Callback>(mCallbacks);
        for (Callback callback : callbacks) {
            callback.onKeyguardChanged();
        }
    }