Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 37ce4a7

Browse files
authored
Revert "Fix first batch of warnings in the Android embedding (#30807)"
This reverts commit 1adccf1.
1 parent 291ca01 commit 37ce4a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+206
-329
lines changed

shell/platform/android/io/flutter/embedding/android/FlutterView.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ public InputConnection onCreateInputConnection(@NonNull EditorInfo outAttrs) {
876876
* methods.
877877
*/
878878
@Override
879-
public boolean checkInputConnectionProxy(@NonNull View view) {
879+
public boolean checkInputConnectionProxy(View view) {
880880
return flutterEngine != null
881881
? flutterEngine.getPlatformViewsController().checkInputConnectionProxy(view)
882882
: super.checkInputConnectionProxy(view);
@@ -894,7 +894,7 @@ public boolean checkInputConnectionProxy(@NonNull View view) {
894894
* previous {@code keyCode} to generate a unicode combined character.
895895
*/
896896
@Override
897-
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
897+
public boolean dispatchKeyEvent(KeyEvent event) {
898898
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
899899
// Tell Android to start tracking this event.
900900
getKeyDispatcherState().startTracking(event, this);
@@ -1003,7 +1003,6 @@ public AccessibilityNodeProvider getAccessibilityNodeProvider() {
10031003
* @return The view matching the accessibility id if any.
10041004
*/
10051005
@SuppressLint("SoonBlockedPrivateApi")
1006-
@Nullable
10071006
public View findViewByAccessibilityIdTraversal(int accessibilityId) {
10081007
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
10091008
return findViewByAccessibilityIdRootedAtCurrentView(accessibilityId, this);
@@ -1350,7 +1349,7 @@ public void onFlutterUiNoLongerDisplayed() {
13501349
});
13511350
}
13521351

1353-
public void attachOverlaySurfaceToRender(@NonNull FlutterImageView view) {
1352+
public void attachOverlaySurfaceToRender(FlutterImageView view) {
13541353
if (flutterEngine != null) {
13551354
view.attachToRenderer(flutterEngine.getRenderer());
13561355
}
@@ -1451,13 +1450,13 @@ private void sendViewportMetricsToFlutter() {
14511450
}
14521451

14531452
@Override
1454-
public void onProvideAutofillVirtualStructure(@NonNull ViewStructure structure, int flags) {
1453+
public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) {
14551454
super.onProvideAutofillVirtualStructure(structure, flags);
14561455
textInputPlugin.onProvideAutofillVirtualStructure(structure, flags);
14571456
}
14581457

14591458
@Override
1460-
public void autofill(@NonNull SparseArray<AutofillValue> values) {
1459+
public void autofill(SparseArray<AutofillValue> values) {
14611460
textInputPlugin.autofill(values);
14621461
}
14631462

shell/platform/android/io/flutter/embedding/android/KeyboardManager.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ public class KeyboardManager {
7979
* dispatched to.
8080
*/
8181
public KeyboardManager(
82-
@NonNull View view,
83-
@NonNull TextInputPlugin textInputPlugin,
84-
@NonNull Responder[] responders) {
82+
View view, @NonNull TextInputPlugin textInputPlugin, Responder[] responders) {
8583
this.view = view;
8684
this.textInputPlugin = textInputPlugin;
8785
this.responders = responders;
@@ -105,7 +103,7 @@ public KeyboardManager(
105103
*/
106104
interface Responder {
107105
interface OnKeyEventHandledCallback {
108-
void onKeyEventHandled(boolean canHandleEvent);
106+
void onKeyEventHandled(Boolean canHandleEvent);
109107
}
110108

111109
/**
@@ -124,7 +122,7 @@ private class Callback implements OnKeyEventHandledCallback {
124122
boolean isCalled = false;
125123

126124
@Override
127-
public void onKeyEventHandled(boolean canHandleEvent) {
125+
public void onKeyEventHandled(Boolean canHandleEvent) {
128126
if (isCalled) {
129127
throw new IllegalStateException(
130128
"The onKeyEventHandledCallback should be called exactly once.");
@@ -142,7 +140,7 @@ public void onKeyEventHandled(boolean canHandleEvent) {
142140
this.keyEvent = keyEvent;
143141
}
144142

145-
final KeyEvent keyEvent;
143+
@NonNull final KeyEvent keyEvent;
146144
int unrepliedCount = responders.length;
147145
boolean isEventHandled = false;
148146

@@ -151,9 +149,9 @@ public OnKeyEventHandledCallback buildCallback() {
151149
}
152150
}
153151

154-
protected final Responder[] responders;
155-
private final HashSet<KeyEvent> redispatchedEvents = new HashSet<>();
156-
private final TextInputPlugin textInputPlugin;
152+
@NonNull protected final Responder[] responders;
153+
@NonNull private final HashSet<KeyEvent> redispatchedEvents = new HashSet<>();
154+
@NonNull private final TextInputPlugin textInputPlugin;
157155
private final View view;
158156

159157
public boolean handleEvent(@NonNull KeyEvent keyEvent) {

shell/platform/android/io/flutter/embedding/android/MotionEventTracker.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.util.LongSparseArray;
44
import android.view.MotionEvent;
5-
import androidx.annotation.NonNull;
65
import androidx.annotation.Nullable;
76
import java.util.PriorityQueue;
87
import java.util.concurrent.atomic.AtomicLong;
@@ -19,12 +18,10 @@ private MotionEventId(long id) {
1918
this.id = id;
2019
}
2120

22-
@NonNull
2321
public static MotionEventId from(long id) {
2422
return new MotionEventId(id);
2523
}
2624

27-
@NonNull
2825
public static MotionEventId createUnique() {
2926
return MotionEventId.from(ID_COUNTER.incrementAndGet());
3027
}
@@ -38,7 +35,6 @@ public long getId() {
3835
private final PriorityQueue<Long> unusedEvents;
3936
private static MotionEventTracker INSTANCE;
4037

41-
@NonNull
4238
public static MotionEventTracker getInstance() {
4339
if (INSTANCE == null) {
4440
INSTANCE = new MotionEventTracker();
@@ -52,8 +48,7 @@ private MotionEventTracker() {
5248
}
5349

5450
/** Tracks the event and returns a unique MotionEventId identifying the event. */
55-
@NonNull
56-
public MotionEventId track(@NonNull MotionEvent event) {
51+
public MotionEventId track(MotionEvent event) {
5752
MotionEventId eventId = MotionEventId.createUnique();
5853
eventById.put(eventId.id, MotionEvent.obtain(event));
5954
unusedEvents.add(eventId.id);
@@ -66,7 +61,7 @@ public MotionEventId track(@NonNull MotionEvent event) {
6661
* popped or discarded.
6762
*/
6863
@Nullable
69-
public MotionEvent pop(@NonNull MotionEventId eventId) {
64+
public MotionEvent pop(MotionEventId eventId) {
7065
// remove all the older events.
7166
while (!unusedEvents.isEmpty() && unusedEvents.peek() < eventId.id) {
7267
eventById.remove(unusedEvents.poll());

shell/platform/android/io/flutter/embedding/engine/deferredcomponents/PlayStoreDeferredComponentManager.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class PlayStoreDeferredComponentManager implements DeferredComponentManag
6666

6767
private class FeatureInstallStateUpdatedListener implements SplitInstallStateUpdatedListener {
6868
@SuppressLint("DefaultLocale")
69-
public void onStateUpdate(@NonNull SplitInstallSessionState state) {
69+
public void onStateUpdate(SplitInstallSessionState state) {
7070
int sessionId = state.sessionId();
7171
if (sessionIdToName.get(sessionId) != null) {
7272
switch (state.status()) {
@@ -231,7 +231,7 @@ private boolean verifyJNI() {
231231
return true;
232232
}
233233

234-
public void setDeferredComponentChannel(@NonNull DeferredComponentChannel channel) {
234+
public void setDeferredComponentChannel(DeferredComponentChannel channel) {
235235
this.channel = channel;
236236
}
237237

@@ -288,7 +288,7 @@ private void initLoadingUnitMappingToComponentNames() {
288288
}
289289
}
290290

291-
public void installDeferredComponent(int loadingUnitId, @Nullable String componentName) {
291+
public void installDeferredComponent(int loadingUnitId, String componentName) {
292292
String resolvedComponentName =
293293
componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId);
294294
if (resolvedComponentName == null) {
@@ -357,9 +357,7 @@ public void installDeferredComponent(int loadingUnitId, @Nullable String compone
357357
});
358358
}
359359

360-
@NonNull
361-
public String getDeferredComponentInstallState(
362-
int loadingUnitId, @Nullable String componentName) {
360+
public String getDeferredComponentInstallState(int loadingUnitId, String componentName) {
363361
String resolvedComponentName =
364362
componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId);
365363
if (resolvedComponentName == null) {
@@ -377,7 +375,7 @@ public String getDeferredComponentInstallState(
377375
return sessionIdToState.get(sessionId);
378376
}
379377

380-
public void loadAssets(int loadingUnitId, @NonNull String componentName) {
378+
public void loadAssets(int loadingUnitId, String componentName) {
381379
if (!verifyJNI()) {
382380
return;
383381
}
@@ -395,7 +393,7 @@ public void loadAssets(int loadingUnitId, @NonNull String componentName) {
395393
}
396394
}
397395

398-
public void loadDartLibrary(int loadingUnitId, @NonNull String componentName) {
396+
public void loadDartLibrary(int loadingUnitId, String componentName) {
399397
if (!verifyJNI()) {
400398
return;
401399
}
@@ -480,7 +478,7 @@ public void loadDartLibrary(int loadingUnitId, @NonNull String componentName) {
480478
loadingUnitId, searchPaths.toArray(new String[searchPaths.size()]));
481479
}
482480

483-
public boolean uninstallDeferredComponent(int loadingUnitId, @Nullable String componentName) {
481+
public boolean uninstallDeferredComponent(int loadingUnitId, String componentName) {
484482
String resolvedComponentName =
485483
componentName != null ? componentName : loadingUnitIdToComponentNames.get(loadingUnitId);
486484
if (resolvedComponentName == null) {

shell/platform/android/io/flutter/embedding/engine/plugins/shim/ShimPluginRegistry.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public ShimPluginRegistry(@NonNull FlutterEngine flutterEngine) {
4848
}
4949

5050
@Override
51-
@NonNull
52-
public Registrar registrarFor(@NonNull String pluginKey) {
51+
public Registrar registrarFor(String pluginKey) {
5352
Log.v(TAG, "Creating plugin Registrar for '" + pluginKey + "'");
5453
if (pluginMap.containsKey(pluginKey)) {
5554
throw new IllegalStateException("Plugin key " + pluginKey + " is already in use");
@@ -61,13 +60,13 @@ public Registrar registrarFor(@NonNull String pluginKey) {
6160
}
6261

6362
@Override
64-
public boolean hasPlugin(@NonNull String pluginKey) {
63+
public boolean hasPlugin(String pluginKey) {
6564
return pluginMap.containsKey(pluginKey);
6665
}
6766

6867
@Override
6968
@SuppressWarnings("unchecked")
70-
public <T> T valuePublishedByPlugin(@NonNull String pluginKey) {
69+
public <T> T valuePublishedByPlugin(String pluginKey) {
7170
return (T) pluginMap.get(pluginKey);
7271
}
7372

shell/platform/android/io/flutter/embedding/engine/renderer/SurfaceTextureWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void detachFromGLContext() {
6767

6868
// Called by native.
6969
@SuppressWarnings("unused")
70-
public void getTransformMatrix(@NonNull float[] mtx) {
70+
public void getTransformMatrix(float[] mtx) {
7171
surfaceTexture.getTransformMatrix(mtx);
7272
}
7373
}

shell/platform/android/io/flutter/embedding/engine/systemchannels/LocalizationChannel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public interface LocalizationMessageHandler {
110110
* The Flutter application would like to obtain the string resource of given {@code key} in
111111
* {@code locale}.
112112
*/
113-
@NonNull
114-
String getStringResource(@NonNull String key, @NonNull String locale);
113+
String getStringResource(@NonNull String key, String locale);
115114
}
116115
}

shell/platform/android/io/flutter/embedding/engine/systemchannels/RestorationChannel.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package io.flutter.embedding.engine.systemchannels;
66

77
import androidx.annotation.NonNull;
8-
import androidx.annotation.Nullable;
98
import io.flutter.Log;
109
import io.flutter.embedding.engine.dart.DartExecutor;
1110
import io.flutter.plugin.common.MethodCall;
@@ -73,13 +72,12 @@ public RestorationChannel(
7372
private boolean frameworkHasRequestedData = false;
7473

7574
/** Obtain the most current restoration data that the framework has provided. */
76-
@Nullable
7775
public byte[] getRestorationData() {
7876
return restorationData;
7977
}
8078

8179
/** Set the restoration data from which the framework will restore its state. */
82-
public void setRestorationData(@NonNull byte[] data) {
80+
public void setRestorationData(byte[] data) {
8381
engineHasProvidedData = true;
8482
if (pendingFrameworkRestorationChannelRequest != null) {
8583
// If their is a pending request from the framework, answer it.

shell/platform/android/io/flutter/embedding/engine/systemchannels/TextInputChannel.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private static HashMap<Object, Object> createEditingDeltaJSON(
205205
*/
206206
public void updateEditingState(
207207
int inputClientId,
208-
@NonNull String text,
208+
String text,
209209
int selectionStart,
210210
int selectionEnd,
211211
int composingStart,
@@ -235,7 +235,7 @@ public void updateEditingState(
235235
}
236236

237237
public void updateEditingStateWithDeltas(
238-
int inputClientId, @NonNull ArrayList<TextEditingDelta> batchDeltas) {
238+
int inputClientId, ArrayList<TextEditingDelta> batchDeltas) {
239239

240240
Log.v(
241241
TAG,
@@ -250,7 +250,7 @@ public void updateEditingStateWithDeltas(
250250
}
251251

252252
public void updateEditingStateWithTag(
253-
int inputClientId, @NonNull HashMap<String, TextEditState> editStates) {
253+
int inputClientId, HashMap<String, TextEditState> editStates) {
254254
Log.v(
255255
TAG,
256256
"Sending message to update editing state for "
@@ -325,8 +325,7 @@ public void unspecifiedAction(int inputClientId) {
325325
Arrays.asList(inputClientId, "TextInputAction.unspecified"));
326326
}
327327

328-
public void performPrivateCommand(
329-
int inputClientId, @NonNull String action, @NonNull Bundle data) {
328+
public void performPrivateCommand(int inputClientId, String action, Bundle data) {
330329
HashMap<Object, Object> json = new HashMap<>();
331330
json.put("action", action);
332331
if (data != null) {
@@ -416,7 +415,7 @@ public interface TextInputMethodHandler {
416415
* @param transform a 4x4 matrix that maps the local paint coordinate system to coordinate
417416
* system of the FlutterView that owns the current client.
418417
*/
419-
void setEditableSizeAndTransform(double width, double height, @NonNull double[] transform);
418+
void setEditableSizeAndTransform(double width, double height, double[] transform);
420419

421420
// TODO(mattcarroll): javadoc
422421
void setEditingState(@NonNull TextEditState editingState);
@@ -433,12 +432,11 @@ public interface TextInputMethodHandler {
433432
* commands.
434433
* @param data Any data to include with the command.
435434
*/
436-
void sendAppPrivateCommand(@NonNull String action, @NonNull Bundle data);
435+
void sendAppPrivateCommand(String action, Bundle data);
437436
}
438437

439438
/** A text editing configuration. */
440439
public static class Configuration {
441-
@NonNull
442440
public static Configuration fromJson(@NonNull JSONObject json)
443441
throws JSONException, NoSuchFieldException {
444442
final String inputActionName = json.getString("inputAction");
@@ -496,7 +494,6 @@ private static Integer inputActionFromTextInputAction(@NonNull String inputActio
496494
}
497495

498496
public static class Autofill {
499-
@NonNull
500497
public static Autofill fromJson(@NonNull JSONObject json)
501498
throws JSONException, NoSuchFieldException {
502499
final String uniqueIdentifier = json.getString("uniqueIdentifier");
@@ -732,7 +729,6 @@ static TextCapitalization fromValue(@NonNull String encodedName) throws NoSuchFi
732729

733730
/** State of an on-going text editing session. */
734731
public static class TextEditState {
735-
@NonNull
736732
public static TextEditState fromJson(@NonNull JSONObject textEditState) throws JSONException {
737733
return new TextEditState(
738734
textEditState.getString("text"),

shell/platform/android/io/flutter/plugin/common/JSONMessageCodec.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
package io.flutter.plugin.common;
66

7-
import androidx.annotation.Nullable;
87
import java.nio.ByteBuffer;
98
import org.json.JSONException;
109
import org.json.JSONObject;
@@ -29,8 +28,7 @@ public final class JSONMessageCodec implements MessageCodec<Object> {
2928
private JSONMessageCodec() {}
3029

3130
@Override
32-
@Nullable
33-
public ByteBuffer encodeMessage(@Nullable Object message) {
31+
public ByteBuffer encodeMessage(Object message) {
3432
if (message == null) {
3533
return null;
3634
}
@@ -43,8 +41,7 @@ public ByteBuffer encodeMessage(@Nullable Object message) {
4341
}
4442

4543
@Override
46-
@Nullable
47-
public Object decodeMessage(@Nullable ByteBuffer message) {
44+
public Object decodeMessage(ByteBuffer message) {
4845
if (message == null) {
4946
return null;
5047
}

0 commit comments

Comments
 (0)