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

Commit b0bc8507 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 am: 0c7f874b am: becb3c6a

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

Change-Id: Id0bb39ecec4ee91086d8478533accd7a9e860a7e
parents d1580db4 becb3c6a
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -225,12 +225,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();
@@ -238,6 +239,9 @@ import java.util.UUID;
                }
            }
        }
        if (find) {
            removeConnectionsByAppId(id);
        }
    }

    List<Integer> getAllAppsIds() {
@@ -400,14 +404,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;
    }