Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 3 years ago
parent a7b04a2de4
commit e57829f21d

@ -581,7 +581,7 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
//noinspection BusyWait //noinspection BusyWait
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
// silence is bliss Thread.currentThread().interrupt();
} }
} }
// attempt to read the existingKey property // attempt to read the existingKey property
@ -607,7 +607,9 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
} }
// create a securely generated random asymmetric RSA key // create a securely generated random asymmetric RSA key
byte[] realmKey = new byte[Realm.ENCRYPTION_KEY_LENGTH]; byte[] realmKey = new byte[Realm.ENCRYPTION_KEY_LENGTH];
new SecureRandom().nextBytes(realmKey); do {
new SecureRandom().nextBytes(realmKey);
} while (realmKey[0] == 0);
// create a cipher that uses AES encryption -- we'll use this to encrypt our key // create a cipher that uses AES encryption -- we'll use this to encrypt our key
Cipher cipher; Cipher cipher;
try { try {

@ -204,7 +204,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
try { try {
Thread.sleep(250); Thread.sleep(250);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); Thread.currentThread().interrupt();
} }
// Log the changes // Log the changes
Timber.d("Setup finished. Preferences: %s", prefs.getAll()); Timber.d("Setup finished. Preferences: %s", prefs.getAll());
@ -218,7 +218,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
try { try {
pendingIntent.send(); pendingIntent.send();
} catch (PendingIntent.CanceledException e) { } catch (PendingIntent.CanceledException e) {
e.printStackTrace(); Timber.e(e);
} }
android.os.Process.killProcess(android.os.Process.myPid()); android.os.Process.killProcess(android.os.Process.myPid());
}); });

@ -24,6 +24,7 @@ import org.matomo.sdk.extra.TrackHelper;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
import io.noties.markwon.Markwon; import io.noties.markwon.Markwon;
@ -223,7 +224,7 @@ public class UpdateActivity extends FoxActivity {
}); });
} }
// convert to JSON // convert to JSON
JSONObject latestJSON = new JSONObject(new String(lastestJSON)); JSONObject latestJSON = new JSONObject(Arrays.toString(lastestJSON));
String changelog = latestJSON.getString("body"); String changelog = latestJSON.getString("body");
// set changelog text. changelog could be markdown, so we need to convert it to HTML // set changelog text. changelog could be markdown, so we need to convert it to HTML
MaterialTextView changelogTextView = findViewById(R.id.update_changelog); MaterialTextView changelogTextView = findViewById(R.id.update_changelog);

