导航菜单

页面标题

页面副标题

Handling Master v2 - PresetPropertiesUtil.java 源代码

正在查看: Handling Master v2 应用的 PresetPropertiesUtil.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.reyun.solar.engine.utils.store;

import android.content.Context;
import com.reyun.solar.engine.Global;
import com.reyun.solar.engine.infos.DeviceInfo;
import com.reyun.solar.engine.infos.UserInfo;
import com.reyun.solar.engine.utils.Command;
import com.reyun.solar.engine.utils.Objects;
import org.json.JSONException;
import org.json.JSONObject;

public class PresetPropertiesUtil {
    public static String getAdid(DeviceInfo deviceInfo) {
        String adid = Objects.isNotNull(deviceInfo) ? deviceInfo.getAdid() : null;
        return Objects.isEmpty(adid) ? SPUtils.getString(Command.SPKEY.ADID, "") : adid;
    }

    public static String getAndroidId(DeviceInfo deviceInfo, Context context) {
        String androidId = Objects.isNotNull(deviceInfo) ? deviceInfo.getAndroidId() : null;
        if (Objects.isEmpty(androidId)) {
            androidId = SPUtils.getString("android_id", "");
        }
        return (Objects.isEmpty(androidId) && Objects.isNotNull(context)) ? AndroidIdUtil.getAndroidID(context) : androidId;
    }

    public static String getDistinctId(DeviceInfo deviceInfo) {
        String distinctId = Objects.isNotNull(deviceInfo) ? deviceInfo.getDistinctId() : null;
        return Objects.isEmpty(distinctId) ? SPUtils.getString(Command.SPKEY.DISTINCTID, "") : distinctId;
    }

    public static String getManufacturer(DeviceInfo deviceInfo) {
        String manufacturer = Objects.isNotNull(deviceInfo) ? deviceInfo.getManufacturer() : null;
        if (Objects.isEmpty(manufacturer)) {
            manufacturer = SPUtils.getString(Command.SPKEY.MANUFACTURER, "");
        }
        return Objects.isEmpty(manufacturer) ? OsUtil.getManufacturer() : manufacturer;
    }

