Skip to content

Commit 3e43f59

Browse files
authored
[path_provider] Fix Unchecked/Unsafe Operation Warning (flutter#5267)
1 parent a59777f commit 3e43f59

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

packages/path_provider/path_provider_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.0.13
2+
3+
* Fixes typing build warning.
4+
15
## 2.0.12
26

37
* Returns to using a different platform channel name, undoing the revert in

packages/path_provider/path_provider_android/android/src/main/java/io/flutter/plugins/pathprovider/PathProviderPlugin.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@
1717
import com.google.common.util.concurrent.ThreadFactoryBuilder;
1818
import io.flutter.embedding.engine.plugins.FlutterPlugin;
1919
import io.flutter.plugin.common.BinaryMessenger;
20+
import io.flutter.plugin.common.BinaryMessenger.TaskQueue;
2021
import io.flutter.plugin.common.MethodCall;
2122
import io.flutter.plugin.common.MethodChannel;
2223
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
2324
import io.flutter.plugin.common.MethodChannel.Result;
24-
import io.flutter.plugin.common.MethodCodec;
2525
import io.flutter.plugin.common.StandardMethodCodec;
2626
import io.flutter.util.PathUtils;
2727
import java.io.File;
28-
import java.lang.reflect.Constructor;
29-
import java.lang.reflect.Method;
3028
import java.util.ArrayList;
3129
import java.util.List;
3230
import java.util.concurrent.Callable;
@@ -154,25 +152,17 @@ public PathProviderPlugin() {}
154152

155153
private void setup(BinaryMessenger messenger, Context context) {
156154
String channelName = "plugins.flutter.io/path_provider_android";
157-
// TODO(gaaclarke): Remove reflection guard when https://github.com/flutter/engine/pull/29147
158-
// becomes available on the stable branch.
155+
TaskQueue taskQueue = messenger.makeBackgroundTaskQueue();
156+
159157
try {
160-
Class methodChannelClass = Class.forName("io.flutter.plugin.common.MethodChannel");
161-
Class taskQueueClass = Class.forName("io.flutter.plugin.common.BinaryMessenger$TaskQueue");
162-
Method makeBackgroundTaskQueue = messenger.getClass().getMethod("makeBackgroundTaskQueue");
163-
Object taskQueue = makeBackgroundTaskQueue.invoke(messenger);
164-
Constructor<MethodChannel> constructor =
165-
methodChannelClass.getConstructor(
166-
BinaryMessenger.class, String.class, MethodCodec.class, taskQueueClass);
167158
channel =
168-
constructor.newInstance(messenger, channelName, StandardMethodCodec.INSTANCE, taskQueue);
159+
(MethodChannel)
160+
new MethodChannel(messenger, channelName, StandardMethodCodec.INSTANCE, taskQueue);
169161
impl = new PathProviderBackgroundThread();
170-
Log.d(TAG, "Use TaskQueues.");
171162
} catch (Exception ex) {
172-
channel = new MethodChannel(messenger, channelName);
173-
impl = new PathProviderPlatformThread();
174-
Log.d(TAG, "Don't use TaskQueues.");
163+
Log.e(TAG, "Received exception while setting up PathProviderPlugin", ex);
175164
}
165+
176166
this.context = context;
177167
channel.setMethodCallHandler(this);
178168
}

packages/path_provider/path_provider_android/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ name: path_provider_android
22
description: Android implementation of the path_provider plugin.
33
repository: https://github.com/flutter/plugins/tree/main/packages/path_provider/path_provider_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+path_provider%22
5-
version: 2.0.12
5+
version: 2.0.13
66

77
environment:
88
sdk: ">=2.14.0 <3.0.0"
9-
flutter: ">=2.8.0"
9+
flutter: ">=2.8.1"
1010

1111
flutter:
1212
plugin:

0 commit comments

Comments
 (0)