Skip to content

Commit ea24e4d

Browse files
Rebase
1 parent f177f2d commit ea24e4d

File tree

6 files changed

+59
-44
lines changed

6 files changed

+59
-44
lines changed

.github/workflows/jnigen.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ jobs:
221221
github-token: ${{ secrets.GITHUB_TOKEN }}
222222
parallel: true
223223
path-to-lcov: ./pkgs/jni/coverage/lcov.info
224+
- name: regenerate & compare jnigen bindings
225+
run: |
226+
dart run tool/generate_jni_bindings.dart
227+
git diff --exit-code -- lib/src/plugin
224228
# TODO(https://github.com/dart-lang/ffigen/issues/555): FFIgen generated
225229
# on my machine has macOS specific stuff and CI does not.
226230
# We should just generate the struct as opaque, but we currently can't.

pkgs/jni/example/android/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pluginManagement {
1919
plugins {
2020
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
2121
id "com.android.application" version "8.6.0" apply false
22-
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
22+
id "org.jetbrains.kotlin.android" version "2.1.0" apply false
2323
}
2424

2525
include ":app"

pkgs/jni/lib/src/jni.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,13 +228,13 @@ abstract final class Jni {
228228
late final StreamController<JObject?> androidActivitiesController;
229229
final activityListener = JniPlugin$ActivityListener.implement(
230230
$JniPlugin$ActivityListener(
231+
onActivityChanged$async: true,
231232
onActivityChanged: (activity) {
232233
androidActivitiesController.add(activity);
233234
},
234235
),
235236
);
236237
androidActivitiesController = StreamController(
237-
sync: true,
238238
onListen: () {
239239
JniPlugin.addActivityListener(engineId, activityListener);
240240
},

pkgs/jni/lib/src/plugin/generated_plugin.dart

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
// ignore_for_file: unused_shown_name
3636
// ignore_for_file: use_super_parameters
3737

38-
import 'dart:core' show Object, String, bool, double, int;
3938
import 'dart:core' as core$_;
39+
import 'dart:core' show Object, String, bool, double, int;
4040

4141
import 'package:jni/_internal.dart' as jni$_;
4242
import 'package:jni/jni.dart' as jni$_;
@@ -45,7 +45,7 @@ import 'package:jni/jni.dart' as jni$_;
4545
class JniPlugin$ActivityListener extends jni$_.JObject {
4646
@jni$_.internal
4747
@core$_.override
48-
final jni$_.JObjType<JniPlugin$ActivityListener> $type;
48+
final jni$_.JType<JniPlugin$ActivityListener> $type;
4949

5050
@jni$_.internal
5151
JniPlugin$ActivityListener.fromReference(
@@ -57,8 +57,12 @@ class JniPlugin$ActivityListener extends jni$_.JObject {
5757
r'com/github/dart_lang/jni/JniPlugin$ActivityListener');
5858

5959
/// The type which includes information such as the signature of this class.
60-
static const nullableType = $JniPlugin$ActivityListener$NullableType();
61-
static const type = $JniPlugin$ActivityListener$Type();
60+
static const jni$_.JType<JniPlugin$ActivityListener?> nullableType =
61+
$JniPlugin$ActivityListener$NullableType$();
62+
63+
/// The type which includes information such as the signature of this class.
64+
static const jni$_.JType<JniPlugin$ActivityListener> type =
65+
$JniPlugin$ActivityListener$Type$();
6266
static final _id_onActivityChanged = _class.instanceMethodId(
6367
r'onActivityChanged',
6468
r'(Landroid/app/Activity;)V',
@@ -117,7 +121,7 @@ class JniPlugin$ActivityListener extends jni$_.JObject {
117121
final $a = $i.args;
118122
if ($d == r'onActivityChanged(Landroid/app/Activity;)V') {
119123
_$impls[$p]!.onActivityChanged(
120-
$a![0]?.as(const jni$_.JObjectType(), releaseOriginal: true),
124+
$a![0]?.as(const jni$_.$JObject$Type$(), releaseOriginal: true),
121125
);
122126
return jni$_.nullptr;
123127
}
@@ -190,10 +194,10 @@ final class _$JniPlugin$ActivityListener with $JniPlugin$ActivityListener {
190194
}
191195
}
192196

193-
final class $JniPlugin$ActivityListener$NullableType
194-
extends jni$_.JObjType<JniPlugin$ActivityListener?> {
197+
final class $JniPlugin$ActivityListener$NullableType$
198+
extends jni$_.JType<JniPlugin$ActivityListener?> {
195199
@jni$_.internal
196-
const $JniPlugin$ActivityListener$NullableType();
200+
const $JniPlugin$ActivityListener$NullableType$();
197201

198202
@jni$_.internal
199203
@core$_.override
@@ -210,30 +214,30 @@ final class $JniPlugin$ActivityListener$NullableType
210214
);
211215
@jni$_.internal
212216
@core$_.override
213-
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
217+
jni$_.JType get superType => const jni$_.$JObject$NullableType$();
214218

215219
@jni$_.internal
216220
@core$_.override
217-
jni$_.JObjType<JniPlugin$ActivityListener?> get nullableType => this;
221+
jni$_.JType<JniPlugin$ActivityListener?> get nullableType => this;
218222

219223
@jni$_.internal
220224
@core$_.override
221225
final superCount = 1;
222226

223227
@core$_.override
224-
int get hashCode => ($JniPlugin$ActivityListener$NullableType).hashCode;
228+
int get hashCode => ($JniPlugin$ActivityListener$NullableType$).hashCode;
225229

226230
@core$_.override
227231
bool operator ==(Object other) {
228-
return other.runtimeType == ($JniPlugin$ActivityListener$NullableType) &&
229-
other is $JniPlugin$ActivityListener$NullableType;
232+
return other.runtimeType == ($JniPlugin$ActivityListener$NullableType$) &&
233+
other is $JniPlugin$ActivityListener$NullableType$;
230234
}
231235
}
232236

233-
final class $JniPlugin$ActivityListener$Type
234-
extends jni$_.JObjType<JniPlugin$ActivityListener> {
237+
final class $JniPlugin$ActivityListener$Type$
238+
extends jni$_.JType<JniPlugin$ActivityListener> {
235239
@jni$_.internal
236-
const $JniPlugin$ActivityListener$Type();
240+
const $JniPlugin$ActivityListener$Type$();
237241

238242
@jni$_.internal
239243
@core$_.override
@@ -248,32 +252,32 @@ final class $JniPlugin$ActivityListener$Type
248252
);
249253
@jni$_.internal
250254
@core$_.override
251-
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
255+
jni$_.JType get superType => const jni$_.$JObject$NullableType$();
252256

253257
@jni$_.internal
254258
@core$_.override
255-
jni$_.JObjType<JniPlugin$ActivityListener?> get nullableType =>
256-
const $JniPlugin$ActivityListener$NullableType();
259+
jni$_.JType<JniPlugin$ActivityListener?> get nullableType =>
260+
const $JniPlugin$ActivityListener$NullableType$();
257261

258262
@jni$_.internal
259263
@core$_.override
260264
final superCount = 1;
261265

262266
@core$_.override
263-
int get hashCode => ($JniPlugin$ActivityListener$Type).hashCode;
267+
int get hashCode => ($JniPlugin$ActivityListener$Type$).hashCode;
264268

265269
@core$_.override
266270
bool operator ==(Object other) {
267-
return other.runtimeType == ($JniPlugin$ActivityListener$Type) &&
268-
other is $JniPlugin$ActivityListener$Type;
271+
return other.runtimeType == ($JniPlugin$ActivityListener$Type$) &&
272+
other is $JniPlugin$ActivityListener$Type$;
269273
}
270274
}
271275

272276
/// from: `com.github.dart_lang.jni.JniPlugin`
273277
class JniPlugin extends jni$_.JObject {
274278
@jni$_.internal
275279
@core$_.override
276-
final jni$_.JObjType<JniPlugin> $type;
280+
final jni$_.JType<JniPlugin> $type;
277281

278282
@jni$_.internal
279283
JniPlugin.fromReference(
@@ -285,8 +289,11 @@ class JniPlugin extends jni$_.JObject {
285289
jni$_.JClass.forName(r'com/github/dart_lang/jni/JniPlugin');
286290

287291
/// The type which includes information such as the signature of this class.
288-
static const nullableType = $JniPlugin$NullableType();
289-
static const type = $JniPlugin$Type();
292+
static const jni$_.JType<JniPlugin?> nullableType =
293+
$JniPlugin$NullableType$();
294+
295+
/// The type which includes information such as the signature of this class.
296+
static const jni$_.JType<JniPlugin> type = $JniPlugin$Type$();
290297
static final _id_new$ = _class.constructorId(
291298
r'()V',
292299
);
@@ -332,7 +339,7 @@ class JniPlugin extends jni$_.JObject {
332339
) {
333340
return _getApplicationContext(_class.reference.pointer,
334341
_id_getApplicationContext as jni$_.JMethodIDPtr, j)
335-
.object<jni$_.JObject>(const jni$_.JObjectType());
342+
.object<jni$_.JObject>(const jni$_.$JObject$Type$());
336343
}
337344

338345
static final _id_addActivityListener = _class.staticMethodId(
@@ -562,9 +569,9 @@ class JniPlugin extends jni$_.JObject {
562569
}
563570
}
564571

565-
final class $JniPlugin$NullableType extends jni$_.JObjType<JniPlugin?> {
572+
final class $JniPlugin$NullableType$ extends jni$_.JType<JniPlugin?> {
566573
@jni$_.internal
567-
const $JniPlugin$NullableType();
574+
const $JniPlugin$NullableType$();
568575

569576
@jni$_.internal
570577
@core$_.override
@@ -579,29 +586,29 @@ final class $JniPlugin$NullableType extends jni$_.JObjType<JniPlugin?> {
579586
);
580587
@jni$_.internal
581588
@core$_.override
582-
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
589+
jni$_.JType get superType => const jni$_.$JObject$NullableType$();
583590

584591
@jni$_.internal
585592
@core$_.override
586-
jni$_.JObjType<JniPlugin?> get nullableType => this;
593+
jni$_.JType<JniPlugin?> get nullableType => this;
587594

588595
@jni$_.internal
589596
@core$_.override
590597
final superCount = 1;
591598

592599
@core$_.override
593-
int get hashCode => ($JniPlugin$NullableType).hashCode;
600+
int get hashCode => ($JniPlugin$NullableType$).hashCode;
594601

595602
@core$_.override
596603
bool operator ==(Object other) {
597-
return other.runtimeType == ($JniPlugin$NullableType) &&
598-
other is $JniPlugin$NullableType;
604+
return other.runtimeType == ($JniPlugin$NullableType$) &&
605+
other is $JniPlugin$NullableType$;
599606
}
600607
}
601608

602-
final class $JniPlugin$Type extends jni$_.JObjType<JniPlugin> {
609+
final class $JniPlugin$Type$ extends jni$_.JType<JniPlugin> {
603610
@jni$_.internal
604-
const $JniPlugin$Type();
611+
const $JniPlugin$Type$();
605612

606613
@jni$_.internal
607614
@core$_.override
@@ -615,22 +622,21 @@ final class $JniPlugin$Type extends jni$_.JObjType<JniPlugin> {
615622
);
616623
@jni$_.internal
617624
@core$_.override
618-
jni$_.JObjType get superType => const jni$_.JObjectNullableType();
625+
jni$_.JType get superType => const jni$_.$JObject$NullableType$();
619626

620627
@jni$_.internal
621628
@core$_.override
622-
jni$_.JObjType<JniPlugin?> get nullableType =>
623-
const $JniPlugin$NullableType();
629+
jni$_.JType<JniPlugin?> get nullableType => const $JniPlugin$NullableType$();
624630

625631
@jni$_.internal
626632
@core$_.override
627633
final superCount = 1;
628634

629635
@core$_.override
630-
int get hashCode => ($JniPlugin$Type).hashCode;
636+
int get hashCode => ($JniPlugin$Type$).hashCode;
631637

632638
@core$_.override
633639
bool operator ==(Object other) {
634-
return other.runtimeType == ($JniPlugin$Type) && other is $JniPlugin$Type;
640+
return other.runtimeType == ($JniPlugin$Type$) && other is $JniPlugin$Type$;
635641
}
636642
}

pkgs/jni/pubspec.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ topics:
1717

1818
environment:
1919
sdk: '>=3.3.0 <4.0.0'
20-
flutter: '>=2.11.0'
20+
flutter: '>=3.35.6'
2121

2222
dependencies:
2323
args: ^2.5.0
@@ -31,6 +31,8 @@ dev_dependencies:
3131
dart_flutter_team_lints: ^3.5.2
3232
ffigen:
3333
path: ../ffigen
34+
jnigen:
35+
path: ../jnigen
3436
logging: ^1.2.0
3537
test: ^1.25.8
3638

pkgs/jni/tool/generate_jni_bindings.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'dart:io';
6+
57
import 'package:jnigen/jnigen.dart';
68

79
void main() {
@@ -13,7 +15,8 @@ void main() {
1315
),
1416
outputConfig: OutputConfig(
1517
dartConfig: DartCodeOutputConfig(
16-
path: Uri.file('lib/src/plugin/generated_plugin.dart'),
18+
path: Platform.script
19+
.resolve('../lib/src/plugin/generated_plugin.dart'),
1720
structure: OutputStructure.singleFile,
1821
),
1922
),

0 commit comments

Comments
 (0)