@ -34,6 +34,7 @@ import java.net.URL;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -154,7 +155,7 @@ public final class AndroidacyRepoData extends RepoData {
try { try {
byte[] resp = Http.doHttpGet("https://" + this.host + "/auth/me?token=" + token + "&device_id=" + deviceId + "&client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, false); byte[] resp = Http.doHttpGet("https://" + this.host + "/auth/me?token=" + token + "&device_id=" + deviceId + "&client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, false);
// response is JSON // response is JSON
JSONObject jsonObject = new JSONObject(new String(resp)); JSONObject jsonObject = new JSONObject(Arrays.toString(resp));
memberLevel = jsonObject.getString("role"); memberLevel = jsonObject.getString("role");
JSONArray memberPermissions = jsonObject.getJSONArray("permissions"); JSONArray memberPermissions = jsonObject.getJSONArray("permissions");
// set role and permissions on userInfo property // set role and permissions on userInfo property
@ -251,7 +252,7 @@ public final class AndroidacyRepoData extends RepoData {
try { try {
Timber.i("Requesting new token..."); Timber.i("Requesting new token...");
// POST json request to https://production-api.androidacy.com/auth/register // POST json request to https://production-api.androidacy.com/auth/register
token = new String(Http.doHttpPost("https://" + this.host + "/auth/register?client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, "{\"device_id\":\"" + deviceId + "\"}", false)); token = Arrays.toString(Http.doHttpPost("https://" + this.host + "/auth/register?client_id=" + BuildConfig.ANDROIDACY_CLIENT_ID, "{\"device_id\":\"" + deviceId + "\"}", false));
// Parse token // Parse token
try { try {
JSONObject jsonObject = new JSONObject(token); JSONObject jsonObject = new JSONObject(token);

@ -9,6 +9,7 @@ import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.utils.io.net.Http; import com.fox2code.mmm.utils.io.net.Http;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays;
import java.util.Objects; import java.util.Objects;
public enum AndroidacyUtil { public enum AndroidacyUtil {
@ -132,6 +133,6 @@ public enum AndroidacyUtil {
if (md == null) { if (md == null) {
return null; return null;
} }
return new String(md); return Arrays.toString(md);
} }
} }

@ -206,7 +206,7 @@ public class BackgroundUpdateChecker extends Worker {
postNotificationForAppUpdate(context); postNotificationForAppUpdate(context);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); Timber.e("Failed to check for app update");
} }
} }
// remove checking notification // remove checking notification

@ -312,7 +312,6 @@ public class InstallerActivity extends FoxActivity {
return; return;
} }
this.installerTerminal.enableAnsi(); this.installerTerminal.enableAnsi();
// Extract customize.sh manually in rootless mode because unzip might not exists
try (ZipFile zipFile = new ZipFile(file)) { try (ZipFile zipFile = new ZipFile(file)) {
ZipArchiveEntry zipEntry = zipFile.getEntry("customize.sh"); ZipArchiveEntry zipEntry = zipFile.getEntry("customize.sh");
if (zipEntry != null) { if (zipEntry != null) {

@ -9,6 +9,7 @@ import com.fox2code.mmm.utils.realm.ReposList;
import org.json.JSONObject; import org.json.JSONObject;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import io.realm.Realm; import io.realm.Realm;
import io.realm.RealmConfiguration; import io.realm.RealmConfiguration;
@ -74,7 +75,7 @@ public class CustomRepoManager {
// parse json // parse json
JSONObject jsonObject; JSONObject jsonObject;
try { try {
jsonObject = new JSONObject(new String(json)); jsonObject = new JSONObject(Arrays.toString(json));
} catch (Exception e) { } catch (Exception e) {
Timber.e(e, "Failed to parse json from repo"); Timber.e(e, "Failed to parse json from repo");
return null; return null;

@ -20,6 +20,7 @@ import android.os.Handler;
import android.os.Looper; import android.os.Looper;
import android.provider.Settings; import android.provider.Settings;
import android.text.Editable; import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -648,6 +649,7 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
materialTextView.setText(localModuleInfo.name); materialTextView.setText(localModuleInfo.name);
layout.addView(materialTextView); layout.addView(materialTextView);
EditText editText = new EditText(this.requireContext()); EditText editText = new EditText(this.requireContext());
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
editText.setLayoutParams(params); editText.setLayoutParams(params);
editText.setHint(R.string.background_update_check_excludes_version_hint); editText.setHint(R.string.background_update_check_excludes_version_hint);
// stringset uses id:version, we show version for name // stringset uses id:version, we show version for name
@ -907,9 +909,10 @@ public class SettingsActivity extends FoxActivity implements LanguageActivity {
Timber.d("Version clicks: %d", ref.versionClicks); Timber.d("Version clicks: %d", ref.versionClicks);
// if it's been 3 clicks, toast "yer a wizard, harry" or "keep tapping to enter hogwarts" // if it's been 3 clicks, toast "yer a wizard, harry" or "keep tapping to enter hogwarts"
if (ref.versionClicks == 3) { if (ref.versionClicks == 3) {
// pick 1 or 2 // random choice of 1 or 2
int random = new Random().nextInt(2) + 1; Random rand = new Random();
Toast.makeText(p.getContext(), random == 1 ? R.string.yer_a_wizard_harry : R.string.keep_tapping_to_enter_hogwarts, Toast.LENGTH_SHORT).show(); int n = rand.nextInt(2) + 1;
Toast.makeText(p.getContext(), n == 1 ? R.string.yer_a_wizard_harry : R.string.keep_tapping_to_enter_hogwarts, Toast.LENGTH_SHORT).show();
} }
if (ref.versionClicks == 7) { if (ref.versionClicks == 7) {
ref.versionClicks = 0; ref.versionClicks = 0;

@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import okhttp3.Cookie; import okhttp3.Cookie;
import okhttp3.CookieJar; import okhttp3.CookieJar;
@ -41,15 +40,13 @@ public class WebkitCookieManagerProxy extends CookieManager implements CookieJar
String url = uri.toString(); String url = uri.toString();
// go over the headers // go over the headers
for (String headerKey : responseHeaders.keySet()) { for (Map.Entry<String, List<String>> entry : responseHeaders.entrySet()) {
// ignore headers which aren't cookie related // ignore headers which aren't cookie related
if ((headerKey == null) if ((entry.getKey() == null)
|| !(headerKey.equalsIgnoreCase("Set-Cookie2") || headerKey || !(entry.getKey().equalsIgnoreCase("Set-Cookie2") || entry
.equalsIgnoreCase("Set-Cookie"))) .getKey().equalsIgnoreCase("Set-Cookie")))
continue; continue;
for (String headerValue : entry.getValue()) {
// process each of the headers
for (String headerValue : Objects.requireNonNull(responseHeaders.get(headerKey))) {
webkitCookieManager.setCookie(url, headerValue); webkitCookieManager.setCookie(url, headerValue);
} }
} }

Loading…
Cancel
Save