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

Commit 76d88483 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Don't synchronize two objects at same time."

parents 77b0ed2d 5d357bc2
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;
    }