{
+ private returnsDirectByteBufferFromDecoding: boolean = false;
+ static readonly INSTANCE_DIRECT = new BinaryCodec(true);
+
+ constructor(returnsDirectByteBufferFromDecoding: boolean) {
+ this.returnsDirectByteBufferFromDecoding = returnsDirectByteBufferFromDecoding;
+ }
+
+ encodeMessage(message: ArrayBuffer): ArrayBuffer {
+ return message
+ }
+
+ decodeMessage(message: ArrayBuffer): ArrayBuffer {
+ if (message == null) {
+ return message;
+ } else if (this.returnsDirectByteBufferFromDecoding) {
+ return message;
+ } else {
+ return message.slice(0, message.byteLength);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger.ets b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger.ets
new file mode 100644
index 0000000000000000000000000000000000000000..988c6a57092f7913f20b65bf6afa97b310385931
--- /dev/null
+++ b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger.ets
@@ -0,0 +1,158 @@
+/*
+* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * An abstraction over the threading policy used to invoke message handlers.
+ *
+ * These are generated by calling methods like {@link
+ * BinaryMessenger#makeBackgroundTaskQueue(TaskQueueOptions)} and can be passed into platform
+ * channels' constructors to control the threading policy for handling platform channels'
+ * messages.
+ */
+export interface TaskQueue {}
+
+/** Options that control how a TaskQueue should operate and be created. */
+export class TaskQueueOptions {
+ private isSerial = true;
+
+ getIsSerial() {
+ return this.isSerial;
+ }
+
+ setIsSerial(isSerial: boolean): TaskQueueOptions {
+ this.isSerial = isSerial;
+ return this;
+ }
+}
+
+/**
+ * Binary message reply callback. Used to submit a reply to an incoming message from Flutter. Also
+ * used in the dual capacity to handle a reply received from Flutter after sending a message.
+ */
+export interface BinaryReply {
+ /**
+ * Handles the specified reply.
+ *
+ * @param reply the reply payload, a direct-allocated {@link ByteBuffer} or null. Senders of
+ * outgoing replies must place the reply bytes between position zero and current position.
+ * Reply receivers can read from the buffer directly.
+ */
+ reply(reply: ArrayBuffer): void;
+}
+
+/** Handler for incoming binary messages from Flutter. */
+export interface BinaryMessageHandler {
+ /**
+ * Handles the specified message.
+ *
+ *
Handler implementations must reply to all incoming messages, by submitting a single reply
+ * message to the given {@link BinaryReply}. Failure to do so will result in lingering Flutter
+ * reply handlers. The reply may be submitted asynchronously.
+ *
+ *
Any uncaught exception thrown by this method will be caught by the messenger
+ * implementation and logged, and a null reply message will be sent back to Flutter.
+ *
+ * @param message the message {@link ByteBuffer} payload, possibly null.
+ * @param reply A {@link BinaryReply} used for submitting a reply back to Flutter.
+ */
+ onMessage(message: ArrayBuffer, reply: BinaryReply): void;
+}
+
+/**
+ * Facility for communicating with Flutter using asynchronous message passing with binary messages.
+ * The Flutter Dart code should use BinaryMessages to
+ * participate.
+ *
+ *
{@code BinaryMessenger} is expected to be utilized from a single thread throughout the
+ * duration of its existence. If created on the main thread, then all invocations should take place
+ * on the main thread. If created on a background thread, then all invocations should take place on
+ * that background thread.
+ *
+ * @see BasicMessageChannel , which supports message passing with Strings and semi-structured
+ * messages.
+ * @see MethodChannel , which supports communication using asynchronous method invocation.
+ * @see EventChannel , which supports communication using event streams.
+ */
+export interface BinaryMessenger {
+ makeBackgroundTaskQueue(options?: TaskQueueOptions): TaskQueue;
+
+ /**
+ * Sends a binary message to the Flutter application.
+ *
+ * @param channel the name {@link String} of the logical channel used for the message.
+ * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message
+ * bytes between position zero and current position, or null.
+ */
+ send(channel: String, message: ArrayBuffer): void;
+
+ /**
+ * Sends a binary message to the Flutter application, optionally expecting a reply.
+ *
+ *
Any uncaught exception thrown by the reply callback will be caught and logged.
+ *
+ * @param channel the name {@link String} of the logical channel used for the message.
+ * @param message the message payload, a direct-allocated {@link ByteBuffer} with the message
+ * bytes between position zero and current position, or null.
+ * @param callback a {@link BinaryReply} callback invoked when the Flutter application responds to
+ * the message, possibly null.
+ */
+ send(channel: String, message: ArrayBuffer, callback?: BinaryReply): void;
+
+ /**
+ * Registers a handler to be invoked when the Flutter application sends a message to its host
+ * platform.
+ *
+ *
Registration overwrites any previous registration for the same channel name. Use a null
+ * handler to deregister.
+ *
+ *
If no handler has been registered for a particular channel, any incoming message on that
+ * channel will be handled silently by sending a null reply.
+ *
+ * @param channel the name {@link String} of the channel.
+ * @param handler a {@link BinaryMessageHandler} to be invoked on incoming messages, or null.
+ * @param taskQueue a {@link BinaryMessenger.TaskQueue} that specifies what thread will execute
+ * the handler. Specifying null means execute on the platform thread.
+ */
+ //setMessageHandler(channel: String, handler: BinaryMessageHandler)
+ setMessageHandler(channel: String, handler: BinaryMessageHandler, taskQueue?: TaskQueue): void;
+ // {
+ // if (taskQueue != null) {
+ // throw new Error("setMessageHandler called with nonnull taskQueue is not supported.")
+ // }
+ // }
+
+ /**
+ * Enables the ability to queue messages received from Dart.
+ *
+ *
This is useful when there are pending channel handler registrations. For example, Dart may
+ * be initialized concurrently, and prior to the registration of the channel handlers. This
+ * implies that Dart may start sending messages while plugins are being registered.
+ */
+ enableBufferingIncomingMessages(): void;
+ // {
+ // throw new Error("enableBufferingIncomingMessages not implemented.");
+ // }
+
+ /**
+ * Disables the ability to queue messages received from Dart.
+ *
+ *
This can be used after all pending channel handlers have been registered.
+ */
+ disableBufferingIncomingMessages(): void;
+ // {
+ // throw new Error("disableBufferingIncomingMessages not implemented.");
+ // }
+}
diff --git a/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/EventChannel.ets b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/EventChannel.ets
new file mode 100644
index 0000000000000000000000000000000000000000..166659a32e819580f2d433886f763dc453d8a597
--- /dev/null
+++ b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/EventChannel.ets
@@ -0,0 +1,263 @@
+/*
+* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+/**
+ * A named channel for communicating with the Flutter application using asynchronous event streams.
+ *
+ *
Incoming requests for event stream setup are decoded from binary on receipt, and Java
+ * responses and events are encoded into binary before being transmitted back to Flutter. The {@link
+ * MethodCodec} used must be compatible with the one used by the Flutter application. This can be
+ * achieved by creating an EventChannel
+ * counterpart of this channel on the Dart side. The Java type of stream configuration arguments,
+ * events, and error details is {@code Object}, but only values supported by the specified {@link
+ * MethodCodec} can be used.
+ *
+ *
The logical identity of the channel is given by its name. Identically named channels will
+ * interfere with each other's communication.
+ */
+import Log from '../../util/Log';
+import { BinaryMessageHandler, BinaryMessenger, BinaryReply, TaskQueue } from './BinaryMessenger';
+import MethodCodec from './MethodCodec';
+import StandardMethodCodec from './StandardMethodCodec';
+
+const TAG = "EventChannel#";
+
+export default class EventChannel {
+ private messenger: BinaryMessenger;
+ private name: string;
+ private codec: MethodCodec;
+ private taskQueue: TaskQueue;
+
+ constructor(messenger: BinaryMessenger, name: string, codec?: MethodCodec, taskQueue?: TaskQueue) {
+ this.messenger = messenger
+ this.name = name
+ this.codec = codec ? codec : StandardMethodCodec.INSTANCE
+ this.taskQueue = taskQueue
+ }
+
+
+ /**
+ * Registers a stream handler on this channel.
+ *
+ *
Overrides any existing handler registration for (the name of) this channel.
+ *
+ *
If no handler has been registered, any incoming stream setup requests will be handled
+ * silently by providing an empty stream.
+ *
+ * @param handler a {@link StreamHandler}, or null to deregister.
+ */
+ setStreamHandler(handler: StreamHandler): void {
+ // We call the 2 parameter variant specifically to avoid breaking changes in
+ // mock verify calls.
+ // See https://github.com/flutter/flutter/issues/92582.
+ if (this.taskQueue != null) {
+ this.messenger.setMessageHandler(
+ this.name, handler == null ? null : new IncomingStreamRequestHandler(handler, this.name, this.codec, this.messenger), this.taskQueue);
+ } else {
+ this.messenger.setMessageHandler(
+ this.name, handler == null ? null : new IncomingStreamRequestHandler(handler, this.name, this.codec, this.messenger));
+ }
+ }
+}
+
+/**
+ * Handler of stream setup and teardown requests.
+ *
+ *
Implementations must be prepared to accept sequences of alternating calls to {@link
+ * #onListen(Object, EventChannel.EventSink)} and {@link #onCancel(Object)}. Implementations
+ * should ideally consume no resources when the last such call is not {@code onListen}. In typical
+ * situations, this means that the implementation should register itself with platform-specific
+ * event sources {@code onListen} and deregister again {@code onCancel}.
+ */
+export interface StreamHandler {
+ /**
+ * Handles a request to set up an event stream.
+ *
+ *
Any uncaught exception thrown by this method will be caught by the channel implementation
+ * and logged. An error result message will be sent back to Flutter.
+ *
+ * @param arguments stream configuration arguments, possibly null.
+ * @param events an {@link EventSink} for emitting events to the Flutter receiver.
+ */
+ onListen(args: ESObject, events: EventSink): void;
+
+ /**
+ * Handles a request to tear down the most recently created event stream.
+ *
+ *
Any uncaught exception thrown by this method will be caught by the channel implementation
+ * and logged. An error result message will be sent back to Flutter.
+ *
+ *
The channel implementation may call this method with null arguments to separate a pair of
+ * two consecutive set up requests. Such request pairs may occur during Flutter hot restart. Any
+ * uncaught exception thrown in this situation will be logged without notifying Flutter.
+ *
+ * @param arguments stream configuration arguments, possibly null.
+ */
+ onCancel(args: ESObject): void;
+}
+
+/**
+ * Event callback. Supports dual use: Producers of events to be sent to Flutter act as clients of
+ * this interface for sending events. Consumers of events sent from Flutter implement this
+ * interface for handling received events (the latter facility has not been implemented yet).
+ */
+export interface EventSink {
+ /**
+ * Consumes a successful event.
+ *
+ * @param event the event, possibly null.
+ */
+ success(event: ESObject): void;
+
+ /**
+ * Consumes an error event.
+ *
+ * @param errorCode an error code String.
+ * @param errorMessage a human-readable error message String, possibly null.
+ * @param errorDetails error details, possibly null
+ */
+ error(errorCode: string, errorMessage: string, errorDetails: ESObject): void;
+
+ /**
+ * Consumes end of stream. Ensuing calls to {@link #success(Object)} or {@link #error(String,
+ * String, Object)}, if any, are ignored.
+ */
+ endOfStream(): void;
+}
+
+class IncomingStreamRequestHandler implements BinaryMessageHandler {
+ private handler: StreamHandler;
+ private activeSink = new AtomicReference(null);
+ private codec: MethodCodec;
+ private name: string;
+ private messenger: BinaryMessenger;
+
+ constructor(handler: StreamHandler, name: string, codec: MethodCodec, messenger: BinaryMessenger) {
+ this.handler = handler;
+ this.codec = codec;
+ this.name = name;
+ this.messenger = messenger;
+ }
+
+ onMessage(message: ArrayBuffer, reply: BinaryReply): void {
+ const call = this.codec.decodeMethodCall(message);
+ if (call.method == "listen") {
+ this.onListen(call.args, reply);
+ } else if (call.method == "cancel") {
+ this.onCancel(call.args, reply);
+ } else {
+ reply.reply(null);
+ }
+ }
+
+ onListen(args: ESObject, callback: BinaryReply): void {
+ const eventSink = new EventSinkImplementation(this.activeSink, this.name, this.codec, this.messenger);
+ const oldSink = this.activeSink.getAndSet(eventSink);
+ if (oldSink != null) {
+ // Repeated calls to onListen may happen during hot restart.
+ // We separate them with a call to onCancel.
+ try {
+ this.handler.onCancel(null);
+ } catch (e) {
+ Log.e(TAG + this.name, "Failed to close existing event stream", e);
+ }
+ }
+ try {
+ this.handler.onListen(args, eventSink);
+ callback.reply(this.codec.encodeSuccessEnvelope(null));
+ } catch (e) {
+ this.activeSink.set(null);
+ Log.e(TAG + this.name, "Failed to open event stream", e);
+ callback.reply(this.codec.encodeErrorEnvelope("error", e.getMessage(), null));
+ }
+ }
+
+ onCancel(args: ESObject, callback: BinaryReply): void {
+ const oldSink = this.activeSink.getAndSet(null);
+ if (oldSink != null) {
+ try {
+ this.handler.onCancel(args);
+ callback.reply(this.codec.encodeSuccessEnvelope(null));
+ } catch (e) {
+ Log.e(TAG + this.name, "Failed to close event stream", e);
+ callback.reply(this.codec.encodeErrorEnvelope("error", e.getMessage(), null));
+ }
+ } else {
+ callback.reply(this.codec.encodeErrorEnvelope("error", "No active stream to cancel", null));
+ }
+ }
+}
+
+class EventSinkImplementation implements EventSink {
+ private hasEnded = false;
+ private activeSink: AtomicReference;
+ private messenger: BinaryMessenger;
+ private codec: MethodCodec;
+ private name: string;
+
+ constructor(activeSink: AtomicReference, name: string, codec: MethodCodec, messenger: BinaryMessenger) {
+ this.activeSink = activeSink;
+ this.codec = codec;
+ this.name = name;
+ this.messenger = messenger;
+ }
+
+ success(event: ESObject): void {
+ if (this.hasEnded || this.activeSink.get() != this) {
+ return;
+ }
+ this.messenger.send(this.name, this.codec.encodeSuccessEnvelope(event));
+ }
+
+ error(errorCode: string, errorMessage: string, errorDetails: ESObject) {
+ if (this.hasEnded || this.activeSink.get() != this) {
+ return;
+ }
+ this.messenger.send(
+ this.name, this.codec.encodeErrorEnvelope(errorCode, errorMessage, errorDetails));
+ }
+
+ endOfStream(): void {
+ if (this.hasEnded || this.activeSink.get() != this) {
+ return;
+ }
+ this.hasEnded = true;
+ this.messenger.send(this.name, null);
+ }
+}
+
+class AtomicReference {
+ private value: T;
+
+ constructor(value: T) {
+ this.value = value
+ }
+
+ get(): T {
+ return this.value;
+ }
+
+ set(newValue: T): void {
+ this.value = newValue;
+ }
+
+ getAndSet(newValue: T) {
+ const oldValue = this.value;
+ this.value = newValue;
+ return oldValue;
+ }
+}
\ No newline at end of file
diff --git a/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/FlutterException.ets b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/FlutterException.ets
new file mode 100644
index 0000000000000000000000000000000000000000..03af6b520acc908d9cb63914ca2236736218aa77
--- /dev/null
+++ b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/FlutterException.ets
@@ -0,0 +1,28 @@
+/*
+* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+export default class FlutterException implements Error {
+ stack?: string;
+ message: string;
+ name: string;
+ code: string;
+ details: ESObject
+
+ constructor(code: string, message: string, details: ESObject) {
+ this.message = message;
+ this.code = code;
+ this.details =details;
+ }
+}
\ No newline at end of file
diff --git a/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/JSONMessageCodec.ets b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/JSONMessageCodec.ets
new file mode 100644
index 0000000000000000000000000000000000000000..4c289c6054e952a5cf7ed48b58fcfab6e343533b
--- /dev/null
+++ b/ohos/test_cached_network_image/lib/path_provider_ohos/ohos/path_provider/oh_modules/.ohpm/@ohos+flutter_ohos@file+libs+flutter_ohos.har/oh_modules/@ohos/flutter_ohos/src/main/ets/plugin/common/JSONMessageCodec.ets
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd.
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import MessageCodec from './MessageCodec';
+import MethodCodec from './MethodCodec';
+import StringCodec from './StringCodec';
+
+/**
+ * A {@link MethodCodec} using UTF-8 encoded JSON method calls and result envelopes.
+ *
+ *