333 lines
11 KiB
Dart
333 lines
11 KiB
Dart
// Autogenerated from Pigeon (v26.3.2), do not edit directly.
|
|
// See also: https://pub.dev/packages/pigeon
|
|
// ignore_for_file: unused_import, unused_shown_name
|
|
// ignore_for_file: type=lint
|
|
|
|
import 'dart:async';
|
|
import 'dart:typed_data' show Float64List, Int32List, Int64List;
|
|
|
|
import 'package:flutter/services.dart';
|
|
import 'package:meta/meta.dart' show immutable, protected, visibleForTesting;
|
|
|
|
Object? _extractReplyValueOrThrow(
|
|
List<Object?>? replyList,
|
|
String channelName, {
|
|
required bool isNullValid,
|
|
}) {
|
|
if (replyList == null) {
|
|
throw PlatformException(
|
|
code: 'channel-error',
|
|
message: 'Unable to establish connection on channel: "$channelName".',
|
|
);
|
|
} else if (replyList.length > 1) {
|
|
throw PlatformException(
|
|
code: replyList[0]! as String,
|
|
message: replyList[1] as String?,
|
|
details: replyList[2],
|
|
);
|
|
} else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) {
|
|
throw PlatformException(
|
|
code: 'null-error',
|
|
message: 'Host platform returned null value for non-null return value.',
|
|
);
|
|
}
|
|
return replyList.firstOrNull;
|
|
}
|
|
|
|
|
|
List<Object?> wrapResponse({Object? result, PlatformException? error, bool empty = false}) {
|
|
if (empty) {
|
|
return <Object?>[];
|
|
}
|
|
if (error == null) {
|
|
return <Object?>[result];
|
|
}
|
|
return <Object?>[error.code, error.message, error.details];
|
|
}
|
|
bool _deepEquals(Object? a, Object? b) {
|
|
if (identical(a, b)) {
|
|
return true;
|
|
}
|
|
if (a is double && b is double) {
|
|
if (a.isNaN && b.isNaN) {
|
|
return true;
|
|
}
|
|
return a == b;
|
|
}
|
|
if (a is List && b is List) {
|
|
return a.length == b.length &&
|
|
a.indexed
|
|
.every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]));
|
|
}
|
|
if (a is Map && b is Map) {
|
|
if (a.length != b.length) {
|
|
return false;
|
|
}
|
|
for (final MapEntry<Object?, Object?> entryA in a.entries) {
|
|
bool found = false;
|
|
for (final MapEntry<Object?, Object?> entryB in b.entries) {
|
|
if (_deepEquals(entryA.key, entryB.key)) {
|
|
if (_deepEquals(entryA.value, entryB.value)) {
|
|
found = true;
|
|
break;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
if (!found) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
return a == b;
|
|
}
|
|
|
|
int _deepHash(Object? value) {
|
|
if (value is List) {
|
|
return Object.hashAll(value.map(_deepHash));
|
|
}
|
|
if (value is Map) {
|
|
int result = 0;
|
|
for (final MapEntry<Object?, Object?> entry in value.entries) {
|
|
result += (_deepHash(entry.key) * 31) ^ _deepHash(entry.value);
|
|
}
|
|
return result;
|
|
}
|
|
if (value is double && value.isNaN) {
|
|
// Normalize NaN to a consistent hash.
|
|
return 0x7FF8000000000000.hashCode;
|
|
}
|
|
if (value is double && value == 0.0) {
|
|
// Normalize -0.0 to 0.0 so they have the same hash code.
|
|
return 0.0.hashCode;
|
|
}
|
|
return value.hashCode;
|
|
}
|
|
|
|
|
|
class Intent {
|
|
Intent({
|
|
this.fromPackageName,
|
|
this.action,
|
|
this.data,
|
|
required this.categories,
|
|
this.mimeType,
|
|
required this.extra,
|
|
});
|
|
|
|
String? fromPackageName;
|
|
|
|
String? action;
|
|
|
|
String? data;
|
|
|
|
List<String> categories;
|
|
|
|
String? mimeType;
|
|
|
|
Map<String, Object?> extra;
|
|
|
|
List<Object?> _toList() {
|
|
return <Object?>[
|
|
fromPackageName,
|
|
action,
|
|
data,
|
|
categories,
|
|
mimeType,
|
|
extra,
|
|
];
|
|
}
|
|
|
|
Object encode() {
|
|
return _toList(); }
|
|
|
|
static Intent decode(Object result) {
|
|
result as List<Object?>;
|
|
return Intent(
|
|
fromPackageName: result[0] as String?,
|
|
action: result[1] as String?,
|
|
data: result[2] as String?,
|
|
categories: (result[3]! as List<Object?>).cast<String>(),
|
|
mimeType: result[4] as String?,
|
|
extra: (result[5]! as Map<Object?, Object?>).cast<String, Object?>(),
|
|
);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
bool operator ==(Object other) {
|
|
if (other is! Intent || other.runtimeType != runtimeType) {
|
|
return false;
|
|
}
|
|
if (identical(this, other)) {
|
|
return true;
|
|
}
|
|
return _deepEquals(fromPackageName, other.fromPackageName) && _deepEquals(action, other.action) && _deepEquals(data, other.data) && _deepEquals(categories, other.categories) && _deepEquals(mimeType, other.mimeType) && _deepEquals(extra, other.extra);
|
|
}
|
|
|
|
@override
|
|
// ignore: avoid_equals_and_hash_code_on_mutable_classes
|
|
int get hashCode => _deepHash(<Object?>[runtimeType, ..._toList()]);
|
|
}
|
|
|
|
|
|
class _PigeonCodec extends StandardMessageCodec {
|
|
const _PigeonCodec();
|
|
@override
|
|
void writeValue(WriteBuffer buffer, Object? value) {
|
|
if (value is int) {
|
|
buffer.putUint8(4);
|
|
buffer.putInt64(value);
|
|
} else if (value is Intent) {
|
|
buffer.putUint8(129);
|
|
writeValue(buffer, value.encode());
|
|
} else {
|
|
super.writeValue(buffer, value);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Object? readValueOfType(int type, ReadBuffer buffer) {
|
|
switch (type) {
|
|
case 129:
|
|
return Intent.decode(readValue(buffer)!);
|
|
default:
|
|
return super.readValueOfType(type, buffer);
|
|
}
|
|
}
|
|
}
|
|
|
|
abstract class IntentEvents {
|
|
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
|
|
|
void onIntentReceived(int sequence, Intent intent);
|
|
|
|
static void setUp(IntentEvents? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) {
|
|
messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
|
{
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
'dev.flutter.pigeon.simple_intent_receiver.IntentEvents.onIntentReceived$messageChannelSuffix', pigeonChannelCodec,
|
|
binaryMessenger: binaryMessenger);
|
|
if (api == null) {
|
|
pigeonVar_channel.setMessageHandler(null);
|
|
} else {
|
|
pigeonVar_channel.setMessageHandler((Object? message) async {
|
|
final List<Object?> args = message! as List<Object?>;
|
|
final int arg_sequence = args[0]! as int;
|
|
final Intent arg_intent = args[1]! as Intent;
|
|
try {
|
|
api.onIntentReceived(arg_sequence, arg_intent);
|
|
return wrapResponse(empty: true);
|
|
} on PlatformException catch (e) {
|
|
return wrapResponse(error: e);
|
|
} catch (e) {
|
|
return wrapResponse(error: PlatformException(code: 'error', message: e.toString()));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class IntentGatekeeperHostApi {
|
|
/// Constructor for [IntentGatekeeperHostApi]. The [binaryMessenger] named argument is
|
|
/// available for dependency injection. If it is left null, the default
|
|
/// BinaryMessenger will be used which routes to the host platform.
|
|
IntentGatekeeperHostApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''})
|
|
: pigeonVar_binaryMessenger = binaryMessenger,
|
|
pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : '';
|
|
final BinaryMessenger? pigeonVar_binaryMessenger;
|
|
|
|
static const MessageCodec<Object?> pigeonChannelCodec = _PigeonCodec();
|
|
|
|
final String pigeonVar_messageChannelSuffix;
|
|
|
|
/// Replicates the blocked-packages policy to the native side so the
|
|
/// [IntentReceiverActivity] can reject intents without launching Flutter.
|
|
Future<void> setConfig(bool enabled, List<String> blockedPackages) async {
|
|
final pigeonVar_channelName = 'dev.flutter.pigeon.simple_intent_receiver.IntentGatekeeperHostApi.setConfig$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[enabled, blockedPackages]);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
)
|
|
;
|
|
}
|
|
|
|
/// Resolves a package name to its user-visible application label via
|
|
/// [PackageManager]. Returns `null` if the package is not installed or the
|
|
/// label cannot be resolved.
|
|
Future<String?> resolvePackageLabel(String packageName) async {
|
|
final pigeonVar_channelName = 'dev.flutter.pigeon.simple_intent_receiver.IntentGatekeeperHostApi.resolvePackageLabel$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[packageName]);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
)
|
|
;
|
|
return pigeonVar_replyValue as String?;
|
|
}
|
|
|
|
/// Returns the list of packages for which the user tapped "Always allow"
|
|
/// via a blocked-intent notification while WebLibre was not running.
|
|
/// Callers must acknowledge persisted packages via
|
|
/// [ackPendingAlwaysAllows] after Flutter settings were updated
|
|
/// successfully.
|
|
Future<List<String>> getPendingAlwaysAllows() async {
|
|
final pigeonVar_channelName = 'dev.flutter.pigeon.simple_intent_receiver.IntentGatekeeperHostApi.getPendingAlwaysAllows$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(null);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
final Object? pigeonVar_replyValue = _extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: false,
|
|
)
|
|
;
|
|
return (pigeonVar_replyValue! as List<Object?>).cast<String>();
|
|
}
|
|
|
|
/// Removes the given packages from the pending "Always allow" set after
|
|
/// Flutter has successfully persisted them into its own policy store.
|
|
Future<void> ackPendingAlwaysAllows(List<String> packageNames) async {
|
|
final pigeonVar_channelName = 'dev.flutter.pigeon.simple_intent_receiver.IntentGatekeeperHostApi.ackPendingAlwaysAllows$pigeonVar_messageChannelSuffix';
|
|
final pigeonVar_channel = BasicMessageChannel<Object?>(
|
|
pigeonVar_channelName,
|
|
pigeonChannelCodec,
|
|
binaryMessenger: pigeonVar_binaryMessenger,
|
|
);
|
|
final Future<Object?> pigeonVar_sendFuture = pigeonVar_channel.send(<Object?>[packageNames]);
|
|
final pigeonVar_replyList = await pigeonVar_sendFuture as List<Object?>?;
|
|
|
|
_extractReplyValueOrThrow(
|
|
pigeonVar_replyList,
|
|
pigeonVar_channelName,
|
|
isNullValid: true,
|
|
)
|
|
;
|
|
}
|
|
}
|