Skip to content

Commit

Permalink
Review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
brianquinlan committed Sep 13, 2023
1 parent 07f22cd commit f8baabc
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 1,339 deletions.
10 changes: 10 additions & 0 deletions pkgs/cronet_http/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ android {
defaultConfig {
minSdkVersion 16
}

defaultConfig {
consumerProguardFiles 'consumer-rules.pro'
}

buildTypes {
release {
minifyEnabled false
}
}
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions pkgs/cronet_http/android/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class io.flutter.plugins.cronet_http.** { *; }
3 changes: 3 additions & 0 deletions pkgs/cronet_http/example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,7 @@ flutter {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// ""com.google.android.gms:play-services-cronet" is only present so that
// `jnigen` will work. Applications should not include this line.
implementation "com.google.android.gms:play-services-cronet:18.0.1"
}
4 changes: 0 additions & 4 deletions pkgs/cronet_http/jnigen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ android_sdk_config:
add_gradle_deps: true
android_example: 'example/'

suspend_fun_to_async: true

output:
bindings_type: dart_only
dart:
Expand All @@ -18,8 +16,6 @@ output:
classes:
- 'io.flutter.plugins.cronet_http.UrlRequestCallbackProxy'
- 'java.net.URL'
- 'java.nio.Buffer'
- 'java.nio.ByteBuffer'
- 'java.util.concurrent.Executors'
- 'org.chromium.net.CronetEngine'
- 'org.chromium.net.CronetException'
Expand Down
8 changes: 3 additions & 5 deletions pkgs/cronet_http/lib/src/cronet_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ jb.UrlRequestCallbackProxy_UrlRequestCallbackInterface _urlRequestCallbacks(
));

jByteBuffer = JByteBuffer.allocateDirect(_bufferSize);
urlRequest.read(jByteBuffer!.castTo(const jb.$ByteBufferType()));
urlRequest.read(jByteBuffer!);
},
onRedirectReceived: (urlRequest, responseInfo, newLocationUrl) {
if (!request.followRedirects) {
Expand Down Expand Up @@ -205,7 +205,7 @@ jb.UrlRequestCallbackProxy_UrlRequestCallbackInterface _urlRequestCallbacks(
onReadCompleted: (urlRequest, responseInfo, byteBuffer) {
byteBuffer.flip();
responseStream!
.add(jByteBuffer!.asUint8List().sublist(0, byteBuffer.remaining()));
.add(jByteBuffer!.asUint8List().sublist(0, byteBuffer.remaining));

byteBuffer.clear();
urlRequest.read(byteBuffer);
Expand Down Expand Up @@ -329,10 +329,8 @@ class CronetClient extends BaseClient {
headers.forEach((k, v) => builder.addHeader(k.toJString(), v.toJString()));

if (body.isNotEmpty) {
final bodyBuffer =
body.toJByteBuffer().castTo(const jb.$ByteBufferType());
builder.setUploadDataProvider(
jb.UploadDataProviders.create2(bodyBuffer), _executor);
jb.UploadDataProviders.create2(body.toJByteBuffer()), _executor);
}
builder.build().start();
return responseCompleter.future;
Expand Down
Loading

0 comments on commit f8baabc

Please sign in to comment.