Skip to content

Commit

Permalink
Remove and clear kSafetynetCheckFailed pref
Browse files Browse the repository at this point in the history
  • Loading branch information
deeppandya committed Nov 28, 2024
1 parent c914a29 commit fc8b8de
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1017,9 +1017,7 @@ public void maybeSolveAdaptiveCaptcha() {
String paymentID =
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
.getString(BravePref.SCHEDULED_CAPTCHA_PAYMENT_ID);
if (!TextUtils.isEmpty(captchaID)
&& !TextUtils.isEmpty(paymentID)
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
if (!TextUtils.isEmpty(captchaID) && !TextUtils.isEmpty(paymentID)) {
AdaptiveCaptchaHelper.startAttestation(captchaID, paymentID);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.chromium.chrome.browser.layouts.LayoutStateProvider;
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher;
import org.chromium.chrome.browser.preferences.BravePref;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
import org.chromium.chrome.browser.readaloud.ReadAloudController;
import org.chromium.chrome.browser.set_default_browser.BraveSetDefaultBrowserUtils;
Expand Down Expand Up @@ -187,9 +186,7 @@ public void prepareMenu(Menu menu, AppMenuHandler handler) {
}

BraveRewardsNativeWorker braveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance();
if (braveRewardsNativeWorker != null
&& braveRewardsNativeWorker.isSupported()
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
if (braveRewardsNativeWorker != null && braveRewardsNativeWorker.isSupported()) {
MenuItem rewards =
menu.add(Menu.NONE, R.id.brave_rewards_id, 0, R.string.menu_brave_rewards);
if (shouldShowIconBeforeItem()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.chromium.chrome.browser.ntp_background_images.model.TopSite;
import org.chromium.chrome.browser.ntp_background_images.model.Wallpaper;
import org.chromium.chrome.browser.ntp_background_images.util.NewTabPageListener;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.profiles.Profile;

import java.util.ArrayList;
Expand Down Expand Up @@ -69,14 +68,12 @@ public void removeObserver(NTPBackgroundImageServiceObserver observer) {
mObservers.removeObserver(observer);
}

static public boolean enableSponsoredImages() {
public static boolean enableSponsoredImages() {
BraveRewardsNativeWorker braveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance();
return braveRewardsNativeWorker != null
&& braveRewardsNativeWorker.isSupported()
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed();
return braveRewardsNativeWorker != null && braveRewardsNativeWorker.isSupported();
}

static public NTPBackgroundImagesBridge getInstance(Profile profile) {
public static NTPBackgroundImagesBridge getInstance(Profile profile) {
return NTPBackgroundImagesBridgeJni.get().getInstance(profile);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,6 @@ public long getDataSaved(Profile profile) {
return BravePrefServiceBridgeJni.get().getDataSaved(profile);
}

/**
* @param whether SafetyNet check failed.
*/
public void setSafetynetCheckFailed(boolean value) {
BravePrefServiceBridgeJni.get().setSafetynetCheckFailed(value);
}

public boolean getSafetynetCheckFailed() {
return BravePrefServiceBridgeJni.get().getSafetynetCheckFailed();
}

public void resetPromotionLastFetchStamp() {
BravePrefServiceBridgeJni.get().resetPromotionLastFetchStamp();
}
Expand Down Expand Up @@ -156,16 +145,17 @@ interface Natives {
// Used to pass total stat from upgrading old tabs based browser
// to a new core based
void setOldTrackersBlockedCount(Profile profile, long count);

void setOldAdsBlockedCount(Profile profile, long count);
void setOldHttpsUpgradesCount(Profile profile, long count);

void setSafetynetCheckFailed(boolean value);
boolean getSafetynetCheckFailed();
void setOldHttpsUpgradesCount(Profile profile, long count);

void resetPromotionLastFetchStamp();

boolean getBooleanForContentSetting(int content_type);

void setWebrtcPolicy(int policy);

int getWebrtcPolicy();

void setNewsOptIn(boolean value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.chromium.chrome.R;
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.settings.developer.BraveRewardsDebugPreferences;

public abstract class BravePreferenceFragment extends ChromeBaseSettingsFragment {
Expand Down Expand Up @@ -54,9 +53,7 @@ public void onCreatePreferences(Bundle bundle, String s) {
public void onResume() {
super.onResume();
BraveRewardsNativeWorker braveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance();
if (braveRewardsNativeWorker == null
|| !braveRewardsNativeWorker.isSupported()
|| BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()) {
if (braveRewardsNativeWorker == null || !braveRewardsNativeWorker.isSupported()) {
if (getPreferenceScreen() == null) return;
Preference braveRewardsDebugPreference =
getPreferenceScreen().findPreference(BraveRewardsDebugPreferences.KEY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.chromium.chrome.browser.BraveRelaunchUtils;
import org.chromium.chrome.browser.BraveRewardsNativeWorker;
import org.chromium.chrome.browser.BraveRewardsObserver;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.rewards.BraveRewardsPanel;
import org.chromium.components.browser_ui.settings.ChromeSwitchPreference;
import org.chromium.components.browser_ui.settings.SettingsUtils;
Expand Down Expand Up @@ -122,7 +121,6 @@ public void OnResetTheWholeState(boolean success) {
sharedPreferencesEditor.putBoolean(
BraveRewardsPanel.PREF_WAS_BRAVE_REWARDS_TURNED_ON, false);
sharedPreferencesEditor.apply();
BravePrefServiceBridge.getInstance().setSafetynetCheckFailed(false);
BraveRelaunchUtils.askForRelaunch(getActivity());
} else {
BraveRelaunchUtils.askForRelaunchCustom(getActivity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.chromium.chrome.browser.billing.LinkSubscriptionUtils;
import org.chromium.chrome.browser.onboarding.OnboardingPrefManager;
import org.chromium.chrome.browser.preferences.BravePref;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.profiles.ProfileManager;
import org.chromium.chrome.browser.rewards.BraveRewardsPanel;
import org.chromium.chrome.browser.settings.BravePreferenceFragment;
Expand Down Expand Up @@ -388,7 +387,6 @@ public void onResetTheWholeState(boolean success) {
BraveRewardsPanel.PREF_WAS_BRAVE_REWARDS_TURNED_ON, false);
sharedPreferencesEditor.apply();

BravePrefServiceBridge.getInstance().setSafetynetCheckFailed(false);
UserPrefs.get(ProfileManager.getLastUsedRegularProfile())
.setBoolean(BravePref.USE_REWARDS_STAGING_SERVER, mUseRewardsStagingServer);
BraveRewardsHelper.setRewardsEnvChange(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
import org.chromium.chrome.browser.playlist.PlaylistServiceFactoryAndroid;
import org.chromium.chrome.browser.playlist.PlaylistServiceObserverImpl;
import org.chromium.chrome.browser.playlist.PlaylistServiceObserverImpl.PlaylistServiceObserverImplDelegate;
import org.chromium.chrome.browser.preferences.BravePrefServiceBridge;
import org.chromium.chrome.browser.preferences.ChromeSharedPreferences;
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettings;
import org.chromium.chrome.browser.preferences.website.BraveShieldsContentSettingsObserver;
Expand Down Expand Up @@ -450,7 +449,6 @@ protected void onNativeLibraryReady() {
mBraveRewardsNativeWorker = BraveRewardsNativeWorker.getInstance();
if (mBraveRewardsNativeWorker != null
&& mBraveRewardsNativeWorker.isSupported()
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()
&& NtpUtil.shouldShowRewardsIcon()
&& mRewardsLayout != null) {
mRewardsLayout.setVisibility(View.VISIBLE);
Expand Down Expand Up @@ -1399,7 +1397,6 @@ public void updateBraveShieldsButtonState(Tab tab) {
} else if (isNativeLibraryReady()
&& mBraveRewardsNativeWorker != null
&& mBraveRewardsNativeWorker.isSupported()
&& !BravePrefServiceBridge.getInstance().getSafetynetCheckFailed()
&& NtpUtil.shouldShowRewardsIcon()) {
mRewardsLayout.setVisibility(View.VISIBLE);
updateShieldsLayoutBackground(false);
Expand Down
9 changes: 0 additions & 9 deletions browser/android/preferences/brave_pref_service_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,6 @@ void JNI_BravePrefServiceBridge_SetOldHttpsUpgradesCount(
kHttpsUpgrades, count + profile->GetPrefs()->GetUint64(kHttpsUpgrades));
}

void JNI_BravePrefServiceBridge_SetSafetynetCheckFailed(JNIEnv* env,
jboolean value) {
GetOriginalProfile()->GetPrefs()->SetBoolean(kSafetynetCheckFailed, value);
}

jboolean JNI_BravePrefServiceBridge_GetSafetynetCheckFailed(JNIEnv* env) {
return GetOriginalProfile()->GetPrefs()->GetBoolean(kSafetynetCheckFailed);
}

void JNI_BravePrefServiceBridge_ResetPromotionLastFetchStamp(JNIEnv* env) {
GetOriginalProfile()->GetPrefs()->SetUint64(
brave_rewards::prefs::kPromotionLastFetchStamp, 0);
Expand Down
6 changes: 0 additions & 6 deletions browser/ui/webui/brave_rewards/rewards_web_ui_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ bool ShouldBlockRewardsWebUI(content::BrowserContext* browser_context,
: brave_rewards::IsSupportedOptions::kNone)) {
return true;
}
#if BUILDFLAG(IS_ANDROID)
auto* prefs = profile->GetPrefs();
if (prefs && prefs->GetBoolean(kSafetynetCheckFailed)) {
return true;
}
#endif // BUILDFLAG(IS_ANDROID)
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions chromium_src/chrome/browser/prefs/browser_prefs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void MigrateObsoleteProfilePrefs(PrefService* profile_prefs,

#if BUILDFLAG(IS_ANDROID)
// Added 27/11/2024: https://github.com/brave/brave-core/pull/26719
profile_prefs->ClearPref(kSafetynetCheckFailed);
profile_prefs->ClearPref(kSafetynetStatus);
#endif // BUILDFLAG(IS_ANDROID)

Expand Down

0 comments on commit fc8b8de

Please sign in to comment.