[cr149][Android] Fixes for the [unchecked] warning
Chromium changes: https://chromium.googlesource.com/chromium/src/+/7d3c16b9bb778a09b643288fe47bae4c1d8e53b7 commit 7d3c16b9bb778a09b643288fe47bae4c1d8e53b7 Author: Jingping Sun <jings@microsoft.com> Date: Mon Apr 27 10:58:12 2026 -0700 [Unchecked] Enable -Xlint:unchecked for Chromium-owned code Conditionally append -Xlint:unchecked to the base javac flags only when options.chromium_code is true. This makes javac fail the build on any new unchecked-conversion / heap-pollution / raw-type warnings in Chromium-owned Java code, while leaving synced third-party Java sources (chromium_code=false; auto-defaulted for third_party/ paths without org.chromium namespace) compiled silently as before. Why conditional, not global: Synced third-party Java code under third_party/{junit,google-truth}/ src/ contains unchecked-warning sites we cannot fix in chromium code base. Bug: 358366667 Change-Id: I904b09cd4484098cee3b59e6d4aae94eba8d33ae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7790536 Commit-Queue: Andrew Grieve <agrieve@chromium.org> Reviewed-by: Peter Wen <wnwen@chromium.org> Commit-Queue: Jingping Sun <jings@microsoft.com> Reviewed-by: Andrew Grieve <agrieve@chromium.org> Cr-Commit-Position: refs/heads/main@{#1621171}
This commit is contained in:
@@ -21,7 +21,7 @@ public class BraveReflectionUtil {
|
||||
// checking parameter types.
|
||||
@Nullable
|
||||
public static Object invokeMethod(
|
||||
Class methodOwner, @Nullable Object obj, String method, Object... typesAndArgs) {
|
||||
Class<?> methodOwner, @Nullable Object obj, String method, Object... typesAndArgs) {
|
||||
try {
|
||||
Class<?>[] parameterTypes = null;
|
||||
Object[] args = null;
|
||||
|
||||
@@ -866,7 +866,7 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
}
|
||||
|
||||
private void verifySubscription() {
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData();
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData<>();
|
||||
LiveData<PurchaseModel> activePurchases = _activePurchases;
|
||||
InAppPurchaseWrapper.getInstance()
|
||||
.queryPurchases(_activePurchases, InAppPurchaseWrapper.SubscriptionProduct.VPN);
|
||||
|
||||
@@ -102,17 +102,17 @@ public class InAppPurchaseWrapper {
|
||||
|
||||
// VPN monthly subscription product details
|
||||
private final MutableLiveData<ProductDetails> mMutableMonthlyProductDetailsVPN =
|
||||
new MutableLiveData();
|
||||
new MutableLiveData<>();
|
||||
private final LiveData<ProductDetails> mMonthlyProductDetailsVPN =
|
||||
mMutableMonthlyProductDetailsVPN;
|
||||
// Leo monthly subscription product details
|
||||
private final MutableLiveData<ProductDetails> mMutableMonthlyProductDetailsLeo =
|
||||
new MutableLiveData();
|
||||
new MutableLiveData<>();
|
||||
private final LiveData<ProductDetails> mMonthlyProductDetailsLeo =
|
||||
mMutableMonthlyProductDetailsLeo;
|
||||
// Origin one-time purchase product details
|
||||
private final MutableLiveData<ProductDetails> mMutableOriginProductDetails =
|
||||
new MutableLiveData();
|
||||
new MutableLiveData<>();
|
||||
private final LiveData<ProductDetails> mOriginProductDetails = mMutableOriginProductDetails;
|
||||
|
||||
/**
|
||||
@@ -155,12 +155,12 @@ public class InAppPurchaseWrapper {
|
||||
|
||||
// VPN yearly subscription product details
|
||||
private final MutableLiveData<ProductDetails> mMutableYearlyProductDetailsVPN =
|
||||
new MutableLiveData();
|
||||
new MutableLiveData<>();
|
||||
private final LiveData<ProductDetails> mYearlyProductDetailsVPN =
|
||||
mMutableYearlyProductDetailsVPN;
|
||||
// Leo yearly subscription product details
|
||||
private final MutableLiveData<ProductDetails> mMutableYearlyProductDetailsLeo =
|
||||
new MutableLiveData();
|
||||
new MutableLiveData<>();
|
||||
private final LiveData<ProductDetails> mYearlyProductDetailsLeo =
|
||||
mMutableYearlyProductDetailsLeo;
|
||||
|
||||
@@ -304,7 +304,7 @@ public class InAppPurchaseWrapper {
|
||||
QueryProductDetailsParams queryProductDetailsParams =
|
||||
QueryProductDetailsParams.newBuilder().setProductList(products).build();
|
||||
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -341,7 +341,7 @@ public class InAppPurchaseWrapper {
|
||||
* Play. This is intended for QA/testing use only via Developer Options.
|
||||
*/
|
||||
public void consumeExistingOriginPurchase() {
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -398,7 +398,7 @@ public class InAppPurchaseWrapper {
|
||||
QueryProductDetailsParams queryProductDetailsParams =
|
||||
QueryProductDetailsParams.newBuilder().setProductList(products).build();
|
||||
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -445,7 +445,7 @@ public class InAppPurchaseWrapper {
|
||||
type.equals(SubscriptionProduct.ORIGIN)
|
||||
? BillingClient.ProductType.INAPP
|
||||
: BillingClient.ProductType.SUBS;
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -523,7 +523,7 @@ public class InAppPurchaseWrapper {
|
||||
BillingFlowParams.newBuilder()
|
||||
.setProductDetailsParamsList(productDetailsParamsList)
|
||||
.build();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -567,7 +567,7 @@ public class InAppPurchaseWrapper {
|
||||
BillingFlowParams.newBuilder()
|
||||
.setProductDetailsParamsList(productDetailsParamsList)
|
||||
.build();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
@@ -601,7 +601,7 @@ public class InAppPurchaseWrapper {
|
||||
boolean isLeoProduct = isLeoProduct(productIds);
|
||||
boolean isOriginProduct = isOriginProduct(productIds);
|
||||
if (!purchase.isAcknowledged()) {
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData();
|
||||
MutableLiveData<Boolean> _billingConnectionState = new MutableLiveData<>();
|
||||
LiveData<Boolean> billingConnectionState = _billingConnectionState;
|
||||
startBillingServiceConnection(_billingConnectionState);
|
||||
LiveDataUtil.observeOnce(
|
||||
|
||||
@@ -29,8 +29,8 @@ import org.chromium.content_public.browser.WebContents;
|
||||
public class BraveLeoUtils {
|
||||
private static final String TAG = "BraveLeoUtils";
|
||||
|
||||
public static void verifySubscription(Callback callback) {
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData();
|
||||
public static void verifySubscription(Callback<Object> callback) {
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData<>();
|
||||
LiveData<PurchaseModel> activePurchases = _activePurchases;
|
||||
InAppPurchaseWrapper.getInstance()
|
||||
.queryPurchases(_activePurchases, InAppPurchaseWrapper.SubscriptionProduct.LEO);
|
||||
|
||||
@@ -1128,6 +1128,10 @@ public class CardBuilderFeedCard {
|
||||
}
|
||||
}
|
||||
|
||||
// Glide's RequestOptions#transform(Transformation<Bitmap>...) is varargs over a generic
|
||||
// type; passing two transformations triggers an unchecked generic-array-creation warning
|
||||
// that is intrinsic to the upstream API and unavoidable from the call site.
|
||||
@SuppressWarnings("unchecked")
|
||||
private void setImage(ImageView imageView, String type, int index) {
|
||||
List<FeedItemCard> feedItemsCard = mNewsItem.getFeedItems();
|
||||
if (feedItemsCard != null) {
|
||||
|
||||
@@ -128,7 +128,7 @@ public class AndroidUtils {
|
||||
}
|
||||
|
||||
public static SpannableString createClickableSpanString(
|
||||
Context context, @StringRes int id, Callback listener) {
|
||||
Context context, @StringRes int id, Callback<View> listener) {
|
||||
ChromeClickableSpan chromeClickableSpan =
|
||||
new ChromeClickableSpan(context.getColor(R.color.brave_link), listener);
|
||||
SpannableString spannableString = new SpannableString(context.getString(id));
|
||||
|
||||
+2
-1
@@ -282,8 +282,9 @@ public class PopupWindowTooltip implements PopupWindow.OnDismissListener {
|
||||
public boolean isShowing() {
|
||||
return mPopupWindow != null && mPopupWindow.isShowing();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends View> T findViewById(int id) {
|
||||
// noinspection unchecked
|
||||
return (T) mContentLayout.findViewById(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,7 @@ public class PlaylistHostActivity extends AsyncInitializationActivity
|
||||
Log.d(TAG, "loadPlaylist is null from service");
|
||||
return;
|
||||
}
|
||||
List<PlaylistItemModel> playlistItems = new ArrayList();
|
||||
List<PlaylistItemModel> playlistItems = new ArrayList<>();
|
||||
for (PlaylistItem playlistItem : playlist.items) {
|
||||
PlaylistItemModel playlistItemModel =
|
||||
new PlaylistItemModel(
|
||||
@@ -373,9 +373,9 @@ public class PlaylistHostActivity extends AsyncInitializationActivity
|
||||
}
|
||||
mPlaylistService.getAllPlaylists(
|
||||
playlists -> {
|
||||
List<PlaylistModel> allPlaylists = new ArrayList();
|
||||
List<PlaylistModel> allPlaylists = new ArrayList<>();
|
||||
for (Playlist playlist : playlists) {
|
||||
List<PlaylistItemModel> playlistItems = new ArrayList();
|
||||
List<PlaylistItemModel> playlistItems = new ArrayList<>();
|
||||
for (PlaylistItem playlistItem : playlist.items) {
|
||||
PlaylistItemModel playlistItemModel =
|
||||
new PlaylistItemModel(
|
||||
|
||||
@@ -291,6 +291,9 @@ public abstract class BraveMainPreferencesBase extends BravePreferenceFragment
|
||||
}
|
||||
|
||||
/** We need to override it to avoid NullPointerException in Chromium's child classes */
|
||||
// mRemovedPreferences stores the erased Preference type, but callers request a typed
|
||||
// subtype via T, so the (T) cast is unverifiable at compile time.
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
@Override
|
||||
public <T extends Preference> T findPreference(CharSequence key) {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class ContentFilteringFragment extends BravePreferenceFragment
|
||||
if (mFilterListAndroidHandler != null) {
|
||||
mFilterListAndroidHandler.getSubscriptions(
|
||||
subscriptions -> {
|
||||
mSubscriptionFilterLists = new ArrayList(Arrays.asList(subscriptions));
|
||||
mSubscriptionFilterLists = new ArrayList<>(Arrays.asList(subscriptions));
|
||||
mAdapter.setSubscriptionFilterLists(mSubscriptionFilterLists);
|
||||
mIsGetSubscriptionsLoaded = true;
|
||||
if (mIsMenuLoaded) {
|
||||
|
||||
+2
-1
@@ -54,6 +54,7 @@ import org.chromium.chrome.browser.ui.BraveAdaptiveToolbarUiCoordinator;
|
||||
import org.chromium.chrome.browser.ui.appmenu.AppMenuBlocker;
|
||||
import org.chromium.chrome.browser.ui.appmenu.AppMenuDelegate;
|
||||
import org.chromium.chrome.browser.ui.bottombar.BottomBarHostManager;
|
||||
import org.chromium.chrome.browser.ui.browser_window.ChromeAndroidTask;
|
||||
import org.chromium.chrome.browser.ui.edge_to_edge.EdgeToEdgeController;
|
||||
import org.chromium.chrome.browser.ui.edge_to_edge.EdgeToEdgeUtils;
|
||||
import org.chromium.chrome.browser.ui.edge_to_edge.TopInsetProvider;
|
||||
@@ -99,7 +100,7 @@ public class BraveTabbedRootUiCoordinator extends TabbedRootUiCoordinator {
|
||||
BrowserControlsManager browserControlsManager,
|
||||
ActivityWindowAndroid windowAndroid,
|
||||
ActivityResultTracker activityResultTracker,
|
||||
OneshotSupplier chromeAndroidTaskSupplier,
|
||||
OneshotSupplier<ChromeAndroidTask> chromeAndroidTaskSupplier,
|
||||
ActivityLifecycleDispatcher activityLifecycleDispatcher,
|
||||
MonotonicObservableSupplier<LayoutManagerImpl> layoutManagerSupplier,
|
||||
MenuOrKeyboardActionController menuOrKeyboardActionController,
|
||||
|
||||
@@ -380,6 +380,9 @@ public class BraveToolbarManager extends ToolbarManager
|
||||
mUndoBarThrottle,
|
||||
mTabBookmarkerSupplier,
|
||||
mShareDelegateSupplier);
|
||||
// mTabGroupUiOneshotSupplier is a OneshotSupplier of a concrete subtype, so narrowing
|
||||
// the wildcard to the bound type is safe in practice but not provable to the compiler.
|
||||
@SuppressWarnings("unchecked")
|
||||
var bottomControlsContentDelegateSupplier =
|
||||
(OneshotSupplier<BottomControlsContentDelegate>)
|
||||
((OneshotSupplier<? extends BottomControlsContentDelegate>)
|
||||
|
||||
@@ -822,7 +822,7 @@ public abstract class BraveToolbarLayoutImpl extends ToolbarLayout
|
||||
for (PlaylistItem defaultPlaylistItem : defaultPlaylist.items) {
|
||||
pageSources.add(defaultPlaylistItem.pageSource.url);
|
||||
}
|
||||
List<PlaylistItem> playlistItems = new ArrayList();
|
||||
List<PlaylistItem> playlistItems = new ArrayList<>();
|
||||
for (PlaylistItem playlistItem : items) {
|
||||
// Check for duplicates in default playlist
|
||||
if (!pageSources.contains(playlistItem.pageSource.url)) {
|
||||
|
||||
@@ -104,7 +104,7 @@ public abstract class BraveVpnParentActivity extends AsyncInitializationActivity
|
||||
|
||||
protected void verifySubscription() {
|
||||
mBraveVpnPrefModel = new BraveVpnPrefModel();
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData();
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData<>();
|
||||
LiveData<PurchaseModel> activePurchases = _activePurchases;
|
||||
InAppPurchaseWrapper.getInstance()
|
||||
.queryPurchases(_activePurchases, InAppPurchaseWrapper.SubscriptionProduct.VPN);
|
||||
|
||||
@@ -363,36 +363,43 @@ public class BraveVpnPreferences extends BravePreferenceFragment implements Brav
|
||||
};
|
||||
|
||||
private void verifyPurchase(boolean isVerification) {
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData();
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData<>();
|
||||
LiveData<PurchaseModel> activePurchases = _activePurchases;
|
||||
InAppPurchaseWrapper.getInstance().queryPurchases(
|
||||
_activePurchases, InAppPurchaseWrapper.SubscriptionProduct.VPN);
|
||||
LiveDataUtil.observeOnce(activePurchases, activePurchaseModel -> {
|
||||
mBraveVpnPrefModel = new BraveVpnPrefModel();
|
||||
if (activePurchaseModel != null) {
|
||||
mBraveVpnPrefModel.setPurchaseToken(activePurchaseModel.getPurchaseToken());
|
||||
mBraveVpnPrefModel.setProductId(activePurchaseModel.getProductId());
|
||||
if (BraveVpnPrefUtils.isResetConfiguration()) {
|
||||
BraveVpnUtils.dismissProgressDialog();
|
||||
BraveVpnUtils.openBraveVpnProfileActivity(getActivity());
|
||||
return;
|
||||
}
|
||||
if (!isVerification) {
|
||||
BraveVpnNativeWorker.getInstance().getSubscriberCredential(
|
||||
BraveVpnUtils.SUBSCRIPTION_PARAM_TEXT,
|
||||
mBraveVpnPrefModel.getProductId(), BraveVpnUtils.IAP_ANDROID_PARAM_TEXT,
|
||||
mBraveVpnPrefModel.getPurchaseToken(), getActivity().getPackageName());
|
||||
} else {
|
||||
BraveVpnNativeWorker.getInstance().verifyPurchaseToken(
|
||||
mBraveVpnPrefModel.getPurchaseToken(),
|
||||
mBraveVpnPrefModel.getProductId(),
|
||||
BraveVpnUtils.SUBSCRIPTION_PARAM_TEXT, getActivity().getPackageName());
|
||||
}
|
||||
} else {
|
||||
BraveVpnApiResponseUtils.queryPurchaseFailed(getActivity());
|
||||
BraveVpnUtils.openBraveVpnPlansActivity(getActivity());
|
||||
}
|
||||
});
|
||||
InAppPurchaseWrapper.getInstance()
|
||||
.queryPurchases(_activePurchases, InAppPurchaseWrapper.SubscriptionProduct.VPN);
|
||||
LiveDataUtil.observeOnce(
|
||||
activePurchases,
|
||||
activePurchaseModel -> {
|
||||
mBraveVpnPrefModel = new BraveVpnPrefModel();
|
||||
if (activePurchaseModel != null) {
|
||||
mBraveVpnPrefModel.setPurchaseToken(activePurchaseModel.getPurchaseToken());
|
||||
mBraveVpnPrefModel.setProductId(activePurchaseModel.getProductId());
|
||||
if (BraveVpnPrefUtils.isResetConfiguration()) {
|
||||
BraveVpnUtils.dismissProgressDialog();
|
||||
BraveVpnUtils.openBraveVpnProfileActivity(getActivity());
|
||||
return;
|
||||
}
|
||||
if (!isVerification) {
|
||||
BraveVpnNativeWorker.getInstance()
|
||||
.getSubscriberCredential(
|
||||
BraveVpnUtils.SUBSCRIPTION_PARAM_TEXT,
|
||||
mBraveVpnPrefModel.getProductId(),
|
||||
BraveVpnUtils.IAP_ANDROID_PARAM_TEXT,
|
||||
mBraveVpnPrefModel.getPurchaseToken(),
|
||||
getActivity().getPackageName());
|
||||
} else {
|
||||
BraveVpnNativeWorker.getInstance()
|
||||
.verifyPurchaseToken(
|
||||
mBraveVpnPrefModel.getPurchaseToken(),
|
||||
mBraveVpnPrefModel.getProductId(),
|
||||
BraveVpnUtils.SUBSCRIPTION_PARAM_TEXT,
|
||||
getActivity().getPackageName());
|
||||
}
|
||||
} else {
|
||||
BraveVpnApiResponseUtils.queryPurchaseFailed(getActivity());
|
||||
BraveVpnUtils.openBraveVpnPlansActivity(getActivity());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BraveVpnApiResponseUtils {
|
||||
public static void handleOnGetSubscriberCredential(Activity activity, boolean isSuccess) {
|
||||
if (isSuccess) {
|
||||
if (!BraveVpnNativeWorker.getInstance().isPurchasedUser()) {
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData();
|
||||
MutableLiveData<PurchaseModel> _activePurchases = new MutableLiveData<>();
|
||||
LiveData<PurchaseModel> activePurchases = _activePurchases;
|
||||
InAppPurchaseWrapper.getInstance()
|
||||
.queryPurchases(
|
||||
|
||||
+1
-1
@@ -402,7 +402,7 @@ public class QuickActionSearchAndBookmarkWidgetProvider extends AppWidgetProvide
|
||||
BravePreferenceKeys
|
||||
.BRAVE_QUICK_ACTION_SEARCH_AND_BOOKMARK_WIDGET_TILES,
|
||||
null);
|
||||
List<WidgetTile> widgetTileList = new ArrayList();
|
||||
List<WidgetTile> widgetTileList = new ArrayList<>();
|
||||
|
||||
// Check if there's any saved data
|
||||
if (widgetTilesJson == null || widgetTilesJson.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user