Snaptube v4.40.0.4401610版本的 MD5 值为:ca2b95dcff63007195db02a6c93091b9

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


package o;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import com.google.android.gms.analytics.HitBuilders;
import com.mobvista.msdk.base.common.CommonConst;
import com.snaptube.premium.activity.DragonActivity;
import com.snaptube.premium.configs.Config;
import com.snaptube.premium.log.TrackingEventWrapper;
import com.wandoujia.base.config.GlobalConfig;
import com.wandoujia.base.utils.SystemUtil;
import com.wandoujia.udid.UDIDUtil;
import io.fabric.sdk.android.services.settings.SettingsJsonConstants;
import java.io.IOException;
import java.util.HashSet;
import java.util.Iterator;
import o.cte;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
public class bpm {
    private String[][] f18196;
    @crd(m22176 = SettingsJsonConstants.APP_KEY)
    @crc
    ctc f18197;
    private final Context f18198;
    private String f18199 = "unknown";
    private int f18200 = 0;
    private String f18201 = "unknown";
    private String[] f18195 = {"key.homepage_notification_text", "key.homepage_notification_text_color", "key.homepage_notification_text_bg", "key.homepage_notification_image_url", "key.homepage_notification_intent", "key.homepage_notification_button_text", "key.homepage_notification_hours_to_hide", "key.homepage_notification_show_hide_button"};

    public bpm(Context context) {
        Context applicationContext = context.getApplicationContext();
        this.f18198 = applicationContext;
        ((bns) cds.m20403(applicationContext)).mo18174(this);
        String str = DragonActivity.m10436() ? "https://api.snappea.com/onlineConfig/" : "http://staging.api.snappea.com/onlineConfig/";
        this.f18196 = new String[][]{new String[]{GlobalConfig.PREF_SWITCHES, str + "android-switches.json"}, new String[]{GlobalConfig.PREF_CONTENT_CONFIG, str + "android-client.json"}, new String[]{"pref.likeus_config", str + "likeus-config.json"}, new String[]{"pref.user_contribute_config", str + "user-contribute-config.json"}, new String[]{"pref.homepage_notification", str + "homepage-notification.json"}, new String[]{"pref.feedback", str + "feedback.json"}, new String[]{"pref.ga", str + "android-ga-config.json"}, new String[]{"pref.fan", "https://config.ad.snappea.com/v2/config?configName=android_ads_for_mediation_merge.json"}, new String[]{"pref.player_guide", str + "android-player_guide.json"}, new String[]{"pref.sa", str + "android-sensor-config.json"}};
    }

    public void m18345() {
        try {
            PackageInfo packageInfo = this.f18198.getPackageManager().getPackageInfo(this.f18198.getPackageName(), 0);
            this.f18199 = packageInfo.versionName;
            this.f18200 = packageInfo.versionCode;
            this.f18201 = this.f18198.getPackageName();
        } catch (Exception e) {
        }
    }

    public void m18347() {
        String[][] strArr;
        for (String[] strArr2 : this.f18196) {
            m18342(strArr2[0], strArr2[1]);
        }
    }

    @Deprecated
    public String m18344(String str) {
        try {
            return Uri.parse(str).buildUpon().appendQueryParameter("v", this.f18199).appendQueryParameter(CommonConst.KEY_REPORT_VC, String.valueOf(this.f18200)).appendQueryParameter("u", UDIDUtil.m12928(this.f18198)).appendQueryParameter("ch", Config.m11041()).appendQueryParameter("pn", this.f18201).appendQueryParameter("lang", cad.m19752()).appendQueryParameter("region", asa.m15193(this.f18198)).appendQueryParameter("networkCountryIso", SystemUtil.getNetworkCountryIso(this.f18198)).appendQueryParameter("random_id", String.valueOf(Config.m11150())).appendQueryParameter("bucket", String.valueOf(Config.m11149())).toString();
        } catch (Throwable th) {
            return str;
        }
    }

    private void m18342(final String str, String str2) {
        this.f18197.mo22429(new cte.Cif().m22635(str2).m22644()).mo22426(new csl() {
            @Override
            public void onFailure(csk cskVar, IOException iOException) {
            }

            @Override
            public void onResponse(csk cskVar, ctg ctgVar) throws IOException {
                if (ctgVar.m22659() == 200) {
                    try {
                        bpm.this.m18346(str, new JSONObject(ctgVar.m22647().string()));
                    } catch (JSONException e) {
                        cdz.m20416(new RuntimeException(e));
                    }
                }
            }
        });
    }