    public static JSONObject getPresetProperties() {
        JSONObject jSONObject;
        try {
            DeviceInfo deviceInfo = Global.getInstance().getDeviceInfo();
            Context context = Global.getInstance().getContext();
            UserInfo userInfo = Global.getInstance().getUserInfo();
            jSONObject = new JSONObject();
            try {
                String appKey = Global.getInstance().getAppKey();
                if (Objects.isNotEmpty(appKey)) {
                    jSONObject.put(Command.PresetAttrKey.APPKEY, appKey);
                }
                String distinctId = getDistinctId(deviceInfo);
                if (Objects.isNotEmpty(distinctId)) {
                    jSONObject.put(Command.PresetAttrKey.DISTINCT_ID, distinctId);
                }
                String adid = getAdid(deviceInfo);
                if (Objects.isNotEmpty(adid)) {
                    jSONObject.put(Command.PresetAttrKey.GAID, adid);
                }
                String androidId = getAndroidId(deviceInfo, context);
                if (Objects.isNotEmpty(androidId)) {
                    jSONObject.put(Command.PresetAttrKey.ANDROID_ID, androidId);
                }
                String ua = getUa(deviceInfo);
                if (Objects.isNotEmpty(ua)) {
                    jSONObject.put(Command.PresetAttrKey.UA, ua);
                }
                String manufacturer = getManufacturer(deviceInfo);
                if (Objects.isNotEmpty(manufacturer)) {
                    jSONObject.put(Command.PresetAttrKey.MANUFACTURER, manufacturer);
                }
                String accountID = userInfo.getAccountID();
                if (Objects.isNotEmpty(accountID)) {
                    jSONObject.put(Command.PresetAttrKey.ACCOUNT_ID, accountID);
                }
                String visitorID = userInfo.getVisitorID();
                if (Objects.isNotEmpty(visitorID)) {
                    jSONObject.put(Command.PresetAttrKey.VISITOR_ID, visitorID);
                }
                String sessionId = Global.getInstance().getSessionId();
                if (Objects.isNotEmpty(sessionId)) {
                    jSONObject.put(Command.PresetAttrKey.SESSION_ID, sessionId);
                }
                String uuid = getUUID(deviceInfo);
                if (Objects.isNotEmpty(uuid)) {
                    jSONObject.put(Command.PresetAttrKey.UUID, uuid);
                }
                String localLanguage = OsUtil.getLocalLanguage();
                if (Objects.isNotEmpty(localLanguage)) {
                    jSONObject.put(Command.PresetAttrKey.LANGUAGE, localLanguage);
                }
                String locale = OsUtil.getLocale();
                if (Objects.isNotEmpty(locale)) {
                    jSONObject.put(Command.PresetAttrKey.LOCALE, locale);
                }
                String timeZone = OsUtil.getTimeZone();
                if (Objects.isNotEmpty(timeZone)) {
                    jSONObject.put(Command.PresetAttrKey.TIME_ZONE, timeZone);
                }
                jSONObject.put(Command.PresetAttrKey.PLATFORM, 1);
                String oSVersion = OsUtil.getOSVersion();
                if (Objects.isNotEmpty(oSVersion)) {
                    jSONObject.put(Command.PresetAttrKey.OS_VERSION, oSVersion);
                }
                jSONObject.put(Command.PresetAttrKey.SCREEN_HEIGHT, OsUtil.getHeight(context));
                jSONObject.put(Command.PresetAttrKey.SCREEN_WIDTH, OsUtil.getWidth(context));
                jSONObject.put(Command.PresetAttrKey.DENSITY, OsUtil.getDensity(context));
                String deviceModel = OsUtil.getDeviceModel();
                if (Objects.isNotEmpty(deviceModel)) {
                    jSONObject.put(Command.PresetAttrKey.DEVICE_MODEL, deviceModel);
                }
                jSONObject.put(Command.PresetAttrKey.DEVICE_TYPE, OsUtil.isTablet(context) ? 2 : 1);
                String appVersionString = OsUtil.getAppVersionString(context);
                if (Objects.isNotEmpty(appVersionString)) {
                    jSONObject.put(Command.PresetAttrKey.APP_VERSION, appVersionString);
                }
                jSONObject.put(Command.PresetAttrKey.APP_VERSION_CODE, OsUtil.getAppVersionCode(context));
                String packageName = OsUtil.getPackageName(context);
                if (Objects.isNotEmpty(packageName)) {
                    jSONObject.put(Command.PresetAttrKey.PACKAGE_NAME, packageName);
                }
                String appName = OsUtil.getAppName(context);
                if (Objects.isNotEmpty(appName)) {
                    jSONObject.put(Command.PresetAttrKey.APP_NAME, appName);
                }
                String channel = userInfo.getChannel();
                if (Objects.isNotEmpty(channel)) {
                    jSONObject.put(Command.PresetAttrKey.CHANNEL, channel);
                }
                jSONObject.put(Command.PresetAttrKey.LIB, 1);
                jSONObject.put(Command.PresetAttrKey.LIB_VERSION, "1.2.9.1");
            } catch (JSONException e) {
                e = e;
                Global.getInstance().getLogger().logError((Exception) e);
                return jSONObject;
            }
        } catch (JSONException e2) {
            e = e2;
            jSONObject = null;
        }
        return jSONObject;
    }

    public static String getUUID(DeviceInfo deviceInfo) {
        String uuid = Objects.isNotNull(deviceInfo) ? deviceInfo.getUUID() : null;
        return Objects.isEmpty(uuid) ? SPUtils.getString(Command.SPKEY.SP_UUID, "") : uuid;
    }

    public static String getUa(DeviceInfo deviceInfo) {
        String ua = Objects.isNotNull(deviceInfo) ? deviceInfo.getUa() : null;
        if (Objects.isEmpty(ua)) {
            ua = SPUtils.getString("ua", "");
        }
        return Objects.isEmpty(ua) ? OsUtil.getUserAgent() : ua;
    }
}