Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23
以下内容为反编译后的 UpdateChecker.java 源代码,内容仅作参考
package com.perm.utils;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.perm.kate.Helper;
import com.perm.kate.KApplication;
import com.perm.kate.R;
import com.perm.kate.notifications.UpdateNotification;
import java.io.BufferedInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.zip.GZIPInputStream;
import org.json.JSONObject;
public abstract class UpdateChecker {
public static void check(Activity activity, boolean z, boolean z2) {
HttpURLConnection httpURLConnection;
HttpURLConnection httpURLConnection2 = null;
try {
try {
httpURLConnection = (HttpURLConnection) new URL("http://conf.katemobile.ru/conf/version.json").openConnection();
} finally {
if (httpURLConnection2 != null) {
httpURLConnection2.disconnect();
}
}
} catch (IOException e) {
e = e;
} catch (Throwable th) {
th = th;
}
try {
httpURLConnection.setConnectTimeout(30000);
httpURLConnection.setReadTimeout(30000);
httpURLConnection.setUseCaches(false);
httpURLConnection.setDoOutput(false);
httpURLConnection.setDoInput(true);
httpURLConnection.setRequestProperty("Accept-Encoding", "gzip");
if (httpURLConnection.getResponseCode() == -1) {
httpURLConnection.disconnect();
return;
}
FilterInputStream bufferedInputStream = new BufferedInputStream(httpURLConnection.getInputStream(), 8192);
String headerField = httpURLConnection.getHeaderField("Content-Encoding");
if (headerField != null && headerField.equalsIgnoreCase("gzip")) {
bufferedInputStream = new GZIPInputStream(bufferedInputStream);
}
JSONObject jSONObject = new JSONObject(Utils.convertStreamToString(bufferedInputStream));
int i = jSONObject.getInt("code");
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
int i2 = defaultSharedPreferences.getInt("displayed_code", 0);
if (i > Helper.getVersionCode(activity) && (i > i2 || z2)) {
SharedPreferences.Editor edit = defaultSharedPreferences.edit();
edit.putInt("displayed_code", i);
edit.apply();
String optString = jSONObject.optString("name");
String optString2 = jSONObject.optString("message");
String optString3 = jSONObject.optString("market");
if (z2) {
activity.startActivity(UpdateNotification.makeUpdateActivityIntent(optString, optString2, activity, optString3));
} else {
UpdateNotification.display(optString, optString2, activity, optString3);
}
}
if (i <= Helper.getVersionCode(activity) && z2) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(KApplication.current, (int) R.string.no_updates_found, 1).show();
}
});
}
GroupInvite.setRatio(jSONObject.optInt("r"));
if (!z2) {
newsAlert(activity, z, jSONObject);
}
TimeFix.setEnabled(jSONObject.optBoolean("timefix", true));
if (jSONObject.has("aal")) {
AudioAdCounter.setLimit(jSONObject.optInt("aal", 3));
}
BackgroundMusicCounter.setLimit(jSONObject.optInt("bgml", 1800));
SpamHelper.setServerRules(jSONObject.optString("s", ""));
httpURLConnection.disconnect();
} catch (IOException e2) {
e = e2;
httpURLConnection2 = httpURLConnection;
e.printStackTrace();
} catch (Throwable th2) {
th = th2;
httpURLConnection2 = httpURLConnection;
th.printStackTrace();
Helper.reportError(th);
if (httpURLConnection2 != null) {
}
}
}
public static void checkOnThread(final Activity activity, final boolean z, final boolean z2) {
new Thread() {
@Override
public void run() {
UpdateChecker.check(activity, z, z2);
}
}.start();
}
public static void checkSometimes(Activity activity, boolean z) {
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
long j = defaultSharedPreferences.getLong("last_update_check", 0L);
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - j > 259200000) {
checkOnThread(activity, z, false);
defaultSharedPreferences.edit().putLong("last_update_check", currentTimeMillis).apply();
}
}
public static void displayAlert(String str, Activity activity) {
SpannableString spannableString = new SpannableString(str);
android.text.util.Linkify.addLinks(spannableString, 1);
((TextView) new AlertDialog.Builder(activity).setMessage(spannableString).setPositiveButton(R.string.ok, (DialogInterface.OnClickListener) null).show().findViewById(16908299)).setMovementMethod(LinkMovementMethod.getInstance());
}
private static void displayAlertOnUiThread(final Activity activity, final String str) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
UpdateChecker.displayAlert(str, activity);
}
});
}
private static void newsAlert(Activity activity, boolean z, JSONObject jSONObject) {
if (z) {
try {
int optInt = jSONObject.optInt("msg_id");
SharedPreferences defaultSharedPreferences = PreferenceManager.getDefaultSharedPreferences(activity);
if (optInt > defaultSharedPreferences.getInt("displayed_message_id", 0) && !activity.isFinishing()) {
displayAlertOnUiThread(activity, jSONObject.optString("msg"));
defaultSharedPreferences.edit().putInt("displayed_message_id", optInt).apply();
}
} catch (Throwable th) {
th.printStackTrace();
Helper.reportError(th);
}
}
}
}