    public void m18346(String str, JSONObject jSONObject) {
        JSONObject jSONObject2;
        JSONArray jSONArray;
        int i;
        String str2 = null;
        try {
            SharedPreferences sharedPreferences = this.f18198.getSharedPreferences(str, 0);
            String string = jSONObject.getString("_version");
            if (!TextUtils.equals(string, sharedPreferences.getString("_version", "_old_version"))) {
                if (str.equals("pref.homepage_notification")) {
                    m18341(sharedPreferences, jSONObject);
                } else if (str.equals("pref.player_guide")) {
                    m18343(sharedPreferences, jSONObject);
                } else {
                    if (str.equals("pref.fan")) {
                        try {
                            jSONObject2 = new JSONObject();
                            try {
                                jSONObject2.put("config", jSONObject.getJSONObject("config").getJSONArray("ad_config"));
                            } catch (JSONException e) {
                                e = e;
                                String[][] strArr = this.f18196;
                                int length = strArr.length;
                                int i2 = 0;
                                while (true) {
                                    if (i2 >= length) {
                                        break;
                                    }
                                    String[] strArr2 = strArr[i2];
                                    if (!TextUtils.equals("pref.fan", strArr2[0])) {
                                        i2++;
                                    } else {
                                        str2 = strArr2[1];
                                        break;
                                    }
                                }
                                arh.m15110("OnlinePreference", "config_error parse fail: " + str2, e);
                                btq.m18827(new HitBuilders.EventBuilder().m3723(TrackingEventWrapper.EV_CATEGORY_AD_MEDIATION.getCategoryName()).m3724("config_error").m3725(e.getMessage()).m3729(7, "ad_config").m3737(true));
                                SharedPreferences.Editor clear = sharedPreferences.edit().clear();
                                if (jSONObject2 == null) {
                                }
                                while (i < jSONArray.length()) {
                                }
                                clear.putString("_version", string);
                                clear.apply();
                                clear.putLong("content_update_time", System.currentTimeMillis());
                                clear.apply();
                            }
                        } catch (JSONException e2) {
                            e = e2;
                            jSONObject2 = null;
                        }
                    } else {
                        jSONObject2 = null;
                    }
                    SharedPreferences.Editor clear2 = sharedPreferences.edit().clear();
                    jSONArray = jSONObject2 == null ? jSONObject2.getJSONArray("config") : jSONObject.getJSONArray("config");
                    for (i = 0; i < jSONArray.length(); i++) {
                        JSONObject jSONObject3 = jSONArray.getJSONObject(i);
                        String string2 = jSONObject3.getString("name");
                        Object obj = jSONObject3.get("value");
                        if (obj instanceof Boolean) {
                            clear2.putBoolean(string2, ((Boolean) obj).booleanValue());
                        } else if (obj instanceof String) {
                            clear2.putString(string2, (String) obj);
                        } else if (obj instanceof Integer) {
                            clear2.putInt(string2, ((Integer) obj).intValue());
                        } else if ((obj instanceof JSONArray) && Build.VERSION.SDK_INT >= 11) {
                            HashSet hashSet = new HashSet();
                            JSONArray jSONArray2 = (JSONArray) obj;
                            for (int i3 = 0; i3 < jSONArray2.length(); i3++) {
                                hashSet.add(jSONArray2.getString(i3));
                            }
                            clear2.putStringSet(string2, hashSet);
                        } else if ((obj instanceof JSONObject) && (TextUtils.equals(string2, "key.expand") || TextUtils.equals(string2, "key.coins") || TextUtils.equals(string2, "key.quiz"))) {
                            m18340(clear2, 0, null, obj);
                        } else {
                            clear2.putString(string2, obj.toString());
                        }
                    }
                    clear2.putString("_version", string);
                    clear2.apply();
                    clear2.putLong("content_update_time", System.currentTimeMillis());
                    clear2.apply();
                }
            }
        } catch (Exception e3) {
            e3.printStackTrace();
        }
    }

    private void m18340(SharedPreferences.Editor editor, int i, String str, Object obj) throws Exception {
        String str2;
        if (i >= 10) {
            throw new IllegalArgumentException("max depth reached");
        }
        if (obj instanceof JSONObject) {
            JSONObject jSONObject = (JSONObject) obj;
            Iterator<String> keys = jSONObject.keys();
            while (keys.hasNext()) {
                String next = keys.next();
                String replace = next.replace('/', '_');
                if (!TextUtils.isEmpty(str)) {
                    str2 = str + "/" + replace;
                } else {
                    str2 = "/" + replace;
                }
                m18340(editor, i + 1, str2, jSONObject.get(next));
            }
        } else if (TextUtils.isEmpty(str)) {
            throw new IllegalArgumentException("invalid key");
        } else {
            if (obj instanceof Boolean) {
                editor.putBoolean(str, ((Boolean) obj).booleanValue());
            } else if (obj instanceof String) {
                editor.putString(str, (String) obj);
            } else if (obj instanceof Integer) {
                editor.putInt(str, ((Integer) obj).intValue());
            } else if (obj instanceof JSONArray) {
                if (Build.VERSION.SDK_INT >= 11) {
                    HashSet hashSet = new HashSet();
                    JSONArray jSONArray = (JSONArray) obj;
                    for (int i2 = 0; i2 < jSONArray.length(); i2++) {
                        hashSet.add(jSONArray.getString(i2));
                    }
                    editor.putStringSet(str, hashSet);
                }
            } else {
                editor.putString(str, obj.toString());
            }
        }
    }

    private void m18341(SharedPreferences sharedPreferences, JSONObject jSONObject) {
        SharedPreferences.Editor edit = sharedPreferences.edit();
        try {
            JSONArray jSONArray = jSONObject.getJSONArray("config");
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                edit.putString(jSONObject2.getString("name"), jSONObject2.getJSONObject("value").toString());
            }
            edit.putString("_version", jSONObject.getString("_version"));
            edit.apply();
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    private void m18343(SharedPreferences sharedPreferences, JSONObject jSONObject) {
        try {
            SharedPreferences.Editor edit = sharedPreferences.edit();
            JSONArray jSONArray = jSONObject.getJSONArray("config");
            for (int i = 0; i < jSONArray.length(); i++) {
                JSONObject jSONObject2 = jSONArray.getJSONObject(i);
                edit.putString(jSONObject2.getString("name"), jSONObject2.getJSONObject("value").toString());
            }
            edit.putString("_version", jSONObject.getString("_version"));
            edit.apply();
            edit.putLong("content_update_time", System.currentTimeMillis());
            edit.apply();
        } catch (JSONException e) {
            cdz.m20416(e);
        }
    }
}