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

Commit 0c7f874b authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Don't synchronize two objects at same time." am: 11cea5d9

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1679755

Change-Id: I6b5bfcc22f03731ee8b46b5de85c85e5dced226d
parents 20d173f0 11cea5d9
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -222,12 +222,13 @@ import java.util.UUID;
     * Remove the context for a given application ID.
     */
    void remove(int id) {
        boolean find = false;
        synchronized (mApps) {
            Iterator<App> i = mApps.iterator();
            while (i.hasNext()) {
                App entry = i.next();
                if (entry.id == id) {
                    removeConnectionsByAppId(id);
                    find = true;
                    entry.unlinkToDeath();
                    entry.appScanStats.isRegistered = false;
                    i.remove();
@@ -235,6 +236,9 @@ import java.util.UUID;
                }
            }
        }
        if (find) {
            removeConnectionsByAppId(id);
        }
    }

    List<Integer> getAllAppsIds() {
@@ -397,14 +401,19 @@ import java.util.UUID;
     * Get an application context by a connection ID.
     */
    App getByConnId(int connId) {
        int appId = -1;
        synchronized (mConnections) {
            Iterator<Connection> ii = mConnections.iterator();
            while (ii.hasNext()) {
                Connection connection = ii.next();
                if (connection.connId == connId) {
                    return getById(connection.appId);
                    appId = connection.appId;
                    break;
                }
            }
        }
        if (appId >= 0) {
            return getById(appId);
        }
        return null;
    }