mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 12:04:50 +08:00
19
lib/utils/android/android_helper.dart
Normal file
19
lib/utils/android/android_helper.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:PiliPlus/utils/android/bindings.g.dart';
|
||||
import 'package:jni/jni.dart';
|
||||
|
||||
abstract final class PiliAndroidHelper {
|
||||
static void createShortcut(String id, String uri, String label, String path) {
|
||||
final jId = id.toJString();
|
||||
final jUri = uri.toJString();
|
||||
final jLabel = label.toJString();
|
||||
final jPath = path.toJString();
|
||||
try {
|
||||
AndroidHelper.createShortcut(jId, jUri, jLabel, jPath);
|
||||
} finally {
|
||||
jId.release();
|
||||
jUri.release();
|
||||
jLabel.release();
|
||||
jPath.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
342
lib/utils/android/bindings.g.dart
Normal file
342
lib/utils/android/bindings.g.dart
Normal file
@@ -0,0 +1,342 @@
|
||||
// AUTO GENERATED BY JNIGEN 0.17.0. DO NOT EDIT!
|
||||
|
||||
// ignore_for_file: annotate_overrides
|
||||
// ignore_for_file: argument_type_not_assignable
|
||||
// ignore_for_file: camel_case_extensions
|
||||
// ignore_for_file: camel_case_types
|
||||
// ignore_for_file: constant_identifier_names
|
||||
// ignore_for_file: comment_references
|
||||
// ignore_for_file: doc_directive_unknown
|
||||
// ignore_for_file: file_names
|
||||
// ignore_for_file: inference_failure_on_untyped_parameter
|
||||
// ignore_for_file: invalid_internal_annotation
|
||||
// ignore_for_file: invalid_use_of_internal_member
|
||||
// ignore_for_file: library_prefixes
|
||||
// ignore_for_file: lines_longer_than_80_chars
|
||||
// ignore_for_file: no_leading_underscores_for_library_prefixes
|
||||
// ignore_for_file: no_leading_underscores_for_local_identifiers
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
// ignore_for_file: only_throw_errors
|
||||
// ignore_for_file: overridden_fields
|
||||
// ignore_for_file: prefer_double_quotes
|
||||
// ignore_for_file: unintended_html_in_doc_comment
|
||||
// ignore_for_file: unnecessary_cast
|
||||
// ignore_for_file: unnecessary_non_null_assertion
|
||||
// ignore_for_file: unnecessary_parenthesis
|
||||
// ignore_for_file: unused_element
|
||||
// ignore_for_file: unused_field
|
||||
// ignore_for_file: unused_import
|
||||
// ignore_for_file: unused_local_variable
|
||||
// ignore_for_file: unused_shown_name
|
||||
// ignore_for_file: use_super_parameters
|
||||
|
||||
import 'dart:core' as core$_;
|
||||
import 'dart:core' show Object, String;
|
||||
|
||||
import 'package:jni/_internal.dart' as jni$_;
|
||||
import 'package:jni/jni.dart' as jni$_;
|
||||
|
||||
const _$jniVersionCheck = jni$_.JniVersionCheck(1, 0);
|
||||
|
||||
/// from: `java.lang.Runnable`
|
||||
extension type Runnable._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
static final _class = jni$_.JClass.forName(r'java/lang/Runnable');
|
||||
|
||||
/// The type which includes information such as the signature of this class.
|
||||
static const jni$_.JType<Runnable> type = $Runnable$Type$();
|
||||
|
||||
/// Maps a specific port to the implemented interface.
|
||||
static final core$_.Map<core$_.int, $Runnable> _$impls = {};
|
||||
static jni$_.JObjectPtr _$invoke(
|
||||
core$_.int port,
|
||||
jni$_.JObjectPtr descriptor,
|
||||
jni$_.JObjectPtr args,
|
||||
) {
|
||||
return _$invokeMethod(
|
||||
port,
|
||||
jni$_.MethodInvocation.fromAddresses(
|
||||
0,
|
||||
descriptor.address,
|
||||
args.address,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static final jni$_.Pointer<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JObjectPtr Function(jni$_.Int64, jni$_.JObjectPtr, jni$_.JObjectPtr)
|
||||
>
|
||||
>
|
||||
_$invokePointer = jni$_.Pointer.fromFunction(_$invoke);
|
||||
|
||||
static jni$_.Pointer<jni$_.Void> _$invokeMethod(
|
||||
core$_.int $p,
|
||||
jni$_.MethodInvocation $i,
|
||||
) {
|
||||
try {
|
||||
final $d = $i.methodDescriptor.toDartString(releaseOriginal: true);
|
||||
final $a = $i.args;
|
||||
if ($d == r'run()V') {
|
||||
_$impls[$p]!.run();
|
||||
return jni$_.nullptr;
|
||||
}
|
||||
} catch (e) {
|
||||
return jni$_.ProtectedJniExtensions.newDartException(e);
|
||||
}
|
||||
return jni$_.nullptr;
|
||||
}
|
||||
|
||||
static void implementIn(
|
||||
jni$_.JImplementer implementer,
|
||||
$Runnable $impl,
|
||||
) {
|
||||
late final jni$_.RawReceivePort $p;
|
||||
$p = jni$_.RawReceivePort(($m) {
|
||||
if ($m == null) {
|
||||
_$impls.remove($p.sendPort.nativePort);
|
||||
$p.close();
|
||||
return;
|
||||
}
|
||||
final $i = jni$_.MethodInvocation.fromMessage($m);
|
||||
final $r = _$invokeMethod($p.sendPort.nativePort, $i);
|
||||
jni$_.ProtectedJniExtensions.returnResult($i.result, $r);
|
||||
});
|
||||
implementer.add(
|
||||
r'java.lang.Runnable',
|
||||
$p,
|
||||
_$invokePointer,
|
||||
[
|
||||
if ($impl.run$async) r'run()V',
|
||||
],
|
||||
);
|
||||
final $a = $p.sendPort.nativePort;
|
||||
_$impls[$a] = $impl;
|
||||
}
|
||||
|
||||
factory Runnable.implement(
|
||||
$Runnable $impl,
|
||||
) {
|
||||
final $i = jni$_.JImplementer();
|
||||
implementIn($i, $impl);
|
||||
return $i.implement<Runnable>();
|
||||
}
|
||||
}
|
||||
|
||||
extension Runnable$$Methods on Runnable {
|
||||
static final _id_run = Runnable._class.instanceMethodId(
|
||||
r'run',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _run =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `public abstract void run()`
|
||||
void run() {
|
||||
final _$$selfRef = reference;
|
||||
_run(_$$selfRef.pointer, _id_run.pointer).check();
|
||||
}
|
||||
}
|
||||
|
||||
abstract base mixin class $Runnable {
|
||||
factory $Runnable({
|
||||
required void Function() run,
|
||||
core$_.bool run$async,
|
||||
}) = _$Runnable;
|
||||
|
||||
void run();
|
||||
core$_.bool get run$async => false;
|
||||
}
|
||||
|
||||
final class _$Runnable with $Runnable {
|
||||
_$Runnable({
|
||||
required void Function() run,
|
||||
this.run$async = false,
|
||||
}) : _run = run;
|
||||
|
||||
final void Function() _run;
|
||||
final core$_.bool run$async;
|
||||
|
||||
void run() {
|
||||
return _run();
|
||||
}
|
||||
}
|
||||
|
||||
final class $Runnable$Type$ extends jni$_.JType<Runnable> {
|
||||
@jni$_.internal
|
||||
const $Runnable$Type$();
|
||||
|
||||
@jni$_.internal
|
||||
@core$_.override
|
||||
String get signature => r'Ljava/lang/Runnable;';
|
||||
}
|
||||
|
||||
/// from: `com.example.piliplus.AndroidHelper`
|
||||
extension type AndroidHelper._(jni$_.JObject _$this) implements jni$_.JObject {
|
||||
static final _class = jni$_.JClass.forName(
|
||||
r'com/example/piliplus/AndroidHelper',
|
||||
);
|
||||
|
||||
/// The type which includes information such as the signature of this class.
|
||||
static const jni$_.JType<AndroidHelper> type = $AndroidHelper$Type$();
|
||||
static final _id_back = _class.staticMethodId(
|
||||
r'back',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _back =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void back()`
|
||||
static void back() {
|
||||
final _$$classRef = _class.reference;
|
||||
_back(_$$classRef.pointer, _id_back.pointer).check();
|
||||
}
|
||||
|
||||
static final _id_sdkInt = _class.staticMethodId(
|
||||
r'sdkInt',
|
||||
r'()I',
|
||||
);
|
||||
|
||||
static final _sdkInt =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticIntMethod')
|
||||
.asFunction<
|
||||
jni$_.JniResult Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public int sdkInt()`
|
||||
static core$_.int sdkInt() {
|
||||
final _$$classRef = _class.reference;
|
||||
return _sdkInt(_$$classRef.pointer, _id_sdkInt.pointer).integer;
|
||||
}
|
||||
|
||||
static final _id_openLinkVerifySettings = _class.staticMethodId(
|
||||
r'openLinkVerifySettings',
|
||||
r'()V',
|
||||
);
|
||||
|
||||
static final _openLinkVerifySettings =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void openLinkVerifySettings()`
|
||||
static void openLinkVerifySettings() {
|
||||
final _$$classRef = _class.reference;
|
||||
_openLinkVerifySettings(
|
||||
_$$classRef.pointer,
|
||||
_id_openLinkVerifySettings.pointer,
|
||||
).check();
|
||||
}
|
||||
|
||||
static final _id_createShortcut = _class.staticMethodId(
|
||||
r'createShortcut',
|
||||
r'(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V',
|
||||
);
|
||||
|
||||
static final _createShortcut =
|
||||
jni$_.ProtectedJniExtensions.lookup<
|
||||
jni$_.NativeFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.VarArgs<
|
||||
(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>,
|
||||
)
|
||||
>
|
||||
>('globalEnv_CallStaticVoidMethod')
|
||||
.asFunction<
|
||||
jni$_.JThrowablePtr Function(
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.JMethodIDPtr,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
jni$_.Pointer<jni$_.Void>,
|
||||
)
|
||||
>();
|
||||
|
||||
/// from: `static public void createShortcut(java.lang.String id, java.lang.String uri, java.lang.String label, java.lang.String icon)`
|
||||
static void createShortcut(
|
||||
jni$_.JString id,
|
||||
jni$_.JString uri,
|
||||
jni$_.JString label,
|
||||
jni$_.JString icon,
|
||||
) {
|
||||
final _$$classRef = _class.reference;
|
||||
final _$id = id.reference;
|
||||
final _$uri = uri.reference;
|
||||
final _$label = label.reference;
|
||||
final _$icon = icon.reference;
|
||||
_createShortcut(
|
||||
_$$classRef.pointer,
|
||||
_id_createShortcut.pointer,
|
||||
_$id.pointer,
|
||||
_$uri.pointer,
|
||||
_$label.pointer,
|
||||
_$icon.pointer,
|
||||
).check();
|
||||
}
|
||||
}
|
||||
|
||||
final class $AndroidHelper$Type$ extends jni$_.JType<AndroidHelper> {
|
||||
@jni$_.internal
|
||||
const $AndroidHelper$Type$();
|
||||
|
||||
@jni$_.internal
|
||||
@core$_.override
|
||||
String get signature => r'Lcom/example/piliplus/AndroidHelper;';
|
||||
}
|
||||
Reference in New Issue
Block a user