diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/shell/platform/android/io/flutter/embedding/android/FlutterView.java index cb6269756a9d6..19b4986c7efe9 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -878,7 +878,7 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) { * previous {@code keyCode} to generate a unicode combined character. */ @Override - public boolean dispatchKeyEvent(KeyEvent event) { + public boolean dispatchKeyEvent(@NonNull KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { // Tell Android to start tracking this event. getKeyDispatcherState().startTracking(event, this); @@ -987,6 +987,7 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() { * @return The view matching the accessibility id if any. */ @SuppressLint("SoonBlockedPrivateApi") + @Nullable public View findViewByAccessibilityIdTraversal(int accessibilityId) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) { return findViewByAccessibilityIdRootedAtCurrentView(accessibilityId, this); @@ -1333,7 +1334,7 @@ public void onFlutterUiNoLongerDisplayed() { }); } - public void attachOverlaySurfaceToRender(FlutterImageView view) { + public void attachOverlaySurfaceToRender(@NonNull FlutterImageView view) { if (flutterEngine != null) { view.attachToRenderer(flutterEngine.getRenderer()); } @@ -1434,13 +1435,13 @@ private void sendViewportMetricsToFlutter() { } @Override - public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) { + public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure, int flags) { super.onProvideAutofillVirtualStructure(structure, flags); textInputPlugin.onProvideAutofillVirtualStructure(structure, flags); } @Override - public void autofill(SparseArray values) { + public void autofill(@NonNull SparseArray values) { textInputPlugin.autofill(values); } diff --git a/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java b/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java index b2a10184f6610..dba9780a2c10a 100644 --- a/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java +++ b/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java @@ -79,7 +79,9 @@ public class KeyboardManager { * dispatched to. */ public KeyboardManager( - View view, @NonNull TextInputPlugin textInputPlugin, Responder[] responders) { + @NonNull View view, + @NonNull TextInputPlugin textInputPlugin, + @NonNull Responder[] responders) { this.view = view; this.textInputPlugin = textInputPlugin; this.responders = responders; @@ -103,7 +105,7 @@ public KeyboardManager( */ interface Responder { interface OnKeyEventHandledCallback { - void onKeyEventHandled(Boolean canHandleEvent); + void onKeyEventHandled(boolean canHandleEvent); } /** @@ -122,7 +124,7 @@ private class Callback implements OnKeyEventHandledCallback { boolean isCalled = false; @Override - public void onKeyEventHandled(Boolean canHandleEvent) { + public void onKeyEventHandled(boolean canHandleEvent) { if (isCalled) { throw new IllegalStateException( "The onKeyEventHandledCallback should be called exactly once."); @@ -140,7 +142,7 @@ public void onKeyEventHandled(Boolean canHandleEvent) { this.keyEvent = keyEvent; } - @NonNull final KeyEvent keyEvent; + final KeyEvent keyEvent; int unrepliedCount = responders.length; boolean isEventHandled = false; @@ -149,9 +151,9 @@ public OnKeyEventHandledCallback buildCallback() { } } - @NonNull protected final Responder[] responders; - @NonNull private final HashSet redispatchedEvents = new HashSet<>(); - @NonNull private final TextInputPlugin textInputPlugin; + protected final Responder[] responders; + private final HashSet redispatchedEvents = new HashSet<>(); + private final TextInputPlugin textInputPlugin; private final View view; public boolean handleEvent(@NonNull KeyEvent keyEvent) { diff --git a/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java b/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java index 1cd12b6e17e77..9ac225c83ae7f 100644 --- a/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java +++ b/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java @@ -2,6 +2,7 @@ import android.util.LongSparseArray; import android.view.MotionEvent; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import java.util.PriorityQueue; import java.util.concurrent.atomic.AtomicLong; @@ -18,10 +19,12 @@ private MotionEventId(long id) { this.id = id; } + @NonNull public static MotionEventId from(long id) { return new MotionEventId(id); } + @NonNull public static MotionEventId createUnique() { return MotionEventId.from(ID_COUNTER.incrementAndGet()); } @@ -35,6 +38,7 @@ public long getId() { private final PriorityQueue unusedEvents; private static MotionEventTracker INSTANCE; + @NonNull public static MotionEventTracker getInstance() { if (INSTANCE == null) { INSTANCE = new MotionEventTracker(); @@ -48,7 +52,8 @@ private MotionEventTracker() { } /** Tracks the event and returns a unique MotionEventId identifying the event. */ - public MotionEventId track(MotionEvent event) { + @NonNull + public MotionEventId track(@NonNull MotionEvent event) { MotionEventId eventId = MotionEventId.createUnique(); eventById.put(eventId.id, MotionEvent.obtain(event)); unusedEvents.add(eventId.id); @@ -61,7 +66,7 @@ public MotionEventId track(MotionEvent event) { * popped or discarded. */ @Nullable - public MotionEvent pop(MotionEventId eventId) { + public MotionEvent pop(@NonNull MotionEventId eventId) { // remove all the older events. while (!unusedEvents.isEmpty() && unusedEvents.peek() < eventId.id) { eventById.remove(unusedEvents.poll()); diff --git a/shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java b/shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java index 156531eb011b8..989566872de04 100644 --- a/shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java +++ b/shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java @@ -66,7 +66,7 @@ public class PlayStoreDeferredComponentManager implements DeferredComponentManag private class FeatureInstallStateUpdatedListener implements SplitInstallStateUpdatedListener { @SuppressLint("DefaultLocale") - public void onStateUpdate(SplitInstallSessionState state) { + public void onStateUpdate(@NonNull SplitInstallSessionState state) { int sessionId = state.sessionId(); if (sessionIdToName.get(sessionId) != null) { switch (state.status()) { @@ -231,7 +231,7 @@ private boolean verifyJNI() { return true; } - public void setDeferredComponentChannel(DeferredComponentChannel channel) { + public void setDeferredComponentChannel(@NonNull DeferredComponentChannel channel) { this.channel = channel; } @@ -288,7 +288,7 @@ private void initLoadingUnitMappingToComponentNames() { } } - public void installDeferredComponent(int loadingUnitId, String componentName) { + public void installDeferredComponent(int loadingUnitId, @Nullable String componentName) { String resolvedComponentName = componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId); if (resolvedComponentName == null) { @@ -357,7 +357,9 @@ public void installDeferredComponent(int loadingUnitId, String componentName) { }); } - public String getDeferredComponentInstallState(int loadingUnitId, String componentName) { + @NonNull + public String getDeferredComponentInstallState( + int loadingUnitId, @Nullable String componentName) { String resolvedComponentName = componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId); if (resolvedComponentName == null) { @@ -375,7 +377,7 @@ public String getDeferredComponentInstallState(int loadingUnitId, String compone return sessionIdToState.get(sessionId); } - public void loadAssets(int loadingUnitId, String componentName) { + public void loadAssets(int loadingUnitId, @NonNull String componentName) { if (!verifyJNI()) { return; } @@ -393,7 +395,7 @@ public void loadAssets(int loadingUnitId, String componentName) { } } - public void loadDartLibrary(int loadingUnitId, String componentName) { + public void loadDartLibrary(int loadingUnitId, @NonNull String componentName) { if (!verifyJNI()) { return; } @@ -478,7 +480,7 @@ public void loadDartLibrary(int loadingUnitId, String componentName) { loadingUnitId, searchPaths.toArray(new String[searchPaths.size()])); } - public boolean uninstallDeferredComponent(int loadingUnitId, String componentName) { + public boolean uninstallDeferredComponent(int loadingUnitId, @Nullable String componentName) { String resolvedComponentName = componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId); if (resolvedComponentName == null) { diff --git a/shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java b/shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java index 671e24e0ee53c..b5db78ab35dd0 100644 --- a/shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java +++ b/shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java @@ -48,7 +48,8 @@ public ShimPluginRegistry(@NonNull FlutterEngine flutterEngine) { } @Override - public Registrar registrarFor(String pluginKey) { + @NonNull + public Registrar registrarFor(@NonNull String pluginKey) { Log.v(TAG, "Creating plugin Registrar for '" + pluginKey + "'"); if (pluginMap.containsKey(pluginKey)) { throw new IllegalStateException("Plugin key " + pluginKey + " is already in use"); @@ -60,13 +61,13 @@ public Registrar registrarFor(String pluginKey) { } @Override - public boolean hasPlugin(String pluginKey) { + public boolean hasPlugin(@NonNull String pluginKey) { return pluginMap.containsKey(pluginKey); } @Override @SuppressWarnings("unchecked") - public T valuePublishedByPlugin(String pluginKey) { + public T valuePublishedByPlugin(@NonNull String pluginKey) { return (T) pluginMap.get(pluginKey); } diff --git a/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java b/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java index 55f183c6c6cd6..379fd3c558fc1 100644 --- a/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java +++ b/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java @@ -86,7 +86,7 @@ public void detachFromGLContext() { // Called by native. @SuppressWarnings("unused") - public void getTransformMatrix(float[] mtx) { + public void getTransformMatrix(@NonNull float[] mtx) { surfaceTexture.getTransformMatrix(mtx); } } diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java index f060a4d89eb45..dbd94b719f074 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java @@ -110,6 +110,7 @@ public interface LocalizationMessageHandler { * The Flutter application would like to obtain the string resource of given {@code key} in * {@code locale}. */ - String getStringResource(@NonNull String key, String locale); + @NonNull + String getStringResource(@NonNull String key, @NonNull String locale); } } diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java index 7249620ecdd1d..1616bb1e93622 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java @@ -5,6 +5,7 @@ package io.flutter.embedding.engine.systemchannels; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.flutter.Log; import io.flutter.embedding.engine.dart.DartExecutor; import io.flutter.plugin.common.MethodCall; @@ -72,12 +73,13 @@ public RestorationChannel( private boolean frameworkHasRequestedData = false; /** Obtain the most current restoration data that the framework has provided. */ + @Nullable public byte[] getRestorationData() { return restorationData; } /** Set the restoration data from which the framework will restore its state. */ - public void setRestorationData(byte[] data) { + public void setRestorationData(@NonNull byte[] data) { engineHasProvidedData = true; if (pendingFrameworkRestorationChannelRequest != null) { // If their is a pending request from the framework, answer it. diff --git a/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java b/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java index 4c497e05d092b..a48e073dc5f60 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -203,7 +203,7 @@ private static HashMap createEditingDeltaJSON( */ public void updateEditingState( int inputClientId, - String text, + @NonNull String text, int selectionStart, int selectionEnd, int composingStart, @@ -233,7 +233,7 @@ public void updateEditingState( } public void updateEditingStateWithDeltas( - int inputClientId, ArrayList batchDeltas) { + int inputClientId, @NonNull ArrayList batchDeltas) { Log.v( TAG, @@ -248,7 +248,7 @@ public void updateEditingStateWithDeltas( } public void updateEditingStateWithTag( - int inputClientId, HashMap editStates) { + int inputClientId, @NonNull HashMap editStates) { Log.v( TAG, "Sending message to update editing state for " @@ -323,7 +323,8 @@ public void unspecifiedAction(int inputClientId) { Arrays.asList(inputClientId, "TextInputAction.unspecified")); } - public void performPrivateCommand(int inputClientId, String action, Bundle data) { + public void performPrivateCommand( + int inputClientId, @NonNull String action, @NonNull Bundle data) { HashMap json = new HashMap<>(); json.put("action", action); if (data != null) { @@ -411,7 +412,7 @@ public interface TextInputMethodHandler { * @param transform a 4x4 matrix that maps the local paint coordinate system to coordinate * system of the FlutterView that owns the current client. */ - void setEditableSizeAndTransform(double width, double height, double[] transform); + void setEditableSizeAndTransform(double width, double height, @NonNull double[] transform); // TODO(mattcarroll): javadoc void setEditingState(@NonNull TextEditState editingState); @@ -428,11 +429,12 @@ public interface TextInputMethodHandler { * commands. * @param data Any data to include with the command. */ - void sendAppPrivateCommand(String action, Bundle data); + void sendAppPrivateCommand(@NonNull String action, @NonNull Bundle data); } /** A text editing configuration. */ public static class Configuration { + @NonNull public static Configuration fromJson(@NonNull JSONObject json) throws JSONException, NoSuchFieldException { final String inputActionName = json.getString("inputAction"); @@ -490,6 +492,7 @@ private static Integer inputActionFromTextInputAction(@NonNull String inputActio } public static class Autofill { + @NonNull public static Autofill fromJson(@NonNull JSONObject json) throws JSONException, NoSuchFieldException { final String uniqueIdentifier = json.getString("uniqueIdentifier"); @@ -725,6 +728,7 @@ static TextCapitalization fromValue(@NonNull String encodedName) throws NoSuchFi /** State of an on-going text editing session. */ public static class TextEditState { + @NonNull public static TextEditState fromJson(@NonNull JSONObject textEditState) throws JSONException { return new TextEditState( textEditState.getString("text"), diff --git a/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java b/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java index c6bf0e668b790..b2b57a452d4f8 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java @@ -4,6 +4,7 @@ package io.flutter.plugin.common; +import androidx.annotation.Nullable; import java.nio.ByteBuffer; import org.json.JSONException; import org.json.JSONObject; @@ -28,7 +29,8 @@ public final class JSONMessageCodec implements MessageCodec { private JSONMessageCodec() {} @Override - public ByteBuffer encodeMessage(Object message) { + @Nullable + public ByteBuffer encodeMessage(@Nullable Object message) { if (message == null) { return null; } @@ -41,7 +43,8 @@ public ByteBuffer encodeMessage(Object message) { } @Override - public Object decodeMessage(ByteBuffer message) { + @Nullable + public Object decodeMessage(@Nullable ByteBuffer message) { if (message == null) { return null; } diff --git a/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java b/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java index df96af0c66b5c..3869bd5169c50 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java @@ -4,6 +4,8 @@ package io.flutter.plugin.common; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.nio.ByteBuffer; import org.json.JSONArray; import org.json.JSONException; @@ -26,7 +28,8 @@ public final class JSONMethodCodec implements MethodCodec { private JSONMethodCodec() {} @Override - public ByteBuffer encodeMethodCall(MethodCall methodCall) { + @NonNull + public ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall) { try { final JSONObject map = new JSONObject(); map.put("method", methodCall.method); @@ -38,7 +41,8 @@ public ByteBuffer encodeMethodCall(MethodCall methodCall) { } @Override - public MethodCall decodeMethodCall(ByteBuffer message) { + @NonNull + public MethodCall decodeMethodCall(@NonNull ByteBuffer message) { try { final Object json = JSONMessageCodec.INSTANCE.decodeMessage(message); if (json instanceof JSONObject) { @@ -56,13 +60,15 @@ public MethodCall decodeMethodCall(ByteBuffer message) { } @Override - public ByteBuffer encodeSuccessEnvelope(Object result) { + @NonNull + public ByteBuffer encodeSuccessEnvelope(@Nullable Object result) { return JSONMessageCodec.INSTANCE.encodeMessage(new JSONArray().put(JSONUtil.wrap(result))); } @Override + @NonNull public ByteBuffer encodeErrorEnvelope( - String errorCode, String errorMessage, Object errorDetails) { + @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { return JSONMessageCodec.INSTANCE.encodeMessage( new JSONArray() .put(errorCode) @@ -71,8 +77,12 @@ public ByteBuffer encodeErrorEnvelope( } @Override + @NonNull public ByteBuffer encodeErrorEnvelopeWithStacktrace( - String errorCode, String errorMessage, Object errorDetails, String errorStacktrace) { + @NonNull String errorCode, + @Nullable String errorMessage, + @Nullable Object errorDetails, + @Nullable String errorStacktrace) { return JSONMessageCodec.INSTANCE.encodeMessage( new JSONArray() .put(errorCode) @@ -82,7 +92,8 @@ public ByteBuffer encodeErrorEnvelopeWithStacktrace( } @Override - public Object decodeEnvelope(ByteBuffer envelope) { + @NonNull + public Object decodeEnvelope(@NonNull ByteBuffer envelope) { try { final Object json = JSONMessageCodec.INSTANCE.decodeMessage(envelope); if (json instanceof JSONArray) { diff --git a/shell/platform/android/io/flutter/plugin/common/JSONUtil.java b/shell/platform/android/io/flutter/plugin/common/JSONUtil.java index bb59833b29fe4..1ee87f6fc397f 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONUtil.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONUtil.java @@ -1,5 +1,6 @@ package io.flutter.plugin.common; +import androidx.annotation.Nullable; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; @@ -17,7 +18,8 @@ private JSONUtil() {} * Convert the Json java representation to Java objects. Particularly used for converting * JSONArray and JSONObject to Lists and Maps. */ - public static Object unwrap(Object o) { + @Nullable + public static Object unwrap(@Nullable Object o) { if (JSONObject.NULL.equals(o) || o == null) { return null; } @@ -57,7 +59,8 @@ public static Object unwrap(Object o) { } /** Backport of {@link JSONObject#wrap(Object)} for use on pre-KitKat systems. */ - public static Object wrap(Object o) { + @Nullable + public static Object wrap(@Nullable Object o) { if (o == null) { return JSONObject.NULL; } diff --git a/shell/platform/android/io/flutter/plugin/common/MethodCall.java b/shell/platform/android/io/flutter/plugin/common/MethodCall.java index 8a6e51783e696..7181a548e713a 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodCall.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodCall.java @@ -4,6 +4,7 @@ package io.flutter.plugin.common; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import io.flutter.BuildConfig; import java.util.Map; @@ -27,9 +28,10 @@ public final class MethodCall { * Creates a {@link MethodCall} with the specified method name and arguments. * * @param method the method name String, not null. - * @param arguments the arguments, a value supported by the channel's message codec. + * @param arguments the arguments, a value supported by the channel's message codec. Possibly, + * null. */ - public MethodCall(String method, Object arguments) { + public MethodCall(@NonNull String method, @Nullable Object arguments) { if (BuildConfig.DEBUG && method == null) { throw new AssertionError("Parameter method must not be null."); } @@ -44,6 +46,7 @@ public MethodCall(String method, Object arguments) { * @return the arguments with static type T */ @SuppressWarnings("unchecked") + @Nullable public T arguments() { return (T) arguments; } @@ -62,7 +65,7 @@ public T arguments() { */ @SuppressWarnings("unchecked") @Nullable - public T argument(String key) { + public T argument(@NonNull String key) { if (arguments == null) { return null; } else if (arguments instanceof Map) { @@ -85,7 +88,7 @@ public T argument(String key) { * @throws ClassCastException if {@link #arguments} can be cast to neither {@link Map} nor {@link * JSONObject}. */ - public boolean hasArgument(String key) { + public boolean hasArgument(@NonNull String key) { if (arguments == null) { return false; } else if (arguments instanceof Map) { diff --git a/shell/platform/android/io/flutter/plugin/common/MethodChannel.java b/shell/platform/android/io/flutter/plugin/common/MethodChannel.java index 5e187cf94cd47..c13f82d2beb1f 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodChannel.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodChannel.java @@ -44,7 +44,7 @@ public class MethodChannel { * @param messenger a {@link BinaryMessenger}. * @param name a channel name String. */ - public MethodChannel(BinaryMessenger messenger, String name) { + public MethodChannel(@NonNull BinaryMessenger messenger, @NonNull String name) { this(messenger, name, StandardMethodCodec.INSTANCE); } @@ -56,7 +56,8 @@ public MethodChannel(BinaryMessenger messenger, String name) { * @param name a channel name String. * @param codec a {@link MessageCodec}. */ - public MethodChannel(BinaryMessenger messenger, String name, MethodCodec codec) { + public MethodChannel( + @NonNull BinaryMessenger messenger, @NonNull String name, @NonNull MethodCodec codec) { this(messenger, name, codec, null); } @@ -72,9 +73,9 @@ public MethodChannel(BinaryMessenger messenger, String name, MethodCodec codec) * BinaryMessenger#makeBackgroundTaskQueue()}. */ public MethodChannel( - BinaryMessenger messenger, - String name, - MethodCodec codec, + @NonNull BinaryMessenger messenger, + @NonNull String name, + @NonNull MethodCodec codec, @Nullable BinaryMessenger.TaskQueue taskQueue) { if (BuildConfig.DEBUG) { if (messenger == null) { @@ -114,7 +115,8 @@ public void invokeMethod(@NonNull String method, @Nullable Object arguments) { * @param callback a {@link Result} callback for the invocation result, or null. */ @UiThread - public void invokeMethod(String method, @Nullable Object arguments, @Nullable Result callback) { + public void invokeMethod( + @NonNull String method, @Nullable Object arguments, @Nullable Result callback) { messenger.send( name, codec.encodeMethodCall(new MethodCall(method, arguments)), @@ -212,7 +214,8 @@ public interface Result { * supported by the codec. For instance, if you are using {@link StandardMessageCodec} * (default), please see its documentation on what types are supported. */ - void error(String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); + void error( + @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); /** Handles a call to an unimplemented method. */ void notImplemented(); diff --git a/shell/platform/android/io/flutter/plugin/common/MethodCodec.java b/shell/platform/android/io/flutter/plugin/common/MethodCodec.java index f958a5307ae9c..74594ad1e69a8 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodCodec.java @@ -4,6 +4,8 @@ package io.flutter.plugin.common; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import java.nio.ByteBuffer; /** @@ -23,7 +25,8 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - ByteBuffer encodeMethodCall(MethodCall methodCall); + @NonNull + ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall); /** * Decodes a message call from binary. @@ -32,7 +35,8 @@ public interface MethodCodec { * @return a {@link MethodCall} representation of the bytes between the given buffer's current * position and its limit. */ - MethodCall decodeMethodCall(ByteBuffer methodCall); + @NonNull + MethodCall decodeMethodCall(@NonNull ByteBuffer methodCall); /** * Encodes a successful result into a binary envelope message. @@ -41,7 +45,8 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - ByteBuffer encodeSuccessEnvelope(Object result); + @NonNull + ByteBuffer encodeSuccessEnvelope(@Nullable Object result); /** * Encodes an error result into a binary envelope message. @@ -53,7 +58,9 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - ByteBuffer encodeErrorEnvelope(String errorCode, String errorMessage, Object errorDetails); + @NonNull + ByteBuffer encodeErrorEnvelope( + @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); /** * Encodes an error result into a binary envelope message with the native stacktrace. @@ -66,8 +73,12 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ + @NonNull ByteBuffer encodeErrorEnvelopeWithStacktrace( - String errorCode, String errorMessage, Object errorDetails, String errorStacktrace); + @NonNull String errorCode, + @Nullable String errorMessage, + @Nullable Object errorDetails, + @Nullable String errorStacktrace); /** * Decodes a result envelope from binary. @@ -76,5 +87,6 @@ ByteBuffer encodeErrorEnvelopeWithStacktrace( * @return the enveloped result Object. * @throws FlutterException if the envelope was an error envelope. */ - Object decodeEnvelope(ByteBuffer envelope); + @NonNull + Object decodeEnvelope(@NonNull ByteBuffer envelope); } diff --git a/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java b/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java index d645e98f7edfa..29b6097933b60 100644 --- a/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java +++ b/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java @@ -7,6 +7,8 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.flutter.embedding.engine.plugins.FlutterPlugin; import io.flutter.embedding.engine.plugins.activity.ActivityAware; import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding; @@ -36,7 +38,8 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - Registrar registrarFor(String pluginKey); + @NonNull + Registrar registrarFor(@NonNull String pluginKey); /** * Returns whether the specified plugin is known to this registry. @@ -47,7 +50,7 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - boolean hasPlugin(String pluginKey); + boolean hasPlugin(@NonNull String pluginKey); /** * Returns the value published by the specified plugin, if any. @@ -63,7 +66,8 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - T valuePublishedByPlugin(String pluginKey); + @Nullable + T valuePublishedByPlugin(@NonNull String pluginKey); /** * Receiver of registrations from a single plugin. @@ -95,6 +99,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @Nullable Activity activity(); /** @@ -107,6 +112,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @NonNull Context context(); /** @@ -122,6 +128,7 @@ interface Registrar { * @return the current {@link #activity() Activity}, if not null, otherwise the {@link * #context() Application}. */ + @NonNull Context activeContext(); /** @@ -135,6 +142,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @NonNull BinaryMessenger messenger(); /** @@ -147,6 +155,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @NonNull TextureRegistry textures(); /** @@ -161,6 +170,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @NonNull PlatformViewRegistry platformViewRegistry(); /** @@ -176,6 +186,7 @@ interface Registrar { *

For instructions on migrating a plugin from Flutter's v1 Android embedding to v2, visit * http://flutter.dev/go/android-plugin-migration */ + @NonNull FlutterView view(); /** @@ -187,7 +198,8 @@ interface Registrar { * @param asset the name of the asset. The name can be hierarchical * @return the filename to be used with {@link android.content.res.AssetManager} */ - String lookupKeyForAsset(String asset); + @NonNull + String lookupKeyForAsset(@NonNull String asset); /** * Returns the file name for the given asset which originates from the specified packageName. @@ -200,7 +212,8 @@ interface Registrar { * @param packageName the name of the package from which the asset originates * @return the file name to be used with {@link android.content.res.AssetManager} */ - String lookupKeyForAsset(String asset, String packageName); + @NonNull + String lookupKeyForAsset(@NonNull String asset, @NonNull String packageName); /** * Publishes a value associated with the plugin being registered. @@ -222,7 +235,8 @@ interface Registrar { * @param value the value, possibly null. * @return this {@link Registrar}. */ - Registrar publish(Object value); + @NonNull + Registrar publish(@Nullable Object value); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@code @@ -240,7 +254,9 @@ interface Registrar { * @param listener a {@link RequestPermissionsResultListener} callback. * @return this {@link Registrar}. */ - Registrar addRequestPermissionsResultListener(RequestPermissionsResultListener listener); + @NonNull + Registrar addRequestPermissionsResultListener( + @NonNull RequestPermissionsResultListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -256,7 +272,8 @@ interface Registrar { * @param listener an {@link ActivityResultListener} callback. * @return this {@link Registrar}. */ - Registrar addActivityResultListener(ActivityResultListener listener); + @NonNull + Registrar addActivityResultListener(@NonNull ActivityResultListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -272,7 +289,8 @@ interface Registrar { * @param listener a {@link NewIntentListener} callback. * @return this {@link Registrar}. */ - Registrar addNewIntentListener(NewIntentListener listener); + @NonNull + Registrar addNewIntentListener(@NonNull NewIntentListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -288,7 +306,8 @@ interface Registrar { * @param listener a {@link UserLeaveHintListener} callback. * @return this {@link Registrar}. */ - Registrar addUserLeaveHintListener(UserLeaveHintListener listener); + @NonNull + Registrar addUserLeaveHintListener(@NonNull UserLeaveHintListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -312,7 +331,8 @@ interface Registrar { */ // TODO(amirh): Add a line in the javadoc above that points to a Platform Views website guide // when one is available (but not a website API doc) - Registrar addViewDestroyListener(ViewDestroyListener listener); + @NonNull + Registrar addViewDestroyListener(@NonNull ViewDestroyListener listener); } /** @@ -328,7 +348,8 @@ interface RequestPermissionsResultListener { * {@code PackageManager.PERMISSION_GRANTED} or {@code PackageManager.PERMISSION_DENIED}. * @return true if the result has been handled. */ - boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); + boolean onRequestPermissionsResult( + int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults); } /** @@ -345,7 +366,7 @@ interface ActivityResultListener { * attached to Intent "extras"). * @return true if the result has been handled. */ - boolean onActivityResult(int requestCode, int resultCode, Intent data); + boolean onActivityResult(int requestCode, int resultCode, @NonNull Intent data); } /** @@ -356,7 +377,7 @@ interface NewIntentListener { * @param intent The new intent that was started for the activity. * @return true if the new intent has been handled. */ - boolean onNewIntent(Intent intent); + boolean onNewIntent(@NonNull Intent intent); } /** @@ -376,7 +397,7 @@ interface UserLeaveHintListener { */ @Deprecated interface ViewDestroyListener { - boolean onViewDestroy(FlutterNativeView view); + boolean onViewDestroy(@NonNull FlutterNativeView view); } /** @@ -389,6 +410,6 @@ interface ViewDestroyListener { */ @Deprecated interface PluginRegistrantCallback { - void registerWith(PluginRegistry registry); + void registerWith(@NonNull PluginRegistry registry); } } diff --git a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java index 8050292174c6c..3cd1bf31cc33d 100644 --- a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -4,6 +4,8 @@ package io.flutter.plugin.common; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.flutter.BuildConfig; import io.flutter.Log; import java.io.ByteArrayOutputStream; @@ -65,7 +67,8 @@ public class StandardMessageCodec implements MessageCodec { public static final StandardMessageCodec INSTANCE = new StandardMessageCodec(); @Override - public ByteBuffer encodeMessage(Object message) { + @Nullable + public ByteBuffer encodeMessage(@Nullable Object message) { if (message == null) { return null; } @@ -77,7 +80,8 @@ public ByteBuffer encodeMessage(Object message) { } @Override - public Object decodeMessage(ByteBuffer message) { + @Nullable + public Object decodeMessage(@Nullable ByteBuffer message) { if (message == null) { return null; } @@ -111,7 +115,7 @@ public Object decodeMessage(ByteBuffer message) { * Writes an int representing a size to the specified stream. Uses an expanding code of 1 to 5 * bytes to optimize for small values. */ - protected static final void writeSize(ByteArrayOutputStream stream, int value) { + protected static final void writeSize(@NonNull ByteArrayOutputStream stream, int value) { if (BuildConfig.DEBUG && 0 > value) { Log.e(TAG, "Attempted to write a negative size."); } @@ -127,7 +131,7 @@ protected static final void writeSize(ByteArrayOutputStream stream, int value) { } /** Writes the least significant two bytes of the specified int to the specified stream. */ - protected static final void writeChar(ByteArrayOutputStream stream, int value) { + protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int value) { if (LITTLE_ENDIAN) { stream.write(value); stream.write(value >>> 8); @@ -138,7 +142,7 @@ protected static final void writeChar(ByteArrayOutputStream stream, int value) { } /** Writes the specified int as 4 bytes to the specified stream. */ - protected static final void writeInt(ByteArrayOutputStream stream, int value) { + protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int value) { if (LITTLE_ENDIAN) { stream.write(value); stream.write(value >>> 8); @@ -153,7 +157,7 @@ protected static final void writeInt(ByteArrayOutputStream stream, int value) { } /** Writes the specified long as 8 bytes to the specified stream. */ - protected static final void writeLong(ByteArrayOutputStream stream, long value) { + protected static final void writeLong(@NonNull ByteArrayOutputStream stream, long value) { if (LITTLE_ENDIAN) { stream.write((byte) value); stream.write((byte) (value >>> 8)); @@ -176,17 +180,18 @@ protected static final void writeLong(ByteArrayOutputStream stream, long value) } /** Writes the specified double as 4 bytes to the specified stream */ - protected static final void writeFloat(ByteArrayOutputStream stream, float value) { + protected static final void writeFloat(@NonNull ByteArrayOutputStream stream, float value) { writeInt(stream, Float.floatToIntBits(value)); } /** Writes the specified double as 8 bytes to the specified stream. */ - protected static final void writeDouble(ByteArrayOutputStream stream, double value) { + protected static final void writeDouble(@NonNull ByteArrayOutputStream stream, double value) { writeLong(stream, Double.doubleToLongBits(value)); } /** Writes the length and then the actual bytes of the specified array to the specified stream. */ - protected static final void writeBytes(ByteArrayOutputStream stream, byte[] bytes) { + protected static final void writeBytes( + @NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) { writeSize(stream, bytes.length); stream.write(bytes, 0, bytes.length); } @@ -196,7 +201,7 @@ protected static final void writeBytes(ByteArrayOutputStream stream, byte[] byte * aligned to a whole multiple of the specified alignment. An example usage with alignment = 8 is * to ensure doubles are word-aligned in the stream. */ - protected static final void writeAlignment(ByteArrayOutputStream stream, int alignment) { + protected static final void writeAlignment(@NonNull ByteArrayOutputStream stream, int alignment) { final int mod = stream.size() % alignment; if (mod != 0) { for (int i = 0; i < alignment - mod; i++) { @@ -212,7 +217,7 @@ protected static final void writeAlignment(ByteArrayOutputStream stream, int ali *

Subclasses can extend the codec by overriding this method, calling super for values that the * extension does not handle. */ - protected void writeValue(ByteArrayOutputStream stream, Object value) { + protected void writeValue(@NonNull ByteArrayOutputStream stream, @NonNull Object value) { if (value == null || value.equals(null)) { stream.write(NULL); } else if (value instanceof Boolean) { @@ -294,7 +299,7 @@ protected void writeValue(ByteArrayOutputStream stream, Object value) { } /** Reads an int representing a size as written by writeSize. */ - protected static final int readSize(ByteBuffer buffer) { + protected static final int readSize(@NonNull ByteBuffer buffer) { if (!buffer.hasRemaining()) { throw new IllegalArgumentException("Message corrupted"); } @@ -309,7 +314,8 @@ protected static final int readSize(ByteBuffer buffer) { } /** Reads a byte array as written by writeBytes. */ - protected static final byte[] readBytes(ByteBuffer buffer) { + @NonNull + protected static final byte[] readBytes(@NonNull ByteBuffer buffer) { final int length = readSize(buffer); final byte[] bytes = new byte[length]; buffer.get(bytes); @@ -317,7 +323,7 @@ protected static final byte[] readBytes(ByteBuffer buffer) { } /** Reads alignment padding bytes as written by writeAlignment. */ - protected static final void readAlignment(ByteBuffer buffer, int alignment) { + protected static final void readAlignment(@NonNull ByteBuffer buffer, int alignment) { final int mod = buffer.position() % alignment; if (mod != 0) { buffer.position(buffer.position() + alignment - mod); @@ -325,7 +331,8 @@ protected static final void readAlignment(ByteBuffer buffer, int alignment) { } /** Reads a value as written by writeValue. */ - protected final Object readValue(ByteBuffer buffer) { + @NonNull + protected final Object readValue(@NonNull ByteBuffer buffer) { if (!buffer.hasRemaining()) { throw new IllegalArgumentException("Message corrupted"); } @@ -339,7 +346,8 @@ protected final Object readValue(ByteBuffer buffer) { *

Subclasses may extend the codec by overriding this method, calling super for types that the * extension does not handle. */ - protected Object readValueOfType(byte type, ByteBuffer buffer) { + @Nullable + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { final Object result; switch (type) { case NULL: diff --git a/shell/platform/android/io/flutter/plugin/common/StandardMethodCodec.java b/shell/platform/android/io/flutter/plugin/common/StandardMethodCodec.java index 7ef509185e27f..a2e8b211c416f 100644 --- a/shell/platform/android/io/flutter/plugin/common/StandardMethodCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StandardMethodCodec.java @@ -4,6 +4,7 @@ package io.flutter.plugin.common; +import androidx.annotation.NonNull; import io.flutter.plugin.common.StandardMessageCodec.ExposedByteArrayOutputStream; import java.io.PrintWriter; import java.io.StringWriter; @@ -27,12 +28,13 @@ public final class StandardMethodCodec implements MethodCodec { private final StandardMessageCodec messageCodec; /** Creates a new method codec based on the specified message codec. */ - public StandardMethodCodec(StandardMessageCodec messageCodec) { + public StandardMethodCodec(@NonNull StandardMessageCodec messageCodec) { this.messageCodec = messageCodec; } @Override - public ByteBuffer encodeMethodCall(MethodCall methodCall) { + @NonNull + public ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall) { final ExposedByteArrayOutputStream stream = new ExposedByteArrayOutputStream(); messageCodec.writeValue(stream, methodCall.method); messageCodec.writeValue(stream, methodCall.arguments); @@ -42,7 +44,8 @@ public ByteBuffer encodeMethodCall(MethodCall methodCall) { } @Override - public MethodCall decodeMethodCall(ByteBuffer methodCall) { + @NonNull + public MethodCall decodeMethodCall(@NonNull ByteBuffer methodCall) { methodCall.order(ByteOrder.nativeOrder()); final Object method = messageCodec.readValue(methodCall); final Object arguments = messageCodec.readValue(methodCall); @@ -53,7 +56,8 @@ public MethodCall decodeMethodCall(ByteBuffer methodCall) { } @Override - public ByteBuffer encodeSuccessEnvelope(Object result) { + @NonNull + public ByteBuffer encodeSuccessEnvelope(@NonNull Object result) { final ExposedByteArrayOutputStream stream = new ExposedByteArrayOutputStream(); stream.write(0); messageCodec.writeValue(stream, result); @@ -63,8 +67,9 @@ public ByteBuffer encodeSuccessEnvelope(Object result) { } @Override + @NonNull public ByteBuffer encodeErrorEnvelope( - String errorCode, String errorMessage, Object errorDetails) { + @NonNull String errorCode, @NonNull String errorMessage, @NonNull Object errorDetails) { final ExposedByteArrayOutputStream stream = new ExposedByteArrayOutputStream(); stream.write(1); messageCodec.writeValue(stream, errorCode); @@ -80,8 +85,12 @@ public ByteBuffer encodeErrorEnvelope( } @Override + @NonNull public ByteBuffer encodeErrorEnvelopeWithStacktrace( - String errorCode, String errorMessage, Object errorDetails, String errorStacktrace) { + @NonNull String errorCode, + @NonNull String errorMessage, + @NonNull Object errorDetails, + @NonNull String errorStacktrace) { final ExposedByteArrayOutputStream stream = new ExposedByteArrayOutputStream(); stream.write(1); messageCodec.writeValue(stream, errorCode); @@ -98,7 +107,8 @@ public ByteBuffer encodeErrorEnvelopeWithStacktrace( } @Override - public Object decodeEnvelope(ByteBuffer envelope) { + @NonNull + public Object decodeEnvelope(@NonNull ByteBuffer envelope) { envelope.order(ByteOrder.nativeOrder()); final byte flag = envelope.get(); switch (flag) { @@ -125,7 +135,8 @@ public Object decodeEnvelope(ByteBuffer envelope) { throw new IllegalArgumentException("Envelope corrupted"); } - private static String getStackTrace(Throwable t) { + @NonNull + private static String getStackTrace(@NonNull Throwable t) { Writer result = new StringWriter(); t.printStackTrace(new PrintWriter(result)); return result.toString(); diff --git a/shell/platform/android/io/flutter/plugin/common/StringCodec.java b/shell/platform/android/io/flutter/plugin/common/StringCodec.java index dfcdbe68bd0fc..3cf17793949ba 100644 --- a/shell/platform/android/io/flutter/plugin/common/StringCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StringCodec.java @@ -4,6 +4,7 @@ package io.flutter.plugin.common; +import androidx.annotation.Nullable; import java.nio.ByteBuffer; import java.nio.charset.Charset; @@ -21,7 +22,8 @@ public final class StringCodec implements MessageCodec { private StringCodec() {} @Override - public ByteBuffer encodeMessage(String message) { + @Nullable + public ByteBuffer encodeMessage(@Nullable String message) { if (message == null) { return null; } @@ -33,7 +35,8 @@ public ByteBuffer encodeMessage(String message) { } @Override - public String decodeMessage(ByteBuffer message) { + @Nullable + public String decodeMessage(@Nullable ByteBuffer message) { if (message == null) { return null; } diff --git a/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java b/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java index c5d2bfc2902b7..8681e23c80678 100644 --- a/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java +++ b/shell/platform/android/io/flutter/plugin/editing/TextEditingDelta.java @@ -4,6 +4,7 @@ package io.flutter.plugin.editing; +import androidx.annotation.NonNull; import androidx.annotation.VisibleForTesting; import io.flutter.Log; import org.json.JSONException; @@ -12,8 +13,8 @@ /// A representation of the change that occured to an editing state, along with the resulting /// composing and selection regions. public final class TextEditingDelta { - private CharSequence oldText; - private CharSequence deltaText; + private @NonNull CharSequence oldText; + private @NonNull CharSequence deltaText; private int deltaStart; private int deltaEnd; private int newSelectionStart; @@ -24,10 +25,10 @@ public final class TextEditingDelta { private static final String TAG = "TextEditingDelta"; public TextEditingDelta( - CharSequence oldEditable, + @NonNull CharSequence oldEditable, int replacementDestinationStart, int replacementDestinationEnd, - CharSequence replacementSource, + @NonNull CharSequence replacementSource, int selectionStart, int selectionEnd, int composingStart, @@ -46,7 +47,7 @@ public TextEditingDelta( // Non text update delta constructor. public TextEditingDelta( - CharSequence oldText, + @NonNull CharSequence oldText, int selectionStart, int selectionEnd, int composingStart, @@ -60,11 +61,13 @@ public TextEditingDelta( } @VisibleForTesting + @NonNull public CharSequence getOldText() { return oldText; } @VisibleForTesting + @NonNull public CharSequence getDeltaText() { return deltaText; } @@ -99,13 +102,15 @@ public int getNewComposingEnd() { return newComposingEnd; } - private void setDeltas(CharSequence oldText, CharSequence newText, int newStart, int newExtent) { + private void setDeltas( + @NonNull CharSequence oldText, @NonNull CharSequence newText, int newStart, int newExtent) { this.oldText = oldText; deltaText = newText; deltaStart = newStart; deltaEnd = newExtent; } + @NonNull public JSONObject toJSON() { JSONObject delta = new JSONObject(); diff --git a/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java b/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java index cfd57ef7a26ea..70658ee934493 100644 --- a/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java +++ b/shell/platform/android/io/flutter/plugin/editing/TextInputPlugin.java @@ -56,7 +56,7 @@ public class TextInputPlugin implements ListenableEditingState.EditingStateWatch @SuppressLint("NewApi") public TextInputPlugin( - View view, + @NonNull View view, @NonNull TextInputChannel textInputChannel, @NonNull PlatformViewsController platformViewsController) { mView = view; @@ -251,8 +251,9 @@ private static int inputTypeFromTextInputType( return textType; } + @Nullable public InputConnection createInputConnection( - View view, KeyboardManager keyboardManager, EditorInfo outAttrs) { + @NonNull View view, @NonNull KeyboardManager keyboardManager, @NonNull EditorInfo outAttrs) { if (inputTarget.type == InputTarget.Type.NO_TARGET) { lastInputConnection = null; return null; @@ -325,7 +326,7 @@ public void clearPlatformViewClient(int platformViewId) { } } - public void sendTextInputAppPrivateCommand(String action, Bundle data) { + public void sendTextInputAppPrivateCommand(@NonNull String action, @NonNull Bundle data) { mImm.sendAppPrivateCommand(mView, action, data); } @@ -506,7 +507,7 @@ public InputTarget(@NonNull Type type, int id) { } // -------- Start: KeyboardManager Synchronous Responder ------- - public boolean handleKeyEvent(KeyEvent keyEvent) { + public boolean handleKeyEvent(@NonNull KeyEvent keyEvent) { if (!getInputMethodManager().isAcceptingText() || lastInputConnection == null) { return false; } @@ -664,7 +665,7 @@ private void updateAutofillConfigurationIfNeeded(TextInputChannel.Configuration } } - public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) { + public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure, int flags) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O || !needsAutofill()) { return; } @@ -708,7 +709,7 @@ public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags } } - public void autofill(SparseArray values) { + public void autofill(@NonNull SparseArray values) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } diff --git a/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java b/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java index 66362931271bf..6d7970a5fcebc 100644 --- a/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java +++ b/shell/platform/android/io/flutter/plugin/localization/LocalizationPlugin.java @@ -82,7 +82,8 @@ public LocalizationPlugin( *

FlutterEngine must be non-null when this method is invoked. */ @SuppressWarnings("deprecation") - public Locale resolveNativeLocale(List supportedLocales) { + @Nullable + public Locale resolveNativeLocale(@Nullable List supportedLocales) { if (supportedLocales == null || supportedLocales.isEmpty()) { return null; } @@ -188,7 +189,8 @@ public void sendLocalesToFlutter(@NonNull Configuration config) { } @VisibleForTesting - public static Locale localeFromString(String localeString) { + @NonNull + public static Locale localeFromString(@NonNull String localeString) { // Use Locale.forLanguageTag if available (API 21+). if (false && Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { return Locale.forLanguageTag(localeString); diff --git a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java index 0daa4959d67f6..f9c3a8e6f76f9 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -121,6 +121,7 @@ public interface MouseCursorViewDelegate { *

This is typically implemented by calling {@link android.view.PointerIcon#getSystemIcon} * with the context associated with this view. */ + @NonNull public PointerIcon getSystemPointerIcon(int type); /** diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java index 59733b29bd0b0..a1d38ba0720db 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -130,12 +130,14 @@ public boolean clipboardHasStrings() { } }; - public PlatformPlugin(Activity activity, PlatformChannel platformChannel) { + public PlatformPlugin(@NonNull Activity activity, @NonNull PlatformChannel platformChannel) { this(activity, platformChannel, null); } public PlatformPlugin( - Activity activity, PlatformChannel platformChannel, PlatformPluginDelegate delegate) { + @NonNull Activity activity, + @NonNull PlatformChannel platformChannel, + @NonNull PlatformPluginDelegate delegate) { this.activity = activity; this.platformChannel = platformChannel; this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler); @@ -153,7 +155,7 @@ public void destroy() { this.platformChannel.setPlatformMessageHandler(null); } - private void playSystemSound(PlatformChannel.SoundType soundType) { + private void playSystemSound(@NonNull PlatformChannel.SoundType soundType) { if (soundType == PlatformChannel.SoundType.CLICK) { View view = activity.getWindow().getDecorView(); view.playSoundEffect(SoundEffectConstants.CLICK); @@ -161,7 +163,8 @@ private void playSystemSound(PlatformChannel.SoundType soundType) { } @VisibleForTesting - /* package */ void vibrateHapticFeedback(PlatformChannel.HapticFeedbackType feedbackType) { + /* package */ void vibrateHapticFeedback( + @NonNull PlatformChannel.HapticFeedbackType feedbackType) { View view = activity.getWindow().getDecorView(); switch (feedbackType) { case STANDARD: diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformView.java b/shell/platform/android/io/flutter/plugin/platform/PlatformView.java index 85ed3c40e8c2e..2c563ccac937b 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformView.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformView.java @@ -7,10 +7,12 @@ import android.annotation.SuppressLint; import android.view.View; import androidx.annotation.NonNull; +import androidx.annotation.Nullable; /** A handle to an Android view to be embedded in the Flutter hierarchy. */ public interface PlatformView { /** Returns the Android view to be embedded in the Flutter hierarchy. */ + @Nullable View getView(); /** diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java index 5144a639694f0..936f9fabeca5b 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java @@ -5,13 +5,15 @@ package io.flutter.plugin.platform; import android.content.Context; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import io.flutter.plugin.common.MessageCodec; public abstract class PlatformViewFactory { private final MessageCodec createArgsCodec; /** @param createArgsCodec the codec used to decode the args parameter of {@link #create}. */ - public PlatformViewFactory(MessageCodec createArgsCodec) { + public PlatformViewFactory(@Nullable MessageCodec createArgsCodec) { this.createArgsCodec = createArgsCodec; } @@ -25,9 +27,11 @@ public PlatformViewFactory(MessageCodec createArgsCodec) { * createArgsCodec argument passed to the constructor. This is null if createArgsCodec was * null, or no arguments were sent from the Flutter app. */ - public abstract PlatformView create(Context context, int viewId, Object args); + @NonNull + public abstract PlatformView create(@Nullable Context context, int viewId, @Nullable Object args); /** Returns the codec to be used for decoding the args parameter of {@link #create}. */ + @Nullable public final MessageCodec getCreateArgsCodec() { return createArgsCodec; } diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java index e03a771cf6637..028b3b1d2eb3f 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java @@ -4,6 +4,8 @@ package io.flutter.plugin.platform; +import androidx.annotation.NonNull; + /** * Registry for platform view factories. * @@ -18,5 +20,5 @@ public interface PlatformViewRegistry { * @param factory factory for creating platform views of the specified type. * @return true if succeeded, false if a factory is already registered for viewTypeId. */ - boolean registerViewFactory(String viewTypeId, PlatformViewFactory factory); + boolean registerViewFactory(@NonNull String viewTypeId, @NonNull PlatformViewFactory factory); } diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java index 0ab99bfe1fc66..968dda33f1ee8 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java @@ -5,6 +5,7 @@ package io.flutter.plugin.platform; import android.view.View; +import androidx.annotation.NonNull; import androidx.annotation.Nullable; import io.flutter.view.AccessibilityBridge; @@ -23,7 +24,7 @@ public interface PlatformViewsAccessibilityDelegate { *

Accessibility events originating in platform views belonging to this delegate will be * delegated to this accessibility bridge. */ - void attachAccessibilityBridge(AccessibilityBridge accessibilityBridge); + void attachAccessibilityBridge(@NonNull AccessibilityBridge accessibilityBridge); /** * Detaches the current accessibility bridge. diff --git a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java index 063882fced75f..3d9e86d749557 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -449,7 +449,9 @@ public PlatformViewsController() { * @param dartExecutor The dart execution context, which is used to set up a system channel. */ public void attach( - Context context, TextureRegistry textureRegistry, @NonNull DartExecutor dartExecutor) { + @Nullable Context context, + @NonNull TextureRegistry textureRegistry, + @NonNull DartExecutor dartExecutor) { if (this.context != null) { throw new AssertionError( "A PlatformViewsController can only be attached to a single output target.\n" @@ -516,7 +518,7 @@ public void detachFromView() { } @Override - public void attachAccessibilityBridge(AccessibilityBridge accessibilityBridge) { + public void attachAccessibilityBridge(@NonNull AccessibilityBridge accessibilityBridge) { accessibilityEventsDelegate.setAccessibilityBridge(accessibilityBridge); } @@ -534,7 +536,7 @@ public void detachAccessibilityBridge() { *

A platform views controller should be attached to a text input plugin whenever it is * possible for the Flutter framework to receive text input. */ - public void attachTextInputPlugin(TextInputPlugin textInputPlugin) { + public void attachTextInputPlugin(@NonNull TextInputPlugin textInputPlugin) { this.textInputPlugin = textInputPlugin; } @@ -568,6 +570,7 @@ public void onPreEngineRestart() { } @Override + @Nullable public View getPlatformViewById(int viewId) { final PlatformView platformView = platformViews.get(viewId); if (platformView == null) { @@ -692,7 +695,7 @@ void initializePlatformViewIfNeeded(int viewId) { flutterView.addView(parentView); } - public void attachToFlutterRenderer(FlutterRenderer flutterRenderer) { + public void attachToFlutterRenderer(@NonNull FlutterRenderer flutterRenderer) { androidTouchProcessor = new AndroidTouchProcessor(flutterRenderer, /*trackMotionEvents=*/ true); } @@ -717,7 +720,7 @@ public void onDisplayPlatformView( int height, int viewWidth, int viewHeight, - FlutterMutatorsStack mutatorsStack) { + @NonNull FlutterMutatorsStack mutatorsStack) { initializeRootImageViewIfNeeded(); initializePlatformViewIfNeeded(viewId); @@ -856,6 +859,7 @@ private void finishFrame(boolean isFrameRenderedUsingImageReaders) { */ @VisibleForTesting @TargetApi(19) + @NonNull public FlutterOverlaySurface createOverlaySurface(@NonNull FlutterImageView imageView) { final int id = nextOverlayLayerId++; overlayLayerViews.put(id, imageView); @@ -870,6 +874,7 @@ public FlutterOverlaySurface createOverlaySurface(@NonNull FlutterImageView imag *

This member is not intended for public use, and is only visible for testing. */ @TargetApi(19) + @NonNull public FlutterOverlaySurface createOverlaySurface() { // Overlay surfaces have the same size as the background surface. // diff --git a/shell/platform/android/io/flutter/util/PathUtils.java b/shell/platform/android/io/flutter/util/PathUtils.java index 1b4d36eb96529..5f3f7bd6845e4 100644 --- a/shell/platform/android/io/flutter/util/PathUtils.java +++ b/shell/platform/android/io/flutter/util/PathUtils.java @@ -6,10 +6,12 @@ import android.content.Context; import android.os.Build; +import androidx.annotation.NonNull; import java.io.File; public final class PathUtils { - public static String getFilesDir(Context applicationContext) { + @NonNull + public static String getFilesDir(@NonNull Context applicationContext) { File filesDir = applicationContext.getFilesDir(); if (filesDir == null) { filesDir = new File(getDataDirPath(applicationContext), "files"); @@ -17,7 +19,8 @@ public static String getFilesDir(Context applicationContext) { return filesDir.getPath(); } - public static String getDataDirectory(Context applicationContext) { + @NonNull + public static String getDataDirectory(@NonNull Context applicationContext) { final String name = "flutter"; File flutterDir = applicationContext.getDir(name, Context.MODE_PRIVATE); if (flutterDir == null) { @@ -26,7 +29,8 @@ public static String getDataDirectory(Context applicationContext) { return flutterDir.getPath(); } - public static String getCacheDirectory(Context applicationContext) { + @NonNull + public static String getCacheDirectory(@NonNull Context applicationContext) { File cacheDir; if (Build.VERSION.SDK_INT >= 21) { cacheDir = applicationContext.getCodeCacheDir(); diff --git a/shell/platform/android/io/flutter/util/ViewUtils.java b/shell/platform/android/io/flutter/util/ViewUtils.java index bac41ac7c06ca..95ea8fa855437 100644 --- a/shell/platform/android/io/flutter/util/ViewUtils.java +++ b/shell/platform/android/io/flutter/util/ViewUtils.java @@ -19,7 +19,8 @@ public final class ViewUtils { *

This method will recursively traverse up the context chain if it is a {@link ContextWrapper} * until it finds the first instance of the base context that is an {@link Activity}. */ - public static Activity getActivity(Context context) { + @Nullable + public static Activity getActivity(@Nullable Context context) { if (context == null) { return null; } diff --git a/shell/platform/android/io/flutter/view/FlutterView.java b/shell/platform/android/io/flutter/view/FlutterView.java index beb15c38c0a8f..f47b8da5bde00 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -846,13 +846,16 @@ public void send(String channel, ByteBuffer message, BinaryReply callback) { @Override @UiThread - public void setMessageHandler(String channel, BinaryMessageHandler handler) { + public void setMessageHandler(@NonNull String channel, @NonNull BinaryMessageHandler handler) { mNativeView.setMessageHandler(channel, handler); } @Override @UiThread - public void setMessageHandler(String channel, BinaryMessageHandler handler, TaskQueue taskQueue) { + public void setMessageHandler( + @NonNull String channel, + @NonNull BinaryMessageHandler handler, + @NonNull TaskQueue taskQueue) { mNativeView.setMessageHandler(channel, handler, taskQueue); } @@ -862,12 +865,14 @@ public interface FirstFrameListener { } @Override + @NonNull public TextureRegistry.SurfaceTextureEntry createSurfaceTexture() { final SurfaceTexture surfaceTexture = new SurfaceTexture(0); return registerSurfaceTexture(surfaceTexture); } @Override + @NonNull public TextureRegistry.SurfaceTextureEntry registerSurfaceTexture( @NonNull SurfaceTexture surfaceTexture) { surfaceTexture.detachFromGLContext(); diff --git a/shell/platform/android/io/flutter/view/TextureRegistry.java b/shell/platform/android/io/flutter/view/TextureRegistry.java index 6af82ce915fcc..1155c4854bf66 100644 --- a/shell/platform/android/io/flutter/view/TextureRegistry.java +++ b/shell/platform/android/io/flutter/view/TextureRegistry.java @@ -19,6 +19,7 @@ public interface TextureRegistry { * * @return A SurfaceTextureEntry. */ + @NonNull SurfaceTextureEntry createSurfaceTexture(); /** @@ -26,11 +27,13 @@ public interface TextureRegistry { * * @return A SurfaceTextureEntry. */ + @NonNull SurfaceTextureEntry registerSurfaceTexture(@NonNull SurfaceTexture surfaceTexture); /** A registry entry for a managed SurfaceTexture. */ interface SurfaceTextureEntry { /** @return The managed SurfaceTexture. */ + @NonNull SurfaceTexture surfaceTexture(); /** @return The identity of this SurfaceTexture. */ diff --git a/shell/platform/android/io/flutter/view/VsyncWaiter.java b/shell/platform/android/io/flutter/view/VsyncWaiter.java index f65d6d569b088..c5021460da89b 100644 --- a/shell/platform/android/io/flutter/view/VsyncWaiter.java +++ b/shell/platform/android/io/flutter/view/VsyncWaiter.java @@ -49,7 +49,7 @@ public void onDisplayChanged(int displayId) { private FlutterJNI flutterJNI; @NonNull - public static VsyncWaiter getInstance(float fps, FlutterJNI flutterJNI) { + public static VsyncWaiter getInstance(float fps, @NonNull FlutterJNI flutterJNI) { if (instance == null) { instance = new VsyncWaiter(flutterJNI); } @@ -60,7 +60,8 @@ public static VsyncWaiter getInstance(float fps, FlutterJNI flutterJNI) { @TargetApi(17) @NonNull - public static VsyncWaiter getInstance(DisplayManager displayManager, FlutterJNI flutterJNI) { + public static VsyncWaiter getInstance( + @NonNull DisplayManager displayManager, @NonNull FlutterJNI flutterJNI) { if (instance == null) { instance = new VsyncWaiter(flutterJNI); } @@ -103,7 +104,7 @@ public void doFrame(long frameTimeNanos) { } }; - private VsyncWaiter(FlutterJNI flutterJNI) { + private VsyncWaiter(@NonNull FlutterJNI flutterJNI) { this.flutterJNI = flutterJNI; } diff --git a/shell/platform/android/test/io/flutter/TestUtils.java b/shell/platform/android/test/io/flutter/TestUtils.java index ae2e79eda1878..907ced48f300c 100644 --- a/shell/platform/android/test/io/flutter/TestUtils.java +++ b/shell/platform/android/test/io/flutter/TestUtils.java @@ -8,6 +8,7 @@ import android.content.res.Configuration; import android.os.Build; +import androidx.annotation.NonNull; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Locale; @@ -29,7 +30,7 @@ public static void setApiVersion(int apiVersion) { } } - public static void setLegacyLocale(Configuration config, Locale locale) { + public static void setLegacyLocale(@NonNull Configuration config, @NonNull Locale locale) { try { Field field = config.getClass().getField("locale"); field.setAccessible(true); diff --git a/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java b/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java index 557d1e89d42b4..938c81a85d6db 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java +++ b/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java @@ -1,6 +1,7 @@ package io.flutter.embedding.android; import android.content.Intent; +import androidx.annotation.NonNull; import org.robolectric.Robolectric; import org.robolectric.android.controller.ActivityController; @@ -14,7 +15,8 @@ public class RobolectricFlutterActivity { * Creates a {@code FlutterActivity} that is controlled by Robolectric, which otherwise can not be * done in a test outside of the io.flutter.embedding.android package. */ - public static FlutterActivity createFlutterActivity(Intent intent) { + @NonNull + public static FlutterActivity createFlutterActivity(@NonNull Intent intent) { ActivityController activityController = Robolectric.buildActivity(FlutterActivity.class, intent); FlutterActivity flutterActivity = activityController.get(); @@ -26,8 +28,9 @@ public static FlutterActivity createFlutterActivity(Intent intent) { * Returns a given {@code FlutterActivity}'s {@code BackgroundMode} for use by tests that do not * sit in the {@code io.flutter.embedding.android} package. */ + @NonNull public static FlutterActivityLaunchConfigs.BackgroundMode getBackgroundMode( - FlutterActivity activity) { + @NonNull FlutterActivity activity) { return activity.getBackgroundMode(); } } diff --git a/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java b/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java index 2747092c836f8..e6cd8b6b6661e 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java +++ b/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java @@ -4,6 +4,7 @@ import android.graphics.Color; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import androidx.annotation.NonNull; import org.robolectric.annotation.Implements; import org.robolectric.annotation.RealObject; import org.robolectric.shadow.api.Shadow; @@ -16,7 +17,8 @@ public class SplashShadowResources { public static final int THEMED_SPLASH_DRAWABLE_ID = 212121; // All other getDrawable() calls, call this method internally. - public Drawable getDrawableForDensity(int id, int density, Resources.Theme theme) + @NonNull + public Drawable getDrawableForDensity(int id, int density, @NonNull Resources.Theme theme) throws Exception { if (id == SPLASH_DRAWABLE_ID) { return new ColorDrawable(Color.BLUE); diff --git a/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java b/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java index c2528725b89b3..387de14de371f 100644 --- a/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -1,5 +1,7 @@ package io.flutter.plugins; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import io.flutter.embedding.engine.FlutterEngine; import java.util.ArrayList; @@ -13,7 +15,7 @@ @VisibleForTesting public class GeneratedPluginRegistrant { private static final List registeredEngines = new ArrayList<>(); - public static RuntimeException pluginRegistrationException; + public static @Nullable RuntimeException pluginRegistrationException; /** * The one and only method currently generated by the tool. @@ -21,7 +23,7 @@ public class GeneratedPluginRegistrant { *

Normally it registers all plugins in an app with the given {@code engine}. This fake tracks * all registered engines instead. */ - public static void registerWith(FlutterEngine engine) { + public static void registerWith(@NonNull FlutterEngine engine) { if (pluginRegistrationException != null) { throw pluginRegistrationException; } @@ -46,6 +48,7 @@ public static void clearRegisteredEngines() { *

CAUTION: This list is static and must be manually wiped in between test runs. See {@link * #clearRegisteredEngines()}. */ + @NonNull public static List getRegisteredEngines() { return new ArrayList<>(registeredEngines); } diff --git a/tools/android_lint/bin/main.dart b/tools/android_lint/bin/main.dart index a7a4dd77e82b0..99b750276fece 100644 --- a/tools/android_lint/bin/main.dart +++ b/tools/android_lint/bin/main.dart @@ -80,6 +80,9 @@ Future runLint(ArgParser argParser, ArgResults argResults) async { if (!entity.path.endsWith('.java')) { continue; } + if (entity.path.endsWith('Test.java')) { + continue; + } projectXml.writeln(' '); } diff --git a/tools/android_lint/project.xml b/tools/android_lint/project.xml index 75b87536362aa..ec80db6767fa6 100644 --- a/tools/android_lint/project.xml +++ b/tools/android_lint/project.xml @@ -5,10 +5,6 @@ - - - -