Skip to content

Commit

Permalink
Fix unused variables warnings at java (#26433)
Browse files Browse the repository at this point in the history
* Removed unused variables and members at Brave java files
  • Loading branch information
AlexeyBarabash authored Nov 7, 2024
1 parent 868c599 commit d6d6a31
Show file tree
Hide file tree
Showing 81 changed files with 284 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ public String call() {
return null;
}

private static String getUrlForCustomTab(Intent intent) {
private static String getUrlForCustomTab(Intent unused_intent) {
assert false;
return null;
}

private static String getUrlForWebapp(Intent intent) {
private static String getUrlForWebapp(Intent unused_intent) {
assert false;
return null;
}

private static boolean isJavascriptSchemeOrInvalidUrl(String url) {
private static boolean isJavascriptSchemeOrInvalidUrl(String unused_url) {
assert false;
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public interface PublisherObserver { void onFrontTabPublisherChanged(boolean ver
public static final int BAT_NOT_ALLOWED = 25;
public static final int SAFETYNET_ATTESTATION_FAILED = 27;

private static final int REWARDS_UNKNOWN = 0;
private static final int REWARDS_DISABLED = 1;
private static final int REWARDS_ENABLED = 2;
private String mFrontTabUrl;
private static final Handler sHandler = new Handler();

Expand Down
7 changes: 0 additions & 7 deletions android/java/org/chromium/chrome/browser/BraveSyncWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@

package org.chromium.chrome.browser;

import android.content.Context;

import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace;
import org.jni_zero.NativeMethods;

import org.chromium.base.Callback;
import org.chromium.base.ContextUtils;

import java.time.LocalDateTime;
import java.time.ZoneOffset;
Expand All @@ -21,9 +18,6 @@
public class BraveSyncWorker {
private static final String TAG = "SYNC";

private Context mContext;
private String mDebug = "true";

private long mNativeBraveSyncWorker;

private static BraveSyncWorker sBraveSyncWorker;
Expand Down Expand Up @@ -67,7 +61,6 @@ private void destroy() {
}

public BraveSyncWorker() {
mContext = ContextUtils.getApplicationContext();
init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public class QRCodeShareDialogFragment extends DialogFragment implements View.On
private static final String TAG = "SUPER-REFERRAL";

// For QR code generation
private static final int WHITE = 0xFFFFFFFF;
private static final int BLACK = 0xFF000000;
// WHITE/BLACK depend on the normal/Night mode
private static final int WIDTH = 300;

private ImageView mQRImage;
Expand Down
15 changes: 2 additions & 13 deletions android/java/org/chromium/chrome/browser/app/BraveActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
import org.chromium.chrome.browser.multiwindow.BraveMultiWindowUtils;
import org.chromium.chrome.browser.multiwindow.MultiInstanceManager;
import org.chromium.chrome.browser.multiwindow.MultiWindowUtils;
import org.chromium.chrome.browser.notifications.BraveNotificationWarningDialog;
import org.chromium.chrome.browser.notifications.permissions.NotificationPermissionController;
import org.chromium.chrome.browser.notifications.retention.RetentionNotificationUtil;
import org.chromium.chrome.browser.ntp.NewTabPageManager;
Expand Down Expand Up @@ -274,9 +273,7 @@ public abstract class BraveActivity extends ChromeActivity
public static final String BRAVE_WEBCOMPAT_INFO_WIKI_URL =
"https://github.com/brave/brave-browser/wiki/Web-compatibility-reports";

private static final int DAYS_1 = 1;
private static final int DAYS_4 = 4;
private static final int DAYS_5 = 5;
private static final int DAYS_7 = 7;
private static final int DAYS_12 = 12;

Expand Down Expand Up @@ -1179,7 +1176,7 @@ public void finishNativeInitialization() {
}

checkFingerPrintingOnUpgrade(isFirstInstall);
checkForVpnCallout(isFirstInstall);
checkForVpnCallout();

if (ChromeFeatureList.isEnabled(BraveFeatureList.BRAVE_VPN_LINK_SUBSCRIPTION_ANDROID_UI)
&& BraveVpnPrefUtils.isSubscriptionPurchase()
Expand Down Expand Up @@ -1366,7 +1363,7 @@ private void handleDeepLinkVpn() {
BraveVpnUtils.openBraveVpnPlansActivity(this);
}

private void checkForVpnCallout(boolean isFirstInstall) {
private void checkForVpnCallout() {
String countryCode = Locale.getDefault().getCountry();

if (!countryCode.equals(BraveConstants.INDIA_COUNTRY_CODE)
Expand Down Expand Up @@ -1635,14 +1632,6 @@ private void checkForYandexSE() {
}
}

private BraveNotificationWarningDialog.DismissListener mCloseDialogListener =
new BraveNotificationWarningDialog.DismissListener() {
@Override
public void onDismiss() {
checkForNotificationData();
}
};

private void checkForNotificationData() {
Intent notifIntent = getIntent();
if (notifIntent != null && notifIntent.getStringExtra(RetentionNotificationUtil.NOTIFICATION_TYPE) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
import java.util.Arrays;
import java.util.List;

// Unused members, never read:
// - mSolanaTxManagerProxy
// - mSwapService
// - mBlockchainRegistry
// - mEthTxManagerProxy
// - mAssetRatioService
@SuppressWarnings("UnusedVariable")
public class CryptoModel {
private TxService mTxService;
private final PendingTxHelper mPendingTxHelper;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,13 @@
import java.lang.ref.WeakReference;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ImageLoader {
private static final String TAG = "ImageLoader";
private static final List<String> ANIMATED_LIST = Arrays.asList(".gif");
private static final String UNUSED_CLIENT_NAME = "unused";
private static final String BASE64_ENCODING_PATTERN =
"^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public void prepareMenu(Menu menu, AppMenuHandler handler) {
menu.findItem(R.id.request_vpn_location_row_menu_id).getSubMenu();
MenuItem vpnLocationSubMenuItem =
vpnLocationSubMenu.findItem(R.id.request_vpn_location_id);
String isoCode = BraveVpnPrefUtils.getRegionIsoCode();
String regionName =
BraveVpnPrefUtils.getRegionPrecision()
.equals(BraveVpnConstants.REGION_PRECISION_COUNTRY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private String inferHint(Context context, ViewNode node, @Nullable String actual
return null;
}

if (isOmnibox(node, hint)) {
if (isOmnibox(node)) {
return null;
}

Expand Down Expand Up @@ -457,7 +457,7 @@ private String inferHint(Context context, ViewNode node, @Nullable String actual
return null;
}

private boolean isOmnibox(ViewNode node, String hint) {
private boolean isOmnibox(ViewNode node) {

int inputType = node.getInputType();
if ((inputType & EditorInfo.TYPE_TEXT_VARIATION_URI)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,14 @@ public void initiatePurchase(Activity activity, ProductDetails productDetails) {
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
LiveData<Boolean> billingConnectionState = _billingConnectionState;
startBillingServiceConnection(_billingConnectionState);
LiveDataUtil.observeOnce(billingConnectionState, isConnected -> {
if (isConnected) {
BillingResult billingResult =
mBillingClient.launchBillingFlow(activity, billingFlowParams);
}
});
LiveDataUtil.observeOnce(
billingConnectionState,
isConnected -> {
if (isConnected) {
BillingResult unused_billingResult =
mBillingClient.launchBillingFlow(activity, billingFlowParams);
}
});
}

public void processPurchases(Context context, Purchase activePurchase) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static String getPromotionIdItem(FeedItemsCard items) {
if (items.getFeedItems() != null) {
for (FeedItemCard itemCard : items.getFeedItems()) {
FeedItem item = itemCard.getFeedItem();
FeedItemMetadata itemMetaData = new FeedItemMetadata();
if (item.which() == FeedItem.Tag.PromotedArticle) {
PromotedArticle promotedArticle = item.getPromotedArticle();
creativeInstanceId = promotedArticle.creativeInstanceId;
Expand Down Expand Up @@ -89,6 +88,7 @@ public static DisplayAd getFromDisplayAdsMap(Integer index) {

// method for logging news object. works by putting Log.d in the desired places of the parsing
// of the object
@SuppressWarnings("UnusedVariable")
public static void logFeedItem(FeedItemsCard items, String id) {
if (items != null) {
if (items.getCardType() == CardType.DISPLAY_AD) {
Expand Down
Loading

0 comments on commit d6d6a31

Please sign in to comment.