Search in sources :

Example 1 with HSIconFileElement

use of com.android.anqp.HSIconFileElement in project platform_frameworks_base by android.

the class IconCache method startIconQuery.

public void startIconQuery(OSUInfo osuInfo, List<IconInfo> icons) {
    Log.d("ZXZ", String.format("Icon query on %012x for %s", osuInfo.getBSSID(), icons));
    if (icons == null || icons.isEmpty()) {
        return;
    }
    QuerySet querySet = new QuerySet(osuInfo, icons);
    for (QueryEntry entry : querySet.getAllEntries()) {
        HSIconFileElement iconElement = mCache.get(entry.getKey());
        if (iconElement != null) {
            osuInfo.setIconFileElement(iconElement, entry.getKey().getFileName());
            mOSUManager.iconResults(Arrays.asList(osuInfo));
            return;
        }
    }
    if (enqueue(querySet)) {
        initiateQuery(querySet.getBssid());
    }
}
Also used : HSIconFileElement(com.android.anqp.HSIconFileElement)

Example 2 with HSIconFileElement

use of com.android.anqp.HSIconFileElement in project android_frameworks_base by DirtyUnicorns.

the class IconCache method startIconQuery.

public void startIconQuery(OSUInfo osuInfo, List<IconInfo> icons) {
    Log.d("ZXZ", String.format("Icon query on %012x for %s", osuInfo.getBSSID(), icons));
    if (icons == null || icons.isEmpty()) {
        return;
    }
    QuerySet querySet = new QuerySet(osuInfo, icons);
    for (QueryEntry entry : querySet.getAllEntries()) {
        HSIconFileElement iconElement = mCache.get(entry.getKey());
        if (iconElement != null) {
            osuInfo.setIconFileElement(iconElement, entry.getKey().getFileName());
            mOSUManager.iconResults(Arrays.asList(osuInfo));
            return;
        }
    }
    if (enqueue(querySet)) {
        initiateQuery(querySet.getBssid());
    }
}
Also used : HSIconFileElement(com.android.anqp.HSIconFileElement)

Example 3 with HSIconFileElement

use of com.android.anqp.HSIconFileElement in project android_frameworks_base by DirtyUnicorns.

the class IconCache method notifyIconReceived.

