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
Thread.sleep(100);
} catch (InterruptedException ignored) {
// silence is bliss
Thread.currentThread().interrupt();
}
}
// 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
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
Cipher cipher;
try {

@ -204,7 +204,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
try {
Thread.sleep(250);
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
// Log the changes
Timber.d("Setup finished. Preferences: %s", prefs.getAll());
@ -218,7 +218,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
e.printStackTrace();
Timber.e(e);
}
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.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Objects;
import io.noties.markwon.Markwon;
@ -223,7 +224,7 @@ public class UpdateActivity extends FoxActivity {
});
}
// convert to JSON
JSONObject latestJSON = new JSONObject(new String(lastestJSON));
JSONObject latestJSON = new JSONObject(Arrays.toString(lastestJSON));
String changelog = latestJSON.getString("body");
// set changelog text. changelog could be markdown, so we need to convert it to HTML
MaterialTextView changelogTextView = findViewById(R.id.update_changelog);

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

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

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

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

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

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

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

Loading…
Cancel
Save