Update prefs for adaptive captcha

Address PR comments

Resolve CI error

Revert changes and address PR comments

Update flag for IOS

Address format error for CI
This commit is contained in:
Deep
2022-08-22 23:05:38 -04:00
parent 238255eac8
commit 4de5d606c0
25 changed files with 150 additions and 107 deletions
@@ -36,11 +36,27 @@ public class BraveAdaptiveCaptchaUtils {
BraveRewardsNativeWorker.getInstance().getCaptchaSolutionURL(
paymentId, captchaId);
Log.e(TAG, adaptiveCaptchaSolutionUrl);
NetworkTrafficAnnotationTag annotation = NetworkTrafficAnnotationTag.createComplete(
"Brave adaptive captcha solution android",
"semantics {"
+ " sender: 'Brave Andrioid app'"
+ " description: "
+ " 'This api solves the scheduled captcha for to refill unblinded tokens '"
+ " trigger: 'When paymenyt id as captcha scheduled'"
+ " data:"
+ " 'payment id'"
+ " destination: Brave grant endpoint"
+ "}"
+ "policy {"
+ " cookies_allowed: NO"
+ " policy_exception_justification: 'Not implemented.'"
+ "}");
String logMessage = "";
try {
URL url = new URL(String.format(adaptiveCaptchaSolutionUrl, paymentId, captchaId));
urlConnection = (HttpURLConnection) ChromiumNetworkAdapter.openConnection(
url, NetworkTrafficAnnotationTag.MISSING_TRAFFIC_ANNOTATION);
urlConnection =
(HttpURLConnection) ChromiumNetworkAdapter.openConnection(url, annotation);
urlConnection.setDoOutput(true);
urlConnection.setRequestMethod("POST");
urlConnection.setUseCaches(false);
@@ -76,7 +92,8 @@ public class BraveAdaptiveCaptchaUtils {
BravePref
.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS)
+ 1);
logMessage = "Captcha solution failed with " + responseCode+ " : " + urlConnection.getResponseMessage();
logMessage = "Captcha solution failed with " + responseCode + " : "
+ urlConnection.getResponseMessage();
}
} catch (MalformedURLException e) {
Log.e(TAG, e.getMessage());
@@ -727,10 +727,10 @@ public abstract class BraveActivity<C extends ChromeActivityComponent> extends C
@Override
public void onPreferenceChange() {
solveAdaptiveCaptcha();
maybeSolveAdaptiveCaptcha();
}
public void solveAdaptiveCaptcha() {
public void maybeSolveAdaptiveCaptcha() {
String captchaID = UserPrefs.get(Profile.getLastUsedRegularProfile())
.getString(BravePref.SCHEDULED_CAPTCHA_ID);
String paymentID = UserPrefs.get(Profile.getLastUsedRegularProfile())
@@ -752,15 +752,18 @@ public abstract class BraveActivity<C extends ChromeActivityComponent> extends C
if (UserPrefs.get(Profile.getLastUsedRegularProfile())
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS)
== 10) {
>= 10) {
UserPrefs.get(Profile.getLastUsedRegularProfile())
.setBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED, true);
}
Log.e("adaptive captcha", "Failed attempts : "+ UserPrefs.get(Profile.getLastUsedRegularProfile()).getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS));
Log.e("adaptive captcha",
"Failed attempts : "
+ UserPrefs.get(Profile.getLastUsedRegularProfile())
.getInteger(BravePref.SCHEDULED_CAPTCHA_FAILED_ATTEMPTS));
if (!UserPrefs.get(Profile.getLastUsedRegularProfile())
.getBoolean(BravePref.SCHEDULED_CAPTCHA_PAUSED)) {
solveAdaptiveCaptcha();
maybeSolveAdaptiveCaptcha();
}
if (SharedPreferencesManager.getInstance().readBoolean(