public void notifyIconReceived(long bssid, String fileName, byte[] iconData) {
    Log.d("ZXZ", String.format("Icon '%s':%d received from %012x", fileName, iconData != null ? iconData.length : -1, bssid));
    IconKey key;
    HSIconFileElement iconFileElement = null;
    List<OSUInfo> updates = new ArrayList<>();
    LinkedList<QuerySet> querySets = mBssQueues.get(bssid);
    if (querySets == null || querySets.isEmpty()) {
        Log.d(OSUManager.TAG, String.format("Spurious icon response from %012x for '%s' (%d) bytes", bssid, fileName, iconData != null ? iconData.length : -1));
        Log.d("ZXZ", "query set: " + querySets + ", BSS queues: " + Utils.bssidsToString(mBssQueues.keySet()));
        return;
    } else {
        QuerySet querySet = querySets.removeFirst();
        if (iconData != null) {
            try {
                iconFileElement = new HSIconFileElement(HSIconFile, ByteBuffer.wrap(iconData).order(ByteOrder.LITTLE_ENDIAN));
            } catch (ProtocolException | BufferUnderflowException e) {
                Log.e(OSUManager.TAG, "Failed to parse ANQP icon file: " + e);
            }
        }
        key = querySet.updateIcon(fileName, iconFileElement);
        if (key == null) {
            Log.d(OSUManager.TAG, String.format("Spurious icon response from %012x for '%s' (%d) bytes", bssid, fileName, iconData != null ? iconData.length : -1));
            Log.d("ZXZ", "query set: " + querySets + ", BSS queues: " + Utils.bssidsToString(mBssQueues.keySet()));
            querySets.addFirst(querySet);
            return;
        }
        if (iconFileElement != null) {
            mCache.put(key, iconFileElement);
        }
        if (querySet.isEmpty()) {
            mBssQueues.remove(bssid);
        }
        updates.add(querySet.getOsuInfo());
    }
    // Update any other pending entries that matches the ESS of the currently resolved icon
    Iterator<Map.Entry<Long, LinkedList<QuerySet>>> bssIterator = mBssQueues.entrySet().iterator();
    while (bssIterator.hasNext()) {
        Map.Entry<Long, LinkedList<QuerySet>> bssEntries = bssIterator.next();
        Iterator<QuerySet> querySetIterator = bssEntries.getValue().iterator();
        while (querySetIterator.hasNext()) {
            QuerySet querySet = querySetIterator.next();
            if (querySet.updateIcon(key, iconFileElement)) {
                querySetIterator.remove();
                updates.add(querySet.getOsuInfo());
            }
        }
        if (bssEntries.getValue().isEmpty()) {
            bssIterator.remove();
        }
    }
    initiateQuery(bssid);
    mOSUManager.iconResults(updates);
}
Also used : ProtocolException(java.net.ProtocolException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HSIconFileElement(com.android.anqp.HSIconFileElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BufferUnderflowException(java.nio.BufferUnderflowException)

Example 4 with HSIconFileElement

use of com.android.anqp.HSIconFileElement in project android_frameworks_base by AOSPA.

the class IconCache method startIconQuery.

public void startIconQuery(OSUInfo osuInfo, List<IconInfo> icons) {
    Log.d("ZXZ", String.format("Icon query on %012x for %s", osuInfo.getBSSID(), icons));
    if (icons == null || icons.isEmpty()) {
        return;
    }
    QuerySet querySet = new QuerySet(osuInfo, icons);
    for (QueryEntry entry : querySet.getAllEntries()) {
        HSIconFileElement iconElement = mCache.get(entry.getKey());
        if (iconElement != null) {
            osuInfo.setIconFileElement(iconElement, entry.getKey().getFileName());
            mOSUManager.iconResults(Arrays.asList(osuInfo));
            return;
        }
    }
    if (enqueue(querySet)) {
        initiateQuery(querySet.getBssid());
    }
}
Also used : HSIconFileElement(com.android.anqp.HSIconFileElement)

Example 5 with HSIconFileElement

use of com.android.anqp.HSIconFileElement in project android_frameworks_base by ResurrectionRemix.

the class IconCache method notifyIconReceived.

public void notifyIconReceived(long bssid, String fileName, byte[] iconData) {
    Log.d("ZXZ", String.format("Icon '%s':%d received from %012x", fileName, iconData != null ? iconData.length : -1, bssid));
    IconKey key;
    HSIconFileElement iconFileElement = null;
    List<OSUInfo> updates = new ArrayList<>();
    LinkedList<QuerySet> querySets = mBssQueues.get(bssid);
    if (querySets == null || querySets.isEmpty()) {
        Log.d(OSUManager.TAG, String.format("Spurious icon response from %012x for '%s' (%d) bytes", bssid, fileName, iconData != null ? iconData.length : -1));
        Log.d("ZXZ", "query set: " + querySets + ", BSS queues: " + Utils.bssidsToString(mBssQueues.keySet()));
        return;
    } else {
        QuerySet querySet = querySets.removeFirst();
        if (iconData != null) {
            try {
                iconFileElement = new HSIconFileElement(HSIconFile, ByteBuffer.wrap(iconData).order(ByteOrder.LITTLE_ENDIAN));
            } catch (ProtocolException | BufferUnderflowException e) {
                Log.e(OSUManager.TAG, "Failed to parse ANQP icon file: " + e);
            }
        }
        key = querySet.updateIcon(fileName, iconFileElement);
        if (key == null) {
            Log.d(OSUManager.TAG, String.format("Spurious icon response from %012x for '%s' (%d) bytes", bssid, fileName, iconData != null ? iconData.length : -1));
            Log.d("ZXZ", "query set: " + querySets + ", BSS queues: " + Utils.bssidsToString(mBssQueues.keySet()));
            querySets.addFirst(querySet);
            return;
        }
        if (iconFileElement != null) {
            mCache.put(key, iconFileElement);
        }
        if (querySet.isEmpty()) {
            mBssQueues.remove(bssid);
        }
        updates.add(querySet.getOsuInfo());
    }
    // Update any other pending entries that matches the ESS of the currently resolved icon
    Iterator<Map.Entry<Long, LinkedList<QuerySet>>> bssIterator = mBssQueues.entrySet().iterator();
    while (bssIterator.hasNext()) {
        Map.Entry<Long, LinkedList<QuerySet>> bssEntries = bssIterator.next();
        Iterator<QuerySet> querySetIterator = bssEntries.getValue().iterator();
        while (querySetIterator.hasNext()) {
            QuerySet querySet = querySetIterator.next();
            if (querySet.updateIcon(key, iconFileElement)) {
                querySetIterator.remove();
                updates.add(querySet.getOsuInfo());
            }
        }
        if (bssEntries.getValue().isEmpty()) {
            bssIterator.remove();
        }
    }
    initiateQuery(bssid);
    mOSUManager.iconResults(updates);
}
Also used : ProtocolException(java.net.ProtocolException) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) HSIconFileElement(com.android.anqp.HSIconFileElement) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BufferUnderflowException(java.nio.BufferUnderflowException)

Aggregations

HSIconFileElement (com.android.anqp.HSIconFileElement)10 ProtocolException (java.net.ProtocolException)5 BufferUnderflowException (java.nio.BufferUnderflowException)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 LinkedList (java.util.LinkedList)5 Map (java.util.Map)5