5package io.flutter.embedding.android;
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
9import java.io.UnsupportedEncodingException;
10import java.nio.ByteBuffer;
11import java.nio.ByteOrder;
23 private static final String TAG =
"KeyData";
30 public static final String
CHANNEL =
"flutter/keydata";
37 private static final int FIELD_COUNT = 6;
38 private static final int BYTES_PER_FIELD = 8;
57 switch ((
int)
value) {
65 throw new AssertionError(
"Unexpected Type value");
78 private final long value;
89 switch ((
int)
value) {
93 return kDirectionalPad;
101 throw new AssertionError(
"Unexpected DeviceType value");
115 final long charSize =
buffer.getLong();
116 this.timestamp =
buffer.getLong();
118 this.physicalKey =
buffer.getLong();
119 this.logicalKey =
buffer.getLong();
120 this.synthesized =
buffer.getLong() != 0;
123 if (
buffer.remaining() != charSize) {
124 throw new AssertionError(
126 "Unexpected char length: charSize is %d while buffer has position %d, capacity %d, limit %d",
129 this.character =
null;
131 final byte[] strBytes =
new byte[(
int) charSize];
132 buffer.get(strBytes, 0, (
int) charSize);
134 this.character =
new String(strBytes,
"UTF-8");
135 }
catch (UnsupportedEncodingException
e) {
136 throw new AssertionError(
"UTF-8 unsupported");
162 }
catch (UnsupportedEncodingException
e) {
163 throw new AssertionError(
"UTF-8 not supported");
165 final int charSize = charBytes ==
null ? 0 : charBytes.length;
166 final ByteBuffer packet =
167 ByteBuffer.allocateDirect((1 + FIELD_COUNT) * BYTES_PER_FIELD + charSize);
168 packet.order(ByteOrder.LITTLE_ENDIAN);
170 packet.putLong(charSize);
177 if (charBytes !=
null) {
178 packet.put(charBytes);
KeyData(@NonNull ByteBuffer buffer)
static final String CHANNEL
static DeviceType fromLong(long value)
static Type fromLong(long value)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer