ADD week 5
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.LinkedBlockingDeque;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ConcurrencyHelpers {
|
||||
private static final int FONT_LOAD_TIMEOUT_SECONDS = 15;
|
||||
|
||||
private ConcurrencyHelpers() {
|
||||
}
|
||||
|
||||
static ThreadPoolExecutor createBackgroundPriorityExecutor(final String str) {
|
||||
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, 15L, TimeUnit.SECONDS, new LinkedBlockingDeque(), new ThreadFactory() { // from class: androidx.emoji2.text.ConcurrencyHelpers$$ExternalSyntheticLambda0
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public final Thread newThread(Runnable runnable) {
|
||||
return ConcurrencyHelpers.lambda$createBackgroundPriorityExecutor$0(str, runnable);
|
||||
}
|
||||
});
|
||||
threadPoolExecutor.allowCoreThreadTimeOut(true);
|
||||
return threadPoolExecutor;
|
||||
}
|
||||
|
||||
static /* synthetic */ Thread lambda$createBackgroundPriorityExecutor$0(String str, Runnable runnable) {
|
||||
Thread thread = new Thread(runnable, str);
|
||||
thread.setPriority(10);
|
||||
return thread;
|
||||
}
|
||||
|
||||
static Handler mainHandlerAsync() {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return Handler28Impl.createAsync(Looper.getMainLooper());
|
||||
}
|
||||
return new Handler(Looper.getMainLooper());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static Executor convertHandlerToExecutor(final Handler handler) {
|
||||
Objects.requireNonNull(handler);
|
||||
return new Executor() { // from class: androidx.emoji2.text.ConcurrencyHelpers$$ExternalSyntheticLambda1
|
||||
@Override // java.util.concurrent.Executor
|
||||
public final void execute(Runnable runnable) {
|
||||
handler.post(runnable);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
static class Handler28Impl {
|
||||
private Handler28Impl() {
|
||||
}
|
||||
|
||||
public static Handler createAsync(Looper looper) {
|
||||
Handler createAsync;
|
||||
createAsync = Handler.createAsync(looper);
|
||||
return createAsync;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.pm.Signature;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import androidx.core.provider.FontRequest;
|
||||
import androidx.core.util.Preconditions;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DefaultEmojiCompatConfig {
|
||||
private DefaultEmojiCompatConfig() {
|
||||
}
|
||||
|
||||
public static FontRequestEmojiCompatConfig create(Context context) {
|
||||
return (FontRequestEmojiCompatConfig) new DefaultEmojiCompatConfigFactory(null).create(context);
|
||||
}
|
||||
|
||||
public static class DefaultEmojiCompatConfigFactory {
|
||||
private static final String DEFAULT_EMOJI_QUERY = "emojicompat-emoji-font";
|
||||
private static final String INTENT_LOAD_EMOJI_FONT = "androidx.content.action.LOAD_EMOJI_FONT";
|
||||
private static final String TAG = "emoji2.text.DefaultEmojiConfig";
|
||||
private final DefaultEmojiCompatConfigHelper mHelper;
|
||||
|
||||
public DefaultEmojiCompatConfigFactory(DefaultEmojiCompatConfigHelper defaultEmojiCompatConfigHelper) {
|
||||
this.mHelper = defaultEmojiCompatConfigHelper == null ? getHelperForApi() : defaultEmojiCompatConfigHelper;
|
||||
}
|
||||
|
||||
public EmojiCompat.Config create(Context context) {
|
||||
return configOrNull(context, queryForDefaultFontRequest(context));
|
||||
}
|
||||
|
||||
private EmojiCompat.Config configOrNull(Context context, FontRequest fontRequest) {
|
||||
if (fontRequest == null) {
|
||||
return null;
|
||||
}
|
||||
return new FontRequestEmojiCompatConfig(context, fontRequest);
|
||||
}
|
||||
|
||||
FontRequest queryForDefaultFontRequest(Context context) {
|
||||
PackageManager packageManager = context.getPackageManager();
|
||||
Preconditions.checkNotNull(packageManager, "Package manager required to locate emoji font provider");
|
||||
ProviderInfo queryDefaultInstalledContentProvider = queryDefaultInstalledContentProvider(packageManager);
|
||||
if (queryDefaultInstalledContentProvider == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return generateFontRequestFrom(queryDefaultInstalledContentProvider, packageManager);
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.wtf(TAG, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ProviderInfo queryDefaultInstalledContentProvider(PackageManager packageManager) {
|
||||
Iterator<ResolveInfo> it = this.mHelper.queryIntentContentProviders(packageManager, new Intent(INTENT_LOAD_EMOJI_FONT), 0).iterator();
|
||||
while (it.hasNext()) {
|
||||
ProviderInfo providerInfo = this.mHelper.getProviderInfo(it.next());
|
||||
if (hasFlagSystem(providerInfo)) {
|
||||
return providerInfo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasFlagSystem(ProviderInfo providerInfo) {
|
||||
return (providerInfo == null || providerInfo.applicationInfo == null || (providerInfo.applicationInfo.flags & 1) != 1) ? false : true;
|
||||
}
|
||||
|
||||
private FontRequest generateFontRequestFrom(ProviderInfo providerInfo, PackageManager packageManager) throws PackageManager.NameNotFoundException {
|
||||
String str = providerInfo.authority;
|
||||
String str2 = providerInfo.packageName;
|
||||
return new FontRequest(str, str2, DEFAULT_EMOJI_QUERY, convertToByteArray(this.mHelper.getSigningSignatures(packageManager, str2)));
|
||||
}
|
||||
|
||||
private List<List<byte[]>> convertToByteArray(Signature[] signatureArr) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
for (Signature signature : signatureArr) {
|
||||
arrayList.add(signature.toByteArray());
|
||||
}
|
||||
return Collections.singletonList(arrayList);
|
||||
}
|
||||
|
||||
private static DefaultEmojiCompatConfigHelper getHelperForApi() {
|
||||
if (Build.VERSION.SDK_INT >= 28) {
|
||||
return new DefaultEmojiCompatConfigHelper_API28();
|
||||
}
|
||||
return new DefaultEmojiCompatConfigHelper_API19();
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultEmojiCompatConfigHelper {
|
||||
public Signature[] getSigningSignatures(PackageManager packageManager, String str) throws PackageManager.NameNotFoundException {
|
||||
return packageManager.getPackageInfo(str, 64).signatures;
|
||||
}
|
||||
|
||||
public List<ResolveInfo> queryIntentContentProviders(PackageManager packageManager, Intent intent, int i) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public ProviderInfo getProviderInfo(ResolveInfo resolveInfo) {
|
||||
throw new IllegalStateException("Unable to get provider info prior to API 19");
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultEmojiCompatConfigHelper_API19 extends DefaultEmojiCompatConfigHelper {
|
||||
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
|
||||
public List<ResolveInfo> queryIntentContentProviders(PackageManager packageManager, Intent intent, int i) {
|
||||
return packageManager.queryIntentContentProviders(intent, i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
|
||||
public ProviderInfo getProviderInfo(ResolveInfo resolveInfo) {
|
||||
return resolveInfo.providerInfo;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DefaultEmojiCompatConfigHelper_API28 extends DefaultEmojiCompatConfigHelper_API19 {
|
||||
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
|
||||
public Signature[] getSigningSignatures(PackageManager packageManager, String str) throws PackageManager.NameNotFoundException {
|
||||
return packageManager.getPackageInfo(str, 64).signatures;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.TextPaint;
|
||||
import androidx.core.graphics.PaintCompat;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class DefaultGlyphChecker implements EmojiCompat.GlyphChecker {
|
||||
private static final int PAINT_TEXT_SIZE = 10;
|
||||
private static final ThreadLocal<StringBuilder> sStringBuilder = new ThreadLocal<>();
|
||||
private final TextPaint mTextPaint;
|
||||
|
||||
DefaultGlyphChecker() {
|
||||
TextPaint textPaint = new TextPaint();
|
||||
this.mTextPaint = textPaint;
|
||||
textPaint.setTextSize(10.0f);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.GlyphChecker
|
||||
public boolean hasGlyph(CharSequence charSequence, int i, int i2, int i3) {
|
||||
if (Build.VERSION.SDK_INT < 23 && i3 > Build.VERSION.SDK_INT) {
|
||||
return false;
|
||||
}
|
||||
StringBuilder stringBuilder = getStringBuilder();
|
||||
stringBuilder.setLength(0);
|
||||
while (i < i2) {
|
||||
stringBuilder.append(charSequence.charAt(i));
|
||||
i++;
|
||||
}
|
||||
return PaintCompat.hasGlyph(this.mTextPaint, stringBuilder.toString());
|
||||
}
|
||||
|
||||
private static StringBuilder getStringBuilder() {
|
||||
ThreadLocal<StringBuilder> threadLocal = sStringBuilder;
|
||||
if (threadLocal.get() == null) {
|
||||
threadLocal.set(new StringBuilder());
|
||||
}
|
||||
return threadLocal.get();
|
||||
}
|
||||
}
|
606
02-Easy5/E5/sources/androidx/emoji2/text/EmojiCompat.java
Normal file
606
02-Easy5/E5/sources/androidx/emoji2/text/EmojiCompat.java
Normal file
@ -0,0 +1,606 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Editable;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import androidx.collection.ArraySet;
|
||||
import androidx.core.util.Preconditions;
|
||||
import androidx.emoji2.text.DefaultEmojiCompatConfig;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class EmojiCompat {
|
||||
public static final String EDITOR_INFO_METAVERSION_KEY = "android.support.text.emoji.emojiCompat_metadataVersion";
|
||||
public static final String EDITOR_INFO_REPLACE_ALL_KEY = "android.support.text.emoji.emojiCompat_replaceAll";
|
||||
static final int EMOJI_COUNT_UNLIMITED = Integer.MAX_VALUE;
|
||||
public static final int EMOJI_FALLBACK = 2;
|
||||
public static final int EMOJI_SUPPORTED = 1;
|
||||
public static final int EMOJI_UNSUPPORTED = 0;
|
||||
public static final int LOAD_STATE_DEFAULT = 3;
|
||||
public static final int LOAD_STATE_FAILED = 2;
|
||||
public static final int LOAD_STATE_LOADING = 0;
|
||||
public static final int LOAD_STATE_SUCCEEDED = 1;
|
||||
public static final int LOAD_STRATEGY_DEFAULT = 0;
|
||||
public static final int LOAD_STRATEGY_MANUAL = 1;
|
||||
private static final String NOT_INITIALIZED_ERROR_TEXT = "EmojiCompat is not initialized.\n\nYou must initialize EmojiCompat prior to referencing the EmojiCompat instance.\n\nThe most likely cause of this error is disabling the EmojiCompatInitializer\neither explicitly in AndroidManifest.xml, or by including\nandroidx.emoji2:emoji2-bundled.\n\nAutomatic initialization is typically performed by EmojiCompatInitializer. If\nyou are not expecting to initialize EmojiCompat manually in your application,\nplease check to ensure it has not been removed from your APK's manifest. You can\ndo this in Android Studio using Build > Analyze APK.\n\nIn the APK Analyzer, ensure that the startup entry for\nEmojiCompatInitializer and InitializationProvider is present in\n AndroidManifest.xml. If it is missing or contains tools:node=\"remove\", and you\nintend to use automatic configuration, verify:\n\n 1. Your application does not include emoji2-bundled\n 2. All modules do not contain an exclusion manifest rule for\n EmojiCompatInitializer or InitializationProvider. For more information\n about manifest exclusions see the documentation for the androidx startup\n library.\n\nIf you intend to use emoji2-bundled, please call EmojiCompat.init. You can\nlearn more in the documentation for BundledEmojiCompatConfig.\n\nIf you intended to perform manual configuration, it is recommended that you call\nEmojiCompat.init immediately on application startup.\n\nIf you still cannot resolve this issue, please open a bug with your specific\nconfiguration to help improve error message.";
|
||||
public static final int REPLACE_STRATEGY_ALL = 1;
|
||||
public static final int REPLACE_STRATEGY_DEFAULT = 0;
|
||||
public static final int REPLACE_STRATEGY_NON_EXISTENT = 2;
|
||||
private static volatile boolean sHasDoneDefaultConfigLookup;
|
||||
private static volatile EmojiCompat sInstance;
|
||||
final int[] mEmojiAsDefaultStyleExceptions;
|
||||
private final int mEmojiSpanIndicatorColor;
|
||||
private final boolean mEmojiSpanIndicatorEnabled;
|
||||
private final GlyphChecker mGlyphChecker;
|
||||
private final CompatInternal mHelper;
|
||||
private final Set<InitCallback> mInitCallbacks;
|
||||
private final ReadWriteLock mInitLock = new ReentrantReadWriteLock();
|
||||
private volatile int mLoadState = 3;
|
||||
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
|
||||
private final int mMetadataLoadStrategy;
|
||||
final MetadataRepoLoader mMetadataLoader;
|
||||
final boolean mReplaceAll;
|
||||
final boolean mUseEmojiAsDefaultStyle;
|
||||
private static final Object INSTANCE_LOCK = new Object();
|
||||
private static final Object CONFIG_LOCK = new Object();
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CodepointSequenceMatchResult {
|
||||
}
|
||||
|
||||
public interface GlyphChecker {
|
||||
boolean hasGlyph(CharSequence charSequence, int i, int i2, int i3);
|
||||
}
|
||||
|
||||
public static abstract class InitCallback {
|
||||
public void onFailed(Throwable th) {
|
||||
}
|
||||
|
||||
public void onInitialized() {
|
||||
}
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LoadStrategy {
|
||||
}
|
||||
|
||||
public interface MetadataRepoLoader {
|
||||
void load(MetadataRepoLoaderCallback metadataRepoLoaderCallback);
|
||||
}
|
||||
|
||||
public static abstract class MetadataRepoLoaderCallback {
|
||||
public abstract void onFailed(Throwable th);
|
||||
|
||||
public abstract void onLoaded(MetadataRepo metadataRepo);
|
||||
}
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ReplaceStrategy {
|
||||
}
|
||||
|
||||
public static boolean isConfigured() {
|
||||
return sInstance != null;
|
||||
}
|
||||
|
||||
public int getEmojiSpanIndicatorColor() {
|
||||
return this.mEmojiSpanIndicatorColor;
|
||||
}
|
||||
|
||||
public boolean isEmojiSpanIndicatorEnabled() {
|
||||
return this.mEmojiSpanIndicatorEnabled;
|
||||
}
|
||||
|
||||
private EmojiCompat(Config config) {
|
||||
this.mReplaceAll = config.mReplaceAll;
|
||||
this.mUseEmojiAsDefaultStyle = config.mUseEmojiAsDefaultStyle;
|
||||
this.mEmojiAsDefaultStyleExceptions = config.mEmojiAsDefaultStyleExceptions;
|
||||
this.mEmojiSpanIndicatorEnabled = config.mEmojiSpanIndicatorEnabled;
|
||||
this.mEmojiSpanIndicatorColor = config.mEmojiSpanIndicatorColor;
|
||||
this.mMetadataLoader = config.mMetadataLoader;
|
||||
this.mMetadataLoadStrategy = config.mMetadataLoadStrategy;
|
||||
this.mGlyphChecker = config.mGlyphChecker;
|
||||
ArraySet arraySet = new ArraySet();
|
||||
this.mInitCallbacks = arraySet;
|
||||
if (config.mInitCallbacks != null && !config.mInitCallbacks.isEmpty()) {
|
||||
arraySet.addAll(config.mInitCallbacks);
|
||||
}
|
||||
this.mHelper = new CompatInternal19(this);
|
||||
loadMetadata();
|
||||
}
|
||||
|
||||
public static EmojiCompat init(Context context) {
|
||||
return init(context, null);
|
||||
}
|
||||
|
||||
public static EmojiCompat init(Context context, DefaultEmojiCompatConfig.DefaultEmojiCompatConfigFactory defaultEmojiCompatConfigFactory) {
|
||||
EmojiCompat emojiCompat;
|
||||
if (sHasDoneDefaultConfigLookup) {
|
||||
return sInstance;
|
||||
}
|
||||
if (defaultEmojiCompatConfigFactory == null) {
|
||||
defaultEmojiCompatConfigFactory = new DefaultEmojiCompatConfig.DefaultEmojiCompatConfigFactory(null);
|
||||
}
|
||||
Config create = defaultEmojiCompatConfigFactory.create(context);
|
||||
synchronized (CONFIG_LOCK) {
|
||||
if (!sHasDoneDefaultConfigLookup) {
|
||||
if (create != null) {
|
||||
init(create);
|
||||
}
|
||||
sHasDoneDefaultConfigLookup = true;
|
||||
}
|
||||
emojiCompat = sInstance;
|
||||
}
|
||||
return emojiCompat;
|
||||
}
|
||||
|
||||
public static EmojiCompat init(Config config) {
|
||||
EmojiCompat emojiCompat = sInstance;
|
||||
if (emojiCompat == null) {
|
||||
synchronized (INSTANCE_LOCK) {
|
||||
emojiCompat = sInstance;
|
||||
if (emojiCompat == null) {
|
||||
emojiCompat = new EmojiCompat(config);
|
||||
sInstance = emojiCompat;
|
||||
}
|
||||
}
|
||||
}
|
||||
return emojiCompat;
|
||||
}
|
||||
|
||||
public static EmojiCompat reset(Config config) {
|
||||
EmojiCompat emojiCompat;
|
||||
synchronized (INSTANCE_LOCK) {
|
||||
emojiCompat = new EmojiCompat(config);
|
||||
sInstance = emojiCompat;
|
||||
}
|
||||
return emojiCompat;
|
||||
}
|
||||
|
||||
public static EmojiCompat reset(EmojiCompat emojiCompat) {
|
||||
EmojiCompat emojiCompat2;
|
||||
synchronized (INSTANCE_LOCK) {
|
||||
sInstance = emojiCompat;
|
||||
emojiCompat2 = sInstance;
|
||||
}
|
||||
return emojiCompat2;
|
||||
}
|
||||
|
||||
public static void skipDefaultConfigurationLookup(boolean z) {
|
||||
synchronized (CONFIG_LOCK) {
|
||||
sHasDoneDefaultConfigLookup = z;
|
||||
}
|
||||
}
|
||||
|
||||
public static EmojiCompat get() {
|
||||
EmojiCompat emojiCompat;
|
||||
synchronized (INSTANCE_LOCK) {
|
||||
emojiCompat = sInstance;
|
||||
Preconditions.checkState(emojiCompat != null, NOT_INITIALIZED_ERROR_TEXT);
|
||||
}
|
||||
return emojiCompat;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Preconditions.checkState(this.mMetadataLoadStrategy == 1, "Set metadataLoadStrategy to LOAD_STRATEGY_MANUAL to execute manual loading");
|
||||
if (isInitialized()) {
|
||||
return;
|
||||
}
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
if (this.mLoadState == 0) {
|
||||
return;
|
||||
}
|
||||
this.mLoadState = 0;
|
||||
this.mInitLock.writeLock().unlock();
|
||||
this.mHelper.loadMetadata();
|
||||
} finally {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMetadata() {
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
if (this.mMetadataLoadStrategy == 0) {
|
||||
this.mLoadState = 0;
|
||||
}
|
||||
this.mInitLock.writeLock().unlock();
|
||||
if (getLoadState() == 0) {
|
||||
this.mHelper.loadMetadata();
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
void onMetadataLoadSuccess() {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
this.mLoadState = 1;
|
||||
arrayList.addAll(this.mInitCallbacks);
|
||||
this.mInitCallbacks.clear();
|
||||
this.mInitLock.writeLock().unlock();
|
||||
this.mMainHandler.post(new ListenerDispatcher(arrayList, this.mLoadState));
|
||||
} catch (Throwable th) {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
void onMetadataLoadFailed(Throwable th) {
|
||||
ArrayList arrayList = new ArrayList();
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
this.mLoadState = 2;
|
||||
arrayList.addAll(this.mInitCallbacks);
|
||||
this.mInitCallbacks.clear();
|
||||
this.mInitLock.writeLock().unlock();
|
||||
this.mMainHandler.post(new ListenerDispatcher(arrayList, this.mLoadState, th));
|
||||
} catch (Throwable th2) {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
throw th2;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerInitCallback(InitCallback initCallback) {
|
||||
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
if (this.mLoadState != 1 && this.mLoadState != 2) {
|
||||
this.mInitCallbacks.add(initCallback);
|
||||
}
|
||||
this.mMainHandler.post(new ListenerDispatcher(initCallback, this.mLoadState));
|
||||
} finally {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterInitCallback(InitCallback initCallback) {
|
||||
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
|
||||
this.mInitLock.writeLock().lock();
|
||||
try {
|
||||
this.mInitCallbacks.remove(initCallback);
|
||||
} finally {
|
||||
this.mInitLock.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
public int getLoadState() {
|
||||
this.mInitLock.readLock().lock();
|
||||
try {
|
||||
return this.mLoadState;
|
||||
} finally {
|
||||
this.mInitLock.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isInitialized() {
|
||||
return getLoadState() == 1;
|
||||
}
|
||||
|
||||
public static boolean handleOnKeyDown(Editable editable, int i, KeyEvent keyEvent) {
|
||||
return EmojiProcessor.handleOnKeyDown(editable, i, keyEvent);
|
||||
}
|
||||
|
||||
public static boolean handleDeleteSurroundingText(InputConnection inputConnection, Editable editable, int i, int i2, boolean z) {
|
||||
return EmojiProcessor.handleDeleteSurroundingText(inputConnection, editable, i, i2, z);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasEmojiGlyph(CharSequence charSequence) {
|
||||
Preconditions.checkState(isInitialized(), "Not initialized yet");
|
||||
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
|
||||
return this.mHelper.hasEmojiGlyph(charSequence);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean hasEmojiGlyph(CharSequence charSequence, int i) {
|
||||
Preconditions.checkState(isInitialized(), "Not initialized yet");
|
||||
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
|
||||
return this.mHelper.hasEmojiGlyph(charSequence, i);
|
||||
}
|
||||
|
||||
public int getEmojiMatch(CharSequence charSequence, int i) {
|
||||
Preconditions.checkState(isInitialized(), "Not initialized yet");
|
||||
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
|
||||
return this.mHelper.getEmojiMatch(charSequence, i);
|
||||
}
|
||||
|
||||
public CharSequence process(CharSequence charSequence) {
|
||||
return process(charSequence, 0, charSequence == null ? 0 : charSequence.length());
|
||||
}
|
||||
|
||||
public CharSequence process(CharSequence charSequence, int i, int i2) {
|
||||
return process(charSequence, i, i2, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public CharSequence process(CharSequence charSequence, int i, int i2, int i3) {
|
||||
return process(charSequence, i, i2, i3, 0);
|
||||
}
|
||||
|
||||
public CharSequence process(CharSequence charSequence, int i, int i2, int i3, int i4) {
|
||||
Preconditions.checkState(isInitialized(), "Not initialized yet");
|
||||
Preconditions.checkArgumentNonnegative(i, "start cannot be negative");
|
||||
Preconditions.checkArgumentNonnegative(i2, "end cannot be negative");
|
||||
Preconditions.checkArgumentNonnegative(i3, "maxEmojiCount cannot be negative");
|
||||
Preconditions.checkArgument(i <= i2, "start should be <= than end");
|
||||
if (charSequence == null) {
|
||||
return null;
|
||||
}
|
||||
Preconditions.checkArgument(i <= charSequence.length(), "start should be < than charSequence length");
|
||||
Preconditions.checkArgument(i2 <= charSequence.length(), "end should be < than charSequence length");
|
||||
if (charSequence.length() == 0 || i == i2) {
|
||||
return charSequence;
|
||||
}
|
||||
return this.mHelper.process(charSequence, i, i2, i3, i4 != 1 ? i4 != 2 ? this.mReplaceAll : false : true);
|
||||
}
|
||||
|
||||
public String getAssetSignature() {
|
||||
Preconditions.checkState(isInitialized(), "Not initialized yet");
|
||||
return this.mHelper.getAssetSignature();
|
||||
}
|
||||
|
||||
public void updateEditorInfo(EditorInfo editorInfo) {
|
||||
if (!isInitialized() || editorInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (editorInfo.extras == null) {
|
||||
editorInfo.extras = new Bundle();
|
||||
}
|
||||
this.mHelper.updateEditorInfoAttrs(editorInfo);
|
||||
}
|
||||
|
||||
static class SpanFactory {
|
||||
SpanFactory() {
|
||||
}
|
||||
|
||||
EmojiSpan createSpan(EmojiMetadata emojiMetadata) {
|
||||
return new TypefaceEmojiSpan(emojiMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class Config {
|
||||
int[] mEmojiAsDefaultStyleExceptions;
|
||||
boolean mEmojiSpanIndicatorEnabled;
|
||||
Set<InitCallback> mInitCallbacks;
|
||||
final MetadataRepoLoader mMetadataLoader;
|
||||
boolean mReplaceAll;
|
||||
boolean mUseEmojiAsDefaultStyle;
|
||||
int mEmojiSpanIndicatorColor = -16711936;
|
||||
int mMetadataLoadStrategy = 0;
|
||||
GlyphChecker mGlyphChecker = new DefaultGlyphChecker();
|
||||
|
||||
protected final MetadataRepoLoader getMetadataRepoLoader() {
|
||||
return this.mMetadataLoader;
|
||||
}
|
||||
|
||||
public Config setEmojiSpanIndicatorColor(int i) {
|
||||
this.mEmojiSpanIndicatorColor = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config setEmojiSpanIndicatorEnabled(boolean z) {
|
||||
this.mEmojiSpanIndicatorEnabled = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config setMetadataLoadStrategy(int i) {
|
||||
this.mMetadataLoadStrategy = i;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config setReplaceAll(boolean z) {
|
||||
this.mReplaceAll = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Config(MetadataRepoLoader metadataRepoLoader) {
|
||||
Preconditions.checkNotNull(metadataRepoLoader, "metadataLoader cannot be null.");
|
||||
this.mMetadataLoader = metadataRepoLoader;
|
||||
}
|
||||
|
||||
public Config registerInitCallback(InitCallback initCallback) {
|
||||
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
|
||||
if (this.mInitCallbacks == null) {
|
||||
this.mInitCallbacks = new ArraySet();
|
||||
}
|
||||
this.mInitCallbacks.add(initCallback);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config unregisterInitCallback(InitCallback initCallback) {
|
||||
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
|
||||
Set<InitCallback> set = this.mInitCallbacks;
|
||||
if (set != null) {
|
||||
set.remove(initCallback);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config setUseEmojiAsDefaultStyle(boolean z) {
|
||||
return setUseEmojiAsDefaultStyle(z, null);
|
||||
}
|
||||
|
||||
public Config setUseEmojiAsDefaultStyle(boolean z, List<Integer> list) {
|
||||
this.mUseEmojiAsDefaultStyle = z;
|
||||
if (!z || list == null) {
|
||||
this.mEmojiAsDefaultStyleExceptions = null;
|
||||
} else {
|
||||
this.mEmojiAsDefaultStyleExceptions = new int[list.size()];
|
||||
Iterator<Integer> it = list.iterator();
|
||||
int i = 0;
|
||||
while (it.hasNext()) {
|
||||
this.mEmojiAsDefaultStyleExceptions[i] = it.next().intValue();
|
||||
i++;
|
||||
}
|
||||
Arrays.sort(this.mEmojiAsDefaultStyleExceptions);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Config setGlyphChecker(GlyphChecker glyphChecker) {
|
||||
Preconditions.checkNotNull(glyphChecker, "GlyphChecker cannot be null");
|
||||
this.mGlyphChecker = glyphChecker;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ListenerDispatcher implements Runnable {
|
||||
private final List<InitCallback> mInitCallbacks;
|
||||
private final int mLoadState;
|
||||
private final Throwable mThrowable;
|
||||
|
||||
ListenerDispatcher(InitCallback initCallback, int i) {
|
||||
this(Arrays.asList((InitCallback) Preconditions.checkNotNull(initCallback, "initCallback cannot be null")), i, null);
|
||||
}
|
||||
|
||||
ListenerDispatcher(Collection<InitCallback> collection, int i) {
|
||||
this(collection, i, null);
|
||||
}
|
||||
|
||||
ListenerDispatcher(Collection<InitCallback> collection, int i, Throwable th) {
|
||||
Preconditions.checkNotNull(collection, "initCallbacks cannot be null");
|
||||
this.mInitCallbacks = new ArrayList(collection);
|
||||
this.mLoadState = i;
|
||||
this.mThrowable = th;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
int size = this.mInitCallbacks.size();
|
||||
int i = 0;
|
||||
if (this.mLoadState != 1) {
|
||||
while (i < size) {
|
||||
this.mInitCallbacks.get(i).onFailed(this.mThrowable);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
while (i < size) {
|
||||
this.mInitCallbacks.get(i).onInitialized();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class CompatInternal {
|
||||
final EmojiCompat mEmojiCompat;
|
||||
|
||||
String getAssetSignature() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public int getEmojiMatch(CharSequence charSequence, int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
boolean hasEmojiGlyph(CharSequence charSequence) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean hasEmojiGlyph(CharSequence charSequence, int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CharSequence process(CharSequence charSequence, int i, int i2, int i3, boolean z) {
|
||||
return charSequence;
|
||||
}
|
||||
|
||||
void updateEditorInfoAttrs(EditorInfo editorInfo) {
|
||||
}
|
||||
|
||||
CompatInternal(EmojiCompat emojiCompat) {
|
||||
this.mEmojiCompat = emojiCompat;
|
||||
}
|
||||
|
||||
void loadMetadata() {
|
||||
this.mEmojiCompat.onMetadataLoadSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CompatInternal19 extends CompatInternal {
|
||||
private volatile MetadataRepo mMetadataRepo;
|
||||
private volatile EmojiProcessor mProcessor;
|
||||
|
||||
CompatInternal19(EmojiCompat emojiCompat) {
|
||||
super(emojiCompat);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
void loadMetadata() {
|
||||
try {
|
||||
this.mEmojiCompat.mMetadataLoader.load(new MetadataRepoLoaderCallback() { // from class: androidx.emoji2.text.EmojiCompat.CompatInternal19.1
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
|
||||
public void onLoaded(MetadataRepo metadataRepo) {
|
||||
CompatInternal19.this.onMetadataLoadSuccess(metadataRepo);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
|
||||
public void onFailed(Throwable th) {
|
||||
CompatInternal19.this.mEmojiCompat.onMetadataLoadFailed(th);
|
||||
}
|
||||
});
|
||||
} catch (Throwable th) {
|
||||
this.mEmojiCompat.onMetadataLoadFailed(th);
|
||||
}
|
||||
}
|
||||
|
||||
void onMetadataLoadSuccess(MetadataRepo metadataRepo) {
|
||||
if (metadataRepo == null) {
|
||||
this.mEmojiCompat.onMetadataLoadFailed(new IllegalArgumentException("metadataRepo cannot be null"));
|
||||
return;
|
||||
}
|
||||
this.mMetadataRepo = metadataRepo;
|
||||
this.mProcessor = new EmojiProcessor(this.mMetadataRepo, new SpanFactory(), this.mEmojiCompat.mGlyphChecker, this.mEmojiCompat.mUseEmojiAsDefaultStyle, this.mEmojiCompat.mEmojiAsDefaultStyleExceptions);
|
||||
this.mEmojiCompat.onMetadataLoadSuccess();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
boolean hasEmojiGlyph(CharSequence charSequence) {
|
||||
return this.mProcessor.getEmojiMatch(charSequence) == 1;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
boolean hasEmojiGlyph(CharSequence charSequence, int i) {
|
||||
return this.mProcessor.getEmojiMatch(charSequence, i) == 1;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
public int getEmojiMatch(CharSequence charSequence, int i) {
|
||||
return this.mProcessor.getEmojiMatch(charSequence, i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
CharSequence process(CharSequence charSequence, int i, int i2, int i3, boolean z) {
|
||||
return this.mProcessor.process(charSequence, i, i2, i3, z);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
void updateEditorInfoAttrs(EditorInfo editorInfo) {
|
||||
editorInfo.extras.putInt(EmojiCompat.EDITOR_INFO_METAVERSION_KEY, this.mMetadataRepo.getMetadataVersion());
|
||||
editorInfo.extras.putBoolean(EmojiCompat.EDITOR_INFO_REPLACE_ALL_KEY, this.mEmojiCompat.mReplaceAll);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
|
||||
String getAssetSignature() {
|
||||
String sourceSha = this.mMetadataRepo.getMetadataList().sourceSha();
|
||||
return sourceSha == null ? "" : sourceSha;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,152 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.core.os.TraceCompat;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
import androidx.emoji2.text.EmojiCompatInitializer;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.Lifecycle;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ProcessLifecycleInitializer;
|
||||
import androidx.startup.AppInitializer;
|
||||
import androidx.startup.Initializer;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import kotlin.jvm.internal.Intrinsics;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class EmojiCompatInitializer implements Initializer<Boolean> {
|
||||
private static final long STARTUP_THREAD_CREATION_DELAY_MS = 500;
|
||||
private static final String S_INITIALIZER_THREAD_NAME = "EmojiCompatInitializer";
|
||||
|
||||
/* JADX WARN: Can't rename method to resolve collision */
|
||||
@Override // androidx.startup.Initializer
|
||||
public Boolean create(Context context) {
|
||||
EmojiCompat.init(new BackgroundDefaultConfig(context));
|
||||
delayUntilFirstResume(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
void delayUntilFirstResume(Context context) {
|
||||
final Lifecycle lifecycle = ((LifecycleOwner) AppInitializer.getInstance(context).initializeComponent(ProcessLifecycleInitializer.class)).getLifecycle();
|
||||
lifecycle.addObserver(new DefaultLifecycleObserver() { // from class: androidx.emoji2.text.EmojiCompatInitializer.1
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public /* synthetic */ void onCreate(LifecycleOwner lifecycleOwner) {
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "owner");
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public /* synthetic */ void onDestroy(LifecycleOwner lifecycleOwner) {
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "owner");
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public /* synthetic */ void onPause(LifecycleOwner lifecycleOwner) {
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "owner");
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public /* synthetic */ void onStart(LifecycleOwner lifecycleOwner) {
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "owner");
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public /* synthetic */ void onStop(LifecycleOwner lifecycleOwner) {
|
||||
Intrinsics.checkNotNullParameter(lifecycleOwner, "owner");
|
||||
}
|
||||
|
||||
@Override // androidx.lifecycle.DefaultLifecycleObserver
|
||||
public void onResume(LifecycleOwner lifecycleOwner) {
|
||||
EmojiCompatInitializer.this.loadEmojiCompatAfterDelay();
|
||||
lifecycle.removeObserver(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void loadEmojiCompatAfterDelay() {
|
||||
ConcurrencyHelpers.mainHandlerAsync().postDelayed(new LoadEmojiCompatRunnable(), STARTUP_THREAD_CREATION_DELAY_MS);
|
||||
}
|
||||
|
||||
@Override // androidx.startup.Initializer
|
||||
public List<Class<? extends Initializer<?>>> dependencies() {
|
||||
return Collections.singletonList(ProcessLifecycleInitializer.class);
|
||||
}
|
||||
|
||||
static class LoadEmojiCompatRunnable implements Runnable {
|
||||
LoadEmojiCompatRunnable() {
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
TraceCompat.beginSection("EmojiCompat.EmojiCompatInitializer.run");
|
||||
if (EmojiCompat.isConfigured()) {
|
||||
EmojiCompat.get().load();
|
||||
}
|
||||
} finally {
|
||||
TraceCompat.endSection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class BackgroundDefaultConfig extends EmojiCompat.Config {
|
||||
protected BackgroundDefaultConfig(Context context) {
|
||||
super(new BackgroundDefaultLoader(context));
|
||||
setMetadataLoadStrategy(1);
|
||||
}
|
||||
}
|
||||
|
||||
static class BackgroundDefaultLoader implements EmojiCompat.MetadataRepoLoader {
|
||||
private final Context mContext;
|
||||
|
||||
BackgroundDefaultLoader(Context context) {
|
||||
this.mContext = context.getApplicationContext();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoader
|
||||
public void load(final EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback) {
|
||||
final ThreadPoolExecutor createBackgroundPriorityExecutor = ConcurrencyHelpers.createBackgroundPriorityExecutor(EmojiCompatInitializer.S_INITIALIZER_THREAD_NAME);
|
||||
createBackgroundPriorityExecutor.execute(new Runnable() { // from class: androidx.emoji2.text.EmojiCompatInitializer$BackgroundDefaultLoader$$ExternalSyntheticLambda0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
EmojiCompatInitializer.BackgroundDefaultLoader.this.m166x5cc8028a(metadataRepoLoaderCallback, createBackgroundPriorityExecutor);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: package-private */
|
||||
/* renamed from: doLoad, reason: merged with bridge method [inline-methods] */
|
||||
public void m166x5cc8028a(final EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback, final ThreadPoolExecutor threadPoolExecutor) {
|
||||
try {
|
||||
FontRequestEmojiCompatConfig create = DefaultEmojiCompatConfig.create(this.mContext);
|
||||
if (create == null) {
|
||||
throw new RuntimeException("EmojiCompat font provider not available on this device.");
|
||||
}
|
||||
create.setLoadingExecutor(threadPoolExecutor);
|
||||
create.getMetadataRepoLoader().load(new EmojiCompat.MetadataRepoLoaderCallback() { // from class: androidx.emoji2.text.EmojiCompatInitializer.BackgroundDefaultLoader.1
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
|
||||
public void onLoaded(MetadataRepo metadataRepo) {
|
||||
try {
|
||||
metadataRepoLoaderCallback.onLoaded(metadataRepo);
|
||||
} finally {
|
||||
threadPoolExecutor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
|
||||
public void onFailed(Throwable th) {
|
||||
try {
|
||||
metadataRepoLoaderCallback.onFailed(th);
|
||||
} finally {
|
||||
threadPoolExecutor.shutdown();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Throwable th) {
|
||||
metadataRepoLoaderCallback.onFailed(th);
|
||||
threadPoolExecutor.shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class EmojiDefaults {
|
||||
public static final int MAX_EMOJI_COUNT = Integer.MAX_VALUE;
|
||||
|
||||
private EmojiDefaults() {
|
||||
}
|
||||
}
|
109
02-Easy5/E5/sources/androidx/emoji2/text/EmojiMetadata.java
Normal file
109
02-Easy5/E5/sources/androidx/emoji2/text/EmojiMetadata.java
Normal file
@ -0,0 +1,109 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Typeface;
|
||||
import androidx.emoji2.text.flatbuffer.MetadataItem;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class EmojiMetadata {
|
||||
public static final int HAS_GLYPH_ABSENT = 1;
|
||||
public static final int HAS_GLYPH_EXISTS = 2;
|
||||
public static final int HAS_GLYPH_UNKNOWN = 0;
|
||||
private static final ThreadLocal<MetadataItem> sMetadataItem = new ThreadLocal<>();
|
||||
private volatile int mHasGlyph = 0;
|
||||
private final int mIndex;
|
||||
private final MetadataRepo mMetadataRepo;
|
||||
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface HasGlyph {
|
||||
}
|
||||
|
||||
public int getHasGlyph() {
|
||||
return this.mHasGlyph;
|
||||
}
|
||||
|
||||
public void resetHasGlyphCache() {
|
||||
this.mHasGlyph = 0;
|
||||
}
|
||||
|
||||
public void setHasGlyph(boolean z) {
|
||||
this.mHasGlyph = z ? 2 : 1;
|
||||
}
|
||||
|
||||
EmojiMetadata(MetadataRepo metadataRepo, int i) {
|
||||
this.mMetadataRepo = metadataRepo;
|
||||
this.mIndex = i;
|
||||
}
|
||||
|
||||
public void draw(Canvas canvas, float f, float f2, Paint paint) {
|
||||
Typeface typeface = this.mMetadataRepo.getTypeface();
|
||||
Typeface typeface2 = paint.getTypeface();
|
||||
paint.setTypeface(typeface);
|
||||
canvas.drawText(this.mMetadataRepo.getEmojiCharArray(), this.mIndex * 2, 2, f, f2, paint);
|
||||
paint.setTypeface(typeface2);
|
||||
}
|
||||
|
||||
public Typeface getTypeface() {
|
||||
return this.mMetadataRepo.getTypeface();
|
||||
}
|
||||
|
||||
private MetadataItem getMetadataItem() {
|
||||
ThreadLocal<MetadataItem> threadLocal = sMetadataItem;
|
||||
MetadataItem metadataItem = threadLocal.get();
|
||||
if (metadataItem == null) {
|
||||
metadataItem = new MetadataItem();
|
||||
threadLocal.set(metadataItem);
|
||||
}
|
||||
this.mMetadataRepo.getMetadataList().list(metadataItem, this.mIndex);
|
||||
return metadataItem;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return getMetadataItem().id();
|
||||
}
|
||||
|
||||
public short getWidth() {
|
||||
return getMetadataItem().width();
|
||||
}
|
||||
|
||||
public short getHeight() {
|
||||
return getMetadataItem().height();
|
||||
}
|
||||
|
||||
public short getCompatAdded() {
|
||||
return getMetadataItem().compatAdded();
|
||||
}
|
||||
|
||||
public short getSdkAdded() {
|
||||
return getMetadataItem().sdkAdded();
|
||||
}
|
||||
|
||||
public boolean isDefaultEmoji() {
|
||||
return getMetadataItem().emojiStyle();
|
||||
}
|
||||
|
||||
public int getCodepointAt(int i) {
|
||||
return getMetadataItem().codepoints(i);
|
||||
}
|
||||
|
||||
public int getCodepointsLength() {
|
||||
return getMetadataItem().codepointsLength();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(super.toString());
|
||||
sb.append(", id:");
|
||||
sb.append(Integer.toHexString(getId()));
|
||||
sb.append(", codepoints:");
|
||||
int codepointsLength = getCodepointsLength();
|
||||
for (int i = 0; i < codepointsLength; i++) {
|
||||
sb.append(Integer.toHexString(getCodepointAt(i)));
|
||||
sb.append(" ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
358
02-Easy5/E5/sources/androidx/emoji2/text/EmojiProcessor.java
Normal file
358
02-Easy5/E5/sources/androidx/emoji2/text/EmojiProcessor.java
Normal file
@ -0,0 +1,358 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.text.Editable;
|
||||
import android.text.Selection;
|
||||
import android.text.Spannable;
|
||||
import android.text.method.MetaKeyKeyListener;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.inputmethod.InputConnection;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
import androidx.emoji2.text.MetadataRepo;
|
||||
import java.util.Arrays;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class EmojiProcessor {
|
||||
private static final int ACTION_ADVANCE_BOTH = 1;
|
||||
private static final int ACTION_ADVANCE_END = 2;
|
||||
private static final int ACTION_FLUSH = 3;
|
||||
private final int[] mEmojiAsDefaultStyleExceptions;
|
||||
private EmojiCompat.GlyphChecker mGlyphChecker;
|
||||
private final MetadataRepo mMetadataRepo;
|
||||
private final EmojiCompat.SpanFactory mSpanFactory;
|
||||
private final boolean mUseEmojiAsDefaultStyle;
|
||||
|
||||
private static boolean hasInvalidSelection(int i, int i2) {
|
||||
return i == -1 || i2 == -1 || i != i2;
|
||||
}
|
||||
|
||||
EmojiProcessor(MetadataRepo metadataRepo, EmojiCompat.SpanFactory spanFactory, EmojiCompat.GlyphChecker glyphChecker, boolean z, int[] iArr) {
|
||||
this.mSpanFactory = spanFactory;
|
||||
this.mMetadataRepo = metadataRepo;
|
||||
this.mGlyphChecker = glyphChecker;
|
||||
this.mUseEmojiAsDefaultStyle = z;
|
||||
this.mEmojiAsDefaultStyleExceptions = iArr;
|
||||
}
|
||||
|
||||
int getEmojiMatch(CharSequence charSequence) {
|
||||
return getEmojiMatch(charSequence, this.mMetadataRepo.getMetadataVersion());
|
||||
}
|
||||
|
||||
int getEmojiMatch(CharSequence charSequence, int i) {
|
||||
ProcessorSm processorSm = new ProcessorSm(this.mMetadataRepo.getRootNode(), this.mUseEmojiAsDefaultStyle, this.mEmojiAsDefaultStyleExceptions);
|
||||
int length = charSequence.length();
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
int i4 = 0;
|
||||
while (i2 < length) {
|
||||
int codePointAt = Character.codePointAt(charSequence, i2);
|
||||
int check = processorSm.check(codePointAt);
|
||||
EmojiMetadata currentMetadata = processorSm.getCurrentMetadata();
|
||||
if (check == 1) {
|
||||
i2 += Character.charCount(codePointAt);
|
||||
i4 = 0;
|
||||
} else if (check == 2) {
|
||||
i2 += Character.charCount(codePointAt);
|
||||
} else if (check == 3) {
|
||||
currentMetadata = processorSm.getFlushMetadata();
|
||||
if (currentMetadata.getCompatAdded() <= i) {
|
||||
i3++;
|
||||
}
|
||||
}
|
||||
if (currentMetadata != null && currentMetadata.getCompatAdded() <= i) {
|
||||
i4++;
|
||||
}
|
||||
}
|
||||
if (i3 != 0) {
|
||||
return 2;
|
||||
}
|
||||
if (!processorSm.isInFlushableState() || processorSm.getCurrentMetadata().getCompatAdded() > i) {
|
||||
return i4 == 0 ? 0 : 2;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:95:0x0126, code lost:
|
||||
|
||||
((androidx.emoji2.text.SpannableBuilder) r10).endBatchEdit();
|
||||
*/
|
||||
/* JADX WARN: Removed duplicated region for block: B:14:0x0048 A[Catch: all -> 0x012d, TryCatch #0 {all -> 0x012d, blocks: (B:98:0x000c, B:101:0x0011, B:103:0x0015, B:105:0x0024, B:8:0x0037, B:10:0x0041, B:12:0x0044, B:14:0x0048, B:16:0x0054, B:18:0x0057, B:22:0x0064, B:28:0x0073, B:29:0x0081, B:33:0x009c, B:59:0x00ac, B:63:0x00b8, B:64:0x00c2, B:46:0x00cc, B:49:0x00d3, B:36:0x00d8, B:38:0x00e3, B:70:0x00ea, B:74:0x00f4, B:77:0x0100, B:78:0x0106, B:80:0x010f, B:5:0x002c), top: B:97:0x000c }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:35:0x00d8 A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:42:0x00a3 A[SYNTHETIC] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:77:0x0100 A[Catch: all -> 0x012d, TryCatch #0 {all -> 0x012d, blocks: (B:98:0x000c, B:101:0x0011, B:103:0x0015, B:105:0x0024, B:8:0x0037, B:10:0x0041, B:12:0x0044, B:14:0x0048, B:16:0x0054, B:18:0x0057, B:22:0x0064, B:28:0x0073, B:29:0x0081, B:33:0x009c, B:59:0x00ac, B:63:0x00b8, B:64:0x00c2, B:46:0x00cc, B:49:0x00d3, B:36:0x00d8, B:38:0x00e3, B:70:0x00ea, B:74:0x00f4, B:77:0x0100, B:78:0x0106, B:80:0x010f, B:5:0x002c), top: B:97:0x000c }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:80:0x010f A[Catch: all -> 0x012d, TRY_LEAVE, TryCatch #0 {all -> 0x012d, blocks: (B:98:0x000c, B:101:0x0011, B:103:0x0015, B:105:0x0024, B:8:0x0037, B:10:0x0041, B:12:0x0044, B:14:0x0048, B:16:0x0054, B:18:0x0057, B:22:0x0064, B:28:0x0073, B:29:0x0081, B:33:0x009c, B:59:0x00ac, B:63:0x00b8, B:64:0x00c2, B:46:0x00cc, B:49:0x00d3, B:36:0x00d8, B:38:0x00e3, B:70:0x00ea, B:74:0x00f4, B:77:0x0100, B:78:0x0106, B:80:0x010f, B:5:0x002c), top: B:97:0x000c }] */
|
||||
/* JADX WARN: Removed duplicated region for block: B:90:0x011b */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
java.lang.CharSequence process(java.lang.CharSequence r10, int r11, int r12, int r13, boolean r14) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 310
|
||||
To view this dump add '--comments-level debug' option
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.emoji2.text.EmojiProcessor.process(java.lang.CharSequence, int, int, int, boolean):java.lang.CharSequence");
|
||||
}
|
||||
|
||||
static boolean handleOnKeyDown(Editable editable, int i, KeyEvent keyEvent) {
|
||||
boolean delete;
|
||||
if (i != 67) {
|
||||
if (i == 112) {
|
||||
delete = delete(editable, keyEvent, true);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
delete = delete(editable, keyEvent, false);
|
||||
if (delete) {
|
||||
MetaKeyKeyListener.adjustMetaAfterKeypress(editable);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean delete(Editable editable, KeyEvent keyEvent, boolean z) {
|
||||
EmojiSpan[] emojiSpanArr;
|
||||
if (hasModifiers(keyEvent)) {
|
||||
return false;
|
||||
}
|
||||
int selectionStart = Selection.getSelectionStart(editable);
|
||||
int selectionEnd = Selection.getSelectionEnd(editable);
|
||||
if (!hasInvalidSelection(selectionStart, selectionEnd) && (emojiSpanArr = (EmojiSpan[]) editable.getSpans(selectionStart, selectionEnd, EmojiSpan.class)) != null && emojiSpanArr.length > 0) {
|
||||
for (EmojiSpan emojiSpan : emojiSpanArr) {
|
||||
int spanStart = editable.getSpanStart(emojiSpan);
|
||||
int spanEnd = editable.getSpanEnd(emojiSpan);
|
||||
if ((z && spanStart == selectionStart) || ((!z && spanEnd == selectionStart) || (selectionStart > spanStart && selectionStart < spanEnd))) {
|
||||
editable.delete(spanStart, spanEnd);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static boolean handleDeleteSurroundingText(InputConnection inputConnection, Editable editable, int i, int i2, boolean z) {
|
||||
int max;
|
||||
int min;
|
||||
if (editable != null && inputConnection != null && i >= 0 && i2 >= 0) {
|
||||
int selectionStart = Selection.getSelectionStart(editable);
|
||||
int selectionEnd = Selection.getSelectionEnd(editable);
|
||||
if (hasInvalidSelection(selectionStart, selectionEnd)) {
|
||||
return false;
|
||||
}
|
||||
if (z) {
|
||||
max = CodepointIndexFinder.findIndexBackward(editable, selectionStart, Math.max(i, 0));
|
||||
min = CodepointIndexFinder.findIndexForward(editable, selectionEnd, Math.max(i2, 0));
|
||||
if (max == -1 || min == -1) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
max = Math.max(selectionStart - i, 0);
|
||||
min = Math.min(selectionEnd + i2, editable.length());
|
||||
}
|
||||
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) editable.getSpans(max, min, EmojiSpan.class);
|
||||
if (emojiSpanArr != null && emojiSpanArr.length > 0) {
|
||||
for (EmojiSpan emojiSpan : emojiSpanArr) {
|
||||
int spanStart = editable.getSpanStart(emojiSpan);
|
||||
int spanEnd = editable.getSpanEnd(emojiSpan);
|
||||
max = Math.min(spanStart, max);
|
||||
min = Math.max(spanEnd, min);
|
||||
}
|
||||
int max2 = Math.max(max, 0);
|
||||
int min2 = Math.min(min, editable.length());
|
||||
inputConnection.beginBatchEdit();
|
||||
editable.delete(max2, min2);
|
||||
inputConnection.endBatchEdit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean hasModifiers(KeyEvent keyEvent) {
|
||||
return !KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState());
|
||||
}
|
||||
|
||||
private void addEmoji(Spannable spannable, EmojiMetadata emojiMetadata, int i, int i2) {
|
||||
spannable.setSpan(this.mSpanFactory.createSpan(emojiMetadata), i, i2, 33);
|
||||
}
|
||||
|
||||
private boolean hasGlyph(CharSequence charSequence, int i, int i2, EmojiMetadata emojiMetadata) {
|
||||
if (emojiMetadata.getHasGlyph() == 0) {
|
||||
emojiMetadata.setHasGlyph(this.mGlyphChecker.hasGlyph(charSequence, i, i2, emojiMetadata.getSdkAdded()));
|
||||
}
|
||||
return emojiMetadata.getHasGlyph() == 2;
|
||||
}
|
||||
|
||||
static final class ProcessorSm {
|
||||
private static final int STATE_DEFAULT = 1;
|
||||
private static final int STATE_WALKING = 2;
|
||||
private int mCurrentDepth;
|
||||
private MetadataRepo.Node mCurrentNode;
|
||||
private final int[] mEmojiAsDefaultStyleExceptions;
|
||||
private MetadataRepo.Node mFlushNode;
|
||||
private int mLastCodepoint;
|
||||
private final MetadataRepo.Node mRootNode;
|
||||
private int mState = 1;
|
||||
private final boolean mUseEmojiAsDefaultStyle;
|
||||
|
||||
private static boolean isEmojiStyle(int i) {
|
||||
return i == 65039;
|
||||
}
|
||||
|
||||
private static boolean isTextStyle(int i) {
|
||||
return i == 65038;
|
||||
}
|
||||
|
||||
private int reset() {
|
||||
this.mState = 1;
|
||||
this.mCurrentNode = this.mRootNode;
|
||||
this.mCurrentDepth = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
ProcessorSm(MetadataRepo.Node node, boolean z, int[] iArr) {
|
||||
this.mRootNode = node;
|
||||
this.mCurrentNode = node;
|
||||
this.mUseEmojiAsDefaultStyle = z;
|
||||
this.mEmojiAsDefaultStyleExceptions = iArr;
|
||||
}
|
||||
|
||||
int check(int i) {
|
||||
MetadataRepo.Node node = this.mCurrentNode.get(i);
|
||||
int i2 = 2;
|
||||
if (this.mState != 2) {
|
||||
if (node == null) {
|
||||
i2 = reset();
|
||||
} else {
|
||||
this.mState = 2;
|
||||
this.mCurrentNode = node;
|
||||
this.mCurrentDepth = 1;
|
||||
}
|
||||
} else if (node != null) {
|
||||
this.mCurrentNode = node;
|
||||
this.mCurrentDepth++;
|
||||
} else if (isTextStyle(i)) {
|
||||
i2 = reset();
|
||||
} else if (!isEmojiStyle(i)) {
|
||||
if (this.mCurrentNode.getData() != null) {
|
||||
i2 = 3;
|
||||
if (this.mCurrentDepth == 1) {
|
||||
if (shouldUseEmojiPresentationStyleForSingleCodepoint()) {
|
||||
this.mFlushNode = this.mCurrentNode;
|
||||
reset();
|
||||
} else {
|
||||
i2 = reset();
|
||||
}
|
||||
} else {
|
||||
this.mFlushNode = this.mCurrentNode;
|
||||
reset();
|
||||
}
|
||||
} else {
|
||||
i2 = reset();
|
||||
}
|
||||
}
|
||||
this.mLastCodepoint = i;
|
||||
return i2;
|
||||
}
|
||||
|
||||
EmojiMetadata getFlushMetadata() {
|
||||
return this.mFlushNode.getData();
|
||||
}
|
||||
|
||||
EmojiMetadata getCurrentMetadata() {
|
||||
return this.mCurrentNode.getData();
|
||||
}
|
||||
|
||||
boolean isInFlushableState() {
|
||||
return this.mState == 2 && this.mCurrentNode.getData() != null && (this.mCurrentDepth > 1 || shouldUseEmojiPresentationStyleForSingleCodepoint());
|
||||
}
|
||||
|
||||
private boolean shouldUseEmojiPresentationStyleForSingleCodepoint() {
|
||||
if (this.mCurrentNode.getData().isDefaultEmoji() || isEmojiStyle(this.mLastCodepoint)) {
|
||||
return true;
|
||||
}
|
||||
if (this.mUseEmojiAsDefaultStyle) {
|
||||
if (this.mEmojiAsDefaultStyleExceptions == null) {
|
||||
return true;
|
||||
}
|
||||
if (Arrays.binarySearch(this.mEmojiAsDefaultStyleExceptions, this.mCurrentNode.getData().getCodepointAt(0)) < 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CodepointIndexFinder {
|
||||
private static final int INVALID_INDEX = -1;
|
||||
|
||||
private CodepointIndexFinder() {
|
||||
}
|
||||
|
||||
static int findIndexBackward(CharSequence charSequence, int i, int i2) {
|
||||
int length = charSequence.length();
|
||||
if (i < 0 || length < i || i2 < 0) {
|
||||
return -1;
|
||||
}
|
||||
while (true) {
|
||||
boolean z = false;
|
||||
while (i2 != 0) {
|
||||
i--;
|
||||
if (i < 0) {
|
||||
return z ? -1 : 0;
|
||||
}
|
||||
char charAt = charSequence.charAt(i);
|
||||
if (z) {
|
||||
if (!Character.isHighSurrogate(charAt)) {
|
||||
return -1;
|
||||
}
|
||||
i2--;
|
||||
} else if (!Character.isSurrogate(charAt)) {
|
||||
i2--;
|
||||
} else {
|
||||
if (Character.isHighSurrogate(charAt)) {
|
||||
return -1;
|
||||
}
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
static int findIndexForward(CharSequence charSequence, int i, int i2) {
|
||||
int length = charSequence.length();
|
||||
if (i < 0 || length < i || i2 < 0) {
|
||||
return -1;
|
||||
}
|
||||
while (true) {
|
||||
boolean z = false;
|
||||
while (i2 != 0) {
|
||||
if (i >= length) {
|
||||
if (z) {
|
||||
return -1;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
char charAt = charSequence.charAt(i);
|
||||
if (z) {
|
||||
if (!Character.isLowSurrogate(charAt)) {
|
||||
return -1;
|
||||
}
|
||||
i2--;
|
||||
i++;
|
||||
} else if (!Character.isSurrogate(charAt)) {
|
||||
i2--;
|
||||
i++;
|
||||
} else {
|
||||
if (Character.isLowSurrogate(charAt)) {
|
||||
return -1;
|
||||
}
|
||||
i++;
|
||||
z = true;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
54
02-Easy5/E5/sources/androidx/emoji2/text/EmojiSpan.java
Normal file
54
02-Easy5/E5/sources/androidx/emoji2/text/EmojiSpan.java
Normal file
@ -0,0 +1,54 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.graphics.Paint;
|
||||
import android.text.style.ReplacementSpan;
|
||||
import androidx.core.util.Preconditions;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class EmojiSpan extends ReplacementSpan {
|
||||
private final EmojiMetadata mMetadata;
|
||||
private final Paint.FontMetricsInt mTmpFontMetrics = new Paint.FontMetricsInt();
|
||||
private short mWidth = -1;
|
||||
private short mHeight = -1;
|
||||
private float mRatio = 1.0f;
|
||||
|
||||
public final int getHeight() {
|
||||
return this.mHeight;
|
||||
}
|
||||
|
||||
public final EmojiMetadata getMetadata() {
|
||||
return this.mMetadata;
|
||||
}
|
||||
|
||||
final float getRatio() {
|
||||
return this.mRatio;
|
||||
}
|
||||
|
||||
final int getWidth() {
|
||||
return this.mWidth;
|
||||
}
|
||||
|
||||
EmojiSpan(EmojiMetadata emojiMetadata) {
|
||||
Preconditions.checkNotNull(emojiMetadata, "metadata cannot be null");
|
||||
this.mMetadata = emojiMetadata;
|
||||
}
|
||||
|
||||
@Override // android.text.style.ReplacementSpan
|
||||
public int getSize(Paint paint, CharSequence charSequence, int i, int i2, Paint.FontMetricsInt fontMetricsInt) {
|
||||
paint.getFontMetricsInt(this.mTmpFontMetrics);
|
||||
this.mRatio = (Math.abs(this.mTmpFontMetrics.descent - this.mTmpFontMetrics.ascent) * 1.0f) / this.mMetadata.getHeight();
|
||||
this.mHeight = (short) (this.mMetadata.getHeight() * this.mRatio);
|
||||
this.mWidth = (short) (this.mMetadata.getWidth() * this.mRatio);
|
||||
if (fontMetricsInt != null) {
|
||||
fontMetricsInt.ascent = this.mTmpFontMetrics.ascent;
|
||||
fontMetricsInt.descent = this.mTmpFontMetrics.descent;
|
||||
fontMetricsInt.top = this.mTmpFontMetrics.top;
|
||||
fontMetricsInt.bottom = this.mTmpFontMetrics.bottom;
|
||||
}
|
||||
return this.mWidth;
|
||||
}
|
||||
|
||||
public final int getId() {
|
||||
return getMetadata().getId();
|
||||
}
|
||||
}
|
@ -0,0 +1,281 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.ContentObserver;
|
||||
import android.graphics.Typeface;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import androidx.core.graphics.TypefaceCompatUtil;
|
||||
import androidx.core.os.TraceCompat;
|
||||
import androidx.core.provider.FontRequest;
|
||||
import androidx.core.provider.FontsContractCompat;
|
||||
import androidx.core.util.Preconditions;
|
||||
import androidx.emoji2.text.EmojiCompat;
|
||||
import androidx.emoji2.text.FontRequestEmojiCompatConfig;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FontRequestEmojiCompatConfig extends EmojiCompat.Config {
|
||||
private static final FontProviderHelper DEFAULT_FONTS_CONTRACT = new FontProviderHelper();
|
||||
|
||||
public static abstract class RetryPolicy {
|
||||
public abstract long getRetryDelay();
|
||||
}
|
||||
|
||||
public static class ExponentialBackoffRetryPolicy extends RetryPolicy {
|
||||
private long mRetryOrigin;
|
||||
private final long mTotalMs;
|
||||
|
||||
public ExponentialBackoffRetryPolicy(long j) {
|
||||
this.mTotalMs = j;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.FontRequestEmojiCompatConfig.RetryPolicy
|
||||
public long getRetryDelay() {
|
||||
if (this.mRetryOrigin == 0) {
|
||||
this.mRetryOrigin = SystemClock.uptimeMillis();
|
||||
return 0L;
|
||||
}
|
||||
long uptimeMillis = SystemClock.uptimeMillis() - this.mRetryOrigin;
|
||||
if (uptimeMillis > this.mTotalMs) {
|
||||
return -1L;
|
||||
}
|
||||
return Math.min(Math.max(uptimeMillis, 1000L), this.mTotalMs - uptimeMillis);
|
||||
}
|
||||
}
|
||||
|
||||
public FontRequestEmojiCompatConfig(Context context, FontRequest fontRequest) {
|
||||
super(new FontRequestMetadataLoader(context, fontRequest, DEFAULT_FONTS_CONTRACT));
|
||||
}
|
||||
|
||||
public FontRequestEmojiCompatConfig(Context context, FontRequest fontRequest, FontProviderHelper fontProviderHelper) {
|
||||
super(new FontRequestMetadataLoader(context, fontRequest, fontProviderHelper));
|
||||
}
|
||||
|
||||
public FontRequestEmojiCompatConfig setLoadingExecutor(Executor executor) {
|
||||
((FontRequestMetadataLoader) getMetadataRepoLoader()).setExecutor(executor);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FontRequestEmojiCompatConfig setHandler(Handler handler) {
|
||||
if (handler == null) {
|
||||
return this;
|
||||
}
|
||||
setLoadingExecutor(ConcurrencyHelpers.convertHandlerToExecutor(handler));
|
||||
return this;
|
||||
}
|
||||
|
||||
public FontRequestEmojiCompatConfig setRetryPolicy(RetryPolicy retryPolicy) {
|
||||
((FontRequestMetadataLoader) getMetadataRepoLoader()).setRetryPolicy(retryPolicy);
|
||||
return this;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
static class FontRequestMetadataLoader implements EmojiCompat.MetadataRepoLoader {
|
||||
private static final String S_TRACE_BUILD_TYPEFACE = "EmojiCompat.FontRequestEmojiCompatConfig.buildTypeface";
|
||||
EmojiCompat.MetadataRepoLoaderCallback mCallback;
|
||||
private final Context mContext;
|
||||
private Executor mExecutor;
|
||||
private final FontProviderHelper mFontProviderHelper;
|
||||
private final Object mLock = new Object();
|
||||
private Handler mMainHandler;
|
||||
private Runnable mMainHandlerLoadCallback;
|
||||
private ThreadPoolExecutor mMyThreadPoolExecutor;
|
||||
private ContentObserver mObserver;
|
||||
private final FontRequest mRequest;
|
||||
private RetryPolicy mRetryPolicy;
|
||||
|
||||
FontRequestMetadataLoader(Context context, FontRequest fontRequest, FontProviderHelper fontProviderHelper) {
|
||||
Preconditions.checkNotNull(context, "Context cannot be null");
|
||||
Preconditions.checkNotNull(fontRequest, "FontRequest cannot be null");
|
||||
this.mContext = context.getApplicationContext();
|
||||
this.mRequest = fontRequest;
|
||||
this.mFontProviderHelper = fontProviderHelper;
|
||||
}
|
||||
|
||||
public void setExecutor(Executor executor) {
|
||||
synchronized (this.mLock) {
|
||||
this.mExecutor = executor;
|
||||
}
|
||||
}
|
||||
|
||||
public void setRetryPolicy(RetryPolicy retryPolicy) {
|
||||
synchronized (this.mLock) {
|
||||
this.mRetryPolicy = retryPolicy;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoader
|
||||
public void load(EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback) {
|
||||
Preconditions.checkNotNull(metadataRepoLoaderCallback, "LoaderCallback cannot be null");
|
||||
synchronized (this.mLock) {
|
||||
this.mCallback = metadataRepoLoaderCallback;
|
||||
}
|
||||
loadInternal();
|
||||
}
|
||||
|
||||
void loadInternal() {
|
||||
synchronized (this.mLock) {
|
||||
if (this.mCallback == null) {
|
||||
return;
|
||||
}
|
||||
if (this.mExecutor == null) {
|
||||
ThreadPoolExecutor createBackgroundPriorityExecutor = ConcurrencyHelpers.createBackgroundPriorityExecutor("emojiCompat");
|
||||
this.mMyThreadPoolExecutor = createBackgroundPriorityExecutor;
|
||||
this.mExecutor = createBackgroundPriorityExecutor;
|
||||
}
|
||||
this.mExecutor.execute(new Runnable() { // from class: androidx.emoji2.text.FontRequestEmojiCompatConfig$FontRequestMetadataLoader$$ExternalSyntheticLambda0
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
FontRequestEmojiCompatConfig.FontRequestMetadataLoader.this.createMetadata();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private FontsContractCompat.FontInfo retrieveFontInfo() {
|
||||
try {
|
||||
FontsContractCompat.FontFamilyResult fetchFonts = this.mFontProviderHelper.fetchFonts(this.mContext, this.mRequest);
|
||||
if (fetchFonts.getStatusCode() != 0) {
|
||||
throw new RuntimeException("fetchFonts failed (" + fetchFonts.getStatusCode() + ")");
|
||||
}
|
||||
FontsContractCompat.FontInfo[] fonts = fetchFonts.getFonts();
|
||||
if (fonts == null || fonts.length == 0) {
|
||||
throw new RuntimeException("fetchFonts failed (empty result)");
|
||||
}
|
||||
return fonts[0];
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
throw new RuntimeException("provider not found", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void scheduleRetry(Uri uri, long j) {
|
||||
synchronized (this.mLock) {
|
||||
Handler handler = this.mMainHandler;
|
||||
if (handler == null) {
|
||||
handler = ConcurrencyHelpers.mainHandlerAsync();
|
||||
this.mMainHandler = handler;
|
||||
}
|
||||
if (this.mObserver == null) {
|
||||
ContentObserver contentObserver = new ContentObserver(handler) { // from class: androidx.emoji2.text.FontRequestEmojiCompatConfig.FontRequestMetadataLoader.1
|
||||
@Override // android.database.ContentObserver
|
||||
public void onChange(boolean z, Uri uri2) {
|
||||
FontRequestMetadataLoader.this.loadInternal();
|
||||
}
|
||||
};
|
||||
this.mObserver = contentObserver;
|
||||
this.mFontProviderHelper.registerObserver(this.mContext, uri, contentObserver);
|
||||
}
|
||||
if (this.mMainHandlerLoadCallback == null) {
|
||||
this.mMainHandlerLoadCallback = new Runnable() { // from class: androidx.emoji2.text.FontRequestEmojiCompatConfig$FontRequestMetadataLoader$$ExternalSyntheticLambda1
|
||||
@Override // java.lang.Runnable
|
||||
public final void run() {
|
||||
FontRequestEmojiCompatConfig.FontRequestMetadataLoader.this.loadInternal();
|
||||
}
|
||||
};
|
||||
}
|
||||
handler.postDelayed(this.mMainHandlerLoadCallback, j);
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanUp() {
|
||||
synchronized (this.mLock) {
|
||||
this.mCallback = null;
|
||||
ContentObserver contentObserver = this.mObserver;
|
||||
if (contentObserver != null) {
|
||||
this.mFontProviderHelper.unregisterObserver(this.mContext, contentObserver);
|
||||
this.mObserver = null;
|
||||
}
|
||||
Handler handler = this.mMainHandler;
|
||||
if (handler != null) {
|
||||
handler.removeCallbacks(this.mMainHandlerLoadCallback);
|
||||
}
|
||||
this.mMainHandler = null;
|
||||
ThreadPoolExecutor threadPoolExecutor = this.mMyThreadPoolExecutor;
|
||||
if (threadPoolExecutor != null) {
|
||||
threadPoolExecutor.shutdown();
|
||||
}
|
||||
this.mExecutor = null;
|
||||
this.mMyThreadPoolExecutor = null;
|
||||
}
|
||||
}
|
||||
|
||||
void createMetadata() {
|
||||
synchronized (this.mLock) {
|
||||
if (this.mCallback == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
FontsContractCompat.FontInfo retrieveFontInfo = retrieveFontInfo();
|
||||
int resultCode = retrieveFontInfo.getResultCode();
|
||||
if (resultCode == 2) {
|
||||
synchronized (this.mLock) {
|
||||
RetryPolicy retryPolicy = this.mRetryPolicy;
|
||||
if (retryPolicy != null) {
|
||||
long retryDelay = retryPolicy.getRetryDelay();
|
||||
if (retryDelay >= 0) {
|
||||
scheduleRetry(retrieveFontInfo.getUri(), retryDelay);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resultCode != 0) {
|
||||
throw new RuntimeException("fetchFonts result is not OK. (" + resultCode + ")");
|
||||
}
|
||||
try {
|
||||
TraceCompat.beginSection(S_TRACE_BUILD_TYPEFACE);
|
||||
Typeface buildTypeface = this.mFontProviderHelper.buildTypeface(this.mContext, retrieveFontInfo);
|
||||
ByteBuffer mmap = TypefaceCompatUtil.mmap(this.mContext, null, retrieveFontInfo.getUri());
|
||||
if (mmap == null || buildTypeface == null) {
|
||||
throw new RuntimeException("Unable to open file.");
|
||||
}
|
||||
MetadataRepo create = MetadataRepo.create(buildTypeface, mmap);
|
||||
TraceCompat.endSection();
|
||||
synchronized (this.mLock) {
|
||||
EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback = this.mCallback;
|
||||
if (metadataRepoLoaderCallback != null) {
|
||||
metadataRepoLoaderCallback.onLoaded(create);
|
||||
}
|
||||
}
|
||||
cleanUp();
|
||||
} catch (Throwable th) {
|
||||
TraceCompat.endSection();
|
||||
throw th;
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
synchronized (this.mLock) {
|
||||
EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback2 = this.mCallback;
|
||||
if (metadataRepoLoaderCallback2 != null) {
|
||||
metadataRepoLoaderCallback2.onFailed(th2);
|
||||
}
|
||||
cleanUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class FontProviderHelper {
|
||||
public FontsContractCompat.FontFamilyResult fetchFonts(Context context, FontRequest fontRequest) throws PackageManager.NameNotFoundException {
|
||||
return FontsContractCompat.fetchFonts(context, null, fontRequest);
|
||||
}
|
||||
|
||||
public Typeface buildTypeface(Context context, FontsContractCompat.FontInfo fontInfo) throws PackageManager.NameNotFoundException {
|
||||
return FontsContractCompat.buildTypeface(context, null, new FontsContractCompat.FontInfo[]{fontInfo});
|
||||
}
|
||||
|
||||
public void registerObserver(Context context, Uri uri, ContentObserver contentObserver) {
|
||||
context.getContentResolver().registerContentObserver(uri, false, contentObserver);
|
||||
}
|
||||
|
||||
public void unregisterObserver(Context context, ContentObserver contentObserver) {
|
||||
context.getContentResolver().unregisterContentObserver(contentObserver);
|
||||
}
|
||||
}
|
||||
}
|
233
02-Easy5/E5/sources/androidx/emoji2/text/MetadataListReader.java
Normal file
233
02-Easy5/E5/sources/androidx/emoji2/text/MetadataListReader.java
Normal file
@ -0,0 +1,233 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import androidx.emoji2.text.flatbuffer.MetadataList;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import kotlin.UShort;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MetadataListReader {
|
||||
private static final int EMJI_TAG = 1164798569;
|
||||
private static final int EMJI_TAG_DEPRECATED = 1701669481;
|
||||
private static final int META_TABLE_NAME = 1835365473;
|
||||
|
||||
private interface OpenTypeReader {
|
||||
public static final int UINT16_BYTE_COUNT = 2;
|
||||
public static final int UINT32_BYTE_COUNT = 4;
|
||||
|
||||
long getPosition();
|
||||
|
||||
int readTag() throws IOException;
|
||||
|
||||
long readUnsignedInt() throws IOException;
|
||||
|
||||
int readUnsignedShort() throws IOException;
|
||||
|
||||
void skip(int i) throws IOException;
|
||||
}
|
||||
|
||||
static long toUnsignedInt(int i) {
|
||||
return i & 4294967295L;
|
||||
}
|
||||
|
||||
static int toUnsignedShort(short s) {
|
||||
return s & UShort.MAX_VALUE;
|
||||
}
|
||||
|
||||
static MetadataList read(InputStream inputStream) throws IOException {
|
||||
InputStreamOpenTypeReader inputStreamOpenTypeReader = new InputStreamOpenTypeReader(inputStream);
|
||||
OffsetInfo findOffsetInfo = findOffsetInfo(inputStreamOpenTypeReader);
|
||||
inputStreamOpenTypeReader.skip((int) (findOffsetInfo.getStartOffset() - inputStreamOpenTypeReader.getPosition()));
|
||||
ByteBuffer allocate = ByteBuffer.allocate((int) findOffsetInfo.getLength());
|
||||
int read = inputStream.read(allocate.array());
|
||||
if (read != findOffsetInfo.getLength()) {
|
||||
throw new IOException("Needed " + findOffsetInfo.getLength() + " bytes, got " + read);
|
||||
}
|
||||
return MetadataList.getRootAsMetadataList(allocate);
|
||||
}
|
||||
|
||||
static MetadataList read(ByteBuffer byteBuffer) throws IOException {
|
||||
ByteBuffer duplicate = byteBuffer.duplicate();
|
||||
duplicate.position((int) findOffsetInfo(new ByteBufferReader(duplicate)).getStartOffset());
|
||||
return MetadataList.getRootAsMetadataList(duplicate);
|
||||
}
|
||||
|
||||
static MetadataList read(AssetManager assetManager, String str) throws IOException {
|
||||
InputStream open = assetManager.open(str);
|
||||
try {
|
||||
MetadataList read = read(open);
|
||||
if (open != null) {
|
||||
open.close();
|
||||
}
|
||||
return read;
|
||||
} catch (Throwable th) {
|
||||
if (open != null) {
|
||||
try {
|
||||
open.close();
|
||||
} catch (Throwable th2) {
|
||||
th.addSuppressed(th2);
|
||||
}
|
||||
}
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
|
||||
private static OffsetInfo findOffsetInfo(OpenTypeReader openTypeReader) throws IOException {
|
||||
long j;
|
||||
openTypeReader.skip(4);
|
||||
int readUnsignedShort = openTypeReader.readUnsignedShort();
|
||||
if (readUnsignedShort > 100) {
|
||||
throw new IOException("Cannot read metadata.");
|
||||
}
|
||||
openTypeReader.skip(6);
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= readUnsignedShort) {
|
||||
j = -1;
|
||||
break;
|
||||
}
|
||||
int readTag = openTypeReader.readTag();
|
||||
openTypeReader.skip(4);
|
||||
j = openTypeReader.readUnsignedInt();
|
||||
openTypeReader.skip(4);
|
||||
if (META_TABLE_NAME == readTag) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (j != -1) {
|
||||
openTypeReader.skip((int) (j - openTypeReader.getPosition()));
|
||||
openTypeReader.skip(12);
|
||||
long readUnsignedInt = openTypeReader.readUnsignedInt();
|
||||
for (int i2 = 0; i2 < readUnsignedInt; i2++) {
|
||||
int readTag2 = openTypeReader.readTag();
|
||||
long readUnsignedInt2 = openTypeReader.readUnsignedInt();
|
||||
long readUnsignedInt3 = openTypeReader.readUnsignedInt();
|
||||
if (EMJI_TAG == readTag2 || EMJI_TAG_DEPRECATED == readTag2) {
|
||||
return new OffsetInfo(readUnsignedInt2 + j, readUnsignedInt3);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new IOException("Cannot read metadata.");
|
||||
}
|
||||
|
||||
private static class OffsetInfo {
|
||||
private final long mLength;
|
||||
private final long mStartOffset;
|
||||
|
||||
long getLength() {
|
||||
return this.mLength;
|
||||
}
|
||||
|
||||
long getStartOffset() {
|
||||
return this.mStartOffset;
|
||||
}
|
||||
|
||||
OffsetInfo(long j, long j2) {
|
||||
this.mStartOffset = j;
|
||||
this.mLength = j2;
|
||||
}
|
||||
}
|
||||
|
||||
private static class InputStreamOpenTypeReader implements OpenTypeReader {
|
||||
private final byte[] mByteArray;
|
||||
private final ByteBuffer mByteBuffer;
|
||||
private final InputStream mInputStream;
|
||||
private long mPosition = 0;
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public long getPosition() {
|
||||
return this.mPosition;
|
||||
}
|
||||
|
||||
InputStreamOpenTypeReader(InputStream inputStream) {
|
||||
this.mInputStream = inputStream;
|
||||
byte[] bArr = new byte[4];
|
||||
this.mByteArray = bArr;
|
||||
ByteBuffer wrap = ByteBuffer.wrap(bArr);
|
||||
this.mByteBuffer = wrap;
|
||||
wrap.order(ByteOrder.BIG_ENDIAN);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public int readUnsignedShort() throws IOException {
|
||||
this.mByteBuffer.position(0);
|
||||
read(2);
|
||||
return MetadataListReader.toUnsignedShort(this.mByteBuffer.getShort());
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public long readUnsignedInt() throws IOException {
|
||||
this.mByteBuffer.position(0);
|
||||
read(4);
|
||||
return MetadataListReader.toUnsignedInt(this.mByteBuffer.getInt());
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public int readTag() throws IOException {
|
||||
this.mByteBuffer.position(0);
|
||||
read(4);
|
||||
return this.mByteBuffer.getInt();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public void skip(int i) throws IOException {
|
||||
while (i > 0) {
|
||||
int skip = (int) this.mInputStream.skip(i);
|
||||
if (skip < 1) {
|
||||
throw new IOException("Skip didn't move at least 1 byte forward");
|
||||
}
|
||||
i -= skip;
|
||||
this.mPosition += skip;
|
||||
}
|
||||
}
|
||||
|
||||
private void read(int i) throws IOException {
|
||||
if (this.mInputStream.read(this.mByteArray, 0, i) != i) {
|
||||
throw new IOException("read failed");
|
||||
}
|
||||
this.mPosition += i;
|
||||
}
|
||||
}
|
||||
|
||||
private static class ByteBufferReader implements OpenTypeReader {
|
||||
private final ByteBuffer mByteBuffer;
|
||||
|
||||
ByteBufferReader(ByteBuffer byteBuffer) {
|
||||
this.mByteBuffer = byteBuffer;
|
||||
byteBuffer.order(ByteOrder.BIG_ENDIAN);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public int readUnsignedShort() throws IOException {
|
||||
return MetadataListReader.toUnsignedShort(this.mByteBuffer.getShort());
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public long readUnsignedInt() throws IOException {
|
||||
return MetadataListReader.toUnsignedInt(this.mByteBuffer.getInt());
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public int readTag() throws IOException {
|
||||
return this.mByteBuffer.getInt();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public void skip(int i) throws IOException {
|
||||
ByteBuffer byteBuffer = this.mByteBuffer;
|
||||
byteBuffer.position(byteBuffer.position() + i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
|
||||
public long getPosition() {
|
||||
return this.mByteBuffer.position();
|
||||
}
|
||||
}
|
||||
|
||||
private MetadataListReader() {
|
||||
}
|
||||
}
|
137
02-Easy5/E5/sources/androidx/emoji2/text/MetadataRepo.java
Normal file
137
02-Easy5/E5/sources/androidx/emoji2/text/MetadataRepo.java
Normal file
@ -0,0 +1,137 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.graphics.Typeface;
|
||||
import android.util.SparseArray;
|
||||
import androidx.core.os.TraceCompat;
|
||||
import androidx.core.util.Preconditions;
|
||||
import androidx.emoji2.text.flatbuffer.MetadataList;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MetadataRepo {
|
||||
private static final int DEFAULT_ROOT_SIZE = 1024;
|
||||
private static final String S_TRACE_CREATE_REPO = "EmojiCompat.MetadataRepo.create";
|
||||
private final char[] mEmojiCharArray;
|
||||
private final MetadataList mMetadataList;
|
||||
private final Node mRootNode = new Node(1024);
|
||||
private final Typeface mTypeface;
|
||||
|
||||
public char[] getEmojiCharArray() {
|
||||
return this.mEmojiCharArray;
|
||||
}
|
||||
|
||||
public MetadataList getMetadataList() {
|
||||
return this.mMetadataList;
|
||||
}
|
||||
|
||||
Node getRootNode() {
|
||||
return this.mRootNode;
|
||||
}
|
||||
|
||||
Typeface getTypeface() {
|
||||
return this.mTypeface;
|
||||
}
|
||||
|
||||
private MetadataRepo(Typeface typeface, MetadataList metadataList) {
|
||||
this.mTypeface = typeface;
|
||||
this.mMetadataList = metadataList;
|
||||
this.mEmojiCharArray = new char[metadataList.listLength() * 2];
|
||||
constructIndex(metadataList);
|
||||
}
|
||||
|
||||
public static MetadataRepo create(Typeface typeface) {
|
||||
try {
|
||||
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
|
||||
return new MetadataRepo(typeface, new MetadataList());
|
||||
} finally {
|
||||
TraceCompat.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
public static MetadataRepo create(Typeface typeface, InputStream inputStream) throws IOException {
|
||||
try {
|
||||
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
|
||||
return new MetadataRepo(typeface, MetadataListReader.read(inputStream));
|
||||
} finally {
|
||||
TraceCompat.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
public static MetadataRepo create(Typeface typeface, ByteBuffer byteBuffer) throws IOException {
|
||||
try {
|
||||
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
|
||||
return new MetadataRepo(typeface, MetadataListReader.read(byteBuffer));
|
||||
} finally {
|
||||
TraceCompat.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
public static MetadataRepo create(AssetManager assetManager, String str) throws IOException {
|
||||
try {
|
||||
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
|
||||
return new MetadataRepo(Typeface.createFromAsset(assetManager, str), MetadataListReader.read(assetManager, str));
|
||||
} finally {
|
||||
TraceCompat.endSection();
|
||||
}
|
||||
}
|
||||
|
||||
private void constructIndex(MetadataList metadataList) {
|
||||
int listLength = metadataList.listLength();
|
||||
for (int i = 0; i < listLength; i++) {
|
||||
EmojiMetadata emojiMetadata = new EmojiMetadata(this, i);
|
||||
Character.toChars(emojiMetadata.getId(), this.mEmojiCharArray, i * 2);
|
||||
put(emojiMetadata);
|
||||
}
|
||||
}
|
||||
|
||||
int getMetadataVersion() {
|
||||
return this.mMetadataList.version();
|
||||
}
|
||||
|
||||
void put(EmojiMetadata emojiMetadata) {
|
||||
Preconditions.checkNotNull(emojiMetadata, "emoji metadata cannot be null");
|
||||
Preconditions.checkArgument(emojiMetadata.getCodepointsLength() > 0, "invalid metadata codepoint length");
|
||||
this.mRootNode.put(emojiMetadata, 0, emojiMetadata.getCodepointsLength() - 1);
|
||||
}
|
||||
|
||||
static class Node {
|
||||
private final SparseArray<Node> mChildren;
|
||||
private EmojiMetadata mData;
|
||||
|
||||
final EmojiMetadata getData() {
|
||||
return this.mData;
|
||||
}
|
||||
|
||||
private Node() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
Node(int i) {
|
||||
this.mChildren = new SparseArray<>(i);
|
||||
}
|
||||
|
||||
Node get(int i) {
|
||||
SparseArray<Node> sparseArray = this.mChildren;
|
||||
if (sparseArray == null) {
|
||||
return null;
|
||||
}
|
||||
return sparseArray.get(i);
|
||||
}
|
||||
|
||||
void put(EmojiMetadata emojiMetadata, int i, int i2) {
|
||||
Node node = get(emojiMetadata.getCodepointAt(i));
|
||||
if (node == null) {
|
||||
node = new Node();
|
||||
this.mChildren.put(emojiMetadata.getCodepointAt(i), node);
|
||||
}
|
||||
if (i2 > i) {
|
||||
node.put(emojiMetadata, i + 1, i2);
|
||||
} else {
|
||||
node.mData = emojiMetadata;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
298
02-Easy5/E5/sources/androidx/emoji2/text/SpannableBuilder.java
Normal file
298
02-Easy5/E5/sources/androidx/emoji2/text/SpannableBuilder.java
Normal file
@ -0,0 +1,298 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.Editable;
|
||||
import android.text.SpanWatcher;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextWatcher;
|
||||
import androidx.core.util.Preconditions;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class SpannableBuilder extends SpannableStringBuilder {
|
||||
private final Class<?> mWatcherClass;
|
||||
private final List<WatcherWrapper> mWatchers;
|
||||
|
||||
private boolean isWatcher(Class<?> cls) {
|
||||
return this.mWatcherClass == cls;
|
||||
}
|
||||
|
||||
SpannableBuilder(Class<?> cls) {
|
||||
this.mWatchers = new ArrayList();
|
||||
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
|
||||
this.mWatcherClass = cls;
|
||||
}
|
||||
|
||||
SpannableBuilder(Class<?> cls, CharSequence charSequence) {
|
||||
super(charSequence);
|
||||
this.mWatchers = new ArrayList();
|
||||
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
|
||||
this.mWatcherClass = cls;
|
||||
}
|
||||
|
||||
SpannableBuilder(Class<?> cls, CharSequence charSequence, int i, int i2) {
|
||||
super(charSequence, i, i2);
|
||||
this.mWatchers = new ArrayList();
|
||||
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
|
||||
this.mWatcherClass = cls;
|
||||
}
|
||||
|
||||
public static SpannableBuilder create(Class<?> cls, CharSequence charSequence) {
|
||||
return new SpannableBuilder(cls, charSequence);
|
||||
}
|
||||
|
||||
private boolean isWatcher(Object obj) {
|
||||
return obj != null && isWatcher(obj.getClass());
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, java.lang.CharSequence
|
||||
public CharSequence subSequence(int i, int i2) {
|
||||
return new SpannableBuilder(this.mWatcherClass, this, i, i2);
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spannable
|
||||
public void setSpan(Object obj, int i, int i2, int i3) {
|
||||
if (isWatcher(obj)) {
|
||||
WatcherWrapper watcherWrapper = new WatcherWrapper(obj);
|
||||
this.mWatchers.add(watcherWrapper);
|
||||
obj = watcherWrapper;
|
||||
}
|
||||
super.setSpan(obj, i, i2, i3);
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spanned
|
||||
public <T> T[] getSpans(int i, int i2, Class<T> cls) {
|
||||
if (isWatcher((Class<?>) cls)) {
|
||||
WatcherWrapper[] watcherWrapperArr = (WatcherWrapper[]) super.getSpans(i, i2, WatcherWrapper.class);
|
||||
T[] tArr = (T[]) ((Object[]) Array.newInstance((Class<?>) cls, watcherWrapperArr.length));
|
||||
for (int i3 = 0; i3 < watcherWrapperArr.length; i3++) {
|
||||
tArr[i3] = watcherWrapperArr[i3].mObject;
|
||||
}
|
||||
return tArr;
|
||||
}
|
||||
return (T[]) super.getSpans(i, i2, cls);
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spannable
|
||||
public void removeSpan(Object obj) {
|
||||
WatcherWrapper watcherWrapper;
|
||||
if (isWatcher(obj)) {
|
||||
watcherWrapper = getWatcherFor(obj);
|
||||
if (watcherWrapper != null) {
|
||||
obj = watcherWrapper;
|
||||
}
|
||||
} else {
|
||||
watcherWrapper = null;
|
||||
}
|
||||
super.removeSpan(obj);
|
||||
if (watcherWrapper != null) {
|
||||
this.mWatchers.remove(watcherWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spanned
|
||||
public int getSpanStart(Object obj) {
|
||||
WatcherWrapper watcherFor;
|
||||
if (isWatcher(obj) && (watcherFor = getWatcherFor(obj)) != null) {
|
||||
obj = watcherFor;
|
||||
}
|
||||
return super.getSpanStart(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spanned
|
||||
public int getSpanEnd(Object obj) {
|
||||
WatcherWrapper watcherFor;
|
||||
if (isWatcher(obj) && (watcherFor = getWatcherFor(obj)) != null) {
|
||||
obj = watcherFor;
|
||||
}
|
||||
return super.getSpanEnd(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spanned
|
||||
public int getSpanFlags(Object obj) {
|
||||
WatcherWrapper watcherFor;
|
||||
if (isWatcher(obj) && (watcherFor = getWatcherFor(obj)) != null) {
|
||||
obj = watcherFor;
|
||||
}
|
||||
return super.getSpanFlags(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Spanned
|
||||
public int nextSpanTransition(int i, int i2, Class cls) {
|
||||
if (cls == null || isWatcher((Class<?>) cls)) {
|
||||
cls = WatcherWrapper.class;
|
||||
}
|
||||
return super.nextSpanTransition(i, i2, cls);
|
||||
}
|
||||
|
||||
private WatcherWrapper getWatcherFor(Object obj) {
|
||||
for (int i = 0; i < this.mWatchers.size(); i++) {
|
||||
WatcherWrapper watcherWrapper = this.mWatchers.get(i);
|
||||
if (watcherWrapper.mObject == obj) {
|
||||
return watcherWrapper;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void beginBatchEdit() {
|
||||
blockWatchers();
|
||||
}
|
||||
|
||||
public void endBatchEdit() {
|
||||
unblockwatchers();
|
||||
fireWatchers();
|
||||
}
|
||||
|
||||
private void blockWatchers() {
|
||||
for (int i = 0; i < this.mWatchers.size(); i++) {
|
||||
this.mWatchers.get(i).blockCalls();
|
||||
}
|
||||
}
|
||||
|
||||
private void unblockwatchers() {
|
||||
for (int i = 0; i < this.mWatchers.size(); i++) {
|
||||
this.mWatchers.get(i).unblockCalls();
|
||||
}
|
||||
}
|
||||
|
||||
private void fireWatchers() {
|
||||
for (int i = 0; i < this.mWatchers.size(); i++) {
|
||||
this.mWatchers.get(i).onTextChanged(this, 0, length(), length());
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable
|
||||
public SpannableStringBuilder replace(int i, int i2, CharSequence charSequence) {
|
||||
blockWatchers();
|
||||
super.replace(i, i2, charSequence);
|
||||
unblockwatchers();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable
|
||||
public SpannableStringBuilder replace(int i, int i2, CharSequence charSequence, int i3, int i4) {
|
||||
blockWatchers();
|
||||
super.replace(i, i2, charSequence, i3, i4);
|
||||
unblockwatchers();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable
|
||||
public SpannableStringBuilder insert(int i, CharSequence charSequence) {
|
||||
super.insert(i, charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable
|
||||
public SpannableStringBuilder insert(int i, CharSequence charSequence, int i2, int i3) {
|
||||
super.insert(i, charSequence, i2, i3);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable
|
||||
public SpannableStringBuilder delete(int i, int i2) {
|
||||
super.delete(i, i2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
|
||||
public SpannableStringBuilder append(CharSequence charSequence) {
|
||||
super.append(charSequence);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
|
||||
public SpannableStringBuilder append(char c) {
|
||||
super.append(c);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
|
||||
public SpannableStringBuilder append(CharSequence charSequence, int i, int i2) {
|
||||
super.append(charSequence, i, i2);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // android.text.SpannableStringBuilder
|
||||
public SpannableStringBuilder append(CharSequence charSequence, Object obj, int i) {
|
||||
super.append(charSequence, obj, i);
|
||||
return this;
|
||||
}
|
||||
|
||||
private static class WatcherWrapper implements TextWatcher, SpanWatcher {
|
||||
private final AtomicInteger mBlockCalls = new AtomicInteger(0);
|
||||
final Object mObject;
|
||||
|
||||
WatcherWrapper(Object obj) {
|
||||
this.mObject = obj;
|
||||
}
|
||||
|
||||
@Override // android.text.TextWatcher
|
||||
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
((TextWatcher) this.mObject).beforeTextChanged(charSequence, i, i2, i3);
|
||||
}
|
||||
|
||||
@Override // android.text.TextWatcher
|
||||
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
||||
((TextWatcher) this.mObject).onTextChanged(charSequence, i, i2, i3);
|
||||
}
|
||||
|
||||
@Override // android.text.TextWatcher
|
||||
public void afterTextChanged(Editable editable) {
|
||||
((TextWatcher) this.mObject).afterTextChanged(editable);
|
||||
}
|
||||
|
||||
@Override // android.text.SpanWatcher
|
||||
public void onSpanAdded(Spannable spannable, Object obj, int i, int i2) {
|
||||
if (this.mBlockCalls.get() <= 0 || !isEmojiSpan(obj)) {
|
||||
((SpanWatcher) this.mObject).onSpanAdded(spannable, obj, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.text.SpanWatcher
|
||||
public void onSpanRemoved(Spannable spannable, Object obj, int i, int i2) {
|
||||
if (this.mBlockCalls.get() <= 0 || !isEmojiSpan(obj)) {
|
||||
((SpanWatcher) this.mObject).onSpanRemoved(spannable, obj, i, i2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.text.SpanWatcher
|
||||
public void onSpanChanged(Spannable spannable, Object obj, int i, int i2, int i3, int i4) {
|
||||
int i5;
|
||||
int i6;
|
||||
if (this.mBlockCalls.get() <= 0 || !isEmojiSpan(obj)) {
|
||||
if (Build.VERSION.SDK_INT < 28) {
|
||||
if (i > i2) {
|
||||
i = 0;
|
||||
}
|
||||
if (i3 > i4) {
|
||||
i5 = i;
|
||||
i6 = 0;
|
||||
((SpanWatcher) this.mObject).onSpanChanged(spannable, obj, i5, i2, i6, i4);
|
||||
}
|
||||
}
|
||||
i5 = i;
|
||||
i6 = i3;
|
||||
((SpanWatcher) this.mObject).onSpanChanged(spannable, obj, i5, i2, i6, i4);
|
||||
}
|
||||
}
|
||||
|
||||
final void blockCalls() {
|
||||
this.mBlockCalls.incrementAndGet();
|
||||
}
|
||||
|
||||
final void unblockCalls() {
|
||||
this.mBlockCalls.decrementAndGet();
|
||||
}
|
||||
|
||||
private boolean isEmojiSpan(Object obj) {
|
||||
return obj instanceof EmojiSpan;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.text.TextPaint;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class TypefaceEmojiSpan extends EmojiSpan {
|
||||
private static Paint sDebugPaint;
|
||||
|
||||
public TypefaceEmojiSpan(EmojiMetadata emojiMetadata) {
|
||||
super(emojiMetadata);
|
||||
}
|
||||
|
||||
@Override // android.text.style.ReplacementSpan
|
||||
public void draw(Canvas canvas, CharSequence charSequence, int i, int i2, float f, int i3, int i4, int i5, Paint paint) {
|
||||
if (EmojiCompat.get().isEmojiSpanIndicatorEnabled()) {
|
||||
canvas.drawRect(f, i3, f + getWidth(), i5, getDebugPaint());
|
||||
}
|
||||
getMetadata().draw(canvas, f, i4, paint);
|
||||
}
|
||||
|
||||
private static Paint getDebugPaint() {
|
||||
if (sDebugPaint == null) {
|
||||
TextPaint textPaint = new TextPaint();
|
||||
sDebugPaint = textPaint;
|
||||
textPaint.setColor(EmojiCompat.get().getEmojiSpanIndicatorColor());
|
||||
sDebugPaint.setStyle(Paint.Style.FILL);
|
||||
}
|
||||
return sDebugPaint;
|
||||
}
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package androidx.emoji2.text;
|
||||
|
||||
import android.os.Build;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import androidx.core.graphics.ColorKt$$ExternalSyntheticApiModelOutline0;
|
||||
import androidx.core.text.PrecomputedTextCompat;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class UnprecomputeTextOnModificationSpannable implements Spannable {
|
||||
private Spannable mDelegate;
|
||||
private boolean mSafeToWrite = false;
|
||||
|
||||
Spannable getUnwrappedSpannable() {
|
||||
return this.mDelegate;
|
||||
}
|
||||
|
||||
UnprecomputeTextOnModificationSpannable(Spannable spannable) {
|
||||
this.mDelegate = spannable;
|
||||
}
|
||||
|
||||
UnprecomputeTextOnModificationSpannable(Spanned spanned) {
|
||||
this.mDelegate = new SpannableString(spanned);
|
||||
}
|
||||
|
||||
UnprecomputeTextOnModificationSpannable(CharSequence charSequence) {
|
||||
this.mDelegate = new SpannableString(charSequence);
|
||||
}
|
||||
|
||||
private void ensureSafeWrites() {
|
||||
Spannable spannable = this.mDelegate;
|
||||
if (!this.mSafeToWrite && precomputedTextDetector().isPrecomputedText(spannable)) {
|
||||
this.mDelegate = new SpannableString(spannable);
|
||||
}
|
||||
this.mSafeToWrite = true;
|
||||
}
|
||||
|
||||
@Override // android.text.Spannable
|
||||
public void setSpan(Object obj, int i, int i2, int i3) {
|
||||
ensureSafeWrites();
|
||||
this.mDelegate.setSpan(obj, i, i2, i3);
|
||||
}
|
||||
|
||||
@Override // android.text.Spannable
|
||||
public void removeSpan(Object obj) {
|
||||
ensureSafeWrites();
|
||||
this.mDelegate.removeSpan(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.Spanned
|
||||
public <T> T[] getSpans(int i, int i2, Class<T> cls) {
|
||||
return (T[]) this.mDelegate.getSpans(i, i2, cls);
|
||||
}
|
||||
|
||||
@Override // android.text.Spanned
|
||||
public int getSpanStart(Object obj) {
|
||||
return this.mDelegate.getSpanStart(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.Spanned
|
||||
public int getSpanEnd(Object obj) {
|
||||
return this.mDelegate.getSpanEnd(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.Spanned
|
||||
public int getSpanFlags(Object obj) {
|
||||
return this.mDelegate.getSpanFlags(obj);
|
||||
}
|
||||
|
||||
@Override // android.text.Spanned
|
||||
public int nextSpanTransition(int i, int i2, Class cls) {
|
||||
return this.mDelegate.nextSpanTransition(i, i2, cls);
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public int length() {
|
||||
return this.mDelegate.length();
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public char charAt(int i) {
|
||||
return this.mDelegate.charAt(i);
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public CharSequence subSequence(int i, int i2) {
|
||||
return this.mDelegate.subSequence(i, i2);
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public String toString() {
|
||||
return this.mDelegate.toString();
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public IntStream chars() {
|
||||
return CharSequenceHelper_API24.chars(this.mDelegate);
|
||||
}
|
||||
|
||||
@Override // java.lang.CharSequence
|
||||
public IntStream codePoints() {
|
||||
return CharSequenceHelper_API24.codePoints(this.mDelegate);
|
||||
}
|
||||
|
||||
private static class CharSequenceHelper_API24 {
|
||||
private CharSequenceHelper_API24() {
|
||||
}
|
||||
|
||||
static IntStream codePoints(CharSequence charSequence) {
|
||||
IntStream codePoints;
|
||||
codePoints = charSequence.codePoints();
|
||||
return codePoints;
|
||||
}
|
||||
|
||||
static IntStream chars(CharSequence charSequence) {
|
||||
IntStream chars;
|
||||
chars = charSequence.chars();
|
||||
return chars;
|
||||
}
|
||||
}
|
||||
|
||||
static PrecomputedTextDetector precomputedTextDetector() {
|
||||
return Build.VERSION.SDK_INT < 28 ? new PrecomputedTextDetector() : new PrecomputedTextDetector_28();
|
||||
}
|
||||
|
||||
static class PrecomputedTextDetector {
|
||||
PrecomputedTextDetector() {
|
||||
}
|
||||
|
||||
boolean isPrecomputedText(CharSequence charSequence) {
|
||||
return charSequence instanceof PrecomputedTextCompat;
|
||||
}
|
||||
}
|
||||
|
||||
static class PrecomputedTextDetector_28 extends PrecomputedTextDetector {
|
||||
PrecomputedTextDetector_28() {
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.UnprecomputeTextOnModificationSpannable.PrecomputedTextDetector
|
||||
boolean isPrecomputedText(CharSequence charSequence) {
|
||||
return ColorKt$$ExternalSyntheticApiModelOutline0.m109m((Object) charSequence) || (charSequence instanceof PrecomputedTextCompat);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,225 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import kotlin.UByte;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ArrayReadWriteBuf implements ReadWriteBuf {
|
||||
private byte[] buffer;
|
||||
private int writePos;
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public byte[] data() {
|
||||
return this.buffer;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf, androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public int limit() {
|
||||
return this.writePos;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public int writePosition() {
|
||||
return this.writePos;
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf() {
|
||||
this(10);
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(int i) {
|
||||
this(new byte[i]);
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(byte[] bArr) {
|
||||
this.buffer = bArr;
|
||||
this.writePos = 0;
|
||||
}
|
||||
|
||||
public ArrayReadWriteBuf(byte[] bArr, int i) {
|
||||
this.buffer = bArr;
|
||||
this.writePos = i;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public boolean getBoolean(int i) {
|
||||
return this.buffer[i] != 0;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public byte get(int i) {
|
||||
return this.buffer[i];
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public short getShort(int i) {
|
||||
byte[] bArr = this.buffer;
|
||||
return (short) ((bArr[i] & UByte.MAX_VALUE) | (bArr[i + 1] << 8));
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public int getInt(int i) {
|
||||
byte[] bArr = this.buffer;
|
||||
return (bArr[i] & UByte.MAX_VALUE) | (bArr[i + 3] << 24) | ((bArr[i + 2] & UByte.MAX_VALUE) << 16) | ((bArr[i + 1] & UByte.MAX_VALUE) << 8);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public long getLong(int i) {
|
||||
byte[] bArr = this.buffer;
|
||||
int i2 = i + 6;
|
||||
return (bArr[i] & 255) | ((bArr[i + 1] & 255) << 8) | ((bArr[i + 2] & 255) << 16) | ((bArr[i + 3] & 255) << 24) | ((bArr[i + 4] & 255) << 32) | ((bArr[i + 5] & 255) << 40) | ((bArr[i2] & 255) << 48) | (bArr[i + 7] << 56);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public float getFloat(int i) {
|
||||
return Float.intBitsToFloat(getInt(i));
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public double getDouble(int i) {
|
||||
return Double.longBitsToDouble(getLong(i));
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public String getString(int i, int i2) {
|
||||
return Utf8Safe.decodeUtf8Array(this.buffer, i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putBoolean(boolean z) {
|
||||
setBoolean(this.writePos, z);
|
||||
this.writePos++;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void put(byte[] bArr, int i, int i2) {
|
||||
set(this.writePos, bArr, i, i2);
|
||||
this.writePos += i2;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void put(byte b) {
|
||||
set(this.writePos, b);
|
||||
this.writePos++;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putShort(short s) {
|
||||
setShort(this.writePos, s);
|
||||
this.writePos += 2;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putInt(int i) {
|
||||
setInt(this.writePos, i);
|
||||
this.writePos += 4;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putLong(long j) {
|
||||
setLong(this.writePos, j);
|
||||
this.writePos += 8;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putFloat(float f) {
|
||||
setFloat(this.writePos, f);
|
||||
this.writePos += 4;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putDouble(double d) {
|
||||
setDouble(this.writePos, d);
|
||||
this.writePos += 8;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setBoolean(int i, boolean z) {
|
||||
set(i, z ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void set(int i, byte b) {
|
||||
requestCapacity(i + 1);
|
||||
this.buffer[i] = b;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void set(int i, byte[] bArr, int i2, int i3) {
|
||||
requestCapacity((i3 - i2) + i);
|
||||
System.arraycopy(bArr, i2, this.buffer, i, i3);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setShort(int i, short s) {
|
||||
requestCapacity(i + 2);
|
||||
byte[] bArr = this.buffer;
|
||||
bArr[i] = (byte) (s & 255);
|
||||
bArr[i + 1] = (byte) ((s >> 8) & 255);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setInt(int i, int i2) {
|
||||
requestCapacity(i + 4);
|
||||
byte[] bArr = this.buffer;
|
||||
bArr[i] = (byte) (i2 & 255);
|
||||
bArr[i + 1] = (byte) ((i2 >> 8) & 255);
|
||||
bArr[i + 2] = (byte) ((i2 >> 16) & 255);
|
||||
bArr[i + 3] = (byte) ((i2 >> 24) & 255);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setLong(int i, long j) {
|
||||
requestCapacity(i + 8);
|
||||
int i2 = (int) j;
|
||||
byte[] bArr = this.buffer;
|
||||
bArr[i] = (byte) (i2 & 255);
|
||||
bArr[i + 1] = (byte) ((i2 >> 8) & 255);
|
||||
bArr[i + 2] = (byte) ((i2 >> 16) & 255);
|
||||
bArr[i + 3] = (byte) ((i2 >> 24) & 255);
|
||||
int i3 = (int) (j >> 32);
|
||||
bArr[i + 4] = (byte) (i3 & 255);
|
||||
bArr[i + 5] = (byte) ((i3 >> 8) & 255);
|
||||
bArr[i + 6] = (byte) ((i3 >> 16) & 255);
|
||||
bArr[i + 7] = (byte) ((i3 >> 24) & 255);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setFloat(int i, float f) {
|
||||
requestCapacity(i + 4);
|
||||
int floatToRawIntBits = Float.floatToRawIntBits(f);
|
||||
byte[] bArr = this.buffer;
|
||||
bArr[i] = (byte) (floatToRawIntBits & 255);
|
||||
bArr[i + 1] = (byte) ((floatToRawIntBits >> 8) & 255);
|
||||
bArr[i + 2] = (byte) ((floatToRawIntBits >> 16) & 255);
|
||||
bArr[i + 3] = (byte) ((floatToRawIntBits >> 24) & 255);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setDouble(int i, double d) {
|
||||
requestCapacity(i + 8);
|
||||
long doubleToRawLongBits = Double.doubleToRawLongBits(d);
|
||||
int i2 = (int) doubleToRawLongBits;
|
||||
byte[] bArr = this.buffer;
|
||||
bArr[i] = (byte) (i2 & 255);
|
||||
bArr[i + 1] = (byte) ((i2 >> 8) & 255);
|
||||
bArr[i + 2] = (byte) ((i2 >> 16) & 255);
|
||||
bArr[i + 3] = (byte) ((i2 >> 24) & 255);
|
||||
int i3 = (int) (doubleToRawLongBits >> 32);
|
||||
bArr[i + 4] = (byte) (i3 & 255);
|
||||
bArr[i + 5] = (byte) ((i3 >> 8) & 255);
|
||||
bArr[i + 6] = (byte) ((i3 >> 16) & 255);
|
||||
bArr[i + 7] = (byte) ((i3 >> 24) & 255);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public boolean requestCapacity(int i) {
|
||||
byte[] bArr = this.buffer;
|
||||
if (bArr.length > i) {
|
||||
return true;
|
||||
}
|
||||
int length = bArr.length;
|
||||
this.buffer = Arrays.copyOf(bArr, length + (length >> 1));
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class BaseVector {
|
||||
protected ByteBuffer bb;
|
||||
private int element_size;
|
||||
private int length;
|
||||
private int vector;
|
||||
|
||||
protected int __element(int i) {
|
||||
return this.vector + (i * this.element_size);
|
||||
}
|
||||
|
||||
protected int __vector() {
|
||||
return this.vector;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
protected void __reset(int i, int i2, ByteBuffer byteBuffer) {
|
||||
this.bb = byteBuffer;
|
||||
if (byteBuffer != null) {
|
||||
this.vector = i;
|
||||
this.length = byteBuffer.getInt(i - 4);
|
||||
this.element_size = i2;
|
||||
} else {
|
||||
this.vector = 0;
|
||||
this.length = 0;
|
||||
this.element_size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
__reset(0, 0, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class BooleanVector extends BaseVector {
|
||||
public BooleanVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 1, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean get(int i) {
|
||||
return this.bb.get(__element(i)) != 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ByteBufferReadWriteBuf implements ReadWriteBuf {
|
||||
private final ByteBuffer buffer;
|
||||
|
||||
public ByteBufferReadWriteBuf(ByteBuffer byteBuffer) {
|
||||
this.buffer = byteBuffer;
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public boolean getBoolean(int i) {
|
||||
return get(i) != 0;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public byte get(int i) {
|
||||
return this.buffer.get(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public short getShort(int i) {
|
||||
return this.buffer.getShort(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public int getInt(int i) {
|
||||
return this.buffer.getInt(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public long getLong(int i) {
|
||||
return this.buffer.getLong(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public float getFloat(int i) {
|
||||
return this.buffer.getFloat(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public double getDouble(int i) {
|
||||
return this.buffer.getDouble(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public String getString(int i, int i2) {
|
||||
return Utf8Safe.decodeUtf8Buffer(this.buffer, i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public byte[] data() {
|
||||
return this.buffer.array();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putBoolean(boolean z) {
|
||||
this.buffer.put(z ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void put(byte[] bArr, int i, int i2) {
|
||||
this.buffer.put(bArr, i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void put(byte b) {
|
||||
this.buffer.put(b);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putShort(short s) {
|
||||
this.buffer.putShort(s);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putInt(int i) {
|
||||
this.buffer.putInt(i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putLong(long j) {
|
||||
this.buffer.putLong(j);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putFloat(float f) {
|
||||
this.buffer.putFloat(f);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void putDouble(double d) {
|
||||
this.buffer.putDouble(d);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setBoolean(int i, boolean z) {
|
||||
set(i, z ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void set(int i, byte b) {
|
||||
requestCapacity(i + 1);
|
||||
this.buffer.put(i, b);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void set(int i, byte[] bArr, int i2, int i3) {
|
||||
requestCapacity((i3 - i2) + i);
|
||||
int position = this.buffer.position();
|
||||
this.buffer.position(i);
|
||||
this.buffer.put(bArr, i2, i3);
|
||||
this.buffer.position(position);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setShort(int i, short s) {
|
||||
requestCapacity(i + 2);
|
||||
this.buffer.putShort(i, s);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setInt(int i, int i2) {
|
||||
requestCapacity(i + 4);
|
||||
this.buffer.putInt(i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setLong(int i, long j) {
|
||||
requestCapacity(i + 8);
|
||||
this.buffer.putLong(i, j);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setFloat(int i, float f) {
|
||||
requestCapacity(i + 4);
|
||||
this.buffer.putFloat(i, f);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public void setDouble(int i, double d) {
|
||||
requestCapacity(i + 8);
|
||||
this.buffer.putDouble(i, d);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public int writePosition() {
|
||||
return this.buffer.position();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf, androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
public int limit() {
|
||||
return this.buffer.limit();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadWriteBuf
|
||||
public boolean requestCapacity(int i) {
|
||||
return i <= this.buffer.limit();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class ByteBufferUtil {
|
||||
public static int getSizePrefix(ByteBuffer byteBuffer) {
|
||||
return byteBuffer.getInt(byteBuffer.position());
|
||||
}
|
||||
|
||||
public static ByteBuffer removeSizePrefix(ByteBuffer byteBuffer) {
|
||||
ByteBuffer duplicate = byteBuffer.duplicate();
|
||||
duplicate.position(duplicate.position() + 4);
|
||||
return duplicate;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import kotlin.UByte;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ByteVector extends BaseVector {
|
||||
public ByteVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 1, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public byte get(int i) {
|
||||
return this.bb.get(__element(i));
|
||||
}
|
||||
|
||||
public int getAsUnsigned(int i) {
|
||||
return get(i) & UByte.MAX_VALUE;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Constants {
|
||||
static final int FILE_IDENTIFIER_LENGTH = 4;
|
||||
static final int SIZEOF_BYTE = 1;
|
||||
static final int SIZEOF_DOUBLE = 8;
|
||||
static final int SIZEOF_FLOAT = 4;
|
||||
static final int SIZEOF_INT = 4;
|
||||
static final int SIZEOF_LONG = 8;
|
||||
static final int SIZEOF_SHORT = 2;
|
||||
public static final int SIZE_PREFIX_LENGTH = 4;
|
||||
|
||||
public static void FLATBUFFERS_1_12_0() {
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class DoubleVector extends BaseVector {
|
||||
public DoubleVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 8, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public double get(int i) {
|
||||
return this.bb.getDouble(__element(i));
|
||||
}
|
||||
}
|
@ -0,0 +1,615 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.BufferUnderflowException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import kotlin.UByte;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FlatBufferBuilder {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
ByteBuffer bb;
|
||||
ByteBufferFactory bb_factory;
|
||||
boolean finished;
|
||||
boolean force_defaults;
|
||||
int minalign;
|
||||
boolean nested;
|
||||
int num_vtables;
|
||||
int object_start;
|
||||
int space;
|
||||
final Utf8 utf8;
|
||||
int vector_num_elems;
|
||||
int[] vtable;
|
||||
int vtable_in_use;
|
||||
int[] vtables;
|
||||
|
||||
public static abstract class ByteBufferFactory {
|
||||
public abstract ByteBuffer newByteBuffer(int i);
|
||||
|
||||
public void releaseByteBuffer(ByteBuffer byteBuffer) {
|
||||
}
|
||||
}
|
||||
|
||||
public FlatBufferBuilder forceDefaults(boolean z) {
|
||||
this.force_defaults = z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FlatBufferBuilder(int i, ByteBufferFactory byteBufferFactory) {
|
||||
this(i, byteBufferFactory, null, Utf8.getDefault());
|
||||
}
|
||||
|
||||
public FlatBufferBuilder(int i, ByteBufferFactory byteBufferFactory, ByteBuffer byteBuffer, Utf8 utf8) {
|
||||
this.minalign = 1;
|
||||
this.vtable = null;
|
||||
this.vtable_in_use = 0;
|
||||
this.nested = false;
|
||||
this.finished = false;
|
||||
this.vtables = new int[16];
|
||||
this.num_vtables = 0;
|
||||
this.vector_num_elems = 0;
|
||||
this.force_defaults = false;
|
||||
i = i <= 0 ? 1 : i;
|
||||
this.bb_factory = byteBufferFactory;
|
||||
if (byteBuffer != null) {
|
||||
this.bb = byteBuffer;
|
||||
byteBuffer.clear();
|
||||
this.bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
} else {
|
||||
this.bb = byteBufferFactory.newByteBuffer(i);
|
||||
}
|
||||
this.utf8 = utf8;
|
||||
this.space = this.bb.capacity();
|
||||
}
|
||||
|
||||
public FlatBufferBuilder(int i) {
|
||||
this(i, HeapByteBufferFactory.INSTANCE, null, Utf8.getDefault());
|
||||
}
|
||||
|
||||
public FlatBufferBuilder() {
|
||||
this(1024);
|
||||
}
|
||||
|
||||
public FlatBufferBuilder(ByteBuffer byteBuffer, ByteBufferFactory byteBufferFactory) {
|
||||
this(byteBuffer.capacity(), byteBufferFactory, byteBuffer, Utf8.getDefault());
|
||||
}
|
||||
|
||||
public FlatBufferBuilder(ByteBuffer byteBuffer) {
|
||||
this(byteBuffer, new HeapByteBufferFactory());
|
||||
}
|
||||
|
||||
public FlatBufferBuilder init(ByteBuffer byteBuffer, ByteBufferFactory byteBufferFactory) {
|
||||
this.bb_factory = byteBufferFactory;
|
||||
this.bb = byteBuffer;
|
||||
byteBuffer.clear();
|
||||
this.bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
this.minalign = 1;
|
||||
this.space = this.bb.capacity();
|
||||
this.vtable_in_use = 0;
|
||||
this.nested = false;
|
||||
this.finished = false;
|
||||
this.object_start = 0;
|
||||
this.num_vtables = 0;
|
||||
this.vector_num_elems = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static final class HeapByteBufferFactory extends ByteBufferFactory {
|
||||
public static final HeapByteBufferFactory INSTANCE = new HeapByteBufferFactory();
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlatBufferBuilder.ByteBufferFactory
|
||||
public ByteBuffer newByteBuffer(int i) {
|
||||
return ByteBuffer.allocate(i).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFieldPresent(Table table, int i) {
|
||||
return table.__offset(i) != 0;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.space = this.bb.capacity();
|
||||
this.bb.clear();
|
||||
this.minalign = 1;
|
||||
while (true) {
|
||||
int i = this.vtable_in_use;
|
||||
if (i <= 0) {
|
||||
this.vtable_in_use = 0;
|
||||
this.nested = false;
|
||||
this.finished = false;
|
||||
this.object_start = 0;
|
||||
this.num_vtables = 0;
|
||||
this.vector_num_elems = 0;
|
||||
return;
|
||||
}
|
||||
int[] iArr = this.vtable;
|
||||
int i2 = i - 1;
|
||||
this.vtable_in_use = i2;
|
||||
iArr[i2] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static ByteBuffer growByteBuffer(ByteBuffer byteBuffer, ByteBufferFactory byteBufferFactory) {
|
||||
int capacity = byteBuffer.capacity();
|
||||
if (((-1073741824) & capacity) != 0) {
|
||||
throw new AssertionError("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
|
||||
}
|
||||
int i = capacity == 0 ? 1 : capacity << 1;
|
||||
byteBuffer.position(0);
|
||||
ByteBuffer newByteBuffer = byteBufferFactory.newByteBuffer(i);
|
||||
newByteBuffer.position(newByteBuffer.clear().capacity() - capacity);
|
||||
newByteBuffer.put(byteBuffer);
|
||||
return newByteBuffer;
|
||||
}
|
||||
|
||||
public int offset() {
|
||||
return this.bb.capacity() - this.space;
|
||||
}
|
||||
|
||||
public void pad(int i) {
|
||||
for (int i2 = 0; i2 < i; i2++) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i3 = this.space - 1;
|
||||
this.space = i3;
|
||||
byteBuffer.put(i3, (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void prep(int i, int i2) {
|
||||
if (i > this.minalign) {
|
||||
this.minalign = i;
|
||||
}
|
||||
int i3 = ((~((this.bb.capacity() - this.space) + i2)) + 1) & (i - 1);
|
||||
while (this.space < i3 + i + i2) {
|
||||
int capacity = this.bb.capacity();
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
ByteBuffer growByteBuffer = growByteBuffer(byteBuffer, this.bb_factory);
|
||||
this.bb = growByteBuffer;
|
||||
if (byteBuffer != growByteBuffer) {
|
||||
this.bb_factory.releaseByteBuffer(byteBuffer);
|
||||
}
|
||||
this.space += this.bb.capacity() - capacity;
|
||||
}
|
||||
pad(i3);
|
||||
}
|
||||
|
||||
public void putBoolean(boolean z) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 1;
|
||||
this.space = i;
|
||||
byteBuffer.put(i, z ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
public void putByte(byte b) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 1;
|
||||
this.space = i;
|
||||
byteBuffer.put(i, b);
|
||||
}
|
||||
|
||||
public void putShort(short s) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 2;
|
||||
this.space = i;
|
||||
byteBuffer.putShort(i, s);
|
||||
}
|
||||
|
||||
public void putInt(int i) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i2 = this.space - 4;
|
||||
this.space = i2;
|
||||
byteBuffer.putInt(i2, i);
|
||||
}
|
||||
|
||||
public void putLong(long j) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 8;
|
||||
this.space = i;
|
||||
byteBuffer.putLong(i, j);
|
||||
}
|
||||
|
||||
public void putFloat(float f) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 4;
|
||||
this.space = i;
|
||||
byteBuffer.putFloat(i, f);
|
||||
}
|
||||
|
||||
public void putDouble(double d) {
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - 8;
|
||||
this.space = i;
|
||||
byteBuffer.putDouble(i, d);
|
||||
}
|
||||
|
||||
public void addBoolean(boolean z) {
|
||||
prep(1, 0);
|
||||
putBoolean(z);
|
||||
}
|
||||
|
||||
public void addByte(byte b) {
|
||||
prep(1, 0);
|
||||
putByte(b);
|
||||
}
|
||||
|
||||
public void addShort(short s) {
|
||||
prep(2, 0);
|
||||
putShort(s);
|
||||
}
|
||||
|
||||
public void addInt(int i) {
|
||||
prep(4, 0);
|
||||
putInt(i);
|
||||
}
|
||||
|
||||
public void addLong(long j) {
|
||||
prep(8, 0);
|
||||
putLong(j);
|
||||
}
|
||||
|
||||
public void addFloat(float f) {
|
||||
prep(4, 0);
|
||||
putFloat(f);
|
||||
}
|
||||
|
||||
public void addDouble(double d) {
|
||||
prep(8, 0);
|
||||
putDouble(d);
|
||||
}
|
||||
|
||||
public void addOffset(int i) {
|
||||
prep(4, 0);
|
||||
putInt((offset() - i) + 4);
|
||||
}
|
||||
|
||||
public void startVector(int i, int i2, int i3) {
|
||||
notNested();
|
||||
this.vector_num_elems = i2;
|
||||
int i4 = i * i2;
|
||||
prep(4, i4);
|
||||
prep(i3, i4);
|
||||
this.nested = true;
|
||||
}
|
||||
|
||||
public int endVector() {
|
||||
if (!this.nested) {
|
||||
throw new AssertionError("FlatBuffers: endVector called without startVector");
|
||||
}
|
||||
this.nested = false;
|
||||
putInt(this.vector_num_elems);
|
||||
return offset();
|
||||
}
|
||||
|
||||
public ByteBuffer createUnintializedVector(int i, int i2, int i3) {
|
||||
int i4 = i * i2;
|
||||
startVector(i, i2, i3);
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i5 = this.space - i4;
|
||||
this.space = i5;
|
||||
byteBuffer.position(i5);
|
||||
ByteBuffer order = this.bb.slice().order(ByteOrder.LITTLE_ENDIAN);
|
||||
order.limit(i4);
|
||||
return order;
|
||||
}
|
||||
|
||||
public int createVectorOfTables(int[] iArr) {
|
||||
notNested();
|
||||
startVector(4, iArr.length, 4);
|
||||
for (int length = iArr.length - 1; length >= 0; length--) {
|
||||
addOffset(iArr[length]);
|
||||
}
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public <T extends Table> int createSortedVectorOfTables(T t, int[] iArr) {
|
||||
t.sortTables(iArr, this.bb);
|
||||
return createVectorOfTables(iArr);
|
||||
}
|
||||
|
||||
public int createString(CharSequence charSequence) {
|
||||
int encodedLength = this.utf8.encodedLength(charSequence);
|
||||
addByte((byte) 0);
|
||||
startVector(1, encodedLength, 1);
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - encodedLength;
|
||||
this.space = i;
|
||||
byteBuffer.position(i);
|
||||
this.utf8.encodeUtf8(charSequence, this.bb);
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public int createString(ByteBuffer byteBuffer) {
|
||||
int remaining = byteBuffer.remaining();
|
||||
addByte((byte) 0);
|
||||
startVector(1, remaining, 1);
|
||||
ByteBuffer byteBuffer2 = this.bb;
|
||||
int i = this.space - remaining;
|
||||
this.space = i;
|
||||
byteBuffer2.position(i);
|
||||
this.bb.put(byteBuffer);
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public int createByteVector(byte[] bArr) {
|
||||
int length = bArr.length;
|
||||
startVector(1, length, 1);
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i = this.space - length;
|
||||
this.space = i;
|
||||
byteBuffer.position(i);
|
||||
this.bb.put(bArr);
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public int createByteVector(byte[] bArr, int i, int i2) {
|
||||
startVector(1, i2, 1);
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
int i3 = this.space - i2;
|
||||
this.space = i3;
|
||||
byteBuffer.position(i3);
|
||||
this.bb.put(bArr, i, i2);
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public int createByteVector(ByteBuffer byteBuffer) {
|
||||
int remaining = byteBuffer.remaining();
|
||||
startVector(1, remaining, 1);
|
||||
ByteBuffer byteBuffer2 = this.bb;
|
||||
int i = this.space - remaining;
|
||||
this.space = i;
|
||||
byteBuffer2.position(i);
|
||||
this.bb.put(byteBuffer);
|
||||
return endVector();
|
||||
}
|
||||
|
||||
public void finished() {
|
||||
if (!this.finished) {
|
||||
throw new AssertionError("FlatBuffers: you can only access the serialized buffer after it has been finished by FlatBufferBuilder.finish().");
|
||||
}
|
||||
}
|
||||
|
||||
public void notNested() {
|
||||
if (this.nested) {
|
||||
throw new AssertionError("FlatBuffers: object serialization must not be nested.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Nested(int i) {
|
||||
if (i != offset()) {
|
||||
throw new AssertionError("FlatBuffers: struct must be serialized inline.");
|
||||
}
|
||||
}
|
||||
|
||||
public void startTable(int i) {
|
||||
notNested();
|
||||
int[] iArr = this.vtable;
|
||||
if (iArr == null || iArr.length < i) {
|
||||
this.vtable = new int[i];
|
||||
}
|
||||
this.vtable_in_use = i;
|
||||
Arrays.fill(this.vtable, 0, i, 0);
|
||||
this.nested = true;
|
||||
this.object_start = offset();
|
||||
}
|
||||
|
||||
public void addBoolean(int i, boolean z, boolean z2) {
|
||||
if (this.force_defaults || z != z2) {
|
||||
addBoolean(z);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addByte(int i, byte b, int i2) {
|
||||
if (this.force_defaults || b != i2) {
|
||||
addByte(b);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addShort(int i, short s, int i2) {
|
||||
if (this.force_defaults || s != i2) {
|
||||
addShort(s);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addInt(int i, int i2, int i3) {
|
||||
if (this.force_defaults || i2 != i3) {
|
||||
addInt(i2);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addLong(int i, long j, long j2) {
|
||||
if (this.force_defaults || j != j2) {
|
||||
addLong(j);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFloat(int i, float f, double d) {
|
||||
if (this.force_defaults || f != d) {
|
||||
addFloat(f);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addDouble(int i, double d, double d2) {
|
||||
if (this.force_defaults || d != d2) {
|
||||
addDouble(d);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addOffset(int i, int i2, int i3) {
|
||||
if (this.force_defaults || i2 != i3) {
|
||||
addOffset(i2);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void addStruct(int i, int i2, int i3) {
|
||||
if (i2 != i3) {
|
||||
Nested(i2);
|
||||
slot(i);
|
||||
}
|
||||
}
|
||||
|
||||
public void slot(int i) {
|
||||
this.vtable[i] = offset();
|
||||
}
|
||||
|
||||
public int endTable() {
|
||||
int i;
|
||||
if (this.vtable == null || !this.nested) {
|
||||
throw new AssertionError("FlatBuffers: endTable called without startTable");
|
||||
}
|
||||
addInt(0);
|
||||
int offset = offset();
|
||||
int i2 = this.vtable_in_use - 1;
|
||||
while (i2 >= 0 && this.vtable[i2] == 0) {
|
||||
i2--;
|
||||
}
|
||||
for (int i3 = i2; i3 >= 0; i3--) {
|
||||
int i4 = this.vtable[i3];
|
||||
addShort((short) (i4 != 0 ? offset - i4 : 0));
|
||||
}
|
||||
addShort((short) (offset - this.object_start));
|
||||
addShort((short) ((i2 + 3) * 2));
|
||||
int i5 = 0;
|
||||
loop2: while (true) {
|
||||
if (i5 >= this.num_vtables) {
|
||||
i = 0;
|
||||
break;
|
||||
}
|
||||
int capacity = this.bb.capacity() - this.vtables[i5];
|
||||
int i6 = this.space;
|
||||
short s = this.bb.getShort(capacity);
|
||||
if (s == this.bb.getShort(i6)) {
|
||||
for (int i7 = 2; i7 < s; i7 += 2) {
|
||||
if (this.bb.getShort(capacity + i7) != this.bb.getShort(i6 + i7)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
i = this.vtables[i5];
|
||||
break loop2;
|
||||
}
|
||||
i5++;
|
||||
}
|
||||
if (i != 0) {
|
||||
int capacity2 = this.bb.capacity() - offset;
|
||||
this.space = capacity2;
|
||||
this.bb.putInt(capacity2, i - offset);
|
||||
} else {
|
||||
int i8 = this.num_vtables;
|
||||
int[] iArr = this.vtables;
|
||||
if (i8 == iArr.length) {
|
||||
this.vtables = Arrays.copyOf(iArr, i8 * 2);
|
||||
}
|
||||
int[] iArr2 = this.vtables;
|
||||
int i9 = this.num_vtables;
|
||||
this.num_vtables = i9 + 1;
|
||||
iArr2[i9] = offset();
|
||||
ByteBuffer byteBuffer = this.bb;
|
||||
byteBuffer.putInt(byteBuffer.capacity() - offset, offset() - offset);
|
||||
}
|
||||
this.nested = false;
|
||||
return offset;
|
||||
}
|
||||
|
||||
public void required(int i, int i2) {
|
||||
int capacity = this.bb.capacity() - i;
|
||||
if (this.bb.getShort((capacity - this.bb.getInt(capacity)) + i2) != 0) {
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("FlatBuffers: field " + i2 + " must be set");
|
||||
}
|
||||
|
||||
protected void finish(int i, boolean z) {
|
||||
prep(this.minalign, (z ? 4 : 0) + 4);
|
||||
addOffset(i);
|
||||
if (z) {
|
||||
addInt(this.bb.capacity() - this.space);
|
||||
}
|
||||
this.bb.position(this.space);
|
||||
this.finished = true;
|
||||
}
|
||||
|
||||
public void finish(int i) {
|
||||
finish(i, false);
|
||||
}
|
||||
|
||||
public void finishSizePrefixed(int i) {
|
||||
finish(i, true);
|
||||
}
|
||||
|
||||
protected void finish(int i, String str, boolean z) {
|
||||
prep(this.minalign, (z ? 4 : 0) + 8);
|
||||
if (str.length() != 4) {
|
||||
throw new AssertionError("FlatBuffers: file identifier must be length 4");
|
||||
}
|
||||
for (int i2 = 3; i2 >= 0; i2--) {
|
||||
addByte((byte) str.charAt(i2));
|
||||
}
|
||||
finish(i, z);
|
||||
}
|
||||
|
||||
public void finish(int i, String str) {
|
||||
finish(i, str, false);
|
||||
}
|
||||
|
||||
public void finishSizePrefixed(int i, String str) {
|
||||
finish(i, str, true);
|
||||
}
|
||||
|
||||
public ByteBuffer dataBuffer() {
|
||||
finished();
|
||||
return this.bb;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private int dataStart() {
|
||||
finished();
|
||||
return this.space;
|
||||
}
|
||||
|
||||
public byte[] sizedByteArray(int i, int i2) {
|
||||
finished();
|
||||
byte[] bArr = new byte[i2];
|
||||
this.bb.position(i);
|
||||
this.bb.get(bArr);
|
||||
return bArr;
|
||||
}
|
||||
|
||||
public byte[] sizedByteArray() {
|
||||
return sizedByteArray(this.space, this.bb.capacity() - this.space);
|
||||
}
|
||||
|
||||
public InputStream sizedInputStream() {
|
||||
finished();
|
||||
ByteBuffer duplicate = this.bb.duplicate();
|
||||
duplicate.position(this.space);
|
||||
duplicate.limit(this.bb.capacity());
|
||||
return new ByteBufferBackedInputStream(duplicate);
|
||||
}
|
||||
|
||||
static class ByteBufferBackedInputStream extends InputStream {
|
||||
ByteBuffer buf;
|
||||
|
||||
public ByteBufferBackedInputStream(ByteBuffer byteBuffer) {
|
||||
this.buf = byteBuffer;
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read() throws IOException {
|
||||
try {
|
||||
return this.buf.get() & UByte.MAX_VALUE;
|
||||
} catch (BufferUnderflowException unused) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,846 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import kotlin.UByte;
|
||||
import kotlin.UShort;
|
||||
import kotlin.text.Typography;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FlexBuffers {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
private static final ReadBuf EMPTY_BB = new ArrayReadWriteBuf(new byte[]{0}, 1);
|
||||
public static final int FBT_BLOB = 25;
|
||||
public static final int FBT_BOOL = 26;
|
||||
public static final int FBT_FLOAT = 3;
|
||||
public static final int FBT_INDIRECT_FLOAT = 8;
|
||||
public static final int FBT_INDIRECT_INT = 6;
|
||||
public static final int FBT_INDIRECT_UINT = 7;
|
||||
public static final int FBT_INT = 1;
|
||||
public static final int FBT_KEY = 4;
|
||||
public static final int FBT_MAP = 9;
|
||||
public static final int FBT_NULL = 0;
|
||||
public static final int FBT_STRING = 5;
|
||||
public static final int FBT_UINT = 2;
|
||||
public static final int FBT_VECTOR = 10;
|
||||
public static final int FBT_VECTOR_BOOL = 36;
|
||||
public static final int FBT_VECTOR_FLOAT = 13;
|
||||
public static final int FBT_VECTOR_FLOAT2 = 18;
|
||||
public static final int FBT_VECTOR_FLOAT3 = 21;
|
||||
public static final int FBT_VECTOR_FLOAT4 = 24;
|
||||
public static final int FBT_VECTOR_INT = 11;
|
||||
public static final int FBT_VECTOR_INT2 = 16;
|
||||
public static final int FBT_VECTOR_INT3 = 19;
|
||||
public static final int FBT_VECTOR_INT4 = 22;
|
||||
public static final int FBT_VECTOR_KEY = 14;
|
||||
public static final int FBT_VECTOR_STRING_DEPRECATED = 15;
|
||||
public static final int FBT_VECTOR_UINT = 12;
|
||||
public static final int FBT_VECTOR_UINT2 = 17;
|
||||
public static final int FBT_VECTOR_UINT3 = 20;
|
||||
public static final int FBT_VECTOR_UINT4 = 23;
|
||||
|
||||
static boolean isTypeInline(int i) {
|
||||
return i <= 3 || i == 26;
|
||||
}
|
||||
|
||||
static boolean isTypedVector(int i) {
|
||||
return (i >= 11 && i <= 15) || i == 36;
|
||||
}
|
||||
|
||||
static boolean isTypedVectorElementType(int i) {
|
||||
return (i >= 1 && i <= 4) || i == 26;
|
||||
}
|
||||
|
||||
static int toTypedVector(int i, int i2) {
|
||||
if (i2 == 0) {
|
||||
return i + 10;
|
||||
}
|
||||
if (i2 == 2) {
|
||||
return i + 15;
|
||||
}
|
||||
if (i2 == 3) {
|
||||
return i + 18;
|
||||
}
|
||||
if (i2 != 4) {
|
||||
return 0;
|
||||
}
|
||||
return i + 21;
|
||||
}
|
||||
|
||||
static int toTypedVectorElementType(int i) {
|
||||
return i - 10;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static int indirect(ReadBuf readBuf, int i, int i2) {
|
||||
return (int) (i - readUInt(readBuf, i, i2));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static long readUInt(ReadBuf readBuf, int i, int i2) {
|
||||
if (i2 == 1) {
|
||||
return Unsigned.byteToUnsignedInt(readBuf.get(i));
|
||||
}
|
||||
if (i2 == 2) {
|
||||
return Unsigned.shortToUnsignedInt(readBuf.getShort(i));
|
||||
}
|
||||
if (i2 == 4) {
|
||||
return Unsigned.intToUnsignedLong(readBuf.getInt(i));
|
||||
}
|
||||
if (i2 != 8) {
|
||||
return -1L;
|
||||
}
|
||||
return readBuf.getLong(i);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static int readInt(ReadBuf readBuf, int i, int i2) {
|
||||
return (int) readLong(readBuf, i, i2);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static long readLong(ReadBuf readBuf, int i, int i2) {
|
||||
int i3;
|
||||
if (i2 == 1) {
|
||||
i3 = readBuf.get(i);
|
||||
} else if (i2 == 2) {
|
||||
i3 = readBuf.getShort(i);
|
||||
} else {
|
||||
if (i2 != 4) {
|
||||
if (i2 != 8) {
|
||||
return -1L;
|
||||
}
|
||||
return readBuf.getLong(i);
|
||||
}
|
||||
i3 = readBuf.getInt(i);
|
||||
}
|
||||
return i3;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static double readDouble(ReadBuf readBuf, int i, int i2) {
|
||||
if (i2 == 4) {
|
||||
return readBuf.getFloat(i);
|
||||
}
|
||||
if (i2 != 8) {
|
||||
return -1.0d;
|
||||
}
|
||||
return readBuf.getDouble(i);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Reference getRoot(ByteBuffer byteBuffer) {
|
||||
return getRoot(byteBuffer.hasArray() ? new ArrayReadWriteBuf(byteBuffer.array(), byteBuffer.limit()) : new ByteBufferReadWriteBuf(byteBuffer));
|
||||
}
|
||||
|
||||
public static Reference getRoot(ReadBuf readBuf) {
|
||||
int limit = readBuf.limit();
|
||||
byte b = readBuf.get(limit - 1);
|
||||
int i = limit - 2;
|
||||
return new Reference(readBuf, i - b, b, Unsigned.byteToUnsignedInt(readBuf.get(i)));
|
||||
}
|
||||
|
||||
public static class Reference {
|
||||
private static final Reference NULL_REFERENCE = new Reference(FlexBuffers.EMPTY_BB, 0, 1, 0);
|
||||
private ReadBuf bb;
|
||||
private int byteWidth;
|
||||
private int end;
|
||||
private int parentWidth;
|
||||
private int type;
|
||||
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
public boolean isBlob() {
|
||||
return this.type == 25;
|
||||
}
|
||||
|
||||
public boolean isBoolean() {
|
||||
return this.type == 26;
|
||||
}
|
||||
|
||||
public boolean isFloat() {
|
||||
int i = this.type;
|
||||
return i == 3 || i == 8;
|
||||
}
|
||||
|
||||
public boolean isInt() {
|
||||
int i = this.type;
|
||||
return i == 1 || i == 6;
|
||||
}
|
||||
|
||||
public boolean isKey() {
|
||||
return this.type == 4;
|
||||
}
|
||||
|
||||
public boolean isMap() {
|
||||
return this.type == 9;
|
||||
}
|
||||
|
||||
public boolean isNull() {
|
||||
return this.type == 0;
|
||||
}
|
||||
|
||||
public boolean isString() {
|
||||
return this.type == 5;
|
||||
}
|
||||
|
||||
public boolean isUInt() {
|
||||
int i = this.type;
|
||||
return i == 2 || i == 7;
|
||||
}
|
||||
|
||||
public boolean isVector() {
|
||||
int i = this.type;
|
||||
return i == 10 || i == 9;
|
||||
}
|
||||
|
||||
Reference(ReadBuf readBuf, int i, int i2, int i3) {
|
||||
this(readBuf, i, i2, 1 << (i3 & 3), i3 >> 2);
|
||||
}
|
||||
|
||||
Reference(ReadBuf readBuf, int i, int i2, int i3, int i4) {
|
||||
this.bb = readBuf;
|
||||
this.end = i;
|
||||
this.parentWidth = i2;
|
||||
this.byteWidth = i3;
|
||||
this.type = i4;
|
||||
}
|
||||
|
||||
public boolean isNumeric() {
|
||||
return isIntOrUInt() || isFloat();
|
||||
}
|
||||
|
||||
public boolean isIntOrUInt() {
|
||||
return isInt() || isUInt();
|
||||
}
|
||||
|
||||
public boolean isTypedVector() {
|
||||
return FlexBuffers.isTypedVector(this.type);
|
||||
}
|
||||
|
||||
public int asInt() {
|
||||
long readUInt;
|
||||
int i = this.type;
|
||||
if (i == 1) {
|
||||
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 2) {
|
||||
readUInt = FlexBuffers.readUInt(this.bb, this.end, this.parentWidth);
|
||||
} else {
|
||||
if (i == 3) {
|
||||
return (int) FlexBuffers.readDouble(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 5) {
|
||||
return Integer.parseInt(asString());
|
||||
}
|
||||
if (i == 6) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return FlexBuffers.readInt(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i != 7) {
|
||||
if (i == 8) {
|
||||
ReadBuf readBuf2 = this.bb;
|
||||
return (int) FlexBuffers.readDouble(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 10) {
|
||||
return asVector().size();
|
||||
}
|
||||
if (i != 26) {
|
||||
return 0;
|
||||
}
|
||||
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
ReadBuf readBuf3 = this.bb;
|
||||
readUInt = FlexBuffers.readUInt(readBuf3, FlexBuffers.indirect(readBuf3, this.end, this.parentWidth), this.parentWidth);
|
||||
}
|
||||
return (int) readUInt;
|
||||
}
|
||||
|
||||
public long asUInt() {
|
||||
int i = this.type;
|
||||
if (i == 2) {
|
||||
return FlexBuffers.readUInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 1) {
|
||||
return FlexBuffers.readLong(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 3) {
|
||||
return (long) FlexBuffers.readDouble(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 10) {
|
||||
return asVector().size();
|
||||
}
|
||||
if (i == 26) {
|
||||
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 5) {
|
||||
return Long.parseLong(asString());
|
||||
}
|
||||
if (i == 6) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return FlexBuffers.readLong(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 7) {
|
||||
ReadBuf readBuf2 = this.bb;
|
||||
return FlexBuffers.readUInt(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i != 8) {
|
||||
return 0L;
|
||||
}
|
||||
ReadBuf readBuf3 = this.bb;
|
||||
return (long) FlexBuffers.readDouble(readBuf3, FlexBuffers.indirect(readBuf3, this.end, this.parentWidth), this.parentWidth);
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
int i = this.type;
|
||||
if (i == 1) {
|
||||
return FlexBuffers.readLong(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 2) {
|
||||
return FlexBuffers.readUInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 3) {
|
||||
return (long) FlexBuffers.readDouble(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i == 5) {
|
||||
try {
|
||||
return Long.parseLong(asString());
|
||||
} catch (NumberFormatException unused) {
|
||||
return 0L;
|
||||
}
|
||||
}
|
||||
if (i == 6) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return FlexBuffers.readLong(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 7) {
|
||||
ReadBuf readBuf2 = this.bb;
|
||||
return FlexBuffers.readUInt(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.parentWidth);
|
||||
}
|
||||
if (i == 8) {
|
||||
ReadBuf readBuf3 = this.bb;
|
||||
return (long) FlexBuffers.readDouble(readBuf3, FlexBuffers.indirect(readBuf3, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 10) {
|
||||
return asVector().size();
|
||||
}
|
||||
if (i != 26) {
|
||||
return 0L;
|
||||
}
|
||||
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
|
||||
public double asFloat() {
|
||||
int i = this.type;
|
||||
if (i == 3) {
|
||||
return FlexBuffers.readDouble(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
if (i != 1) {
|
||||
if (i != 2) {
|
||||
if (i == 5) {
|
||||
return Double.parseDouble(asString());
|
||||
}
|
||||
if (i == 6) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return FlexBuffers.readInt(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 7) {
|
||||
ReadBuf readBuf2 = this.bb;
|
||||
return FlexBuffers.readUInt(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 8) {
|
||||
ReadBuf readBuf3 = this.bb;
|
||||
return FlexBuffers.readDouble(readBuf3, FlexBuffers.indirect(readBuf3, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
if (i == 10) {
|
||||
return asVector().size();
|
||||
}
|
||||
if (i != 26) {
|
||||
return 0.0d;
|
||||
}
|
||||
}
|
||||
return FlexBuffers.readUInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
|
||||
}
|
||||
|
||||
public Key asKey() {
|
||||
if (isKey()) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return new Key(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
return Key.empty();
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
if (isString()) {
|
||||
int indirect = FlexBuffers.indirect(this.bb, this.end, this.parentWidth);
|
||||
ReadBuf readBuf = this.bb;
|
||||
int i = this.byteWidth;
|
||||
return this.bb.getString(indirect, (int) FlexBuffers.readUInt(readBuf, indirect - i, i));
|
||||
}
|
||||
if (!isKey()) {
|
||||
return "";
|
||||
}
|
||||
int indirect2 = FlexBuffers.indirect(this.bb, this.end, this.byteWidth);
|
||||
int i2 = indirect2;
|
||||
while (this.bb.get(i2) != 0) {
|
||||
i2++;
|
||||
}
|
||||
return this.bb.getString(indirect2, i2 - indirect2);
|
||||
}
|
||||
|
||||
public Map asMap() {
|
||||
if (isMap()) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return new Map(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
return Map.empty();
|
||||
}
|
||||
|
||||
public Vector asVector() {
|
||||
if (isVector()) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return new Vector(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
int i = this.type;
|
||||
if (i == 15) {
|
||||
ReadBuf readBuf2 = this.bb;
|
||||
return new TypedVector(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.byteWidth, 4);
|
||||
}
|
||||
if (FlexBuffers.isTypedVector(i)) {
|
||||
ReadBuf readBuf3 = this.bb;
|
||||
return new TypedVector(readBuf3, FlexBuffers.indirect(readBuf3, this.end, this.parentWidth), this.byteWidth, FlexBuffers.toTypedVectorElementType(this.type));
|
||||
}
|
||||
return Vector.empty();
|
||||
}
|
||||
|
||||
public Blob asBlob() {
|
||||
if (isBlob() || isString()) {
|
||||
ReadBuf readBuf = this.bb;
|
||||
return new Blob(readBuf, FlexBuffers.indirect(readBuf, this.end, this.parentWidth), this.byteWidth);
|
||||
}
|
||||
return Blob.empty();
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return isBoolean() ? this.bb.get(this.end) != 0 : asUInt() != 0;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return toString(new StringBuilder(128)).toString();
|
||||
}
|
||||
|
||||
StringBuilder toString(StringBuilder sb) {
|
||||
int i = this.type;
|
||||
if (i != 36) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
sb.append("null");
|
||||
return sb;
|
||||
case 1:
|
||||
case 6:
|
||||
sb.append(asLong());
|
||||
return sb;
|
||||
case 2:
|
||||
case 7:
|
||||
sb.append(asUInt());
|
||||
return sb;
|
||||
case 3:
|
||||
case 8:
|
||||
sb.append(asFloat());
|
||||
return sb;
|
||||
case 4:
|
||||
Key asKey = asKey();
|
||||
sb.append(Typography.quote);
|
||||
StringBuilder key = asKey.toString(sb);
|
||||
key.append(Typography.quote);
|
||||
return key;
|
||||
case 5:
|
||||
sb.append(Typography.quote);
|
||||
sb.append(asString());
|
||||
sb.append(Typography.quote);
|
||||
return sb;
|
||||
case 9:
|
||||
return asMap().toString(sb);
|
||||
case 10:
|
||||
return asVector().toString(sb);
|
||||
case 11:
|
||||
case 12:
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
case 20:
|
||||
case 21:
|
||||
case 22:
|
||||
case 23:
|
||||
case 24:
|
||||
throw new FlexBufferException("not_implemented:" + this.type);
|
||||
case 25:
|
||||
return asBlob().toString(sb);
|
||||
case 26:
|
||||
sb.append(asBoolean());
|
||||
return sb;
|
||||
default:
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
sb.append(asVector());
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class Object {
|
||||
ReadBuf bb;
|
||||
int byteWidth;
|
||||
int end;
|
||||
|
||||
public abstract StringBuilder toString(StringBuilder sb);
|
||||
|
||||
Object(ReadBuf readBuf, int i, int i2) {
|
||||
this.bb = readBuf;
|
||||
this.end = i;
|
||||
this.byteWidth = i2;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return toString(new StringBuilder(128)).toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static abstract class Sized extends Object {
|
||||
protected final int size;
|
||||
|
||||
public int size() {
|
||||
return this.size;
|
||||
}
|
||||
|
||||
Sized(ReadBuf readBuf, int i, int i2) {
|
||||
super(readBuf, i, i2);
|
||||
this.size = FlexBuffers.readInt(this.bb, i - i2, i2);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Blob extends Sized {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
static final Blob EMPTY = new Blob(FlexBuffers.EMPTY_BB, 1, 1);
|
||||
|
||||
public static Blob empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Sized
|
||||
public /* bridge */ /* synthetic */ int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
Blob(ReadBuf readBuf, int i, int i2) {
|
||||
super(readBuf, i, i2);
|
||||
}
|
||||
|
||||
public ByteBuffer data() {
|
||||
ByteBuffer wrap = ByteBuffer.wrap(this.bb.data());
|
||||
wrap.position(this.end);
|
||||
wrap.limit(this.end + size());
|
||||
return wrap.asReadOnlyBuffer().slice();
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
int size = size();
|
||||
byte[] bArr = new byte[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
bArr[i] = this.bb.get(this.end + i);
|
||||
}
|
||||
return bArr;
|
||||
}
|
||||
|
||||
public byte get(int i) {
|
||||
return this.bb.get(this.end + i);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public String toString() {
|
||||
return this.bb.getString(this.end, size());
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public StringBuilder toString(StringBuilder sb) {
|
||||
sb.append(Typography.quote);
|
||||
sb.append(this.bb.getString(this.end, size()));
|
||||
sb.append(Typography.quote);
|
||||
return sb;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Key extends Object {
|
||||
private static final Key EMPTY = new Key(FlexBuffers.EMPTY_BB, 0, 0);
|
||||
|
||||
public static Key empty() {
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
Key(ReadBuf readBuf, int i, int i2) {
|
||||
super(readBuf, i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public StringBuilder toString(StringBuilder sb) {
|
||||
sb.append(toString());
|
||||
return sb;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public String toString() {
|
||||
int i = this.end;
|
||||
while (this.bb.get(i) != 0) {
|
||||
i++;
|
||||
}
|
||||
return this.bb.getString(this.end, i - this.end);
|
||||
}
|
||||
|
||||
int compareTo(byte[] bArr) {
|
||||
byte b;
|
||||
byte b2;
|
||||
int i = this.end;
|
||||
int i2 = 0;
|
||||
do {
|
||||
b = this.bb.get(i);
|
||||
b2 = bArr[i2];
|
||||
if (b == 0) {
|
||||
return b - b2;
|
||||
}
|
||||
i++;
|
||||
i2++;
|
||||
if (i2 == bArr.length) {
|
||||
return b - b2;
|
||||
}
|
||||
} while (b == b2);
|
||||
return b - b2;
|
||||
}
|
||||
|
||||
public boolean equals(java.lang.Object obj) {
|
||||
if (!(obj instanceof Key)) {
|
||||
return false;
|
||||
}
|
||||
Key key = (Key) obj;
|
||||
return key.end == this.end && key.byteWidth == this.byteWidth;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return this.end ^ this.byteWidth;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Map extends Vector {
|
||||
private static final Map EMPTY_MAP = new Map(FlexBuffers.EMPTY_BB, 1, 1);
|
||||
|
||||
public static Map empty() {
|
||||
return EMPTY_MAP;
|
||||
}
|
||||
|
||||
Map(ReadBuf readBuf, int i, int i2) {
|
||||
super(readBuf, i, i2);
|
||||
}
|
||||
|
||||
public Reference get(String str) {
|
||||
return get(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
public Reference get(byte[] bArr) {
|
||||
KeyVector keys = keys();
|
||||
int size = keys.size();
|
||||
int binarySearch = binarySearch(keys, bArr);
|
||||
if (binarySearch >= 0 && binarySearch < size) {
|
||||
return get(binarySearch);
|
||||
}
|
||||
return Reference.NULL_REFERENCE;
|
||||
}
|
||||
|
||||
public KeyVector keys() {
|
||||
int i = this.end - (this.byteWidth * 3);
|
||||
return new KeyVector(new TypedVector(this.bb, FlexBuffers.indirect(this.bb, i, this.byteWidth), FlexBuffers.readInt(this.bb, i + this.byteWidth, this.byteWidth), 4));
|
||||
}
|
||||
|
||||
public Vector values() {
|
||||
return new Vector(this.bb, this.end, this.byteWidth);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Vector, androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public StringBuilder toString(StringBuilder sb) {
|
||||
sb.append("{ ");
|
||||
KeyVector keys = keys();
|
||||
int size = size();
|
||||
Vector values = values();
|
||||
for (int i = 0; i < size; i++) {
|
||||
sb.append(Typography.quote);
|
||||
sb.append(keys.get(i).toString());
|
||||
sb.append("\" : ");
|
||||
sb.append(values.get(i).toString());
|
||||
if (i != size - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(" }");
|
||||
return sb;
|
||||
}
|
||||
|
||||
private int binarySearch(KeyVector keyVector, byte[] bArr) {
|
||||
int size = keyVector.size() - 1;
|
||||
int i = 0;
|
||||
while (i <= size) {
|
||||
int i2 = (i + size) >>> 1;
|
||||
int compareTo = keyVector.get(i2).compareTo(bArr);
|
||||
if (compareTo < 0) {
|
||||
i = i2 + 1;
|
||||
} else {
|
||||
if (compareTo <= 0) {
|
||||
return i2;
|
||||
}
|
||||
size = i2 - 1;
|
||||
}
|
||||
}
|
||||
return -(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Vector extends Sized {
|
||||
private static final Vector EMPTY_VECTOR = new Vector(FlexBuffers.EMPTY_BB, 1, 1);
|
||||
|
||||
public static Vector empty() {
|
||||
return EMPTY_VECTOR;
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this == EMPTY_VECTOR;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Sized
|
||||
public /* bridge */ /* synthetic */ int size() {
|
||||
return super.size();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public /* bridge */ /* synthetic */ String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
Vector(ReadBuf readBuf, int i, int i2) {
|
||||
super(readBuf, i, i2);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Object
|
||||
public StringBuilder toString(StringBuilder sb) {
|
||||
sb.append("[ ");
|
||||
int size = size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
get(i).toString(sb);
|
||||
if (i != size - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append(" ]");
|
||||
return sb;
|
||||
}
|
||||
|
||||
public Reference get(int i) {
|
||||
long size = size();
|
||||
long j = i;
|
||||
if (j >= size) {
|
||||
return Reference.NULL_REFERENCE;
|
||||
}
|
||||
return new Reference(this.bb, this.end + (i * this.byteWidth), this.byteWidth, Unsigned.byteToUnsignedInt(this.bb.get((int) (this.end + (size * this.byteWidth) + j))));
|
||||
}
|
||||
}
|
||||
|
||||
public static class TypedVector extends Vector {
|
||||
private static final TypedVector EMPTY_VECTOR = new TypedVector(FlexBuffers.EMPTY_BB, 1, 1, 1);
|
||||
private final int elemType;
|
||||
|
||||
public static TypedVector empty() {
|
||||
return EMPTY_VECTOR;
|
||||
}
|
||||
|
||||
public int getElemType() {
|
||||
return this.elemType;
|
||||
}
|
||||
|
||||
public boolean isEmptyVector() {
|
||||
return this == EMPTY_VECTOR;
|
||||
}
|
||||
|
||||
TypedVector(ReadBuf readBuf, int i, int i2, int i3) {
|
||||
super(readBuf, i, i2);
|
||||
this.elemType = i3;
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.FlexBuffers.Vector
|
||||
public Reference get(int i) {
|
||||
if (i >= size()) {
|
||||
return Reference.NULL_REFERENCE;
|
||||
}
|
||||
return new Reference(this.bb, this.end + (i * this.byteWidth), this.byteWidth, 1, this.elemType);
|
||||
}
|
||||
}
|
||||
|
||||
public static class KeyVector {
|
||||
private final TypedVector vec;
|
||||
|
||||
KeyVector(TypedVector typedVector) {
|
||||
this.vec = typedVector;
|
||||
}
|
||||
|
||||
public Key get(int i) {
|
||||
if (i >= size()) {
|
||||
return Key.EMPTY;
|
||||
}
|
||||
return new Key(this.vec.bb, FlexBuffers.indirect(this.vec.bb, this.vec.end + (i * this.vec.byteWidth), this.vec.byteWidth), 1);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.vec.size();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append('[');
|
||||
for (int i = 0; i < this.vec.size(); i++) {
|
||||
this.vec.get(i).toString(sb);
|
||||
if (i != this.vec.size() - 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
}
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class FlexBufferException extends RuntimeException {
|
||||
FlexBufferException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
|
||||
static class Unsigned {
|
||||
static int byteToUnsignedInt(byte b) {
|
||||
return b & UByte.MAX_VALUE;
|
||||
}
|
||||
|
||||
static long intToUnsignedLong(int i) {
|
||||
return i & 4294967295L;
|
||||
}
|
||||
|
||||
static int shortToUnsignedInt(short s) {
|
||||
return s & UShort.MAX_VALUE;
|
||||
}
|
||||
|
||||
Unsigned() {
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,531 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import androidx.emoji2.text.flatbuffer.FlexBuffers;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class FlexBuffersBuilder {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
public static final int BUILDER_FLAG_NONE = 0;
|
||||
public static final int BUILDER_FLAG_SHARE_ALL = 7;
|
||||
public static final int BUILDER_FLAG_SHARE_KEYS = 1;
|
||||
public static final int BUILDER_FLAG_SHARE_KEYS_AND_STRINGS = 3;
|
||||
public static final int BUILDER_FLAG_SHARE_KEY_VECTORS = 4;
|
||||
public static final int BUILDER_FLAG_SHARE_STRINGS = 2;
|
||||
private static final int WIDTH_16 = 1;
|
||||
private static final int WIDTH_32 = 2;
|
||||
private static final int WIDTH_64 = 3;
|
||||
private static final int WIDTH_8 = 0;
|
||||
private final ReadWriteBuf bb;
|
||||
private boolean finished;
|
||||
private final int flags;
|
||||
private Comparator<Value> keyComparator;
|
||||
private final HashMap<String, Integer> keyPool;
|
||||
private final ArrayList<Value> stack;
|
||||
private final HashMap<String, Integer> stringPool;
|
||||
|
||||
public ReadWriteBuf getBuffer() {
|
||||
return this.bb;
|
||||
}
|
||||
|
||||
public FlexBuffersBuilder(int i) {
|
||||
this(new ArrayReadWriteBuf(i), 1);
|
||||
}
|
||||
|
||||
public FlexBuffersBuilder() {
|
||||
this(256);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public FlexBuffersBuilder(ByteBuffer byteBuffer, int i) {
|
||||
this(new ArrayReadWriteBuf(byteBuffer.array()), i);
|
||||
}
|
||||
|
||||
public FlexBuffersBuilder(ReadWriteBuf readWriteBuf, int i) {
|
||||
this.stack = new ArrayList<>();
|
||||
this.keyPool = new HashMap<>();
|
||||
this.stringPool = new HashMap<>();
|
||||
this.finished = false;
|
||||
this.keyComparator = new Comparator<Value>() { // from class: androidx.emoji2.text.flatbuffer.FlexBuffersBuilder.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Value value, Value value2) {
|
||||
byte b;
|
||||
byte b2;
|
||||
int i2 = value.key;
|
||||
int i3 = value2.key;
|
||||
do {
|
||||
b = FlexBuffersBuilder.this.bb.get(i2);
|
||||
b2 = FlexBuffersBuilder.this.bb.get(i3);
|
||||
if (b == 0) {
|
||||
return b - b2;
|
||||
}
|
||||
i2++;
|
||||
i3++;
|
||||
} while (b == b2);
|
||||
return b - b2;
|
||||
}
|
||||
};
|
||||
this.bb = readWriteBuf;
|
||||
this.flags = i;
|
||||
}
|
||||
|
||||
public FlexBuffersBuilder(ByteBuffer byteBuffer) {
|
||||
this(byteBuffer, 1);
|
||||
}
|
||||
|
||||
public void putBoolean(boolean z) {
|
||||
putBoolean(null, z);
|
||||
}
|
||||
|
||||
public void putBoolean(String str, boolean z) {
|
||||
this.stack.add(Value.bool(putKey(str), z));
|
||||
}
|
||||
|
||||
private int putKey(String str) {
|
||||
if (str == null) {
|
||||
return -1;
|
||||
}
|
||||
int writePosition = this.bb.writePosition();
|
||||
if ((this.flags & 1) != 0) {
|
||||
Integer num = this.keyPool.get(str);
|
||||
if (num == null) {
|
||||
byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
|
||||
this.bb.put(bytes, 0, bytes.length);
|
||||
this.bb.put((byte) 0);
|
||||
this.keyPool.put(str, Integer.valueOf(writePosition));
|
||||
return writePosition;
|
||||
}
|
||||
return num.intValue();
|
||||
}
|
||||
byte[] bytes2 = str.getBytes(StandardCharsets.UTF_8);
|
||||
this.bb.put(bytes2, 0, bytes2.length);
|
||||
this.bb.put((byte) 0);
|
||||
this.keyPool.put(str, Integer.valueOf(writePosition));
|
||||
return writePosition;
|
||||
}
|
||||
|
||||
public void putInt(int i) {
|
||||
putInt((String) null, i);
|
||||
}
|
||||
|
||||
public void putInt(String str, int i) {
|
||||
putInt(str, i);
|
||||
}
|
||||
|
||||
public void putInt(String str, long j) {
|
||||
int putKey = putKey(str);
|
||||
if (-128 <= j && j <= 127) {
|
||||
this.stack.add(Value.int8(putKey, (int) j));
|
||||
return;
|
||||
}
|
||||
if (-32768 <= j && j <= 32767) {
|
||||
this.stack.add(Value.int16(putKey, (int) j));
|
||||
} else if (-2147483648L <= j && j <= 2147483647L) {
|
||||
this.stack.add(Value.int32(putKey, (int) j));
|
||||
} else {
|
||||
this.stack.add(Value.int64(putKey, j));
|
||||
}
|
||||
}
|
||||
|
||||
public void putInt(long j) {
|
||||
putInt((String) null, j);
|
||||
}
|
||||
|
||||
public void putUInt(int i) {
|
||||
putUInt(null, i);
|
||||
}
|
||||
|
||||
public void putUInt(long j) {
|
||||
putUInt(null, j);
|
||||
}
|
||||
|
||||
public void putUInt64(BigInteger bigInteger) {
|
||||
putUInt64(null, bigInteger.longValue());
|
||||
}
|
||||
|
||||
private void putUInt64(String str, long j) {
|
||||
this.stack.add(Value.uInt64(putKey(str), j));
|
||||
}
|
||||
|
||||
private void putUInt(String str, long j) {
|
||||
Value uInt64;
|
||||
int putKey = putKey(str);
|
||||
int widthUInBits = widthUInBits(j);
|
||||
if (widthUInBits == 0) {
|
||||
uInt64 = Value.uInt8(putKey, (int) j);
|
||||
} else if (widthUInBits == 1) {
|
||||
uInt64 = Value.uInt16(putKey, (int) j);
|
||||
} else if (widthUInBits == 2) {
|
||||
uInt64 = Value.uInt32(putKey, (int) j);
|
||||
} else {
|
||||
uInt64 = Value.uInt64(putKey, j);
|
||||
}
|
||||
this.stack.add(uInt64);
|
||||
}
|
||||
|
||||
public void putFloat(float f) {
|
||||
putFloat((String) null, f);
|
||||
}
|
||||
|
||||
public void putFloat(String str, float f) {
|
||||
this.stack.add(Value.float32(putKey(str), f));
|
||||
}
|
||||
|
||||
public void putFloat(double d) {
|
||||
putFloat((String) null, d);
|
||||
}
|
||||
|
||||
public void putFloat(String str, double d) {
|
||||
this.stack.add(Value.float64(putKey(str), d));
|
||||
}
|
||||
|
||||
public int putString(String str) {
|
||||
return putString(null, str);
|
||||
}
|
||||
|
||||
public int putString(String str, String str2) {
|
||||
long j;
|
||||
int putKey = putKey(str);
|
||||
if ((this.flags & 2) != 0) {
|
||||
Integer num = this.stringPool.get(str2);
|
||||
if (num == null) {
|
||||
Value writeString = writeString(putKey, str2);
|
||||
this.stringPool.put(str2, Integer.valueOf((int) writeString.iValue));
|
||||
this.stack.add(writeString);
|
||||
j = writeString.iValue;
|
||||
} else {
|
||||
this.stack.add(Value.blob(putKey, num.intValue(), 5, widthUInBits(str2.length())));
|
||||
return num.intValue();
|
||||
}
|
||||
} else {
|
||||
Value writeString2 = writeString(putKey, str2);
|
||||
this.stack.add(writeString2);
|
||||
j = writeString2.iValue;
|
||||
}
|
||||
return (int) j;
|
||||
}
|
||||
|
||||
private Value writeString(int i, String str) {
|
||||
return writeBlob(i, str.getBytes(StandardCharsets.UTF_8), 5, true);
|
||||
}
|
||||
|
||||
static int widthUInBits(long j) {
|
||||
if (j <= FlexBuffers.Unsigned.byteToUnsignedInt((byte) -1)) {
|
||||
return 0;
|
||||
}
|
||||
if (j <= FlexBuffers.Unsigned.shortToUnsignedInt((short) -1)) {
|
||||
return 1;
|
||||
}
|
||||
return j <= FlexBuffers.Unsigned.intToUnsignedLong(-1) ? 2 : 3;
|
||||
}
|
||||
|
||||
private Value writeBlob(int i, byte[] bArr, int i2, boolean z) {
|
||||
int widthUInBits = widthUInBits(bArr.length);
|
||||
writeInt(bArr.length, align(widthUInBits));
|
||||
int writePosition = this.bb.writePosition();
|
||||
this.bb.put(bArr, 0, bArr.length);
|
||||
if (z) {
|
||||
this.bb.put((byte) 0);
|
||||
}
|
||||
return Value.blob(i, writePosition, i2, widthUInBits);
|
||||
}
|
||||
|
||||
private int align(int i) {
|
||||
int i2 = 1 << i;
|
||||
int paddingBytes = Value.paddingBytes(this.bb.writePosition(), i2);
|
||||
while (true) {
|
||||
int i3 = paddingBytes - 1;
|
||||
if (paddingBytes == 0) {
|
||||
return i2;
|
||||
}
|
||||
this.bb.put((byte) 0);
|
||||
paddingBytes = i3;
|
||||
}
|
||||
}
|
||||
|
||||
private void writeInt(long j, int i) {
|
||||
if (i == 1) {
|
||||
this.bb.put((byte) j);
|
||||
return;
|
||||
}
|
||||
if (i == 2) {
|
||||
this.bb.putShort((short) j);
|
||||
} else if (i == 4) {
|
||||
this.bb.putInt((int) j);
|
||||
} else {
|
||||
if (i != 8) {
|
||||
return;
|
||||
}
|
||||
this.bb.putLong(j);
|
||||
}
|
||||
}
|
||||
|
||||
public int putBlob(byte[] bArr) {
|
||||
return putBlob(null, bArr);
|
||||
}
|
||||
|
||||
public int putBlob(String str, byte[] bArr) {
|
||||
Value writeBlob = writeBlob(putKey(str), bArr, 25, false);
|
||||
this.stack.add(writeBlob);
|
||||
return (int) writeBlob.iValue;
|
||||
}
|
||||
|
||||
public int startVector() {
|
||||
return this.stack.size();
|
||||
}
|
||||
|
||||
public int endVector(String str, int i, boolean z, boolean z2) {
|
||||
Value createVector = createVector(putKey(str), i, this.stack.size() - i, z, z2, null);
|
||||
while (this.stack.size() > i) {
|
||||
this.stack.remove(r10.size() - 1);
|
||||
}
|
||||
this.stack.add(createVector);
|
||||
return (int) createVector.iValue;
|
||||
}
|
||||
|
||||
public ByteBuffer finish() {
|
||||
int align = align(this.stack.get(0).elemWidth(this.bb.writePosition(), 0));
|
||||
writeAny(this.stack.get(0), align);
|
||||
this.bb.put(this.stack.get(0).storedPackedType());
|
||||
this.bb.put((byte) align);
|
||||
this.finished = true;
|
||||
return ByteBuffer.wrap(this.bb.data(), 0, this.bb.writePosition());
|
||||
}
|
||||
|
||||
private Value createVector(int i, int i2, int i3, boolean z, boolean z2, Value value) {
|
||||
int i4;
|
||||
int i5;
|
||||
int i6 = i3;
|
||||
long j = i6;
|
||||
int max = Math.max(0, widthUInBits(j));
|
||||
if (value != null) {
|
||||
max = Math.max(max, value.elemWidth(this.bb.writePosition(), 0));
|
||||
i4 = 3;
|
||||
} else {
|
||||
i4 = 1;
|
||||
}
|
||||
int i7 = 4;
|
||||
int i8 = max;
|
||||
for (int i9 = i2; i9 < this.stack.size(); i9++) {
|
||||
i8 = Math.max(i8, this.stack.get(i9).elemWidth(this.bb.writePosition(), i9 + i4));
|
||||
if (z && i9 == i2) {
|
||||
i7 = this.stack.get(i9).type;
|
||||
if (!FlexBuffers.isTypedVectorElementType(i7)) {
|
||||
throw new FlexBuffers.FlexBufferException("TypedVector does not support this element type");
|
||||
}
|
||||
}
|
||||
}
|
||||
int i10 = i2;
|
||||
int align = align(i8);
|
||||
if (value != null) {
|
||||
writeOffset(value.iValue, align);
|
||||
writeInt(1 << value.minBitWidth, align);
|
||||
}
|
||||
if (!z2) {
|
||||
writeInt(j, align);
|
||||
}
|
||||
int writePosition = this.bb.writePosition();
|
||||
for (int i11 = i10; i11 < this.stack.size(); i11++) {
|
||||
writeAny(this.stack.get(i11), align);
|
||||
}
|
||||
if (!z) {
|
||||
while (i10 < this.stack.size()) {
|
||||
this.bb.put(this.stack.get(i10).storedPackedType(i8));
|
||||
i10++;
|
||||
}
|
||||
}
|
||||
if (value != null) {
|
||||
i5 = 9;
|
||||
} else if (z) {
|
||||
if (!z2) {
|
||||
i6 = 0;
|
||||
}
|
||||
i5 = FlexBuffers.toTypedVector(i7, i6);
|
||||
} else {
|
||||
i5 = 10;
|
||||
}
|
||||
return new Value(i, i5, i8, writePosition);
|
||||
}
|
||||
|
||||
private void writeOffset(long j, int i) {
|
||||
writeInt((int) (this.bb.writePosition() - j), i);
|
||||
}
|
||||
|
||||
private void writeAny(Value value, int i) {
|
||||
int i2 = value.type;
|
||||
if (i2 != 0 && i2 != 1 && i2 != 2) {
|
||||
if (i2 == 3) {
|
||||
writeDouble(value.dValue, i);
|
||||
return;
|
||||
} else if (i2 != 26) {
|
||||
writeOffset(value.iValue, i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
writeInt(value.iValue, i);
|
||||
}
|
||||
|
||||
private void writeDouble(double d, int i) {
|
||||
if (i == 4) {
|
||||
this.bb.putFloat((float) d);
|
||||
} else if (i == 8) {
|
||||
this.bb.putDouble(d);
|
||||
}
|
||||
}
|
||||
|
||||
public int startMap() {
|
||||
return this.stack.size();
|
||||
}
|
||||
|
||||
public int endMap(String str, int i) {
|
||||
int putKey = putKey(str);
|
||||
ArrayList<Value> arrayList = this.stack;
|
||||
Collections.sort(arrayList.subList(i, arrayList.size()), this.keyComparator);
|
||||
Value createVector = createVector(putKey, i, this.stack.size() - i, false, false, createKeyVector(i, this.stack.size() - i));
|
||||
while (this.stack.size() > i) {
|
||||
this.stack.remove(r0.size() - 1);
|
||||
}
|
||||
this.stack.add(createVector);
|
||||
return (int) createVector.iValue;
|
||||
}
|
||||
|
||||
private Value createKeyVector(int i, int i2) {
|
||||
long j = i2;
|
||||
int max = Math.max(0, widthUInBits(j));
|
||||
int i3 = i;
|
||||
while (i3 < this.stack.size()) {
|
||||
i3++;
|
||||
max = Math.max(max, Value.elemWidth(4, 0, this.stack.get(i3).key, this.bb.writePosition(), i3));
|
||||
}
|
||||
int align = align(max);
|
||||
writeInt(j, align);
|
||||
int writePosition = this.bb.writePosition();
|
||||
while (i < this.stack.size()) {
|
||||
int i4 = this.stack.get(i).key;
|
||||
writeOffset(this.stack.get(i).key, align);
|
||||
i++;
|
||||
}
|
||||
return new Value(-1, FlexBuffers.toTypedVector(4, 0), max, writePosition);
|
||||
}
|
||||
|
||||
private static class Value {
|
||||
static final /* synthetic */ boolean $assertionsDisabled = false;
|
||||
final double dValue;
|
||||
long iValue;
|
||||
int key;
|
||||
final int minBitWidth;
|
||||
final int type;
|
||||
|
||||
private static byte packedType(int i, int i2) {
|
||||
return (byte) (i | (i2 << 2));
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static int paddingBytes(int i, int i2) {
|
||||
return ((~i) + 1) & (i2 - 1);
|
||||
}
|
||||
|
||||
Value(int i, int i2, int i3, long j) {
|
||||
this.key = i;
|
||||
this.type = i2;
|
||||
this.minBitWidth = i3;
|
||||
this.iValue = j;
|
||||
this.dValue = Double.MIN_VALUE;
|
||||
}
|
||||
|
||||
Value(int i, int i2, int i3, double d) {
|
||||
this.key = i;
|
||||
this.type = i2;
|
||||
this.minBitWidth = i3;
|
||||
this.dValue = d;
|
||||
this.iValue = Long.MIN_VALUE;
|
||||
}
|
||||
|
||||
static Value bool(int i, boolean z) {
|
||||
return new Value(i, 26, 0, z ? 1L : 0L);
|
||||
}
|
||||
|
||||
static Value blob(int i, int i2, int i3, int i4) {
|
||||
return new Value(i, i3, i4, i2);
|
||||
}
|
||||
|
||||
static Value int8(int i, int i2) {
|
||||
return new Value(i, 1, 0, i2);
|
||||
}
|
||||
|
||||
static Value int16(int i, int i2) {
|
||||
return new Value(i, 1, 1, i2);
|
||||
}
|
||||
|
||||
static Value int32(int i, int i2) {
|
||||
return new Value(i, 1, 2, i2);
|
||||
}
|
||||
|
||||
static Value int64(int i, long j) {
|
||||
return new Value(i, 1, 3, j);
|
||||
}
|
||||
|
||||
static Value uInt8(int i, int i2) {
|
||||
return new Value(i, 2, 0, i2);
|
||||
}
|
||||
|
||||
static Value uInt16(int i, int i2) {
|
||||
return new Value(i, 2, 1, i2);
|
||||
}
|
||||
|
||||
static Value uInt32(int i, int i2) {
|
||||
return new Value(i, 2, 2, i2);
|
||||
}
|
||||
|
||||
static Value uInt64(int i, long j) {
|
||||
return new Value(i, 2, 3, j);
|
||||
}
|
||||
|
||||
static Value float32(int i, float f) {
|
||||
return new Value(i, 3, 2, f);
|
||||
}
|
||||
|
||||
static Value float64(int i, double d) {
|
||||
return new Value(i, 3, 3, d);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public byte storedPackedType() {
|
||||
return storedPackedType(0);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public byte storedPackedType(int i) {
|
||||
return packedType(storedWidth(i), this.type);
|
||||
}
|
||||
|
||||
private int storedWidth(int i) {
|
||||
return FlexBuffers.isTypeInline(this.type) ? Math.max(this.minBitWidth, i) : this.minBitWidth;
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public int elemWidth(int i, int i2) {
|
||||
return elemWidth(this.type, this.minBitWidth, this.iValue, i, i2);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public static int elemWidth(int i, int i2, long j, int i3, int i4) {
|
||||
if (FlexBuffers.isTypeInline(i)) {
|
||||
return i2;
|
||||
}
|
||||
for (int i5 = 1; i5 <= 32; i5 *= 2) {
|
||||
int widthUInBits = FlexBuffersBuilder.widthUInBits((int) (((paddingBytes(i3, i5) + i3) + (i4 * i5)) - j));
|
||||
if ((1 << widthUInBits) == i5) {
|
||||
return widthUInBits;
|
||||
}
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class FloatVector extends BaseVector {
|
||||
public FloatVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 4, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public float get(int i) {
|
||||
return this.bb.getFloat(__element(i));
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class IntVector extends BaseVector {
|
||||
public IntVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 4, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int get(int i) {
|
||||
return this.bb.getInt(__element(i));
|
||||
}
|
||||
|
||||
public long getAsUnsigned(int i) {
|
||||
return get(i) & 4294967295L;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class LongVector extends BaseVector {
|
||||
public LongVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 8, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public long get(int i) {
|
||||
return this.bb.getLong(__element(i));
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MetadataItem extends Table {
|
||||
public static void ValidateVersion() {
|
||||
Constants.FLATBUFFERS_1_12_0();
|
||||
}
|
||||
|
||||
public static MetadataItem getRootAsMetadataItem(ByteBuffer byteBuffer) {
|
||||
return getRootAsMetadataItem(byteBuffer, new MetadataItem());
|
||||
}
|
||||
|
||||
public static MetadataItem getRootAsMetadataItem(ByteBuffer byteBuffer, MetadataItem metadataItem) {
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return metadataItem.__assign(byteBuffer.getInt(byteBuffer.position()) + byteBuffer.position(), byteBuffer);
|
||||
}
|
||||
|
||||
public void __init(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, byteBuffer);
|
||||
}
|
||||
|
||||
public MetadataItem __assign(int i, ByteBuffer byteBuffer) {
|
||||
__init(i, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int id() {
|
||||
int __offset = __offset(4);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getInt(__offset + this.bb_pos);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean emojiStyle() {
|
||||
int __offset = __offset(6);
|
||||
return (__offset == 0 || this.bb.get(__offset + this.bb_pos) == 0) ? false : true;
|
||||
}
|
||||
|
||||
public short sdkAdded() {
|
||||
int __offset = __offset(8);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getShort(__offset + this.bb_pos);
|
||||
}
|
||||
return (short) 0;
|
||||
}
|
||||
|
||||
public short compatAdded() {
|
||||
int __offset = __offset(10);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getShort(__offset + this.bb_pos);
|
||||
}
|
||||
return (short) 0;
|
||||
}
|
||||
|
||||
public short width() {
|
||||
int __offset = __offset(12);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getShort(__offset + this.bb_pos);
|
||||
}
|
||||
return (short) 0;
|
||||
}
|
||||
|
||||
public short height() {
|
||||
int __offset = __offset(14);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getShort(__offset + this.bb_pos);
|
||||
}
|
||||
return (short) 0;
|
||||
}
|
||||
|
||||
public int codepoints(int i) {
|
||||
int __offset = __offset(16);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getInt(__vector(__offset) + (i * 4));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int codepointsLength() {
|
||||
int __offset = __offset(16);
|
||||
if (__offset != 0) {
|
||||
return __vector_len(__offset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public IntVector codepointsVector() {
|
||||
return codepointsVector(new IntVector());
|
||||
}
|
||||
|
||||
public IntVector codepointsVector(IntVector intVector) {
|
||||
int __offset = __offset(16);
|
||||
if (__offset != 0) {
|
||||
return intVector.__assign(__vector(__offset), this.bb);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ByteBuffer codepointsAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(16, 4);
|
||||
}
|
||||
|
||||
public ByteBuffer codepointsInByteBuffer(ByteBuffer byteBuffer) {
|
||||
return __vector_in_bytebuffer(byteBuffer, 16, 4);
|
||||
}
|
||||
|
||||
public static int createMetadataItem(FlatBufferBuilder flatBufferBuilder, int i, boolean z, short s, short s2, short s3, short s4, int i2) {
|
||||
flatBufferBuilder.startTable(7);
|
||||
addCodepoints(flatBufferBuilder, i2);
|
||||
addId(flatBufferBuilder, i);
|
||||
addHeight(flatBufferBuilder, s4);
|
||||
addWidth(flatBufferBuilder, s3);
|
||||
addCompatAdded(flatBufferBuilder, s2);
|
||||
addSdkAdded(flatBufferBuilder, s);
|
||||
addEmojiStyle(flatBufferBuilder, z);
|
||||
return endMetadataItem(flatBufferBuilder);
|
||||
}
|
||||
|
||||
public static void startMetadataItem(FlatBufferBuilder flatBufferBuilder) {
|
||||
flatBufferBuilder.startTable(7);
|
||||
}
|
||||
|
||||
public static void addId(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.addInt(0, i, 0);
|
||||
}
|
||||
|
||||
public static void addEmojiStyle(FlatBufferBuilder flatBufferBuilder, boolean z) {
|
||||
flatBufferBuilder.addBoolean(1, z, false);
|
||||
}
|
||||
|
||||
public static void addSdkAdded(FlatBufferBuilder flatBufferBuilder, short s) {
|
||||
flatBufferBuilder.addShort(2, s, 0);
|
||||
}
|
||||
|
||||
public static void addCompatAdded(FlatBufferBuilder flatBufferBuilder, short s) {
|
||||
flatBufferBuilder.addShort(3, s, 0);
|
||||
}
|
||||
|
||||
public static void addWidth(FlatBufferBuilder flatBufferBuilder, short s) {
|
||||
flatBufferBuilder.addShort(4, s, 0);
|
||||
}
|
||||
|
||||
public static void addHeight(FlatBufferBuilder flatBufferBuilder, short s) {
|
||||
flatBufferBuilder.addShort(5, s, 0);
|
||||
}
|
||||
|
||||
public static void addCodepoints(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.addOffset(6, i, 0);
|
||||
}
|
||||
|
||||
public static int createCodepointsVector(FlatBufferBuilder flatBufferBuilder, int[] iArr) {
|
||||
flatBufferBuilder.startVector(4, iArr.length, 4);
|
||||
for (int length = iArr.length - 1; length >= 0; length--) {
|
||||
flatBufferBuilder.addInt(iArr[length]);
|
||||
}
|
||||
return flatBufferBuilder.endVector();
|
||||
}
|
||||
|
||||
public static void startCodepointsVector(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.startVector(4, i, 4);
|
||||
}
|
||||
|
||||
public static int endMetadataItem(FlatBufferBuilder flatBufferBuilder) {
|
||||
return flatBufferBuilder.endTable();
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int i, int i2, ByteBuffer byteBuffer) {
|
||||
__reset(i, i2, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MetadataItem get(int i) {
|
||||
return get(new MetadataItem(), i);
|
||||
}
|
||||
|
||||
public MetadataItem get(MetadataItem metadataItem, int i) {
|
||||
return metadataItem.__assign(MetadataItem.__indirect(__element(i), this.bb), this.bb);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import androidx.emoji2.text.flatbuffer.MetadataItem;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class MetadataList extends Table {
|
||||
public static void ValidateVersion() {
|
||||
Constants.FLATBUFFERS_1_12_0();
|
||||
}
|
||||
|
||||
public static MetadataList getRootAsMetadataList(ByteBuffer byteBuffer) {
|
||||
return getRootAsMetadataList(byteBuffer, new MetadataList());
|
||||
}
|
||||
|
||||
public static MetadataList getRootAsMetadataList(ByteBuffer byteBuffer, MetadataList metadataList) {
|
||||
byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return metadataList.__assign(byteBuffer.getInt(byteBuffer.position()) + byteBuffer.position(), byteBuffer);
|
||||
}
|
||||
|
||||
public void __init(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, byteBuffer);
|
||||
}
|
||||
|
||||
public MetadataList __assign(int i, ByteBuffer byteBuffer) {
|
||||
__init(i, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int version() {
|
||||
int __offset = __offset(4);
|
||||
if (__offset != 0) {
|
||||
return this.bb.getInt(__offset + this.bb_pos);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MetadataItem list(int i) {
|
||||
return list(new MetadataItem(), i);
|
||||
}
|
||||
|
||||
public MetadataItem list(MetadataItem metadataItem, int i) {
|
||||
int __offset = __offset(6);
|
||||
if (__offset != 0) {
|
||||
return metadataItem.__assign(__indirect(__vector(__offset) + (i * 4)), this.bb);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int listLength() {
|
||||
int __offset = __offset(6);
|
||||
if (__offset != 0) {
|
||||
return __vector_len(__offset);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public MetadataItem.Vector listVector() {
|
||||
return listVector(new MetadataItem.Vector());
|
||||
}
|
||||
|
||||
public MetadataItem.Vector listVector(MetadataItem.Vector vector) {
|
||||
int __offset = __offset(6);
|
||||
if (__offset != 0) {
|
||||
return vector.__assign(__vector(__offset), 4, this.bb);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String sourceSha() {
|
||||
int __offset = __offset(8);
|
||||
if (__offset != 0) {
|
||||
return __string(__offset + this.bb_pos);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ByteBuffer sourceShaAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(8, 1);
|
||||
}
|
||||
|
||||
public ByteBuffer sourceShaInByteBuffer(ByteBuffer byteBuffer) {
|
||||
return __vector_in_bytebuffer(byteBuffer, 8, 1);
|
||||
}
|
||||
|
||||
public static int createMetadataList(FlatBufferBuilder flatBufferBuilder, int i, int i2, int i3) {
|
||||
flatBufferBuilder.startTable(3);
|
||||
addSourceSha(flatBufferBuilder, i3);
|
||||
addList(flatBufferBuilder, i2);
|
||||
addVersion(flatBufferBuilder, i);
|
||||
return endMetadataList(flatBufferBuilder);
|
||||
}
|
||||
|
||||
public static void startMetadataList(FlatBufferBuilder flatBufferBuilder) {
|
||||
flatBufferBuilder.startTable(3);
|
||||
}
|
||||
|
||||
public static void addVersion(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.addInt(0, i, 0);
|
||||
}
|
||||
|
||||
public static void addList(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.addOffset(1, i, 0);
|
||||
}
|
||||
|
||||
public static int createListVector(FlatBufferBuilder flatBufferBuilder, int[] iArr) {
|
||||
flatBufferBuilder.startVector(4, iArr.length, 4);
|
||||
for (int length = iArr.length - 1; length >= 0; length--) {
|
||||
flatBufferBuilder.addOffset(iArr[length]);
|
||||
}
|
||||
return flatBufferBuilder.endVector();
|
||||
}
|
||||
|
||||
public static void startListVector(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.startVector(4, i, 4);
|
||||
}
|
||||
|
||||
public static void addSourceSha(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.addOffset(2, i, 0);
|
||||
}
|
||||
|
||||
public static int endMetadataList(FlatBufferBuilder flatBufferBuilder) {
|
||||
return flatBufferBuilder.endTable();
|
||||
}
|
||||
|
||||
public static void finishMetadataListBuffer(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.finish(i);
|
||||
}
|
||||
|
||||
public static void finishSizePrefixedMetadataListBuffer(FlatBufferBuilder flatBufferBuilder, int i) {
|
||||
flatBufferBuilder.finishSizePrefixed(i);
|
||||
}
|
||||
|
||||
public static final class Vector extends BaseVector {
|
||||
public Vector __assign(int i, int i2, ByteBuffer byteBuffer) {
|
||||
__reset(i, i2, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MetadataList get(int i) {
|
||||
return get(new MetadataList(), i);
|
||||
}
|
||||
|
||||
public MetadataList get(MetadataList metadataList, int i) {
|
||||
return metadataList.__assign(MetadataList.__indirect(__element(i), this.bb), this.bb);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface ReadBuf {
|
||||
byte[] data();
|
||||
|
||||
byte get(int i);
|
||||
|
||||
boolean getBoolean(int i);
|
||||
|
||||
double getDouble(int i);
|
||||
|
||||
float getFloat(int i);
|
||||
|
||||
int getInt(int i);
|
||||
|
||||
long getLong(int i);
|
||||
|
||||
short getShort(int i);
|
||||
|
||||
String getString(int i, int i2);
|
||||
|
||||
int limit();
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
interface ReadWriteBuf extends ReadBuf {
|
||||
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
|
||||
int limit();
|
||||
|
||||
void put(byte b);
|
||||
|
||||
void put(byte[] bArr, int i, int i2);
|
||||
|
||||
void putBoolean(boolean z);
|
||||
|
||||
void putDouble(double d);
|
||||
|
||||
void putFloat(float f);
|
||||
|
||||
void putInt(int i);
|
||||
|
||||
void putLong(long j);
|
||||
|
||||
void putShort(short s);
|
||||
|
||||
boolean requestCapacity(int i);
|
||||
|
||||
void set(int i, byte b);
|
||||
|
||||
void set(int i, byte[] bArr, int i2, int i3);
|
||||
|
||||
void setBoolean(int i, boolean z);
|
||||
|
||||
void setDouble(int i, double d);
|
||||
|
||||
void setFloat(int i, float f);
|
||||
|
||||
void setInt(int i, int i2);
|
||||
|
||||
void setLong(int i, long j);
|
||||
|
||||
void setShort(int i, short s);
|
||||
|
||||
int writePosition();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import kotlin.UShort;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class ShortVector extends BaseVector {
|
||||
public ShortVector __assign(int i, ByteBuffer byteBuffer) {
|
||||
__reset(i, 2, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public short get(int i) {
|
||||
return this.bb.getShort(__element(i));
|
||||
}
|
||||
|
||||
public int getAsUnsigned(int i) {
|
||||
return get(i) & UShort.MAX_VALUE;
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class StringVector extends BaseVector {
|
||||
private Utf8 utf8 = Utf8.getDefault();
|
||||
|
||||
public StringVector __assign(int i, int i2, ByteBuffer byteBuffer) {
|
||||
__reset(i, i2, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String get(int i) {
|
||||
return Table.__string(__element(i), this.bb, this.utf8);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Struct {
|
||||
protected ByteBuffer bb;
|
||||
protected int bb_pos;
|
||||
|
||||
protected void __reset(int i, ByteBuffer byteBuffer) {
|
||||
this.bb = byteBuffer;
|
||||
if (byteBuffer != null) {
|
||||
this.bb_pos = i;
|
||||
} else {
|
||||
this.bb_pos = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void __reset() {
|
||||
__reset(0, null);
|
||||
}
|
||||
}
|
174
02-Easy5/E5/sources/androidx/emoji2/text/flatbuffer/Table.java
Normal file
174
02-Easy5/E5/sources/androidx/emoji2/text/flatbuffer/Table.java
Normal file
@ -0,0 +1,174 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Table {
|
||||
protected ByteBuffer bb;
|
||||
protected int bb_pos;
|
||||
Utf8 utf8 = Utf8.getDefault();
|
||||
private int vtable_size;
|
||||
private int vtable_start;
|
||||
|
||||
public ByteBuffer getByteBuffer() {
|
||||
return this.bb;
|
||||
}
|
||||
|
||||
protected int keysCompare(Integer num, Integer num2, ByteBuffer byteBuffer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int __offset(int i) {
|
||||
if (i < this.vtable_size) {
|
||||
return this.bb.getShort(this.vtable_start + i);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected static int __offset(int i, int i2, ByteBuffer byteBuffer) {
|
||||
int capacity = byteBuffer.capacity() - i2;
|
||||
return byteBuffer.getShort((i + capacity) - byteBuffer.getInt(capacity)) + capacity;
|
||||
}
|
||||
|
||||
protected int __indirect(int i) {
|
||||
return i + this.bb.getInt(i);
|
||||
}
|
||||
|
||||
protected static int __indirect(int i, ByteBuffer byteBuffer) {
|
||||
return i + byteBuffer.getInt(i);
|
||||
}
|
||||
|
||||
protected String __string(int i) {
|
||||
return __string(i, this.bb, this.utf8);
|
||||
}
|
||||
|
||||
protected static String __string(int i, ByteBuffer byteBuffer, Utf8 utf8) {
|
||||
int i2 = i + byteBuffer.getInt(i);
|
||||
return utf8.decodeUtf8(byteBuffer, i2 + 4, byteBuffer.getInt(i2));
|
||||
}
|
||||
|
||||
protected int __vector_len(int i) {
|
||||
int i2 = i + this.bb_pos;
|
||||
return this.bb.getInt(i2 + this.bb.getInt(i2));
|
||||
}
|
||||
|
||||
protected int __vector(int i) {
|
||||
int i2 = i + this.bb_pos;
|
||||
return i2 + this.bb.getInt(i2) + 4;
|
||||
}
|
||||
|
||||
protected ByteBuffer __vector_as_bytebuffer(int i, int i2) {
|
||||
int __offset = __offset(i);
|
||||
if (__offset == 0) {
|
||||
return null;
|
||||
}
|
||||
ByteBuffer order = this.bb.duplicate().order(ByteOrder.LITTLE_ENDIAN);
|
||||
int __vector = __vector(__offset);
|
||||
order.position(__vector);
|
||||
order.limit(__vector + (__vector_len(__offset) * i2));
|
||||
return order;
|
||||
}
|
||||
|
||||
protected ByteBuffer __vector_in_bytebuffer(ByteBuffer byteBuffer, int i, int i2) {
|
||||
int __offset = __offset(i);
|
||||
if (__offset == 0) {
|
||||
return null;
|
||||
}
|
||||
int __vector = __vector(__offset);
|
||||
byteBuffer.rewind();
|
||||
byteBuffer.limit((__vector_len(__offset) * i2) + __vector);
|
||||
byteBuffer.position(__vector);
|
||||
return byteBuffer;
|
||||
}
|
||||
|
||||
protected Table __union(Table table, int i) {
|
||||
return __union(table, i, this.bb);
|
||||
}
|
||||
|
||||
protected static Table __union(Table table, int i, ByteBuffer byteBuffer) {
|
||||
table.__reset(__indirect(i, byteBuffer), byteBuffer);
|
||||
return table;
|
||||
}
|
||||
|
||||
protected static boolean __has_identifier(ByteBuffer byteBuffer, String str) {
|
||||
if (str.length() != 4) {
|
||||
throw new AssertionError("FlatBuffers: file identifier must be length 4");
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (str.charAt(i) != ((char) byteBuffer.get(byteBuffer.position() + 4 + i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void sortTables(int[] iArr, final ByteBuffer byteBuffer) {
|
||||
Integer[] numArr = new Integer[iArr.length];
|
||||
for (int i = 0; i < iArr.length; i++) {
|
||||
numArr[i] = Integer.valueOf(iArr[i]);
|
||||
}
|
||||
Arrays.sort(numArr, new Comparator<Integer>() { // from class: androidx.emoji2.text.flatbuffer.Table.1
|
||||
@Override // java.util.Comparator
|
||||
public int compare(Integer num, Integer num2) {
|
||||
return Table.this.keysCompare(num, num2, byteBuffer);
|
||||
}
|
||||
});
|
||||
for (int i2 = 0; i2 < iArr.length; i2++) {
|
||||
iArr[i2] = numArr[i2].intValue();
|
||||
}
|
||||
}
|
||||
|
||||
protected static int compareStrings(int i, int i2, ByteBuffer byteBuffer) {
|
||||
int i3 = i + byteBuffer.getInt(i);
|
||||
int i4 = i2 + byteBuffer.getInt(i2);
|
||||
int i5 = byteBuffer.getInt(i3);
|
||||
int i6 = byteBuffer.getInt(i4);
|
||||
int i7 = i3 + 4;
|
||||
int i8 = i4 + 4;
|
||||
int min = Math.min(i5, i6);
|
||||
for (int i9 = 0; i9 < min; i9++) {
|
||||
int i10 = i9 + i7;
|
||||
int i11 = i9 + i8;
|
||||
if (byteBuffer.get(i10) != byteBuffer.get(i11)) {
|
||||
return byteBuffer.get(i10) - byteBuffer.get(i11);
|
||||
}
|
||||
}
|
||||
return i5 - i6;
|
||||
}
|
||||
|
||||
protected static int compareStrings(int i, byte[] bArr, ByteBuffer byteBuffer) {
|
||||
int i2 = i + byteBuffer.getInt(i);
|
||||
int i3 = byteBuffer.getInt(i2);
|
||||
int length = bArr.length;
|
||||
int i4 = i2 + 4;
|
||||
int min = Math.min(i3, length);
|
||||
for (int i5 = 0; i5 < min; i5++) {
|
||||
int i6 = i5 + i4;
|
||||
if (byteBuffer.get(i6) != bArr[i5]) {
|
||||
return byteBuffer.get(i6) - bArr[i5];
|
||||
}
|
||||
}
|
||||
return i3 - length;
|
||||
}
|
||||
|
||||
protected void __reset(int i, ByteBuffer byteBuffer) {
|
||||
this.bb = byteBuffer;
|
||||
if (byteBuffer == null) {
|
||||
this.bb_pos = 0;
|
||||
this.vtable_start = 0;
|
||||
this.vtable_size = 0;
|
||||
} else {
|
||||
this.bb_pos = i;
|
||||
int i2 = i - byteBuffer.getInt(i);
|
||||
this.vtable_start = i2;
|
||||
this.vtable_size = this.bb.getShort(i2);
|
||||
}
|
||||
}
|
||||
|
||||
public void __reset() {
|
||||
__reset(0, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class UnionVector extends BaseVector {
|
||||
public UnionVector __assign(int i, int i2, ByteBuffer byteBuffer) {
|
||||
__reset(i, i2, byteBuffer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Table get(Table table, int i) {
|
||||
return Table.__union(table, __element(i), this.bb);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Utf8 {
|
||||
private static Utf8 DEFAULT;
|
||||
|
||||
public static void setDefault(Utf8 utf8) {
|
||||
DEFAULT = utf8;
|
||||
}
|
||||
|
||||
public abstract String decodeUtf8(ByteBuffer byteBuffer, int i, int i2);
|
||||
|
||||
public abstract void encodeUtf8(CharSequence charSequence, ByteBuffer byteBuffer);
|
||||
|
||||
public abstract int encodedLength(CharSequence charSequence);
|
||||
|
||||
public static Utf8 getDefault() {
|
||||
if (DEFAULT == null) {
|
||||
DEFAULT = new Utf8Safe();
|
||||
}
|
||||
return DEFAULT;
|
||||
}
|
||||
|
||||
static class DecodeUtil {
|
||||
private static char highSurrogate(int i) {
|
||||
return (char) ((i >>> 10) + 55232);
|
||||
}
|
||||
|
||||
private static boolean isNotTrailingByte(byte b) {
|
||||
return b > -65;
|
||||
}
|
||||
|
||||
static boolean isOneByte(byte b) {
|
||||
return b >= 0;
|
||||
}
|
||||
|
||||
static boolean isThreeBytes(byte b) {
|
||||
return b < -16;
|
||||
}
|
||||
|
||||
static boolean isTwoBytes(byte b) {
|
||||
return b < -32;
|
||||
}
|
||||
|
||||
private static char lowSurrogate(int i) {
|
||||
return (char) ((i & 1023) + 56320);
|
||||
}
|
||||
|
||||
private static int trailingByteValue(byte b) {
|
||||
return b & 63;
|
||||
}
|
||||
|
||||
DecodeUtil() {
|
||||
}
|
||||
|
||||
static void handleOneByte(byte b, char[] cArr, int i) {
|
||||
cArr[i] = (char) b;
|
||||
}
|
||||
|
||||
static void handleTwoBytes(byte b, byte b2, char[] cArr, int i) throws IllegalArgumentException {
|
||||
if (b < -62) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8: Illegal leading byte in 2 bytes utf");
|
||||
}
|
||||
if (isNotTrailingByte(b2)) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8: Illegal trailing byte in 2 bytes utf");
|
||||
}
|
||||
cArr[i] = (char) (((b & 31) << 6) | trailingByteValue(b2));
|
||||
}
|
||||
|
||||
static void handleThreeBytes(byte b, byte b2, byte b3, char[] cArr, int i) throws IllegalArgumentException {
|
||||
if (isNotTrailingByte(b2) || ((b == -32 && b2 < -96) || ((b == -19 && b2 >= -96) || isNotTrailingByte(b3)))) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
cArr[i] = (char) (((b & 15) << 12) | (trailingByteValue(b2) << 6) | trailingByteValue(b3));
|
||||
}
|
||||
|
||||
static void handleFourBytes(byte b, byte b2, byte b3, byte b4, char[] cArr, int i) throws IllegalArgumentException {
|
||||
if (isNotTrailingByte(b2) || (((b << 28) + (b2 + 112)) >> 30) != 0 || isNotTrailingByte(b3) || isNotTrailingByte(b4)) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
int trailingByteValue = ((b & 7) << 18) | (trailingByteValue(b2) << 12) | (trailingByteValue(b3) << 6) | trailingByteValue(b4);
|
||||
cArr[i] = highSurrogate(trailingByteValue);
|
||||
cArr[i + 1] = lowSurrogate(trailingByteValue);
|
||||
}
|
||||
}
|
||||
|
||||
static class UnpairedSurrogateException extends IllegalArgumentException {
|
||||
UnpairedSurrogateException(int i, int i2) {
|
||||
super("Unpaired surrogate at index " + i + " of " + i2);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.CharacterCodingException;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Utf8Old extends Utf8 {
|
||||
private static final ThreadLocal<Cache> CACHE;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
static class Cache {
|
||||
CharSequence lastInput = null;
|
||||
ByteBuffer lastOutput = null;
|
||||
final CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
|
||||
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder();
|
||||
|
||||
Cache() {
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
ThreadLocal<Cache> withInitial;
|
||||
withInitial = ThreadLocal.withInitial(new Supplier() { // from class: androidx.emoji2.text.flatbuffer.Utf8Old$$ExternalSyntheticLambda1
|
||||
@Override // java.util.function.Supplier
|
||||
public final Object get() {
|
||||
return Utf8Old.lambda$static$0();
|
||||
}
|
||||
});
|
||||
CACHE = withInitial;
|
||||
}
|
||||
|
||||
static /* synthetic */ Cache lambda$static$0() {
|
||||
return new Cache();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public int encodedLength(CharSequence charSequence) {
|
||||
Cache cache = CACHE.get();
|
||||
int length = (int) (charSequence.length() * cache.encoder.maxBytesPerChar());
|
||||
if (cache.lastOutput == null || cache.lastOutput.capacity() < length) {
|
||||
cache.lastOutput = ByteBuffer.allocate(Math.max(128, length));
|
||||
}
|
||||
cache.lastOutput.clear();
|
||||
cache.lastInput = charSequence;
|
||||
CoderResult encode = cache.encoder.encode(charSequence instanceof CharBuffer ? (CharBuffer) charSequence : CharBuffer.wrap(charSequence), cache.lastOutput, true);
|
||||
if (encode.isError()) {
|
||||
try {
|
||||
encode.throwException();
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("bad character encoding", e);
|
||||
}
|
||||
}
|
||||
cache.lastOutput.flip();
|
||||
return cache.lastOutput.remaining();
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public void encodeUtf8(CharSequence charSequence, ByteBuffer byteBuffer) {
|
||||
Cache cache = CACHE.get();
|
||||
if (cache.lastInput != charSequence) {
|
||||
encodedLength(charSequence);
|
||||
}
|
||||
byteBuffer.put(cache.lastOutput);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public String decodeUtf8(ByteBuffer byteBuffer, int i, int i2) {
|
||||
CharsetDecoder charsetDecoder = CACHE.get().decoder;
|
||||
charsetDecoder.reset();
|
||||
ByteBuffer duplicate = byteBuffer.duplicate();
|
||||
duplicate.position(i);
|
||||
duplicate.limit(i + i2);
|
||||
try {
|
||||
return charsetDecoder.decode(duplicate).toString();
|
||||
} catch (CharacterCodingException e) {
|
||||
throw new IllegalArgumentException("Bad encoding", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,309 @@
|
||||
package androidx.emoji2.text.flatbuffer;
|
||||
|
||||
import androidx.emoji2.text.flatbuffer.Utf8;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Utf8Safe extends Utf8 {
|
||||
private static int computeEncodedLength(CharSequence charSequence) {
|
||||
int length = charSequence.length();
|
||||
int i = 0;
|
||||
while (i < length && charSequence.charAt(i) < 128) {
|
||||
i++;
|
||||
}
|
||||
int i2 = length;
|
||||
while (true) {
|
||||
if (i < length) {
|
||||
char charAt = charSequence.charAt(i);
|
||||
if (charAt >= 2048) {
|
||||
i2 += encodedLengthGeneral(charSequence, i);
|
||||
break;
|
||||
}
|
||||
i2 += (127 - charAt) >>> 31;
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i2 >= length) {
|
||||
return i2;
|
||||
}
|
||||
throw new IllegalArgumentException("UTF-8 length does not fit in int: " + (i2 + 4294967296L));
|
||||
}
|
||||
|
||||
private static int encodedLengthGeneral(CharSequence charSequence, int i) {
|
||||
int length = charSequence.length();
|
||||
int i2 = 0;
|
||||
while (i < length) {
|
||||
char charAt = charSequence.charAt(i);
|
||||
if (charAt < 2048) {
|
||||
i2 += (127 - charAt) >>> 31;
|
||||
} else {
|
||||
i2 += 2;
|
||||
if (55296 <= charAt && charAt <= 57343) {
|
||||
if (Character.codePointAt(charSequence, i) < 65536) {
|
||||
throw new UnpairedSurrogateException(i, length);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return i2;
|
||||
}
|
||||
|
||||
public static String decodeUtf8Array(byte[] bArr, int i, int i2) {
|
||||
if ((i | i2 | ((bArr.length - i) - i2)) < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(String.format("buffer length=%d, index=%d, size=%d", Integer.valueOf(bArr.length), Integer.valueOf(i), Integer.valueOf(i2)));
|
||||
}
|
||||
int i3 = i + i2;
|
||||
char[] cArr = new char[i2];
|
||||
int i4 = 0;
|
||||
while (i < i3) {
|
||||
byte b = bArr[i];
|
||||
if (!Utf8.DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
Utf8.DecodeUtil.handleOneByte(b, cArr, i4);
|
||||
i4++;
|
||||
}
|
||||
int i5 = i4;
|
||||
while (i < i3) {
|
||||
int i6 = i + 1;
|
||||
byte b2 = bArr[i];
|
||||
if (Utf8.DecodeUtil.isOneByte(b2)) {
|
||||
int i7 = i5 + 1;
|
||||
Utf8.DecodeUtil.handleOneByte(b2, cArr, i5);
|
||||
while (i6 < i3) {
|
||||
byte b3 = bArr[i6];
|
||||
if (!Utf8.DecodeUtil.isOneByte(b3)) {
|
||||
break;
|
||||
}
|
||||
i6++;
|
||||
Utf8.DecodeUtil.handleOneByte(b3, cArr, i7);
|
||||
i7++;
|
||||
}
|
||||
i5 = i7;
|
||||
i = i6;
|
||||
} else if (Utf8.DecodeUtil.isTwoBytes(b2)) {
|
||||
if (i6 >= i3) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
i += 2;
|
||||
Utf8.DecodeUtil.handleTwoBytes(b2, bArr[i6], cArr, i5);
|
||||
i5++;
|
||||
} else if (Utf8.DecodeUtil.isThreeBytes(b2)) {
|
||||
if (i6 >= i3 - 1) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
int i8 = i + 2;
|
||||
i += 3;
|
||||
Utf8.DecodeUtil.handleThreeBytes(b2, bArr[i6], bArr[i8], cArr, i5);
|
||||
i5++;
|
||||
} else {
|
||||
if (i6 >= i3 - 2) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
byte b4 = bArr[i6];
|
||||
int i9 = i + 3;
|
||||
byte b5 = bArr[i + 2];
|
||||
i += 4;
|
||||
Utf8.DecodeUtil.handleFourBytes(b2, b4, b5, bArr[i9], cArr, i5);
|
||||
i5 += 2;
|
||||
}
|
||||
}
|
||||
return new String(cArr, 0, i5);
|
||||
}
|
||||
|
||||
public static String decodeUtf8Buffer(ByteBuffer byteBuffer, int i, int i2) {
|
||||
if ((i | i2 | ((byteBuffer.limit() - i) - i2)) < 0) {
|
||||
throw new ArrayIndexOutOfBoundsException(String.format("buffer limit=%d, index=%d, limit=%d", Integer.valueOf(byteBuffer.limit()), Integer.valueOf(i), Integer.valueOf(i2)));
|
||||
}
|
||||
int i3 = i + i2;
|
||||
char[] cArr = new char[i2];
|
||||
int i4 = 0;
|
||||
while (i < i3) {
|
||||
byte b = byteBuffer.get(i);
|
||||
if (!Utf8.DecodeUtil.isOneByte(b)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
Utf8.DecodeUtil.handleOneByte(b, cArr, i4);
|
||||
i4++;
|
||||
}
|
||||
int i5 = i4;
|
||||
while (i < i3) {
|
||||
int i6 = i + 1;
|
||||
byte b2 = byteBuffer.get(i);
|
||||
if (Utf8.DecodeUtil.isOneByte(b2)) {
|
||||
int i7 = i5 + 1;
|
||||
Utf8.DecodeUtil.handleOneByte(b2, cArr, i5);
|
||||
while (i6 < i3) {
|
||||
byte b3 = byteBuffer.get(i6);
|
||||
if (!Utf8.DecodeUtil.isOneByte(b3)) {
|
||||
break;
|
||||
}
|
||||
i6++;
|
||||
Utf8.DecodeUtil.handleOneByte(b3, cArr, i7);
|
||||
i7++;
|
||||
}
|
||||
i5 = i7;
|
||||
i = i6;
|
||||
} else if (Utf8.DecodeUtil.isTwoBytes(b2)) {
|
||||
if (i6 >= i3) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
i += 2;
|
||||
Utf8.DecodeUtil.handleTwoBytes(b2, byteBuffer.get(i6), cArr, i5);
|
||||
i5++;
|
||||
} else if (Utf8.DecodeUtil.isThreeBytes(b2)) {
|
||||
if (i6 >= i3 - 1) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
int i8 = i + 2;
|
||||
i += 3;
|
||||
Utf8.DecodeUtil.handleThreeBytes(b2, byteBuffer.get(i6), byteBuffer.get(i8), cArr, i5);
|
||||
i5++;
|
||||
} else {
|
||||
if (i6 >= i3 - 2) {
|
||||
throw new IllegalArgumentException("Invalid UTF-8");
|
||||
}
|
||||
byte b4 = byteBuffer.get(i6);
|
||||
int i9 = i + 3;
|
||||
byte b5 = byteBuffer.get(i + 2);
|
||||
i += 4;
|
||||
Utf8.DecodeUtil.handleFourBytes(b2, b4, b5, byteBuffer.get(i9), cArr, i5);
|
||||
i5 += 2;
|
||||
}
|
||||
}
|
||||
return new String(cArr, 0, i5);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public int encodedLength(CharSequence charSequence) {
|
||||
return computeEncodedLength(charSequence);
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public String decodeUtf8(ByteBuffer byteBuffer, int i, int i2) throws IllegalArgumentException {
|
||||
if (byteBuffer.hasArray()) {
|
||||
return decodeUtf8Array(byteBuffer.array(), byteBuffer.arrayOffset() + i, i2);
|
||||
}
|
||||
return decodeUtf8Buffer(byteBuffer, i, i2);
|
||||
}
|
||||
|
||||
private static void encodeUtf8Buffer(CharSequence charSequence, ByteBuffer byteBuffer) {
|
||||
int length = charSequence.length();
|
||||
int position = byteBuffer.position();
|
||||
int i = 0;
|
||||
while (i < length) {
|
||||
try {
|
||||
char charAt = charSequence.charAt(i);
|
||||
if (charAt >= 128) {
|
||||
break;
|
||||
}
|
||||
byteBuffer.put(position + i, (byte) charAt);
|
||||
i++;
|
||||
} catch (IndexOutOfBoundsException unused) {
|
||||
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i) + " at index " + (byteBuffer.position() + Math.max(i, (position - byteBuffer.position()) + 1)));
|
||||
}
|
||||
}
|
||||
if (i == length) {
|
||||
byteBuffer.position(position + i);
|
||||
return;
|
||||
}
|
||||
position += i;
|
||||
while (i < length) {
|
||||
char charAt2 = charSequence.charAt(i);
|
||||
if (charAt2 < 128) {
|
||||
byteBuffer.put(position, (byte) charAt2);
|
||||
} else if (charAt2 < 2048) {
|
||||
int i2 = position + 1;
|
||||
try {
|
||||
byteBuffer.put(position, (byte) ((charAt2 >>> 6) | 192));
|
||||
byteBuffer.put(i2, (byte) ((charAt2 & '?') | 128));
|
||||
position = i2;
|
||||
} catch (IndexOutOfBoundsException unused2) {
|
||||
position = i2;
|
||||
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i) + " at index " + (byteBuffer.position() + Math.max(i, (position - byteBuffer.position()) + 1)));
|
||||
}
|
||||
} else if (charAt2 < 55296 || 57343 < charAt2) {
|
||||
int i3 = position + 1;
|
||||
byteBuffer.put(position, (byte) ((charAt2 >>> '\f') | 224));
|
||||
position += 2;
|
||||
byteBuffer.put(i3, (byte) (((charAt2 >>> 6) & 63) | 128));
|
||||
byteBuffer.put(position, (byte) ((charAt2 & '?') | 128));
|
||||
} else {
|
||||
int i4 = i + 1;
|
||||
if (i4 != length) {
|
||||
try {
|
||||
char charAt3 = charSequence.charAt(i4);
|
||||
if (Character.isSurrogatePair(charAt2, charAt3)) {
|
||||
int codePoint = Character.toCodePoint(charAt2, charAt3);
|
||||
int i5 = position + 1;
|
||||
try {
|
||||
byteBuffer.put(position, (byte) ((codePoint >>> 18) | 240));
|
||||
int i6 = position + 2;
|
||||
try {
|
||||
byteBuffer.put(i5, (byte) (((codePoint >>> 12) & 63) | 128));
|
||||
position += 3;
|
||||
byteBuffer.put(i6, (byte) (((codePoint >>> 6) & 63) | 128));
|
||||
byteBuffer.put(position, (byte) ((codePoint & 63) | 128));
|
||||
i = i4;
|
||||
} catch (IndexOutOfBoundsException unused3) {
|
||||
i = i4;
|
||||
position = i6;
|
||||
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i) + " at index " + (byteBuffer.position() + Math.max(i, (position - byteBuffer.position()) + 1)));
|
||||
}
|
||||
} catch (IndexOutOfBoundsException unused4) {
|
||||
position = i5;
|
||||
i = i4;
|
||||
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i) + " at index " + (byteBuffer.position() + Math.max(i, (position - byteBuffer.position()) + 1)));
|
||||
}
|
||||
} else {
|
||||
i = i4;
|
||||
}
|
||||
} catch (IndexOutOfBoundsException unused5) {
|
||||
}
|
||||
}
|
||||
throw new UnpairedSurrogateException(i, length);
|
||||
}
|
||||
i++;
|
||||
position++;
|
||||
}
|
||||
byteBuffer.position(position);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:12:0x001d, code lost:
|
||||
|
||||
return r9 + r0;
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct add '--show-bad-code' argument
|
||||
*/
|
||||
private static int encodeUtf8Array(java.lang.CharSequence r7, byte[] r8, int r9, int r10) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 251
|
||||
To view this dump add '--comments-level debug' option
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: androidx.emoji2.text.flatbuffer.Utf8Safe.encodeUtf8Array(java.lang.CharSequence, byte[], int, int):int");
|
||||
}
|
||||
|
||||
@Override // androidx.emoji2.text.flatbuffer.Utf8
|
||||
public void encodeUtf8(CharSequence charSequence, ByteBuffer byteBuffer) {
|
||||
if (byteBuffer.hasArray()) {
|
||||
int arrayOffset = byteBuffer.arrayOffset();
|
||||
byteBuffer.position(encodeUtf8Array(charSequence, byteBuffer.array(), byteBuffer.position() + arrayOffset, byteBuffer.remaining()) - arrayOffset);
|
||||
} else {
|
||||
encodeUtf8Buffer(charSequence, byteBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
static class UnpairedSurrogateException extends IllegalArgumentException {
|
||||
UnpairedSurrogateException(int i, int i2) {
|
||||
super("Unpaired surrogate at index " + i + " of " + i2);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user