diff --git a/shell/platform/android/io/flutter/embedding/android/FlutterView.java b/shell/platform/android/io/flutter/embedding/android/FlutterView.java index 60a4f7001281f..39b4ebd23c704 100644 --- a/shell/platform/android/io/flutter/embedding/android/FlutterView.java +++ b/shell/platform/android/io/flutter/embedding/android/FlutterView.java @@ -876,7 +876,7 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) { * methods. */ @Override - public boolean checkInputConnectionProxy(@NonNull View view) { + public boolean checkInputConnectionProxy(View view) { return flutterEngine != null ? flutterEngine.getPlatformViewsController().checkInputConnectionProxy(view) : super.checkInputConnectionProxy(view); @@ -894,7 +894,7 @@ public boolean checkInputConnectionProxy(@NonNull View view) { * previous {@code keyCode} to generate a unicode combined character. */ @Override - public boolean dispatchKeyEvent(@NonNull KeyEvent event) { + public boolean dispatchKeyEvent(KeyEvent event) { if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) { // Tell Android to start tracking this event. getKeyDispatcherState().startTracking(event, this); @@ -1003,7 +1003,6 @@ 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); @@ -1350,7 +1349,7 @@ public void onFlutterUiNoLongerDisplayed() { }); } - public void attachOverlaySurfaceToRender(@NonNull FlutterImageView view) { + public void attachOverlaySurfaceToRender(FlutterImageView view) { if (flutterEngine != null) { view.attachToRenderer(flutterEngine.getRenderer()); } @@ -1451,13 +1450,13 @@ private void sendViewportMetricsToFlutter() { } @Override - public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure, int flags) { + public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) { super.onProvideAutofillVirtualStructure(structure, flags); textInputPlugin.onProvideAutofillVirtualStructure(structure, flags); } @Override - public void autofill(@NonNull SparseArray values) { + public void autofill(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 dba9780a2c10a..b2a10184f6610 100644 --- a/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java +++ b/shell/platform/android/io/flutter/embedding/android/KeyboardManager.java @@ -79,9 +79,7 @@ public class KeyboardManager { * dispatched to. */ public KeyboardManager( - @NonNull View view, - @NonNull TextInputPlugin textInputPlugin, - @NonNull Responder[] responders) { + View view, @NonNull TextInputPlugin textInputPlugin, Responder[] responders) { this.view = view; this.textInputPlugin = textInputPlugin; this.responders = responders; @@ -105,7 +103,7 @@ public KeyboardManager( */ interface Responder { interface OnKeyEventHandledCallback { - void onKeyEventHandled(boolean canHandleEvent); + void onKeyEventHandled(Boolean canHandleEvent); } /** @@ -124,7 +122,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."); @@ -142,7 +140,7 @@ public void onKeyEventHandled(boolean canHandleEvent) { this.keyEvent = keyEvent; } - final KeyEvent keyEvent; + @NonNull final KeyEvent keyEvent; int unrepliedCount = responders.length; boolean isEventHandled = false; @@ -151,9 +149,9 @@ public OnKeyEventHandledCallback buildCallback() { } } - protected final Responder[] responders; - private final HashSet redispatchedEvents = new HashSet<>(); - private final TextInputPlugin textInputPlugin; + @NonNull protected final Responder[] responders; + @NonNull private final HashSet redispatchedEvents = new HashSet<>(); + @NonNull 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 9ac225c83ae7f..1cd12b6e17e77 100644 --- a/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java +++ b/shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java @@ -2,7 +2,6 @@ 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; @@ -19,12 +18,10 @@ 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()); } @@ -38,7 +35,6 @@ public long getId() { private final PriorityQueue unusedEvents; private static MotionEventTracker INSTANCE; - @NonNull public static MotionEventTracker getInstance() { if (INSTANCE == null) { INSTANCE = new MotionEventTracker(); @@ -52,8 +48,7 @@ private MotionEventTracker() { } /** Tracks the event and returns a unique MotionEventId identifying the event. */ - @NonNull - public MotionEventId track(@NonNull MotionEvent event) { + public MotionEventId track(MotionEvent event) { MotionEventId eventId = MotionEventId.createUnique(); eventById.put(eventId.id, MotionEvent.obtain(event)); unusedEvents.add(eventId.id); @@ -66,7 +61,7 @@ public MotionEventId track(@NonNull MotionEvent event) { * popped or discarded. */ @Nullable - public MotionEvent pop(@NonNull MotionEventId eventId) { + public MotionEvent pop(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 989566872de04..156531eb011b8 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(@NonNull SplitInstallSessionState state) { + public void onStateUpdate(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(@NonNull DeferredComponentChannel channel) { + public void setDeferredComponentChannel(DeferredComponentChannel channel) { this.channel = channel; } @@ -288,7 +288,7 @@ private void initLoadingUnitMappingToComponentNames() { } } - public void installDeferredComponent(int loadingUnitId, @Nullable String componentName) { + public void installDeferredComponent(int loadingUnitId, String componentName) { String resolvedComponentName = componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId); if (resolvedComponentName == null) { @@ -357,9 +357,7 @@ public void installDeferredComponent(int loadingUnitId, @Nullable String compone }); } - @NonNull - public String getDeferredComponentInstallState( - int loadingUnitId, @Nullable String componentName) { + public String getDeferredComponentInstallState(int loadingUnitId, String componentName) { String resolvedComponentName = componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId); if (resolvedComponentName == null) { @@ -377,7 +375,7 @@ public String getDeferredComponentInstallState( return sessionIdToState.get(sessionId); } - public void loadAssets(int loadingUnitId, @NonNull String componentName) { + public void loadAssets(int loadingUnitId, String componentName) { if (!verifyJNI()) { return; } @@ -395,7 +393,7 @@ public void loadAssets(int loadingUnitId, @NonNull String componentName) { } } - public void loadDartLibrary(int loadingUnitId, @NonNull String componentName) { + public void loadDartLibrary(int loadingUnitId, String componentName) { if (!verifyJNI()) { return; } @@ -480,7 +478,7 @@ public void loadDartLibrary(int loadingUnitId, @NonNull String componentName) { loadingUnitId, searchPaths.toArray(new String[searchPaths.size()])); } - public boolean uninstallDeferredComponent(int loadingUnitId, @Nullable String componentName) { + public boolean uninstallDeferredComponent(int loadingUnitId, 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 b5db78ab35dd0..671e24e0ee53c 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,8 +48,7 @@ public ShimPluginRegistry(@NonNull FlutterEngine flutterEngine) { } @Override - @NonNull - public Registrar registrarFor(@NonNull String pluginKey) { + public Registrar registrarFor(String pluginKey) { Log.v(TAG, "Creating plugin Registrar for '" + pluginKey + "'"); if (pluginMap.containsKey(pluginKey)) { throw new IllegalStateException("Plugin key " + pluginKey + " is already in use"); @@ -61,13 +60,13 @@ public Registrar registrarFor(@NonNull String pluginKey) { } @Override - public boolean hasPlugin(@NonNull String pluginKey) { + public boolean hasPlugin(String pluginKey) { return pluginMap.containsKey(pluginKey); } @Override @SuppressWarnings("unchecked") - public T valuePublishedByPlugin(@NonNull String pluginKey) { + public T valuePublishedByPlugin(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 1a63bbd300727..b9a9c57d95de4 100644 --- a/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java +++ b/shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java @@ -67,7 +67,7 @@ public void detachFromGLContext() { // Called by native. @SuppressWarnings("unused") - public void getTransformMatrix(@NonNull float[] mtx) { + public void getTransformMatrix(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 dbd94b719f074..f060a4d89eb45 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java @@ -110,7 +110,6 @@ public interface LocalizationMessageHandler { * The Flutter application would like to obtain the string resource of given {@code key} in * {@code locale}. */ - @NonNull - String getStringResource(@NonNull String key, @NonNull String locale); + String getStringResource(@NonNull String key, 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 1616bb1e93622..7249620ecdd1d 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java @@ -5,7 +5,6 @@ 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; @@ -73,13 +72,12 @@ 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(@NonNull byte[] data) { + public void setRestorationData(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 094786f6d825e..ecdf86c71820e 100644 --- a/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java +++ b/shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java @@ -205,7 +205,7 @@ private static HashMap createEditingDeltaJSON( */ public void updateEditingState( int inputClientId, - @NonNull String text, + String text, int selectionStart, int selectionEnd, int composingStart, @@ -235,7 +235,7 @@ public void updateEditingState( } public void updateEditingStateWithDeltas( - int inputClientId, @NonNull ArrayList batchDeltas) { + int inputClientId, ArrayList batchDeltas) { Log.v( TAG, @@ -250,7 +250,7 @@ public void updateEditingStateWithDeltas( } public void updateEditingStateWithTag( - int inputClientId, @NonNull HashMap editStates) { + int inputClientId, HashMap editStates) { Log.v( TAG, "Sending message to update editing state for " @@ -325,8 +325,7 @@ public void unspecifiedAction(int inputClientId) { Arrays.asList(inputClientId, "TextInputAction.unspecified")); } - public void performPrivateCommand( - int inputClientId, @NonNull String action, @NonNull Bundle data) { + public void performPrivateCommand(int inputClientId, String action, Bundle data) { HashMap json = new HashMap<>(); json.put("action", action); if (data != null) { @@ -416,7 +415,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, @NonNull double[] transform); + void setEditableSizeAndTransform(double width, double height, double[] transform); // TODO(mattcarroll): javadoc void setEditingState(@NonNull TextEditState editingState); @@ -433,12 +432,11 @@ public interface TextInputMethodHandler { * commands. * @param data Any data to include with the command. */ - void sendAppPrivateCommand(@NonNull String action, @NonNull Bundle data); + void sendAppPrivateCommand(String action, 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"); @@ -496,7 +494,6 @@ 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"); @@ -732,7 +729,6 @@ 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 b2b57a452d4f8..c6bf0e668b790 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java @@ -4,7 +4,6 @@ package io.flutter.plugin.common; -import androidx.annotation.Nullable; import java.nio.ByteBuffer; import org.json.JSONException; import org.json.JSONObject; @@ -29,8 +28,7 @@ public final class JSONMessageCodec implements MessageCodec { private JSONMessageCodec() {} @Override - @Nullable - public ByteBuffer encodeMessage(@Nullable Object message) { + public ByteBuffer encodeMessage(Object message) { if (message == null) { return null; } @@ -43,8 +41,7 @@ public ByteBuffer encodeMessage(@Nullable Object message) { } @Override - @Nullable - public Object decodeMessage(@Nullable ByteBuffer message) { + public Object decodeMessage(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 3869bd5169c50..df96af0c66b5c 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONMethodCodec.java @@ -4,8 +4,6 @@ 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; @@ -28,8 +26,7 @@ public final class JSONMethodCodec implements MethodCodec { private JSONMethodCodec() {} @Override - @NonNull - public ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall) { + public ByteBuffer encodeMethodCall(MethodCall methodCall) { try { final JSONObject map = new JSONObject(); map.put("method", methodCall.method); @@ -41,8 +38,7 @@ public ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall) { } @Override - @NonNull - public MethodCall decodeMethodCall(@NonNull ByteBuffer message) { + public MethodCall decodeMethodCall(ByteBuffer message) { try { final Object json = JSONMessageCodec.INSTANCE.decodeMessage(message); if (json instanceof JSONObject) { @@ -60,15 +56,13 @@ public MethodCall decodeMethodCall(@NonNull ByteBuffer message) { } @Override - @NonNull - public ByteBuffer encodeSuccessEnvelope(@Nullable Object result) { + public ByteBuffer encodeSuccessEnvelope(Object result) { return JSONMessageCodec.INSTANCE.encodeMessage(new JSONArray().put(JSONUtil.wrap(result))); } @Override - @NonNull public ByteBuffer encodeErrorEnvelope( - @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails) { + String errorCode, String errorMessage, Object errorDetails) { return JSONMessageCodec.INSTANCE.encodeMessage( new JSONArray() .put(errorCode) @@ -77,12 +71,8 @@ public ByteBuffer encodeErrorEnvelope( } @Override - @NonNull public ByteBuffer encodeErrorEnvelopeWithStacktrace( - @NonNull String errorCode, - @Nullable String errorMessage, - @Nullable Object errorDetails, - @Nullable String errorStacktrace) { + String errorCode, String errorMessage, Object errorDetails, String errorStacktrace) { return JSONMessageCodec.INSTANCE.encodeMessage( new JSONArray() .put(errorCode) @@ -92,8 +82,7 @@ public ByteBuffer encodeErrorEnvelopeWithStacktrace( } @Override - @NonNull - public Object decodeEnvelope(@NonNull ByteBuffer envelope) { + public Object decodeEnvelope(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 1ee87f6fc397f..bb59833b29fe4 100644 --- a/shell/platform/android/io/flutter/plugin/common/JSONUtil.java +++ b/shell/platform/android/io/flutter/plugin/common/JSONUtil.java @@ -1,6 +1,5 @@ package io.flutter.plugin.common; -import androidx.annotation.Nullable; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; @@ -18,8 +17,7 @@ private JSONUtil() {} * Convert the Json java representation to Java objects. Particularly used for converting * JSONArray and JSONObject to Lists and Maps. */ - @Nullable - public static Object unwrap(@Nullable Object o) { + public static Object unwrap(Object o) { if (JSONObject.NULL.equals(o) || o == null) { return null; } @@ -59,8 +57,7 @@ public static Object unwrap(@Nullable Object o) { } /** Backport of {@link JSONObject#wrap(Object)} for use on pre-KitKat systems. */ - @Nullable - public static Object wrap(@Nullable Object o) { + public static Object wrap(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 7181a548e713a..8a6e51783e696 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodCall.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodCall.java @@ -4,7 +4,6 @@ package io.flutter.plugin.common; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import io.flutter.BuildConfig; import java.util.Map; @@ -28,10 +27,9 @@ 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. Possibly, - * null. + * @param arguments the arguments, a value supported by the channel's message codec. */ - public MethodCall(@NonNull String method, @Nullable Object arguments) { + public MethodCall(String method, Object arguments) { if (BuildConfig.DEBUG && method == null) { throw new AssertionError("Parameter method must not be null."); } @@ -46,7 +44,6 @@ public MethodCall(@NonNull String method, @Nullable Object arguments) { * @return the arguments with static type T */ @SuppressWarnings("unchecked") - @Nullable public T arguments() { return (T) arguments; } @@ -65,7 +62,7 @@ public T arguments() { */ @SuppressWarnings("unchecked") @Nullable - public T argument(@NonNull String key) { + public T argument(String key) { if (arguments == null) { return null; } else if (arguments instanceof Map) { @@ -88,7 +85,7 @@ public T argument(@NonNull String key) { * @throws ClassCastException if {@link #arguments} can be cast to neither {@link Map} nor {@link * JSONObject}. */ - public boolean hasArgument(@NonNull String key) { + public boolean hasArgument(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 c13f82d2beb1f..5e187cf94cd47 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(@NonNull BinaryMessenger messenger, @NonNull String name) { + public MethodChannel(BinaryMessenger messenger, String name) { this(messenger, name, StandardMethodCodec.INSTANCE); } @@ -56,8 +56,7 @@ public MethodChannel(@NonNull BinaryMessenger messenger, @NonNull String name) { * @param name a channel name String. * @param codec a {@link MessageCodec}. */ - public MethodChannel( - @NonNull BinaryMessenger messenger, @NonNull String name, @NonNull MethodCodec codec) { + public MethodChannel(BinaryMessenger messenger, String name, MethodCodec codec) { this(messenger, name, codec, null); } @@ -73,9 +72,9 @@ public MethodChannel( * BinaryMessenger#makeBackgroundTaskQueue()}. */ public MethodChannel( - @NonNull BinaryMessenger messenger, - @NonNull String name, - @NonNull MethodCodec codec, + BinaryMessenger messenger, + String name, + MethodCodec codec, @Nullable BinaryMessenger.TaskQueue taskQueue) { if (BuildConfig.DEBUG) { if (messenger == null) { @@ -115,8 +114,7 @@ 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( - @NonNull String method, @Nullable Object arguments, @Nullable Result callback) { + public void invokeMethod(String method, @Nullable Object arguments, @Nullable Result callback) { messenger.send( name, codec.encodeMethodCall(new MethodCall(method, arguments)), @@ -214,8 +212,7 @@ 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( - @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); + void error(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 74594ad1e69a8..f958a5307ae9c 100644 --- a/shell/platform/android/io/flutter/plugin/common/MethodCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/MethodCodec.java @@ -4,8 +4,6 @@ package io.flutter.plugin.common; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import java.nio.ByteBuffer; /** @@ -25,8 +23,7 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - @NonNull - ByteBuffer encodeMethodCall(@NonNull MethodCall methodCall); + ByteBuffer encodeMethodCall(MethodCall methodCall); /** * Decodes a message call from binary. @@ -35,8 +32,7 @@ public interface MethodCodec { * @return a {@link MethodCall} representation of the bytes between the given buffer's current * position and its limit. */ - @NonNull - MethodCall decodeMethodCall(@NonNull ByteBuffer methodCall); + MethodCall decodeMethodCall(ByteBuffer methodCall); /** * Encodes a successful result into a binary envelope message. @@ -45,8 +41,7 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - @NonNull - ByteBuffer encodeSuccessEnvelope(@Nullable Object result); + ByteBuffer encodeSuccessEnvelope(Object result); /** * Encodes an error result into a binary envelope message. @@ -58,9 +53,7 @@ public interface MethodCodec { * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - @NonNull - ByteBuffer encodeErrorEnvelope( - @NonNull String errorCode, @Nullable String errorMessage, @Nullable Object errorDetails); + ByteBuffer encodeErrorEnvelope(String errorCode, String errorMessage, Object errorDetails); /** * Encodes an error result into a binary envelope message with the native stacktrace. @@ -73,12 +66,8 @@ ByteBuffer encodeErrorEnvelope( * @return a {@link ByteBuffer} containing the encoding between position 0 and the current * position. */ - @NonNull ByteBuffer encodeErrorEnvelopeWithStacktrace( - @NonNull String errorCode, - @Nullable String errorMessage, - @Nullable Object errorDetails, - @Nullable String errorStacktrace); + String errorCode, String errorMessage, Object errorDetails, String errorStacktrace); /** * Decodes a result envelope from binary. @@ -87,6 +76,5 @@ ByteBuffer encodeErrorEnvelopeWithStacktrace( * @return the enveloped result Object. * @throws FlutterException if the envelope was an error envelope. */ - @NonNull - Object decodeEnvelope(@NonNull ByteBuffer envelope); + Object decodeEnvelope(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 29b6097933b60..d645e98f7edfa 100644 --- a/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java +++ b/shell/platform/android/io/flutter/plugin/common/PluginRegistry.java @@ -7,8 +7,6 @@ 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; @@ -38,8 +36,7 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - @NonNull - Registrar registrarFor(@NonNull String pluginKey); + Registrar registrarFor(String pluginKey); /** * Returns whether the specified plugin is known to this registry. @@ -50,7 +47,7 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - boolean hasPlugin(@NonNull String pluginKey); + boolean hasPlugin(String pluginKey); /** * Returns the value published by the specified plugin, if any. @@ -66,8 +63,7 @@ public interface PluginRegistry { * @deprecated See https://flutter.dev/go/android-project-migration for migration details. */ @Deprecated - @Nullable - T valuePublishedByPlugin(@NonNull String pluginKey); + T valuePublishedByPlugin(String pluginKey); /** * Receiver of registrations from a single plugin. @@ -99,7 +95,6 @@ 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(); /** @@ -112,7 +107,6 @@ 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(); /** @@ -128,7 +122,6 @@ interface Registrar { * @return the current {@link #activity() Activity}, if not null, otherwise the {@link * #context() Application}. */ - @NonNull Context activeContext(); /** @@ -142,7 +135,6 @@ 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(); /** @@ -155,7 +147,6 @@ 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(); /** @@ -170,7 +161,6 @@ 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(); /** @@ -186,7 +176,6 @@ 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(); /** @@ -198,8 +187,7 @@ 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} */ - @NonNull - String lookupKeyForAsset(@NonNull String asset); + String lookupKeyForAsset(String asset); /** * Returns the file name for the given asset which originates from the specified packageName. @@ -212,8 +200,7 @@ 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} */ - @NonNull - String lookupKeyForAsset(@NonNull String asset, @NonNull String packageName); + String lookupKeyForAsset(String asset, String packageName); /** * Publishes a value associated with the plugin being registered. @@ -235,8 +222,7 @@ interface Registrar { * @param value the value, possibly null. * @return this {@link Registrar}. */ - @NonNull - Registrar publish(@Nullable Object value); + Registrar publish(Object value); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@code @@ -254,9 +240,7 @@ interface Registrar { * @param listener a {@link RequestPermissionsResultListener} callback. * @return this {@link Registrar}. */ - @NonNull - Registrar addRequestPermissionsResultListener( - @NonNull RequestPermissionsResultListener listener); + Registrar addRequestPermissionsResultListener(RequestPermissionsResultListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -272,8 +256,7 @@ Registrar addRequestPermissionsResultListener( * @param listener an {@link ActivityResultListener} callback. * @return this {@link Registrar}. */ - @NonNull - Registrar addActivityResultListener(@NonNull ActivityResultListener listener); + Registrar addActivityResultListener(ActivityResultListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -289,8 +272,7 @@ Registrar addRequestPermissionsResultListener( * @param listener a {@link NewIntentListener} callback. * @return this {@link Registrar}. */ - @NonNull - Registrar addNewIntentListener(@NonNull NewIntentListener listener); + Registrar addNewIntentListener(NewIntentListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -306,8 +288,7 @@ Registrar addRequestPermissionsResultListener( * @param listener a {@link UserLeaveHintListener} callback. * @return this {@link Registrar}. */ - @NonNull - Registrar addUserLeaveHintListener(@NonNull UserLeaveHintListener listener); + Registrar addUserLeaveHintListener(UserLeaveHintListener listener); /** * Adds a callback allowing the plugin to take part in handling incoming calls to {@link @@ -331,8 +312,7 @@ Registrar addRequestPermissionsResultListener( */ // 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) - @NonNull - Registrar addViewDestroyListener(@NonNull ViewDestroyListener listener); + Registrar addViewDestroyListener(ViewDestroyListener listener); } /** @@ -348,8 +328,7 @@ interface RequestPermissionsResultListener { * {@code PackageManager.PERMISSION_GRANTED} or {@code PackageManager.PERMISSION_DENIED}. * @return true if the result has been handled. */ - boolean onRequestPermissionsResult( - int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults); + boolean onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); } /** @@ -366,7 +345,7 @@ interface ActivityResultListener { * attached to Intent "extras"). * @return true if the result has been handled. */ - boolean onActivityResult(int requestCode, int resultCode, @NonNull Intent data); + boolean onActivityResult(int requestCode, int resultCode, Intent data); } /** @@ -377,7 +356,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(@NonNull Intent intent); + boolean onNewIntent(Intent intent); } /** @@ -397,7 +376,7 @@ interface UserLeaveHintListener { */ @Deprecated interface ViewDestroyListener { - boolean onViewDestroy(@NonNull FlutterNativeView view); + boolean onViewDestroy(FlutterNativeView view); } /** @@ -410,6 +389,6 @@ interface ViewDestroyListener { */ @Deprecated interface PluginRegistrantCallback { - void registerWith(@NonNull PluginRegistry registry); + void registerWith(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 3cd1bf31cc33d..8050292174c6c 100644 --- a/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java +++ b/shell/platform/android/io/flutter/plugin/common/StandardMessageCodec.java @@ -4,8 +4,6 @@ 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; @@ -67,8 +65,7 @@ public class StandardMessageCodec implements MessageCodec { public static final StandardMessageCodec INSTANCE = new StandardMessageCodec(); @Override - @Nullable - public ByteBuffer encodeMessage(@Nullable Object message) { + public ByteBuffer encodeMessage(Object message) { if (message == null) { return null; } @@ -80,8 +77,7 @@ public ByteBuffer encodeMessage(@Nullable Object message) { } @Override - @Nullable - public Object decodeMessage(@Nullable ByteBuffer message) { + public Object decodeMessage(ByteBuffer message) { if (message == null) { return null; } @@ -115,7 +111,7 @@ public Object decodeMessage(@Nullable 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(@NonNull ByteArrayOutputStream stream, int value) { + protected static final void writeSize(ByteArrayOutputStream stream, int value) { if (BuildConfig.DEBUG && 0 > value) { Log.e(TAG, "Attempted to write a negative size."); } @@ -131,7 +127,7 @@ protected static final void writeSize(@NonNull ByteArrayOutputStream stream, int } /** Writes the least significant two bytes of the specified int to the specified stream. */ - protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int value) { + protected static final void writeChar(ByteArrayOutputStream stream, int value) { if (LITTLE_ENDIAN) { stream.write(value); stream.write(value >>> 8); @@ -142,7 +138,7 @@ protected static final void writeChar(@NonNull ByteArrayOutputStream stream, int } /** Writes the specified int as 4 bytes to the specified stream. */ - protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int value) { + protected static final void writeInt(ByteArrayOutputStream stream, int value) { if (LITTLE_ENDIAN) { stream.write(value); stream.write(value >>> 8); @@ -157,7 +153,7 @@ protected static final void writeInt(@NonNull ByteArrayOutputStream stream, int } /** Writes the specified long as 8 bytes to the specified stream. */ - protected static final void writeLong(@NonNull ByteArrayOutputStream stream, long value) { + protected static final void writeLong(ByteArrayOutputStream stream, long value) { if (LITTLE_ENDIAN) { stream.write((byte) value); stream.write((byte) (value >>> 8)); @@ -180,18 +176,17 @@ protected static final void writeLong(@NonNull ByteArrayOutputStream stream, lon } /** Writes the specified double as 4 bytes to the specified stream */ - protected static final void writeFloat(@NonNull ByteArrayOutputStream stream, float value) { + protected static final void writeFloat(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(@NonNull ByteArrayOutputStream stream, double value) { + protected static final void writeDouble(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( - @NonNull ByteArrayOutputStream stream, @NonNull byte[] bytes) { + protected static final void writeBytes(ByteArrayOutputStream stream, byte[] bytes) { writeSize(stream, bytes.length); stream.write(bytes, 0, bytes.length); } @@ -201,7 +196,7 @@ protected static final void writeBytes( * 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(@NonNull ByteArrayOutputStream stream, int alignment) { + protected static final void writeAlignment(ByteArrayOutputStream stream, int alignment) { final int mod = stream.size() % alignment; if (mod != 0) { for (int i = 0; i < alignment - mod; i++) { @@ -217,7 +212,7 @@ protected static final void writeAlignment(@NonNull ByteArrayOutputStream stream *

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

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

FlutterEngine must be non-null when this method is invoked. */ @SuppressWarnings("deprecation") - @Nullable - public Locale resolveNativeLocale(@Nullable List supportedLocales) { + public Locale resolveNativeLocale(List supportedLocales) { if (supportedLocales == null || supportedLocales.isEmpty()) { return null; } @@ -189,8 +188,7 @@ public void sendLocalesToFlutter(@NonNull Configuration config) { } @VisibleForTesting - @NonNull - public static Locale localeFromString(@NonNull String localeString) { + public static Locale localeFromString(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 f9c3a8e6f76f9..0daa4959d67f6 100644 --- a/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java +++ b/shell/platform/android/io/flutter/plugin/mouse/MouseCursorPlugin.java @@ -121,7 +121,6 @@ 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 a1d38ba0720db..59733b29bd0b0 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java @@ -130,14 +130,12 @@ public boolean clipboardHasStrings() { } }; - public PlatformPlugin(@NonNull Activity activity, @NonNull PlatformChannel platformChannel) { + public PlatformPlugin(Activity activity, PlatformChannel platformChannel) { this(activity, platformChannel, null); } public PlatformPlugin( - @NonNull Activity activity, - @NonNull PlatformChannel platformChannel, - @NonNull PlatformPluginDelegate delegate) { + Activity activity, PlatformChannel platformChannel, PlatformPluginDelegate delegate) { this.activity = activity; this.platformChannel = platformChannel; this.platformChannel.setPlatformMessageHandler(mPlatformMessageHandler); @@ -155,7 +153,7 @@ public void destroy() { this.platformChannel.setPlatformMessageHandler(null); } - private void playSystemSound(@NonNull PlatformChannel.SoundType soundType) { + private void playSystemSound(PlatformChannel.SoundType soundType) { if (soundType == PlatformChannel.SoundType.CLICK) { View view = activity.getWindow().getDecorView(); view.playSoundEffect(SoundEffectConstants.CLICK); @@ -163,8 +161,7 @@ private void playSystemSound(@NonNull PlatformChannel.SoundType soundType) { } @VisibleForTesting - /* package */ void vibrateHapticFeedback( - @NonNull PlatformChannel.HapticFeedbackType feedbackType) { + /* package */ void vibrateHapticFeedback(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 974d7e34ef0a0..92f034d840d11 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformView.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformView.java @@ -7,12 +7,10 @@ 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 a44447e0754b4..5144a639694f0 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewFactory.java @@ -5,15 +5,13 @@ 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(@NonNull MessageCodec createArgsCodec) { + public PlatformViewFactory(MessageCodec createArgsCodec) { this.createArgsCodec = createArgsCodec; } @@ -27,11 +25,9 @@ public PlatformViewFactory(@NonNull MessageCodec createArgsCodec) { * createArgsCodec argument passed to the constructor. This is null if createArgsCodec was * null, or no arguments were sent from the Flutter app. */ - @NonNull - public abstract PlatformView create(@Nullable Context context, int viewId, @NonNull Object args); + public abstract PlatformView create(Context context, int viewId, Object args); /** Returns the codec to be used for decoding the args parameter of {@link #create}. */ - @NonNull 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 028b3b1d2eb3f..e03a771cf6637 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewRegistry.java @@ -4,8 +4,6 @@ package io.flutter.plugin.platform; -import androidx.annotation.NonNull; - /** * Registry for platform view factories. * @@ -20,5 +18,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(@NonNull String viewTypeId, @NonNull PlatformViewFactory factory); + boolean registerViewFactory(String viewTypeId, 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 ecc3881bd96b3..ad693a8724880 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsAccessibilityDelegate.java @@ -5,7 +5,6 @@ package io.flutter.plugin.platform; import android.view.View; -import androidx.annotation.NonNull; import io.flutter.view.AccessibilityBridge; /** Facilitates interaction between the accessibility bridge and embedded platform views. */ @@ -14,11 +13,10 @@ public interface PlatformViewsAccessibilityDelegate { * Returns the root of the view hierarchy for the platform view with the requested id, or null if * there is no corresponding view. */ - @NonNull - View getPlatformViewById(int id); + View getPlatformViewById(Integer id); /** Returns true if the platform view uses virtual displays. */ - boolean usesVirtualDisplay(int id); + boolean usesVirtualDisplay(Integer id); /** * Attaches an accessibility bridge for this platform views accessibility delegate. @@ -26,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(@NonNull AccessibilityBridge accessibilityBridge); + void attachAccessibilityBridge(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 5688f36be5273..29ace9e502c2d 100644 --- a/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java +++ b/shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java @@ -161,10 +161,7 @@ public void disposeAndroidViewForPlatformView(int viewId) { final FlutterMutatorView parentView = platformViewParent.get(viewId); if (platformView != null) { if (parentView != null) { - final View view = platformView.getView(); - if (view != null) { - parentView.removeView(view); - } + parentView.removeView(platformView.getView()); } platformViews.remove(viewId); platformView.dispose(); @@ -244,17 +241,9 @@ public long createVirtualDisplayForPlatformView( } vdControllers.put(request.viewId, vdController); - View view = vdController.getView(); - if (view == null) { - throw new IllegalStateException( - "Platform view of type " - + request.viewType - + " with id: " - + request.viewId - + " cannot be null at this time"); - } - view.setLayoutDirection(request.direction); - contextToPlatformView.put(view.getContext(), view); + View platformView = vdController.getView(); + platformView.setLayoutDirection(request.direction); + contextToPlatformView.put(platformView.getContext(), platformView); // TODO(amirh): copy accessibility nodes to the FlutterView's accessibility tree. @@ -361,17 +350,12 @@ public void setDirection(int viewId, int direction) { public void clearFocus(int viewId) { final PlatformView platformView = platformViews.get(viewId); if (platformView != null) { - final View view = platformView.getView(); - if (view != null) { - view.clearFocus(); - } + platformView.getView().clearFocus(); return; } ensureValidAndroidVersion(Build.VERSION_CODES.KITKAT_WATCH); - final View view = vdControllers.get(viewId).getView(); - if (view != null) { - view.clearFocus(); - } + View view = vdControllers.get(viewId).getView(); + view.clearFocus(); } private void ensureValidAndroidVersion(int minSdkVersion) { @@ -391,11 +375,8 @@ public void synchronizeToNativeViewHierarchy(boolean yes) { }; @VisibleForTesting - @NonNull public MotionEvent toMotionEvent( - float density, - @NonNull PlatformViewsChannel.PlatformViewTouch touch, - boolean usingVirtualDiplays) { + float density, PlatformViewsChannel.PlatformViewTouch touch, boolean usingVirtualDiplays) { MotionEventTracker.MotionEventId motionEventId = MotionEventTracker.MotionEventId.from(touch.motionEventId); MotionEvent trackedEvent = motionEventTracker.pop(motionEventId); @@ -473,9 +454,7 @@ public PlatformViewsController() { * @param dartExecutor The dart execution context, which is used to set up a system channel. */ public void attach( - @Nullable Context context, - @NonNull TextureRegistry textureRegistry, - @NonNull DartExecutor dartExecutor) { + Context context, TextureRegistry textureRegistry, @NonNull DartExecutor dartExecutor) { if (this.context != null) { throw new AssertionError( "A PlatformViewsController can only be attached to a single output target.\n" @@ -541,7 +520,7 @@ public void detachFromView() { } @Override - public void attachAccessibilityBridge(@NonNull AccessibilityBridge accessibilityBridge) { + public void attachAccessibilityBridge(AccessibilityBridge accessibilityBridge) { accessibilityEventsDelegate.setAccessibilityBridge(accessibilityBridge); } @@ -559,7 +538,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(@NonNull TextInputPlugin textInputPlugin) { + public void attachTextInputPlugin(TextInputPlugin textInputPlugin) { this.textInputPlugin = textInputPlugin; } @@ -591,7 +570,6 @@ public boolean checkInputConnectionProxy(@Nullable View view) { return platformView.checkInputConnectionProxy(view); } - @NonNull public PlatformViewRegistry getRegistry() { return registry; } @@ -619,8 +597,7 @@ public void onPreEngineRestart() { } @Override - @Nullable - public View getPlatformViewById(int id) { + public View getPlatformViewById(Integer id) { // Hybrid composition. if (platformViews.get(id) != null) { return platformViews.get(id).getView(); @@ -633,7 +610,7 @@ public View getPlatformViewById(int id) { } @Override - public boolean usesVirtualDisplay(int id) { + public boolean usesVirtualDisplay(Integer id) { return vdControllers.containsKey(id); } @@ -797,7 +774,7 @@ void initializePlatformViewIfNeeded(int viewId) { flutterView.addView(parentView); } - public void attachToFlutterRenderer(@NonNull FlutterRenderer flutterRenderer) { + public void attachToFlutterRenderer(FlutterRenderer flutterRenderer) { androidTouchProcessor = new AndroidTouchProcessor(flutterRenderer, /*trackMotionEvents=*/ true); } @@ -822,7 +799,7 @@ public void onDisplayPlatformView( int height, int viewWidth, int viewHeight, - @NonNull FlutterMutatorsStack mutatorsStack) { + FlutterMutatorsStack mutatorsStack) { initializeRootImageViewIfNeeded(); initializePlatformViewIfNeeded(viewId); @@ -961,7 +938,6 @@ private void finishFrame(boolean isFrameRenderedUsingImageReaders) { */ @VisibleForTesting @TargetApi(19) - @NonNull public FlutterOverlaySurface createOverlaySurface(@NonNull FlutterImageView imageView) { final int id = nextOverlayLayerId++; overlayLayerViews.put(id, imageView); @@ -976,7 +952,6 @@ 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/plugin/platform/VirtualDisplayController.java b/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java index 43988796b34ff..fec53e89a6d9b 100644 --- a/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java +++ b/shell/platform/android/io/flutter/plugin/platform/VirtualDisplayController.java @@ -16,7 +16,6 @@ import android.view.View; import android.view.ViewTreeObserver; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.annotation.VisibleForTesting; import io.flutter.view.TextureRegistry; @@ -204,7 +203,6 @@ public void dispose() { presentation.getView().onInputConnectionUnlocked(); } - @Nullable public View getView() { if (presentation == null) return null; PlatformView platformView = presentation.getView(); diff --git a/shell/platform/android/io/flutter/util/PathUtils.java b/shell/platform/android/io/flutter/util/PathUtils.java index 5f3f7bd6845e4..1b4d36eb96529 100644 --- a/shell/platform/android/io/flutter/util/PathUtils.java +++ b/shell/platform/android/io/flutter/util/PathUtils.java @@ -6,12 +6,10 @@ import android.content.Context; import android.os.Build; -import androidx.annotation.NonNull; import java.io.File; public final class PathUtils { - @NonNull - public static String getFilesDir(@NonNull Context applicationContext) { + public static String getFilesDir(Context applicationContext) { File filesDir = applicationContext.getFilesDir(); if (filesDir == null) { filesDir = new File(getDataDirPath(applicationContext), "files"); @@ -19,8 +17,7 @@ public static String getFilesDir(@NonNull Context applicationContext) { return filesDir.getPath(); } - @NonNull - public static String getDataDirectory(@NonNull Context applicationContext) { + public static String getDataDirectory(Context applicationContext) { final String name = "flutter"; File flutterDir = applicationContext.getDir(name, Context.MODE_PRIVATE); if (flutterDir == null) { @@ -29,8 +26,7 @@ public static String getDataDirectory(@NonNull Context applicationContext) { return flutterDir.getPath(); } - @NonNull - public static String getCacheDirectory(@NonNull Context applicationContext) { + public static String getCacheDirectory(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 cc63ebadfccec..6ebac49a00f89 100644 --- a/shell/platform/android/io/flutter/util/ViewUtils.java +++ b/shell/platform/android/io/flutter/util/ViewUtils.java @@ -9,7 +9,6 @@ import android.content.ContextWrapper; import android.os.Build; import android.view.View; -import androidx.annotation.Nullable; public final class ViewUtils { /** @@ -18,8 +17,7 @@ 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}. */ - @Nullable - public static Activity getActivity(@Nullable Context context) { + public static Activity getActivity(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 b2bd7eb7d47ac..9b86ed08193fe 100644 --- a/shell/platform/android/io/flutter/view/FlutterView.java +++ b/shell/platform/android/io/flutter/view/FlutterView.java @@ -855,16 +855,13 @@ public void send(String channel, ByteBuffer message, BinaryReply callback) { @Override @UiThread - public void setMessageHandler(@NonNull String channel, @NonNull BinaryMessageHandler handler) { + public void setMessageHandler(String channel, BinaryMessageHandler handler) { mNativeView.setMessageHandler(channel, handler); } @Override @UiThread - public void setMessageHandler( - @NonNull String channel, - @NonNull BinaryMessageHandler handler, - @NonNull TaskQueue taskQueue) { + public void setMessageHandler(String channel, BinaryMessageHandler handler, TaskQueue taskQueue) { mNativeView.setMessageHandler(channel, handler, taskQueue); } @@ -874,14 +871,12 @@ 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 1155c4854bf66..6af82ce915fcc 100644 --- a/shell/platform/android/io/flutter/view/TextureRegistry.java +++ b/shell/platform/android/io/flutter/view/TextureRegistry.java @@ -19,7 +19,6 @@ public interface TextureRegistry { * * @return A SurfaceTextureEntry. */ - @NonNull SurfaceTextureEntry createSurfaceTexture(); /** @@ -27,13 +26,11 @@ 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 c5021460da89b..f65d6d569b088 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, @NonNull FlutterJNI flutterJNI) { + public static VsyncWaiter getInstance(float fps, FlutterJNI flutterJNI) { if (instance == null) { instance = new VsyncWaiter(flutterJNI); } @@ -60,8 +60,7 @@ public static VsyncWaiter getInstance(float fps, @NonNull FlutterJNI flutterJNI) @TargetApi(17) @NonNull - public static VsyncWaiter getInstance( - @NonNull DisplayManager displayManager, @NonNull FlutterJNI flutterJNI) { + public static VsyncWaiter getInstance(DisplayManager displayManager, FlutterJNI flutterJNI) { if (instance == null) { instance = new VsyncWaiter(flutterJNI); } @@ -104,7 +103,7 @@ public void doFrame(long frameTimeNanos) { } }; - private VsyncWaiter(@NonNull FlutterJNI flutterJNI) { + private VsyncWaiter(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 907ced48f300c..ae2e79eda1878 100644 --- a/shell/platform/android/test/io/flutter/TestUtils.java +++ b/shell/platform/android/test/io/flutter/TestUtils.java @@ -8,7 +8,6 @@ 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; @@ -30,7 +29,7 @@ public static void setApiVersion(int apiVersion) { } } - public static void setLegacyLocale(@NonNull Configuration config, @NonNull Locale locale) { + public static void setLegacyLocale(Configuration config, 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 938c81a85d6db..557d1e89d42b4 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java +++ b/shell/platform/android/test/io/flutter/embedding/android/RobolectricFlutterActivity.java @@ -1,7 +1,6 @@ package io.flutter.embedding.android; import android.content.Intent; -import androidx.annotation.NonNull; import org.robolectric.Robolectric; import org.robolectric.android.controller.ActivityController; @@ -15,8 +14,7 @@ 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. */ - @NonNull - public static FlutterActivity createFlutterActivity(@NonNull Intent intent) { + public static FlutterActivity createFlutterActivity(Intent intent) { ActivityController activityController = Robolectric.buildActivity(FlutterActivity.class, intent); FlutterActivity flutterActivity = activityController.get(); @@ -28,9 +26,8 @@ public static FlutterActivity createFlutterActivity(@NonNull 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( - @NonNull FlutterActivity activity) { + 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 e6cd8b6b6661e..2747092c836f8 100644 --- a/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java +++ b/shell/platform/android/test/io/flutter/embedding/android/SplashShadowResources.java @@ -4,7 +4,6 @@ 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; @@ -17,8 +16,7 @@ public class SplashShadowResources { public static final int THEMED_SPLASH_DRAWABLE_ID = 212121; // All other getDrawable() calls, call this method internally. - @NonNull - public Drawable getDrawableForDensity(int id, int density, @NonNull Resources.Theme theme) + public Drawable getDrawableForDensity(int id, int density, 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 387de14de371f..c2528725b89b3 100644 --- a/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java +++ b/shell/platform/android/test/io/flutter/plugins/GeneratedPluginRegistrant.java @@ -1,7 +1,5 @@ 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; @@ -15,7 +13,7 @@ @VisibleForTesting public class GeneratedPluginRegistrant { private static final List registeredEngines = new ArrayList<>(); - public static @Nullable RuntimeException pluginRegistrationException; + public static RuntimeException pluginRegistrationException; /** * The one and only method currently generated by the tool. @@ -23,7 +21,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(@NonNull FlutterEngine engine) { + public static void registerWith(FlutterEngine engine) { if (pluginRegistrationException != null) { throw pluginRegistrationException; } @@ -48,7 +46,6 @@ 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 99b750276fece..a7a4dd77e82b0 100644 --- a/tools/android_lint/bin/main.dart +++ b/tools/android_lint/bin/main.dart @@ -80,9 +80,6 @@ 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 7d76efedfe348..b37e7f0029a4c 100644 --- a/tools/android_lint/project.xml +++ b/tools/android_lint/project.xml @@ -5,11 +5,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -129,8 +178,8 @@ - +