package com.ubt.jimu.unity.bluetooth; import android.text.TextUtils; import com.ubt.jimu.base.cache.Cache; import com.ubt.jimu.base.entities.User; import com.ubt.jimu.blockly.bean.BlocklyProject; import com.ubt.jimu.blockly.dao.BlocklyProjectDbHandler; import com.ubt.jimu.utils.JsonHelper; import com.ubt.jimu.utils.LocaleUtils; import com.ubtrobot.log.ALog; import java.util.HashMap; import java.util.List; import org.json.JSONException; import org.json.JSONObject; /* loaded from: classes2.dex */ public class AndroidData { private static final String DIY_STEP = "diyStepData"; private static final String LANGUAGE = "language"; private static final String PROGRAM = "program"; private static final String TAG = "AndroidData"; private static final String USER_ID = "userId"; private UnityActivity unityActivity; public AndroidData(UnityActivity unityActivity) { this.unityActivity = unityActivity; } private String getLang() { return LocaleUtils.a(); } private String getLanguage() { return LocaleUtils.a(); } private String getUserId() { User user = Cache.getInstance().getUser(); if (user == null) { return "local"; } return user.getUserId() + ""; } public String getData(String str, String str2) { char c; int hashCode = str.hashCode(); if (hashCode != -926533302) { if (hashCode == -309387644 && str.equals("program")) { c = 0; } c = 65535; } else { if (str.equals(DIY_STEP)) { c = 1; } c = 65535; } if (c == 0) { getProgram(str2); return ""; } if (c != 1) { return ""; } getDiyStep(); return ""; } public String getDiyStep() { HashMap hashMap = new HashMap(); hashMap.put("nowStep", 8); hashMap.put("totalStep", 10); return JsonHelper.a(hashMap); } public String getProgram(String str) { if (TextUtils.isEmpty(str)) { return "[]"; } String str2 = ""; try { JSONObject jSONObject = new JSONObject(str); List projects = BlocklyProjectDbHandler.getProjects(Cache.getInstance().getUserId(), jSONObject.getString(UnityActivity.modelId), jSONObject.getInt(UnityActivity.pModelType)); String lang = getLang(); for (BlocklyProject blocklyProject : projects) { if (blocklyProject.xmlNameLang != null) { try { blocklyProject.setXmlName(blocklyProject.xmlNameLang.get(lang)); } catch (Exception e) { e.printStackTrace(); } } } str2 = JsonHelper.a(projects); ALog.a(TAG).d(str2); return str2; } catch (JSONException e2) { e2.printStackTrace(); return str2; } } public String getUserData(String str) { if (TextUtils.isEmpty(str)) { return "null"; } char c = 65535; int hashCode = str.hashCode(); if (hashCode != -1613589672) { if (hashCode == -836030906 && str.equals(USER_ID)) { c = 0; } } else if (str.equals("language")) { c = 1; } return c != 0 ? c != 1 ? "null" : getLanguage() : getUserId(); } }