速狼加速器 v1.3.05版本的 MD5 值为:16b5e8af5c3774d85c1aa8bd4f624d0b

以下内容为反编译后的 LocalDataManager.java 源代码,内容仅作参考


package com.lzz.youtu.network;

import com.lzz.youtu.App;
import com.lzz.youtu.AppControl;
import com.lzz.youtu.data.LogUtils;
import com.lzz.youtu.data.SharedPreferenceUtil;
import com.lzz.youtu.pojo.ProxyMode;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class LocalDataManager {
    private static LocalDataManager instance = new LocalDataManager();
    private Lock lock = new ReentrantLock();
    private Map<String, CacheDataItem> CacheMap = new HashMap();

    public enum ValueTyep {
        TypeBoolean,
        TypeInt,
        TypeLong,
        TypeString,
        TypeObject
    }

    public static LocalDataManager getInstance() {
        return instance;
    }

    private void onLoadObjectToCache(CacheKey cacheKey) {
        String string = SharedPreferenceUtil.getInstance(App.getAppContext()).getString(cacheKey.getKey(), cacheKey.strDefault);
        Object obj = null;
        if (string != null && !string.isEmpty() && cacheKey.packetName != null && !cacheKey.packetName.isEmpty()) {
            try {
                LogUtils.dLog(getClass().getSimpleName(), "[onLoadObjectToCache]: [packetname]:" + cacheKey.packetName + "[function name]:" + cacheKey.funcName);
                obj = Class.forName(cacheKey.packetName).getMethod(cacheKey.funcName, String.class).invoke(null, string);
            } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | VerifyError | InvocationTargetException unused) {
                LogUtils.eLog(getClass().getSimpleName(), "[onLoadObjectToCache]");
                string = null;
            }
        }
        updateCache(cacheKey, obj, string);
    }

    public void init() {
        for (CacheKey cacheKey : CacheKey.values()) {
            if (cacheKey.isWriteDisk) {
                try {
                    int i = AnonymousClass1.$SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[cacheKey.type.ordinal()];
                    if (i == 1) {
                        updateCache(cacheKey, Boolean.valueOf(SharedPreferenceUtil.getInstance(App.getAppContext()).getBoolean(cacheKey.getKey(), cacheKey.bDefault)), null);
                    } else if (i == 2) {
                        updateCache(cacheKey, Integer.valueOf(SharedPreferenceUtil.getInstance(App.getAppContext()).getInt(cacheKey.getKey(), cacheKey.iDefault)), null);
                    } else if (i == 3) {
                        updateCache(cacheKey, Long.valueOf(SharedPreferenceUtil.getInstance(App.getAppContext()).getLong(cacheKey.getKey(), Long.valueOf(cacheKey.lDefault))), null);
                    } else if (i == 4) {
                        updateCache(cacheKey, SharedPreferenceUtil.getInstance(App.getAppContext()).getString(cacheKey.getKey(), cacheKey.strDefault), null);
                    } else if (i == 5) {
                        LogUtils.dLog(getClass().getSimpleName(), "[init]: [key]:" + cacheKey.key + "[packet name]:" + cacheKey.packetName);
                        onLoadObjectToCache(cacheKey);
                    }
                } catch (Exception unused) {
                    LogUtils.eLog(getClass().getName(), "[init] error: [key]:" + cacheKey.key + "[packet name]:" + cacheKey.packetName);
                }
            }
        }
    }

    public static class AnonymousClass1 {
        static final int[] $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep;

        static {
            int[] iArr = new int[ValueTyep.values().length];
            $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep = iArr;
            try {
                iArr[ValueTyep.TypeBoolean.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[ValueTyep.TypeInt.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
            try {
                $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[ValueTyep.TypeLong.ordinal()] = 3;
            } catch (NoSuchFieldError unused3) {
            }
            try {
                $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[ValueTyep.TypeString.ordinal()] = 4;
            } catch (NoSuchFieldError unused4) {
            }
            try {
                $SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[ValueTyep.TypeObject.ordinal()] = 5;
            } catch (NoSuchFieldError unused5) {
            }
        }
    }

    private void updateCache(CacheKey cacheKey, Object obj, String str) {
        this.lock.lock();
        CacheDataItem cacheDataItem = this.CacheMap.get(cacheKey.getKey());
        if (cacheDataItem != null) {
            cacheDataItem.setValue(cacheKey.type, obj, str);
        } else {
            this.CacheMap.put(cacheKey.getKey(), new CacheDataItem(cacheKey.type, obj, str));
        }
        this.lock.unlock();
    }

    public void setData(CacheKey cacheKey, String str) {
        updateCache(cacheKey, str, null);
        if (cacheKey.isWriteDisk()) {
            if (str == null) {
                SharedPreferenceUtil.getInstance(App.getAppContext()).cleanData(cacheKey.getKey());
            } else {
                SharedPreferenceUtil.getInstance(App.getAppContext()).putString(cacheKey.getKey(), str);
            }
        }
    }

    public void setData(CacheKey cacheKey, int i) {
        updateCache(cacheKey, Integer.valueOf(i), null);
        if (cacheKey.isWriteDisk()) {
            SharedPreferenceUtil.getInstance(App.getAppContext()).putInt(cacheKey.getKey(), i);
        }
    }

    public void setData(CacheKey cacheKey, boolean z) {
        updateCache(cacheKey, Boolean.valueOf(z), null);
        if (cacheKey.isWriteDisk()) {
            SharedPreferenceUtil.getInstance(App.getAppContext()).putBoolean(cacheKey.getKey(), z);
        }
    }

    public void setData(CacheKey cacheKey, long j) {
        updateCache(cacheKey, Long.valueOf(j), null);
        if (cacheKey.isWriteDisk()) {
            SharedPreferenceUtil.getInstance(App.getAppContext()).putLong(cacheKey.getKey(), j);
        }
    }

    public void setData(CacheKey cacheKey, Object obj, String str) {
        updateCache(cacheKey, obj, str);
        if (cacheKey.isWriteDisk()) {
            if (str == null) {
                SharedPreferenceUtil.getInstance(App.getAppContext()).cleanData(cacheKey.getKey());
            } else {
                SharedPreferenceUtil.getInstance(App.getAppContext()).putString(cacheKey.getKey(), str);
            }
        }
    }

    private CacheDataItem getItem(CacheKey cacheKey) {
        this.lock.lock();
        CacheDataItem cacheDataItem = this.CacheMap.get(cacheKey.getKey());
        this.lock.unlock();
        return cacheDataItem;
    }

    public boolean getBoolean(CacheKey cacheKey) {
        CacheDataItem item = getItem(cacheKey);
        if (item == null) {
            return cacheKey.bDefault;
        }
        return item.bValue;
    }

    public int getInt(CacheKey cacheKey) {
        CacheDataItem item = getItem(cacheKey);
        if (item == null) {
            return cacheKey.iDefault;
        }
        return item.iValue;
    }

    public long getLong(CacheKey cacheKey) {
        CacheDataItem item = getItem(cacheKey);
        if (item == null) {
            return cacheKey.lDefault;
        }
        return item.lValue;
    }

    public String getString(CacheKey cacheKey) {
        CacheDataItem item = getItem(cacheKey);
        if (item == null) {
            return cacheKey.strDefault;
        }
        return item.strValue;
    }

    public Object getObject(CacheKey cacheKey) {
        CacheDataItem item = getItem(cacheKey);
        if (item == null) {
            return cacheKey.oDefault;
        }
        return item.oValue;
    }

    public enum CacheKey {
        DEVICE_ID("device_id", true, "", ValueTyep.TypeString, null, null),
        DEFAULT_NODE("default_node", true, null, ValueTyep.TypeObject, "com.lzz.youtu.pojo.Nodes$NodeBean", "stringToObject"),
        AD_CONFIG("ad_config", true, null, ValueTyep.TypeObject, "com.lzz.youtu.pojo.UserInfo$AdvertisementInfo", "stringToObject"),
        NODE_DYNAMIC_DATA("node_dynamic_data", true, null, ValueTyep.TypeObject, "com.lzz.youtu.pojo.NodeDynamicData", "stringToObject"),
        NODE_BETTWEEN_DATA("node_bettween_data", true, null, ValueTyep.TypeObject, "com.lzz.youtu.CacheStruct.NodeBettweenData", "stringToObject"),
        NODE_BETTWEEN_DATA_TIME("node_bettween_data_time", true, 0, ValueTyep.TypeLong, null, null),
        NODE_BETTWEEN_LOAD_TIME("node_bettween_load_time", true, 0, ValueTyep.TypeLong, null, null),
        NODE_LIST("node_list", true, null, ValueTyep.TypeObject, "com.lzz.youtu.CacheStruct.NodeListInfo", "stringToObject"),
        LOGIN_MODE("login_mode", true, Integer.valueOf(AppControl.LoginMode.INIT_LOGIN.ordinal()), ValueTyep.TypeInt, null, null),
        CHOSE_NODE("chose_node", true, null, ValueTyep.TypeString, null, null),
        CHOSE_NODE_SUPER("chose_node_super", true, -1, ValueTyep.TypeInt, null, null),
        SOURCE_VERSION("source_version", true, null, ValueTyep.TypeString, null, null),
        ICON_VERSION("icon_version", true, null, ValueTyep.TypeString, null, null),
        FIRST_OPEN("first_open", true, false, ValueTyep.TypeBoolean, null, null),
        HIDE_SYSTEM_APP("Hide_system_app", true, true, ValueTyep.TypeBoolean, null, null),
        AD_CONFIG_VERSION("ad_config_version", true, null, ValueTyep.TypeString, null, null),
        AD_CONFIG_KEY("ad_config_key", true, null, ValueTyep.TypeString, null, null),
        DEVICE_NAME("device_name", true, null, ValueTyep.TypeString, null, null),
        LOGIN_COUNT("login_count", true, 0, ValueTyep.TypeInt, null, null),
        SHARE_COUNT("share_count", true, 0, ValueTyep.TypeInt, null, null),
        SHARE_URL("share_url", true, null, ValueTyep.TypeString, null, null),
        BANNER_INFO("banner_info", true, null, ValueTyep.TypeString, null, null),
        NOTICE_INFO("notice_info", true, 0, ValueTyep.TypeObject, "com.lzz.youtu.pojo.UserInfo$Notice", "stringToListObject"),
        USER_INFO("user_info", true, null, ValueTyep.TypeObject, "com.lzz.youtu.pojo.UserInfo", "stringToObject"),
        MAIN_PAGE("main_page", true, true, ValueTyep.TypeBoolean, null, null),
        IS_SEND_FOR_UPDATE("is_send_for_update", true, false, ValueTyep.TypeBoolean, null, null),
        PRIVACY("privacy", true, false, ValueTyep.TypeBoolean, null, null),
        ISSIGNIN("signin", true, false, ValueTyep.TypeBoolean, null, null),
        ISSHARE("isShare", true, false, ValueTyep.TypeBoolean, null, null),
        H5RESOURCE_KYE("h5resource_key", true, null, ValueTyep.TypeString, null, null),
        BIND_PHONE("bind_phone", true, null, ValueTyep.TypeString, null, null),
        BIND_EMAIL("bind_emial", true, null, ValueTyep.TypeString, null, null),
        PROXY_MODE("proxy_mode", true, Integer.valueOf(ProxyMode.ALL.ordinal()), ValueTyep.TypeInt, null, null),
        PROXY_APPS("proxy_apps_list", true, "", ValueTyep.TypeString, null, null),
        APPS_RECORD("apps_record", true, "", ValueTyep.TypeObject, "com.lzz.youtu.CacheStruct.AppListRecord", "stringToObject"),
        FEEDBACK_TITLE("feedbakc_title", true, null, ValueTyep.TypeString, null, null),
        HOME_PAGE("hame_page", true, "http://www.youtuvpn.com", ValueTyep.TypeString, null, null),
        APP_VERSION("app_version", true, null, ValueTyep.TypeString, null, null),
        FIRST_TIME_LAUNCH("first_time_launch", true, true, ValueTyep.TypeBoolean, null, null),
        ADD_SHOW_TODAY("add_show_today", true, null, ValueTyep.TypeString, null, null),
        PURCHASE_PRODUCT_DATA("purchase_product", true, null, ValueTyep.TypeString, null, null),
        CUSTOMER_CONFIG("customer_config", true, null, ValueTyep.TypeObject, "com.lzz.youtu.CacheStruct.CustomerConfig", "stringToObject"),
        IS_LOGIN("is_login", false, false, ValueTyep.TypeBoolean, null, null),
        H5RESOURCE_DATA("h5resource_data", false, null, ValueTyep.TypeObject, null, null),
        USER_GET_PLANS("user_get_plans", false, null, ValueTyep.TypeObject, null, null),
        JS_CONTEXT_MAP("h5_request_map", false, null, ValueTyep.TypeObject, null, null),
        VPN_CONFIG_GLOBAL("vpn_config_global", false, null, ValueTyep.TypeObject, null, null),
        VPN_PRO_FILE("vpn_pro_file", false, null, ValueTyep.TypeObject, null, null),
        NORMAL_ANIMATION_STATUS("normalAnimationStatus", false, 6, ValueTyep.TypeInt, null, null),
        SUPER_ANIMATION_STATUS("superAnimationStatus", false, 6, ValueTyep.TypeInt, null, null),
        VPN_SETTING_TIP_COUNT("vpn_setting_tip_count", true, 0, ValueTyep.TypeInt, null, null),
        NORMAl_ANIMATION_DATA("normal_animation_data", false, null, ValueTyep.TypeObject, null, null),
        SUPER_ANIMATION_DATA("super_animation_data", false, null, ValueTyep.TypeObject, null, null),
        APP_UPDATE_LAST_PACKET("app_update_last_packet", true, null, ValueTyep.TypeString, null, null),
        AD_CLICK_LAST_PACKET("ad_click_last_packet", true, null, ValueTyep.TypeString, null, null),
        VPN_CONNECTED_CLOCK_TIME("vpn_connected_clock_time", true, "0", ValueTyep.TypeString, null, null),
        IS_recycled("is_recycled", true, false, ValueTyep.TypeBoolean, null, null),
        USER_ORDER_HISTORY("user_order_history", false, null, ValueTyep.TypeObject, null, null),
        USER_GET_POINT_HISTORY("user_get_point_history", false, null, ValueTyep.TypeObject, null, null),
        USER_GET_EXCHANGE_PLANS("user_get_exchange_plan", false, null, ValueTyep.TypeObject, null, null);

        private boolean bDefault;
        private String funcName;
        private int iDefault;
        private boolean isWriteDisk;
        private String key;
        private long lDefault;
        private Object oDefault;
        private String packetName;
        private String strDefault;
        private ValueTyep type;

        CacheKey(String str, boolean z, Object obj, ValueTyep valueTyep, String str2, String str3) {
            this.key = str;
            this.isWriteDisk = z;
            this.type = valueTyep;
            this.packetName = str2;
            this.funcName = str3;
            int i = AnonymousClass1.$SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[valueTyep.ordinal()];
            if (i == 1) {
                this.bDefault = ((Boolean) obj).booleanValue();
                return;
            }
            if (i == 2) {
                this.iDefault = ((Integer) obj).intValue();
            } else if (i == 4) {
                this.strDefault = (String) obj;
            } else {
                if (i != 5) {
                    return;
                }
                this.oDefault = obj;
            }
        }

        public final String getKey() {
            return this.key;
        }

        public boolean isWriteDisk() {
            return this.isWriteDisk;
        }

        public ValueTyep getValueType() {
            return this.type;
        }

        public String getPacketName() {
            return this.packetName;
        }
    }

    public class CacheDataItem {
        private boolean bValue;
        private int iValue;
        private long lValue;
        private Object oValue;
        private String strValue;
        private ValueTyep type;

        public CacheDataItem(ValueTyep valueTyep, Object obj, String str) {
            setValue(valueTyep, obj, str);
        }

        public void setValue(ValueTyep valueTyep, Object obj, String str) {
            this.type = valueTyep;
            int i = AnonymousClass1.$SwitchMap$com$lzz$youtu$network$LocalDataManager$ValueTyep[valueTyep.ordinal()];
            if (i == 1) {
                this.bValue = ((Boolean) obj).booleanValue();
                return;
            }
            if (i == 2) {
                this.iValue = ((Integer) obj).intValue();
                return;
            }
            if (i == 3) {
                this.lValue = ((Long) obj).longValue();
                return;
            }
            if (i == 4) {
                this.strValue = (String) obj;
            } else {
                if (i != 5) {
                    return;
                }
                this.oValue = obj;
                this.strValue = str;
            }
        }
    }
}