0

Add @NullMarked to a a few files in base, cc, content, ui

Bug: 389129271
Change-Id: Ia204a2336bff8ec4446b7ca3aa34798c3906b22f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6262628
Auto-Submit: Andrew Grieve <agrieve@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Owners-Override: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1419928}
This commit is contained in:
Andrew Grieve
2025-02-13 08:56:36 -08:00
committed by Chromium LUCI CQ
parent c57e52b485
commit 5535e95d4f
10 changed files with 57 additions and 35 deletions
base/android/java/src/org/chromium/base
cc/input/android/java/src/org/chromium/cc/input
content/public/android/java/src/org/chromium
content
browser
content_public
ui/android/java/src/org/chromium/ui

@ -12,8 +12,11 @@ import org.jni_zero.CalledByNative;
import org.jni_zero.JNINamespace; import org.jni_zero.JNINamespace;
import org.jni_zero.NativeMethods; import org.jni_zero.NativeMethods;
import org.chromium.build.annotations.NullMarked;
/** AndroidInfo is a utility class to access Android's Build information specific data. */ /** AndroidInfo is a utility class to access Android's Build information specific data. */
@JNINamespace("base::android::android_info") @JNINamespace("base::android::android_info")
@NullMarked
public final class AndroidInfo { public final class AndroidInfo {
private static final String TAG = "AndroidInfo"; private static final String TAG = "AndroidInfo";

@ -19,6 +19,7 @@ import org.jni_zero.NativeMethods;
import org.chromium.base.version_info.VersionInfo; import org.chromium.base.version_info.VersionInfo;
import org.chromium.build.BuildConfig; import org.chromium.build.BuildConfig;
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable; import org.chromium.build.annotations.Nullable;
/** /**
@ -30,13 +31,14 @@ import org.chromium.build.annotations.Nullable;
* regressions. * regressions.
*/ */
@JNINamespace("base::android::apk_info") @JNINamespace("base::android::apk_info")
@NullMarked
public final class ApkInfo { public final class ApkInfo {
private static final String TAG = "ApkInfo"; private static final String TAG = "ApkInfo";
private static boolean sInitialized; private static boolean sInitialized;
private static @Nullable PackageInfo sBrowserPackageInfo; private static @Nullable PackageInfo sBrowserPackageInfo;
private ApplicationInfo mBrowserApplicationInfo; private final ApplicationInfo mBrowserApplicationInfo;
/** /**
* The package name of the host app which has loaded WebView, retrieved from the application * The package name of the host app which has loaded WebView, retrieved from the application
@ -75,7 +77,7 @@ public final class ApkInfo {
/** Product version as stored in Android resources. */ /** Product version as stored in Android resources. */
private final String mResourcesVersion; private final String mResourcesVersion;
private static volatile ApkInfo sInstance; private static volatile @Nullable ApkInfo sInstance;
private static final Object CREATION_LOCK = new Object(); private static final Object CREATION_LOCK = new Object();
@ -238,15 +240,14 @@ public final class ApkInfo {
// In the case of the SDK Runtime, we would like to retrieve the package name loading the // In the case of the SDK Runtime, we would like to retrieve the package name loading the
// SDK. // SDK.
String appInstalledPackageName = appContextPackageName; String appInstalledPackageName = appContextPackageName;
ApplicationInfo appInfo = appContext.getApplicationInfo();
if (hostInformationProvided) { if (hostInformationProvided) {
mHostPackageName = providedHostPackageName; mHostPackageName = assumeNonNull(providedHostPackageName);
mHostPackageLabel = providedHostPackageLabel; mHostPackageLabel = assumeNonNull(providedHostPackageLabel);
mHostVersionCode = providedHostVersionCode; mHostVersionCode = assumeNonNull(providedHostVersionCode);
mVersionName = providedPackageVersionName; mVersionName = assumeNonNull(providedPackageVersionName);
mPackageName = providedPackageName; mPackageName = assumeNonNull(providedPackageName);
mBrowserApplicationInfo = appContext.getApplicationInfo();
} else { } else {
// The SDK Qualified package name will retrieve the same information as // The SDK Qualified package name will retrieve the same information as
// appInstalledPackageName but prefix it with the SDK Sandbox process so that we can // appInstalledPackageName but prefix it with the SDK Sandbox process so that we can
@ -272,7 +273,6 @@ public final class ApkInfo {
} }
} }
ApplicationInfo appInfo = appContext.getApplicationInfo();
mHostPackageName = sdkQualifiedName; mHostPackageName = sdkQualifiedName;
mHostPackageLabel = nullToEmpty(pm.getApplicationLabel(appInfo)); mHostPackageLabel = nullToEmpty(pm.getApplicationLabel(appInfo));
@ -282,15 +282,16 @@ public final class ApkInfo {
mHostVersionCode = PackageUtils.packageVersionCode(pi); mHostVersionCode = PackageUtils.packageVersionCode(pi);
mPackageName = sBrowserPackageInfo.packageName; mPackageName = sBrowserPackageInfo.packageName;
mVersionName = nullToEmpty(sBrowserPackageInfo.versionName); mVersionName = nullToEmpty(sBrowserPackageInfo.versionName);
mBrowserApplicationInfo = sBrowserPackageInfo.applicationInfo; appInfo = sBrowserPackageInfo.applicationInfo;
sBrowserPackageInfo = null; sBrowserPackageInfo = null;
} else { } else {
mPackageName = appContextPackageName; mPackageName = appContextPackageName;
mHostVersionCode = BuildConfig.VERSION_CODE; mHostVersionCode = BuildConfig.VERSION_CODE;
mVersionName = VersionInfo.getProductVersion(); mVersionName = VersionInfo.getProductVersion();
mBrowserApplicationInfo = appInfo;
} }
} }
assert appInfo != null;
mBrowserApplicationInfo = appInfo;
mInstallerPackageName = nullToEmpty(pm.getInstallerPackageName(appInstalledPackageName)); mInstallerPackageName = nullToEmpty(pm.getInstallerPackageName(appInstalledPackageName));

@ -24,10 +24,12 @@ import org.jni_zero.JniType;
import org.jni_zero.NativeMethods; import org.jni_zero.NativeMethods;
import org.chromium.build.BuildConfig; import org.chromium.build.BuildConfig;
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable; import org.chromium.build.annotations.Nullable;
/** DeviceInfo is a utility class to access the device-related information. */ /** DeviceInfo is a utility class to access the device-related information. */
@JNINamespace("base::android::device_info") @JNINamespace("base::android::device_info")
@NullMarked
public final class DeviceInfo { public final class DeviceInfo {
private static final String TAG = "DeviceInfo"; private static final String TAG = "DeviceInfo";
@ -58,7 +60,7 @@ public final class DeviceInfo {
private final int mVulkanDeqpLevel; private final int mVulkanDeqpLevel;
@GuardedBy("CREATION_LOCK") @GuardedBy("CREATION_LOCK")
private static DeviceInfo sInstance; private static @Nullable DeviceInfo sInstance;
private static final Object CREATION_LOCK = new Object(); private static final Object CREATION_LOCK = new Object();

@ -8,8 +8,11 @@ import com.google.errorprone.annotations.DoNotMock;
import org.jni_zero.CalledByNative; import org.jni_zero.CalledByNative;
import org.chromium.build.annotations.NullMarked;
/** Java counterpart to the native cc::BrowserControlsOffsetTagModifications. */ /** Java counterpart to the native cc::BrowserControlsOffsetTagModifications. */
@DoNotMock("This is a simple value object.") @DoNotMock("This is a simple value object.")
@NullMarked
public final class BrowserControlsOffsetTagModifications { public final class BrowserControlsOffsetTagModifications {
private final BrowserControlsOffsetTags mTags; private final BrowserControlsOffsetTags mTags;

@ -8,12 +8,16 @@ import com.google.errorprone.annotations.DoNotMock;
import org.jni_zero.CalledByNative; import org.jni_zero.CalledByNative;
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;
/** Java counterpart to the native cc::BrowserControlsOffsetTags. */ /** Java counterpart to the native cc::BrowserControlsOffsetTags. */
@DoNotMock("This is a simple value object.") @DoNotMock("This is a simple value object.")
@NullMarked
public final class BrowserControlsOffsetTags { public final class BrowserControlsOffsetTags {
private final OffsetTag mTopControlsOffsetTag; private final @Nullable OffsetTag mTopControlsOffsetTag;
private final OffsetTag mContentOffsetTag; private final @Nullable OffsetTag mContentOffsetTag;
private final OffsetTag mBottomControlsOffsetTag; private final @Nullable OffsetTag mBottomControlsOffsetTag;
public BrowserControlsOffsetTags() { public BrowserControlsOffsetTags() {
mTopControlsOffsetTag = OffsetTag.createRandom(); mTopControlsOffsetTag = OffsetTag.createRandom();
@ -22,7 +26,9 @@ public final class BrowserControlsOffsetTags {
} }
public BrowserControlsOffsetTags( public BrowserControlsOffsetTags(
OffsetTag topControls, OffsetTag content, OffsetTag bottomControls) { @Nullable OffsetTag topControls,
@Nullable OffsetTag content,
@Nullable OffsetTag bottomControls) {
mTopControlsOffsetTag = topControls; mTopControlsOffsetTag = topControls;
mContentOffsetTag = content; mContentOffsetTag = content;
mBottomControlsOffsetTag = bottomControls; mBottomControlsOffsetTag = bottomControls;
@ -41,17 +47,17 @@ public final class BrowserControlsOffsetTags {
} }
@CalledByNative @CalledByNative
public OffsetTag getBottomControlsOffsetTag() { public @Nullable OffsetTag getBottomControlsOffsetTag() {
return mBottomControlsOffsetTag; return mBottomControlsOffsetTag;
} }
@CalledByNative @CalledByNative
public OffsetTag getContentOffsetTag() { public @Nullable OffsetTag getContentOffsetTag() {
return mContentOffsetTag; return mContentOffsetTag;
} }
@CalledByNative @CalledByNative
public OffsetTag getTopControlsOffsetTag() { public @Nullable OffsetTag getTopControlsOffsetTag() {
return mTopControlsOffsetTag; return mTopControlsOffsetTag;
} }
} }

@ -867,7 +867,7 @@ public class WebContentsImpl
} }
@Override @Override
public void setStylusWritingHandler(StylusWritingHandler stylusWritingHandler) { public void setStylusWritingHandler(@Nullable StylusWritingHandler stylusWritingHandler) {
mStylusWritingHandler = stylusWritingHandler; mStylusWritingHandler = stylusWritingHandler;
if (mNativeWebContentsAndroid == 0) return; if (mNativeWebContentsAndroid == 0) return;
WebContentsImplJni.get() WebContentsImplJni.get()

@ -452,14 +452,13 @@ public interface WebContents extends Parcelable {
* *
* @param stylusWritingHandler the object that implements StylusWritingHandler interface. * @param stylusWritingHandler the object that implements StylusWritingHandler interface.
*/ */
void setStylusWritingHandler(StylusWritingHandler stylusWritingHandler); void setStylusWritingHandler(@Nullable StylusWritingHandler stylusWritingHandler);
/** /**
* @return {@link StylusWritingImeCallback} which is used to implement the IME functionality for * @return {@link StylusWritingImeCallback} which is used to implement the IME functionality for
* the Stylus handwriting feature. * the Stylus handwriting feature.
*/ */
@Nullable @Nullable StylusWritingImeCallback getStylusWritingImeCallback();
StylusWritingImeCallback getStylusWritingImeCallback();
/** /**
* Returns {@link EventForwarder} which is used to forward input/view events to native content * Returns {@link EventForwarder} which is used to forward input/view events to native content
@ -522,8 +521,7 @@ public interface WebContents extends Parcelable {
* the rectangle is meaningless. Will return null if there is no such video. Fullscreen videos * the rectangle is meaningless. Will return null if there is no such video. Fullscreen videos
* may take a moment to register. * may take a moment to register.
*/ */
@Nullable @Nullable Rect getFullscreenVideoSize();
Rect getFullscreenVideoSize();
/** /**
* Notifies the WebContents about the new persistent video status. It should be called whenever * Notifies the WebContents about the new persistent video status. It should be called whenever

@ -8,34 +8,38 @@ import com.google.errorprone.annotations.DoNotMock;
import org.jni_zero.CalledByNative; import org.jni_zero.CalledByNative;
import org.chromium.build.annotations.NullMarked;
import org.chromium.build.annotations.Nullable;
/** Java counterpart to the native ui::android::BrowserControlsOffsetTagConstraints. */ /** Java counterpart to the native ui::android::BrowserControlsOffsetTagConstraints. */
@DoNotMock("This is a simple value object.") @DoNotMock("This is a simple value object.")
@NullMarked
public final class BrowserControlsOffsetTagConstraints { public final class BrowserControlsOffsetTagConstraints {
private final OffsetTagConstraints mTopControlsConstraints; private final @Nullable OffsetTagConstraints mTopControlsConstraints;
private final OffsetTagConstraints mContentConstraints; private final @Nullable OffsetTagConstraints mContentConstraints;
private final OffsetTagConstraints mBottomControlsConstraints; private final @Nullable OffsetTagConstraints mBottomControlsConstraints;
public BrowserControlsOffsetTagConstraints( public BrowserControlsOffsetTagConstraints(
OffsetTagConstraints topControlsConstraints, @Nullable OffsetTagConstraints topControlsConstraints,
OffsetTagConstraints contentConstraints, @Nullable OffsetTagConstraints contentConstraints,
OffsetTagConstraints bottomControlsConstraints) { @Nullable OffsetTagConstraints bottomControlsConstraints) {
mTopControlsConstraints = topControlsConstraints; mTopControlsConstraints = topControlsConstraints;
mContentConstraints = contentConstraints; mContentConstraints = contentConstraints;
mBottomControlsConstraints = bottomControlsConstraints; mBottomControlsConstraints = bottomControlsConstraints;
} }
@CalledByNative @CalledByNative
public OffsetTagConstraints getTopControlsConstraints() { public @Nullable OffsetTagConstraints getTopControlsConstraints() {
return mTopControlsConstraints; return mTopControlsConstraints;
} }
@CalledByNative @CalledByNative
public OffsetTagConstraints getContentConstraints() { public @Nullable OffsetTagConstraints getContentConstraints() {
return mContentConstraints; return mContentConstraints;
} }
@CalledByNative @CalledByNative
public OffsetTagConstraints getBottomControlsConstraints() { public @Nullable OffsetTagConstraints getBottomControlsConstraints() {
return mBottomControlsConstraints; return mBottomControlsConstraints;
} }
} }

@ -8,10 +8,12 @@ import com.google.errorprone.annotations.DoNotMock;
import org.jni_zero.CalledByNative; import org.jni_zero.CalledByNative;
import org.chromium.build.annotations.NullMarked;
import org.chromium.cc.input.BrowserControlsOffsetTags; import org.chromium.cc.input.BrowserControlsOffsetTags;
/** Java counterpart to the native ui::BrowserControlsOffsetTagDefinitions. */ /** Java counterpart to the native ui::BrowserControlsOffsetTagDefinitions. */
@DoNotMock("This is a simple value object.") @DoNotMock("This is a simple value object.")
@NullMarked
public final class BrowserControlsOffsetTagDefinitions { public final class BrowserControlsOffsetTagDefinitions {
private final BrowserControlsOffsetTags mTags; private final BrowserControlsOffsetTags mTags;
private final BrowserControlsOffsetTagConstraints mConstraints; private final BrowserControlsOffsetTagConstraints mConstraints;

@ -8,8 +8,11 @@ import com.google.errorprone.annotations.DoNotMock;
import org.jni_zero.CalledByNative; import org.jni_zero.CalledByNative;
import org.chromium.build.annotations.NullMarked;
/** Java counterpart to the native viz::OffsetTagConstraints. */ /** Java counterpart to the native viz::OffsetTagConstraints. */
@DoNotMock("This is a simple value object.") @DoNotMock("This is a simple value object.")
@NullMarked
public final class OffsetTagConstraints { public final class OffsetTagConstraints {
public float mMinX; public float mMinX;
public float mMinY; public float mMinY;