private static void internalSetExtraInfo()

in alibabacloud-android-rum-sdk/src/main/java/com/alibabacloud/rum/AlibabaCloudRum.java [211:270]


    private static void internalSetExtraInfo(Map<String, Object> extraInfo, boolean user, boolean append) {
        if (null == extraInfo || extraInfo.isEmpty()) {
            return;
        }

        Map<String, Object> cachedExtraInfo = SingletonHolder.INSTANCE.cachedExtraInfo;
        //noinspection unchecked
        Map<String, Object> global = (Map<String, Object>)cachedExtraInfo.get(CUSTOM_ATTRIBUTES_PREFIX);
        if (null == global) {
            global = new LinkedHashMap<>();
        }

        if (!append) {
            Iterator<Entry<String, Object>> iterator = cachedExtraInfo.entrySet().iterator();
            while (iterator.hasNext()) {
                Entry<String, Object> next = iterator.next();
                if (null == next.getKey()) {
                    continue;
                }

                // keep SDK_VERSION_PREFIX
                if (SDK_VERSION_PREFIX.equals(next.getKey())) {
                    continue;
                }

                // keep SDK_FRAMEWORK
                if (SDK_FRAMEWORK.equals(next.getKey())) {
                    continue;
                }

                if (user) {
                    // in user attributes mode
                    // remove kv if is not global attributes
                    if (!next.getKey().equals(CUSTOM_ATTRIBUTES_PREFIX)) {
                        iterator.remove();
                    }
                } else {
                    // not in user attributes mode
                    // remove kv if is global attributes
                    if (next.getKey().equals(CUSTOM_ATTRIBUTES_PREFIX)) {
                        global.clear();
                        iterator.remove();
                    }
                }
            }
        }

        if (user) {
            cachedExtraInfo.putAll(extraInfo);
        } else {
            global.putAll(extraInfo);
        }

        if (!global.isEmpty()) {
            cachedExtraInfo.put(CUSTOM_ATTRIBUTES_PREFIX, global);
        }

        //noinspection deprecation
        OpenRum.setExtraInfo(cachedExtraInfo);
    }