Add decompiled APK source code (JADX)

- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
2026-02-18 14:52:23 -08:00
parent cc210a65ea
commit f9d20bb3fc
26991 changed files with 2541449 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
package androidx.emoji2.text;
import android.os.Handler;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public final /* synthetic */ class ConcurrencyHelpers$$ExternalSyntheticLambda1 implements Executor {
public final /* synthetic */ Handler f$0;
@Override // java.util.concurrent.Executor
public final void execute(Runnable runnable) {
this.f$0.post(runnable);
}
}

View File

@@ -0,0 +1,5 @@
package androidx.emoji2.text;
/* loaded from: classes.dex */
public abstract /* synthetic */ class ConcurrencyHelpers$Handler28Impl$$ExternalSyntheticApiModelOutline0 {
}

View File

@@ -0,0 +1,69 @@
package androidx.emoji2.text;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
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() {
}
public static ThreadPoolExecutor createBackgroundPriorityExecutor(@NonNull 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) {
Thread lambda$createBackgroundPriorityExecutor$0;
lambda$createBackgroundPriorityExecutor$0 = ConcurrencyHelpers.lambda$createBackgroundPriorityExecutor$0(str, runnable);
return lambda$createBackgroundPriorityExecutor$0;
}
});
threadPoolExecutor.allowCoreThreadTimeOut(true);
return threadPoolExecutor;
}
/* JADX INFO: Access modifiers changed from: private */
public static /* synthetic */ Thread lambda$createBackgroundPriorityExecutor$0(String str, Runnable runnable) {
Thread thread = new Thread(runnable, str);
thread.setPriority(10);
return thread;
}
public static Handler mainHandlerAsync() {
if (Build.VERSION.SDK_INT >= 28) {
return Handler28Impl.createAsync(Looper.getMainLooper());
}
return new Handler(Looper.getMainLooper());
}
@NonNull
@Deprecated
public static Executor convertHandlerToExecutor(@NonNull Handler handler) {
Objects.requireNonNull(handler);
return new ConcurrencyHelpers$$ExternalSyntheticLambda1(handler);
}
@RequiresApi(28)
public static class Handler28Impl {
private Handler28Impl() {
}
@DoNotInline
public static Handler createAsync(Looper looper) {
Handler createAsync;
createAsync = Handler.createAsync(looper);
return createAsync;
}
}
}

View File

@@ -0,0 +1,170 @@
package androidx.emoji2.text;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
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.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
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() {
}
@Nullable
public static FontRequestEmojiCompatConfig create(@NonNull Context context) {
return (FontRequestEmojiCompatConfig) new DefaultEmojiCompatConfigFactory(null).create(context);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class DefaultEmojiCompatConfigFactory {
@NonNull
private static final String DEFAULT_EMOJI_QUERY = "emojicompat-emoji-font";
@NonNull
private static final String INTENT_LOAD_EMOJI_FONT = "androidx.content.action.LOAD_EMOJI_FONT";
@NonNull
private static final String TAG = "emoji2.text.DefaultEmojiConfig";
private final DefaultEmojiCompatConfigHelper mHelper;
@RestrictTo({RestrictTo.Scope.LIBRARY})
public DefaultEmojiCompatConfigFactory(@Nullable DefaultEmojiCompatConfigHelper defaultEmojiCompatConfigHelper) {
this.mHelper = defaultEmojiCompatConfigHelper == null ? getHelperForApi() : defaultEmojiCompatConfigHelper;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public EmojiCompat.Config create(@NonNull Context context) {
return configOrNull(context, queryForDefaultFontRequest(context));
}
@Nullable
private EmojiCompat.Config configOrNull(@NonNull Context context, @Nullable FontRequest fontRequest) {
if (fontRequest == null) {
return null;
}
return new FontRequestEmojiCompatConfig(context, fontRequest);
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
@VisibleForTesting
public FontRequest queryForDefaultFontRequest(@NonNull 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;
}
}
@Nullable
private ProviderInfo queryDefaultInstalledContentProvider(@NonNull 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(@Nullable ProviderInfo providerInfo) {
ApplicationInfo applicationInfo;
return (providerInfo == null || (applicationInfo = providerInfo.applicationInfo) == null || (applicationInfo.flags & 1) != 1) ? false : true;
}
@NonNull
private FontRequest generateFontRequestFrom(@NonNull ProviderInfo providerInfo, @NonNull 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)));
}
@NonNull
private List<List<byte[]>> convertToByteArray(@NonNull Signature[] signatureArr) {
ArrayList arrayList = new ArrayList();
for (Signature signature : signatureArr) {
arrayList.add(signature.toByteArray());
}
return Collections.singletonList(arrayList);
}
@NonNull
private static DefaultEmojiCompatConfigHelper getHelperForApi() {
if (Build.VERSION.SDK_INT >= 28) {
return new DefaultEmojiCompatConfigHelper_API28();
}
return new DefaultEmojiCompatConfigHelper_API19();
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class DefaultEmojiCompatConfigHelper {
@NonNull
public Signature[] getSigningSignatures(@NonNull PackageManager packageManager, @NonNull String str) throws PackageManager.NameNotFoundException {
return packageManager.getPackageInfo(str, 64).signatures;
}
@NonNull
public List<ResolveInfo> queryIntentContentProviders(@NonNull PackageManager packageManager, @NonNull Intent intent, int i) {
return Collections.emptyList();
}
@Nullable
public ProviderInfo getProviderInfo(@NonNull ResolveInfo resolveInfo) {
throw new IllegalStateException("Unable to get provider info prior to API 19");
}
}
@RequiresApi(19)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class DefaultEmojiCompatConfigHelper_API19 extends DefaultEmojiCompatConfigHelper {
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
@NonNull
public List<ResolveInfo> queryIntentContentProviders(@NonNull PackageManager packageManager, @NonNull Intent intent, int i) {
return packageManager.queryIntentContentProviders(intent, i);
}
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
@Nullable
public ProviderInfo getProviderInfo(@NonNull ResolveInfo resolveInfo) {
return resolveInfo.providerInfo;
}
}
@RequiresApi(28)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class DefaultEmojiCompatConfigHelper_API28 extends DefaultEmojiCompatConfigHelper_API19 {
@Override // androidx.emoji2.text.DefaultEmojiCompatConfig.DefaultEmojiCompatConfigHelper
@NonNull
public Signature[] getSigningSignatures(@NonNull PackageManager packageManager, @NonNull String str) throws PackageManager.NameNotFoundException {
return packageManager.getPackageInfo(str, 64).signatures;
}
}
}

View File

@@ -0,0 +1,42 @@
package androidx.emoji2.text;
import android.text.TextPaint;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.PaintCompat;
import androidx.emoji2.text.EmojiCompat;
@AnyThread
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* 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;
public DefaultGlyphChecker() {
TextPaint textPaint = new TextPaint();
this.mTextPaint = textPaint;
textPaint.setTextSize(10.0f);
}
@Override // androidx.emoji2.text.EmojiCompat.GlyphChecker
public boolean hasGlyph(@NonNull CharSequence charSequence, int i, int i2, int i3) {
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();
}
}

View File

@@ -0,0 +1,747 @@
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.annotation.AnyThread;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.GuardedBy;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
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;
@AnyThread
/* 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";
@RestrictTo({RestrictTo.Scope.LIBRARY})
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;
@GuardedBy("CONFIG_LOCK")
private static volatile boolean sHasDoneDefaultConfigLookup;
@Nullable
@GuardedBy("INSTANCE_LOCK")
private static volatile EmojiCompat sInstance;
@Nullable
final int[] mEmojiAsDefaultStyleExceptions;
private final int mEmojiSpanIndicatorColor;
private final boolean mEmojiSpanIndicatorEnabled;
private final GlyphChecker mGlyphChecker;
@NonNull
private final CompatInternal mHelper;
@NonNull
@GuardedBy("mInitLock")
private final Set<InitCallback> mInitCallbacks;
@NonNull
private final ReadWriteLock mInitLock = new ReentrantReadWriteLock();
@GuardedBy("mInitLock")
private volatile int mLoadState = 3;
@NonNull
private final Handler mMainHandler = new Handler(Looper.getMainLooper());
private final int mMetadataLoadStrategy;
@NonNull
final MetadataRepoLoader mMetadataLoader;
final boolean mReplaceAll;
@NonNull
private final SpanFactory mSpanFactory;
final boolean mUseEmojiAsDefaultStyle;
private static final Object INSTANCE_LOCK = new Object();
private static final Object CONFIG_LOCK = new Object();
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface CodepointSequenceMatchResult {
}
public interface GlyphChecker {
boolean hasGlyph(@NonNull CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3);
}
public static abstract class InitCallback {
public void onFailed(@Nullable Throwable th) {
}
public void onInitialized() {
}
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface LoadStrategy {
}
public interface MetadataRepoLoader {
void load(@NonNull MetadataRepoLoaderCallback metadataRepoLoaderCallback);
}
public static abstract class MetadataRepoLoaderCallback {
public abstract void onFailed(@Nullable Throwable th);
public abstract void onLoaded(@NonNull MetadataRepo metadataRepo);
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY})
public @interface ReplaceStrategy {
}
public interface SpanFactory {
@NonNull
@RequiresApi(19)
EmojiSpan createSpan(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer);
}
public static boolean isConfigured() {
return sInstance != null;
}
@ColorInt
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public int getEmojiSpanIndicatorColor() {
return this.mEmojiSpanIndicatorColor;
}
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public boolean isEmojiSpanIndicatorEnabled() {
return this.mEmojiSpanIndicatorEnabled;
}
private EmojiCompat(@NonNull 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;
SpanFactory spanFactory = config.mSpanFactory;
this.mSpanFactory = spanFactory == null ? new DefaultSpanFactory() : spanFactory;
Set<InitCallback> set = config.mInitCallbacks;
if (set != null && !set.isEmpty()) {
arraySet.addAll(config.mInitCallbacks);
}
this.mHelper = new CompatInternal19(this);
loadMetadata();
}
@Nullable
public static EmojiCompat init(@NonNull Context context) {
return init(context, null);
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static EmojiCompat init(@NonNull Context context, @Nullable 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) {
try {
if (!sHasDoneDefaultConfigLookup) {
if (create != null) {
init(create);
}
sHasDoneDefaultConfigLookup = true;
}
emojiCompat = sInstance;
} catch (Throwable th) {
throw th;
}
}
return emojiCompat;
}
@NonNull
public static EmojiCompat init(@NonNull Config config) {
EmojiCompat emojiCompat = sInstance;
if (emojiCompat == null) {
synchronized (INSTANCE_LOCK) {
try {
emojiCompat = sInstance;
if (emojiCompat == null) {
emojiCompat = new EmojiCompat(config);
sInstance = emojiCompat;
}
} finally {
}
}
}
return emojiCompat;
}
@NonNull
public static EmojiCompat reset(@NonNull Config config) {
EmojiCompat emojiCompat;
synchronized (INSTANCE_LOCK) {
emojiCompat = new EmojiCompat(config);
sInstance = emojiCompat;
}
return emojiCompat;
}
@Nullable
@RestrictTo({RestrictTo.Scope.TESTS})
public static EmojiCompat reset(@Nullable EmojiCompat emojiCompat) {
EmojiCompat emojiCompat2;
synchronized (INSTANCE_LOCK) {
sInstance = emojiCompat;
emojiCompat2 = sInstance;
}
return emojiCompat2;
}
@RestrictTo({RestrictTo.Scope.TESTS})
public static void skipDefaultConfigurationLookup(boolean z) {
synchronized (CONFIG_LOCK) {
sHasDoneDefaultConfigLookup = z;
}
}
@NonNull
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;
}
}
public 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;
}
}
public void onMetadataLoadFailed(@Nullable 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(@NonNull 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.mInitLock.writeLock().unlock();
}
this.mMainHandler.post(new ListenerDispatcher(initCallback, this.mLoadState));
this.mInitLock.writeLock().unlock();
} catch (Throwable th) {
this.mInitLock.writeLock().unlock();
throw th;
}
}
public void unregisterInitCallback(@NonNull 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 int getEmojiStart(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
return this.mHelper.getEmojiStart(charSequence, i);
}
public int getEmojiEnd(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
return this.mHelper.getEmojiEnd(charSequence, i);
}
public static boolean handleOnKeyDown(@NonNull Editable editable, int i, @NonNull KeyEvent keyEvent) {
return EmojiProcessor.handleOnKeyDown(editable, i, keyEvent);
}
public static boolean handleDeleteSurroundingText(@NonNull InputConnection inputConnection, @NonNull Editable editable, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, boolean z) {
return EmojiProcessor.handleDeleteSurroundingText(inputConnection, editable, i, i2, z);
}
@Deprecated
public boolean hasEmojiGlyph(@NonNull CharSequence charSequence) {
Preconditions.checkState(isInitialized(), "Not initialized yet");
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
return this.mHelper.hasEmojiGlyph(charSequence);
}
@Deprecated
public boolean hasEmojiGlyph(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
Preconditions.checkState(isInitialized(), "Not initialized yet");
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
return this.mHelper.hasEmojiGlyph(charSequence, i);
}
public int getEmojiMatch(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
Preconditions.checkState(isInitialized(), "Not initialized yet");
Preconditions.checkNotNull(charSequence, "sequence cannot be null");
return this.mHelper.getEmojiMatch(charSequence, i);
}
@Nullable
@CheckResult
public CharSequence process(@Nullable CharSequence charSequence) {
return process(charSequence, 0, charSequence == null ? 0 : charSequence.length());
}
@Nullable
@CheckResult
public CharSequence process(@Nullable CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2) {
return process(charSequence, i, i2, Integer.MAX_VALUE);
}
@Nullable
@CheckResult
public CharSequence process(@Nullable CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3) {
return process(charSequence, i, i2, i3, 0);
}
@Nullable
@CheckResult
public CharSequence process(@Nullable CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3, int i4) {
boolean z;
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;
}
if (i4 != 1) {
z = i4 != 2 ? this.mReplaceAll : false;
} else {
z = true;
}
return this.mHelper.process(charSequence, i, i2, i3, z);
}
@NonNull
public String getAssetSignature() {
Preconditions.checkState(isInitialized(), "Not initialized yet");
return this.mHelper.getAssetSignature();
}
public void updateEditorInfo(@NonNull EditorInfo editorInfo) {
if (!isInitialized() || editorInfo == null) {
return;
}
if (editorInfo.extras == null) {
editorInfo.extras = new Bundle();
}
this.mHelper.updateEditorInfoAttrs(editorInfo);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class DefaultSpanFactory implements SpanFactory {
@Override // androidx.emoji2.text.EmojiCompat.SpanFactory
@NonNull
@RequiresApi(19)
public EmojiSpan createSpan(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
return new TypefaceEmojiSpan(typefaceEmojiRasterizer);
}
}
public static abstract class Config {
@Nullable
int[] mEmojiAsDefaultStyleExceptions;
boolean mEmojiSpanIndicatorEnabled;
@Nullable
Set<InitCallback> mInitCallbacks;
@NonNull
final MetadataRepoLoader mMetadataLoader;
boolean mReplaceAll;
SpanFactory mSpanFactory;
boolean mUseEmojiAsDefaultStyle;
int mEmojiSpanIndicatorColor = -16711936;
int mMetadataLoadStrategy = 0;
@NonNull
GlyphChecker mGlyphChecker = new DefaultGlyphChecker();
@NonNull
public final MetadataRepoLoader getMetadataRepoLoader() {
return this.mMetadataLoader;
}
@NonNull
public Config setEmojiSpanIndicatorColor(@ColorInt int i) {
this.mEmojiSpanIndicatorColor = i;
return this;
}
@NonNull
public Config setEmojiSpanIndicatorEnabled(boolean z) {
this.mEmojiSpanIndicatorEnabled = z;
return this;
}
@NonNull
public Config setMetadataLoadStrategy(int i) {
this.mMetadataLoadStrategy = i;
return this;
}
@NonNull
public Config setReplaceAll(boolean z) {
this.mReplaceAll = z;
return this;
}
@NonNull
public Config setSpanFactory(@NonNull SpanFactory spanFactory) {
this.mSpanFactory = spanFactory;
return this;
}
public Config(@NonNull MetadataRepoLoader metadataRepoLoader) {
Preconditions.checkNotNull(metadataRepoLoader, "metadataLoader cannot be null.");
this.mMetadataLoader = metadataRepoLoader;
}
@NonNull
public Config registerInitCallback(@NonNull InitCallback initCallback) {
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
if (this.mInitCallbacks == null) {
this.mInitCallbacks = new ArraySet();
}
this.mInitCallbacks.add(initCallback);
return this;
}
@NonNull
public Config unregisterInitCallback(@NonNull InitCallback initCallback) {
Preconditions.checkNotNull(initCallback, "initCallback cannot be null");
Set<InitCallback> set = this.mInitCallbacks;
if (set != null) {
set.remove(initCallback);
}
return this;
}
@NonNull
public Config setUseEmojiAsDefaultStyle(boolean z) {
return setUseEmojiAsDefaultStyle(z, null);
}
@NonNull
public Config setUseEmojiAsDefaultStyle(boolean z, @Nullable 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;
}
@NonNull
public Config setGlyphChecker(@NonNull GlyphChecker glyphChecker) {
Preconditions.checkNotNull(glyphChecker, "GlyphChecker cannot be null");
this.mGlyphChecker = glyphChecker;
return this;
}
}
public static class ListenerDispatcher implements Runnable {
private final List<InitCallback> mInitCallbacks;
private final int mLoadState;
private final Throwable mThrowable;
public ListenerDispatcher(@NonNull InitCallback initCallback, int i) {
this(Arrays.asList((InitCallback) Preconditions.checkNotNull(initCallback, "initCallback cannot be null")), i, null);
}
public ListenerDispatcher(@NonNull Collection<InitCallback> collection, int i) {
this(collection, i, null);
}
public ListenerDispatcher(@NonNull Collection<InitCallback> collection, int i, @Nullable 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++;
}
}
}
}
public static class CompatInternal {
final EmojiCompat mEmojiCompat;
public String getAssetSignature() {
return "";
}
public int getEmojiEnd(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
return -1;
}
public int getEmojiMatch(CharSequence charSequence, int i) {
return 0;
}
public int getEmojiStart(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
return -1;
}
public boolean hasEmojiGlyph(@NonNull CharSequence charSequence) {
return false;
}
public boolean hasEmojiGlyph(@NonNull CharSequence charSequence, int i) {
return false;
}
public CharSequence process(@NonNull CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3, boolean z) {
return charSequence;
}
public void updateEditorInfoAttrs(@NonNull EditorInfo editorInfo) {
}
public CompatInternal(EmojiCompat emojiCompat) {
this.mEmojiCompat = emojiCompat;
}
public void loadMetadata() {
this.mEmojiCompat.onMetadataLoadSuccess();
}
}
@RequiresApi(19)
public static final class CompatInternal19 extends CompatInternal {
private volatile MetadataRepo mMetadataRepo;
private volatile EmojiProcessor mProcessor;
public CompatInternal19(EmojiCompat emojiCompat) {
super(emojiCompat);
}
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
public 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(@NonNull MetadataRepo metadataRepo) {
CompatInternal19.this.onMetadataLoadSuccess(metadataRepo);
}
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
public void onFailed(@Nullable Throwable th) {
CompatInternal19.this.mEmojiCompat.onMetadataLoadFailed(th);
}
});
} catch (Throwable th) {
this.mEmojiCompat.onMetadataLoadFailed(th);
}
}
public void onMetadataLoadSuccess(@NonNull MetadataRepo metadataRepo) {
if (metadataRepo != null) {
this.mMetadataRepo = metadataRepo;
MetadataRepo metadataRepo2 = this.mMetadataRepo;
SpanFactory spanFactory = this.mEmojiCompat.mSpanFactory;
GlyphChecker glyphChecker = this.mEmojiCompat.mGlyphChecker;
EmojiCompat emojiCompat = this.mEmojiCompat;
this.mProcessor = new EmojiProcessor(metadataRepo2, spanFactory, glyphChecker, emojiCompat.mUseEmojiAsDefaultStyle, emojiCompat.mEmojiAsDefaultStyleExceptions, EmojiExclusions.getEmojiExclusions());
this.mEmojiCompat.onMetadataLoadSuccess();
return;
}
this.mEmojiCompat.onMetadataLoadFailed(new IllegalArgumentException("metadataRepo cannot be null"));
}
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
public boolean hasEmojiGlyph(@NonNull CharSequence charSequence) {
return this.mProcessor.getEmojiMatch(charSequence) == 1;
}
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
public boolean hasEmojiGlyph(@NonNull 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
public int getEmojiStart(@NonNull CharSequence charSequence, int i) {
return this.mProcessor.getEmojiStart(charSequence, i);
}
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
public int getEmojiEnd(@NonNull CharSequence charSequence, int i) {
return this.mProcessor.getEmojiEnd(charSequence, i);
}
@Override // androidx.emoji2.text.EmojiCompat.CompatInternal
public CharSequence process(@NonNull 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
public void updateEditorInfoAttrs(@NonNull 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
public String getAssetSignature() {
String sourceSha = this.mMetadataRepo.getMetadataList().sourceSha();
return sourceSha == null ? "" : sourceSha;
}
}
}

View File

@@ -0,0 +1,133 @@
package androidx.emoji2.text;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.WorkerThread;
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;
/* 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
@NonNull
public Boolean create(@NonNull Context context) {
EmojiCompat.init(new BackgroundDefaultConfig(context));
delayUntilFirstResume(context);
return Boolean.TRUE;
}
@RequiresApi(19)
public void delayUntilFirstResume(@NonNull 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 void onResume(@NonNull LifecycleOwner lifecycleOwner) {
EmojiCompatInitializer.this.loadEmojiCompatAfterDelay();
lifecycle.removeObserver(this);
}
});
}
@RequiresApi(19)
public void loadEmojiCompatAfterDelay() {
ConcurrencyHelpers.mainHandlerAsync().postDelayed(new LoadEmojiCompatRunnable(), 500L);
}
@Override // androidx.startup.Initializer
@NonNull
public List<Class<? extends Initializer<?>>> dependencies() {
return Collections.singletonList(ProcessLifecycleInitializer.class);
}
public static class LoadEmojiCompatRunnable implements Runnable {
@Override // java.lang.Runnable
public void run() {
try {
TraceCompat.beginSection("EmojiCompat.EmojiCompatInitializer.run");
if (EmojiCompat.isConfigured()) {
EmojiCompat.get().load();
}
} finally {
TraceCompat.endSection();
}
}
}
@RequiresApi(19)
public static class BackgroundDefaultConfig extends EmojiCompat.Config {
public BackgroundDefaultConfig(Context context) {
super(new BackgroundDefaultLoader(context));
setMetadataLoadStrategy(1);
}
}
@RequiresApi(19)
public static class BackgroundDefaultLoader implements EmojiCompat.MetadataRepoLoader {
private final Context mContext;
public BackgroundDefaultLoader(Context context) {
this.mContext = context.getApplicationContext();
}
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoader
public void load(@NonNull 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.lambda$load$0(metadataRepoLoaderCallback, createBackgroundPriorityExecutor);
}
});
}
@WorkerThread
/* renamed from: doLoad, reason: merged with bridge method [inline-methods] */
public void lambda$load$0(@NonNull final EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback, @NonNull 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(@NonNull MetadataRepo metadataRepo) {
try {
metadataRepoLoaderCallback.onLoaded(metadataRepo);
} finally {
threadPoolExecutor.shutdown();
}
}
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoaderCallback
public void onFailed(@Nullable Throwable th) {
try {
metadataRepoLoaderCallback.onFailed(th);
} finally {
threadPoolExecutor.shutdown();
}
}
});
} catch (Throwable th) {
metadataRepoLoaderCallback.onFailed(th);
threadPoolExecutor.shutdown();
}
}
}
}

View File

@@ -0,0 +1,12 @@
package androidx.emoji2.text;
import androidx.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* loaded from: classes.dex */
public class EmojiDefaults {
public static final int MAX_EMOJI_COUNT = Integer.MAX_VALUE;
private EmojiDefaults() {
}
}

View File

@@ -0,0 +1,62 @@
package androidx.emoji2.text;
import android.annotation.SuppressLint;
import android.os.Build;
import androidx.annotation.DoNotInline;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import java.util.Collections;
import java.util.Iterator;
import java.util.Set;
/* loaded from: classes.dex */
class EmojiExclusions {
private EmojiExclusions() {
}
@NonNull
public static Set<int[]> getEmojiExclusions() {
if (Build.VERSION.SDK_INT >= 34) {
return EmojiExclusions_Api34.getExclusions();
}
return EmojiExclusions_Reflections.getExclusions();
}
@RequiresApi(34)
public static class EmojiExclusions_Api34 {
private EmojiExclusions_Api34() {
}
@NonNull
@DoNotInline
public static Set<int[]> getExclusions() {
return EmojiExclusions_Reflections.getExclusions();
}
}
public static class EmojiExclusions_Reflections {
private EmojiExclusions_Reflections() {
}
@NonNull
@SuppressLint({"BanUncheckedReflection"})
public static Set<int[]> getExclusions() {
try {
Object invoke = Class.forName("android.text.EmojiConsistency").getMethod("getEmojiConsistencySet", new Class[0]).invoke(null, new Object[0]);
if (invoke == null) {
return Collections.emptySet();
}
Set<int[]> set = (Set) invoke;
Iterator<int[]> it = set.iterator();
while (it.hasNext()) {
if (!(it.next() instanceof int[])) {
return Collections.emptySet();
}
}
return set;
} catch (Throwable unused) {
return Collections.emptySet();
}
}
}
}

View File

@@ -0,0 +1,644 @@
package androidx.emoji2.text;
import android.text.Editable;
import android.text.Selection;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.MetaKeyKeyListener;
import android.view.KeyEvent;
import android.view.inputmethod.InputConnection;
import androidx.annotation.AnyThread;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.emoji2.text.EmojiCompat;
import androidx.emoji2.text.MetadataRepo;
import java.util.Arrays;
import java.util.Set;
@AnyThread
@RequiresApi(19)
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* 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 static final int MAX_LOOK_AROUND_CHARACTER = 16;
@Nullable
private final int[] mEmojiAsDefaultStyleExceptions;
@NonNull
private EmojiCompat.GlyphChecker mGlyphChecker;
@NonNull
private final MetadataRepo mMetadataRepo;
@NonNull
private final EmojiCompat.SpanFactory mSpanFactory;
private final boolean mUseEmojiAsDefaultStyle;
public interface EmojiProcessCallback<T> {
T getResult();
boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer);
}
private static boolean hasInvalidSelection(int i, int i2) {
return i == -1 || i2 == -1 || i != i2;
}
public EmojiProcessor(@NonNull MetadataRepo metadataRepo, @NonNull EmojiCompat.SpanFactory spanFactory, @NonNull EmojiCompat.GlyphChecker glyphChecker, boolean z, @Nullable int[] iArr, @NonNull Set<int[]> set) {
this.mSpanFactory = spanFactory;
this.mMetadataRepo = metadataRepo;
this.mGlyphChecker = glyphChecker;
this.mUseEmojiAsDefaultStyle = z;
this.mEmojiAsDefaultStyleExceptions = iArr;
initExclusions(set);
}
private void initExclusions(@NonNull Set<int[]> set) {
if (set.isEmpty()) {
return;
}
for (int[] iArr : set) {
String str = new String(iArr, 0, iArr.length);
process(str, 0, str.length(), 1, true, new MarkExclusionCallback(str));
}
}
public int getEmojiMatch(@NonNull CharSequence charSequence) {
return getEmojiMatch(charSequence, this.mMetadataRepo.getMetadataVersion());
}
public int getEmojiMatch(@NonNull 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);
TypefaceEmojiRasterizer 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;
}
public int getEmojiStart(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
if (i < 0 || i >= charSequence.length()) {
return -1;
}
if (charSequence instanceof Spanned) {
Spanned spanned = (Spanned) charSequence;
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) spanned.getSpans(i, i + 1, EmojiSpan.class);
if (emojiSpanArr.length > 0) {
return spanned.getSpanStart(emojiSpanArr[0]);
}
}
return ((EmojiProcessLookupCallback) process(charSequence, Math.max(0, i - 16), Math.min(charSequence.length(), i + 16), Integer.MAX_VALUE, true, new EmojiProcessLookupCallback(i))).start;
}
public int getEmojiEnd(@NonNull CharSequence charSequence, @IntRange(from = 0) int i) {
if (i < 0 || i >= charSequence.length()) {
return -1;
}
if (charSequence instanceof Spanned) {
Spanned spanned = (Spanned) charSequence;
EmojiSpan[] emojiSpanArr = (EmojiSpan[]) spanned.getSpans(i, i + 1, EmojiSpan.class);
if (emojiSpanArr.length > 0) {
return spanned.getSpanEnd(emojiSpanArr[0]);
}
}
return ((EmojiProcessLookupCallback) process(charSequence, Math.max(0, i - 16), Math.min(charSequence.length(), i + 16), Integer.MAX_VALUE, true, new EmojiProcessLookupCallback(i))).end;
}
/* JADX WARN: Removed duplicated region for block: B:15:0x0049 A[Catch: all -> 0x002a, TryCatch #0 {all -> 0x002a, blocks: (B:51:0x000e, B:54:0x0013, B:56:0x0017, B:58:0x0024, B:9:0x003a, B:11:0x0042, B:13:0x0045, B:15:0x0049, B:17:0x0055, B:19:0x0058, B:24:0x0066, B:30:0x0074, B:31:0x0080, B:33:0x0094, B:6:0x002f), top: B:50:0x000e }] */
/* JADX WARN: Removed duplicated region for block: B:33:0x0094 A[Catch: all -> 0x002a, TRY_LEAVE, TryCatch #0 {all -> 0x002a, blocks: (B:51:0x000e, B:54:0x0013, B:56:0x0017, B:58:0x0024, B:9:0x003a, B:11:0x0042, B:13:0x0045, B:15:0x0049, B:17:0x0055, B:19:0x0058, B:24:0x0066, B:30:0x0074, B:31:0x0080, B:33:0x0094, B:6:0x002f), top: B:50:0x000e }] */
/* JADX WARN: Removed duplicated region for block: B:44:0x00a0 */
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public java.lang.CharSequence process(@androidx.annotation.NonNull java.lang.CharSequence r11, @androidx.annotation.IntRange(from = 0) int r12, @androidx.annotation.IntRange(from = 0) int r13, @androidx.annotation.IntRange(from = 0) int r14, boolean r15) {
/*
r10 = this;
boolean r0 = r11 instanceof androidx.emoji2.text.SpannableBuilder
if (r0 == 0) goto La
r1 = r11
androidx.emoji2.text.SpannableBuilder r1 = (androidx.emoji2.text.SpannableBuilder) r1
r1.beginBatchEdit()
La:
java.lang.Class<androidx.emoji2.text.EmojiSpan> r1 = androidx.emoji2.text.EmojiSpan.class
if (r0 != 0) goto L2f
boolean r2 = r11 instanceof android.text.Spannable // Catch: java.lang.Throwable -> L2a
if (r2 == 0) goto L13
goto L2f
L13:
boolean r2 = r11 instanceof android.text.Spanned // Catch: java.lang.Throwable -> L2a
if (r2 == 0) goto L2d
r2 = r11
android.text.Spanned r2 = (android.text.Spanned) r2 // Catch: java.lang.Throwable -> L2a
int r3 = r12 + (-1)
int r4 = r13 + 1
int r2 = r2.nextSpanTransition(r3, r4, r1) // Catch: java.lang.Throwable -> L2a
if (r2 > r13) goto L2d
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r2 = new androidx.emoji2.text.UnprecomputeTextOnModificationSpannable // Catch: java.lang.Throwable -> L2a
r2.<init>(r11) // Catch: java.lang.Throwable -> L2a
goto L37
L2a:
r12 = move-exception
goto Lb2
L2d:
r2 = 0
goto L37
L2f:
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r2 = new androidx.emoji2.text.UnprecomputeTextOnModificationSpannable // Catch: java.lang.Throwable -> L2a
r3 = r11
android.text.Spannable r3 = (android.text.Spannable) r3 // Catch: java.lang.Throwable -> L2a
r2.<init>(r3) // Catch: java.lang.Throwable -> L2a
L37:
r3 = 0
if (r2 == 0) goto L63
java.lang.Object[] r4 = r2.getSpans(r12, r13, r1) // Catch: java.lang.Throwable -> L2a
androidx.emoji2.text.EmojiSpan[] r4 = (androidx.emoji2.text.EmojiSpan[]) r4 // Catch: java.lang.Throwable -> L2a
if (r4 == 0) goto L63
int r5 = r4.length // Catch: java.lang.Throwable -> L2a
if (r5 <= 0) goto L63
int r5 = r4.length // Catch: java.lang.Throwable -> L2a
r6 = r3
L47:
if (r6 >= r5) goto L63
r7 = r4[r6] // Catch: java.lang.Throwable -> L2a
int r8 = r2.getSpanStart(r7) // Catch: java.lang.Throwable -> L2a
int r9 = r2.getSpanEnd(r7) // Catch: java.lang.Throwable -> L2a
if (r8 == r13) goto L58
r2.removeSpan(r7) // Catch: java.lang.Throwable -> L2a
L58:
int r12 = java.lang.Math.min(r8, r12) // Catch: java.lang.Throwable -> L2a
int r13 = java.lang.Math.max(r9, r13) // Catch: java.lang.Throwable -> L2a
int r6 = r6 + 1
goto L47
L63:
r4 = r13
if (r12 == r4) goto La9
int r13 = r11.length() // Catch: java.lang.Throwable -> L2a
if (r12 < r13) goto L6d
goto La9
L6d:
r13 = 2147483647(0x7fffffff, float:NaN)
if (r14 == r13) goto L80
if (r2 == 0) goto L80
int r13 = r2.length() // Catch: java.lang.Throwable -> L2a
java.lang.Object[] r13 = r2.getSpans(r3, r13, r1) // Catch: java.lang.Throwable -> L2a
androidx.emoji2.text.EmojiSpan[] r13 = (androidx.emoji2.text.EmojiSpan[]) r13 // Catch: java.lang.Throwable -> L2a
int r13 = r13.length // Catch: java.lang.Throwable -> L2a
int r14 = r14 - r13
L80:
r5 = r14
androidx.emoji2.text.EmojiProcessor$EmojiProcessAddSpanCallback r7 = new androidx.emoji2.text.EmojiProcessor$EmojiProcessAddSpanCallback // Catch: java.lang.Throwable -> L2a
androidx.emoji2.text.EmojiCompat$SpanFactory r13 = r10.mSpanFactory // Catch: java.lang.Throwable -> L2a
r7.<init>(r2, r13) // Catch: java.lang.Throwable -> L2a
r1 = r10
r2 = r11
r3 = r12
r6 = r15
java.lang.Object r12 = r1.process(r2, r3, r4, r5, r6, r7) // Catch: java.lang.Throwable -> L2a
androidx.emoji2.text.UnprecomputeTextOnModificationSpannable r12 = (androidx.emoji2.text.UnprecomputeTextOnModificationSpannable) r12 // Catch: java.lang.Throwable -> L2a
if (r12 == 0) goto La0
android.text.Spannable r12 = r12.getUnwrappedSpannable() // Catch: java.lang.Throwable -> L2a
if (r0 == 0) goto L9f
androidx.emoji2.text.SpannableBuilder r11 = (androidx.emoji2.text.SpannableBuilder) r11
r11.endBatchEdit()
L9f:
return r12
La0:
if (r0 == 0) goto La8
r12 = r11
androidx.emoji2.text.SpannableBuilder r12 = (androidx.emoji2.text.SpannableBuilder) r12
r12.endBatchEdit()
La8:
return r11
La9:
if (r0 == 0) goto Lb1
r12 = r11
androidx.emoji2.text.SpannableBuilder r12 = (androidx.emoji2.text.SpannableBuilder) r12
r12.endBatchEdit()
Lb1:
return r11
Lb2:
if (r0 == 0) goto Lb9
androidx.emoji2.text.SpannableBuilder r11 = (androidx.emoji2.text.SpannableBuilder) r11
r11.endBatchEdit()
Lb9:
throw r12
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.emoji2.text.EmojiProcessor.process(java.lang.CharSequence, int, int, int, boolean):java.lang.CharSequence");
}
private <T> T process(@NonNull CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, @IntRange(from = 0) int i3, boolean z, EmojiProcessCallback<T> emojiProcessCallback) {
int i4;
ProcessorSm processorSm = new ProcessorSm(this.mMetadataRepo.getRootNode(), this.mUseEmojiAsDefaultStyle, this.mEmojiAsDefaultStyleExceptions);
int i5 = 0;
boolean z2 = true;
int codePointAt = Character.codePointAt(charSequence, i);
loop0: while (true) {
i4 = i;
while (i < i2 && i5 < i3 && z2) {
int check = processorSm.check(codePointAt);
if (check == 1) {
i4 += Character.charCount(Character.codePointAt(charSequence, i4));
if (i4 < i2) {
codePointAt = Character.codePointAt(charSequence, i4);
}
i = i4;
} else if (check == 2) {
i += Character.charCount(codePointAt);
if (i < i2) {
codePointAt = Character.codePointAt(charSequence, i);
}
} else if (check == 3) {
if (z || !hasGlyph(charSequence, i4, i, processorSm.getFlushMetadata())) {
z2 = emojiProcessCallback.handleEmoji(charSequence, i4, i, processorSm.getFlushMetadata());
i5++;
}
}
}
}
if (processorSm.isInFlushableState() && i5 < i3 && z2 && (z || !hasGlyph(charSequence, i4, i, processorSm.getCurrentMetadata()))) {
emojiProcessCallback.handleEmoji(charSequence, i4, i, processorSm.getCurrentMetadata());
}
return emojiProcessCallback.getResult();
}
public static boolean handleOnKeyDown(@NonNull Editable editable, int i, @NonNull 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(@NonNull Editable editable, @NonNull 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;
}
public static boolean handleDeleteSurroundingText(@NonNull InputConnection inputConnection, @NonNull Editable editable, @IntRange(from = 0) int i, @IntRange(from = 0) 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(@NonNull KeyEvent keyEvent) {
return !KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState());
}
private boolean hasGlyph(CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
if (typefaceEmojiRasterizer.getHasGlyph() == 0) {
typefaceEmojiRasterizer.setHasGlyph(this.mGlyphChecker.hasGlyph(charSequence, i, i2, typefaceEmojiRasterizer.getSdkAdded()));
}
return typefaceEmojiRasterizer.getHasGlyph() == 2;
}
public 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;
}
public ProcessorSm(MetadataRepo.Node node, boolean z, int[] iArr) {
this.mRootNode = node;
this.mCurrentNode = node;
this.mUseEmojiAsDefaultStyle = z;
this.mEmojiAsDefaultStyleExceptions = iArr;
}
public 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;
}
public TypefaceEmojiRasterizer getFlushMetadata() {
return this.mFlushNode.getData();
}
public TypefaceEmojiRasterizer getCurrentMetadata() {
return this.mCurrentNode.getData();
}
public 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;
}
}
@RequiresApi(19)
public static final class CodepointIndexFinder {
private static final int INVALID_INDEX = -1;
private CodepointIndexFinder() {
}
public 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;
}
}
public 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;
}
}
}
public static class EmojiProcessAddSpanCallback implements EmojiProcessCallback<UnprecomputeTextOnModificationSpannable> {
private final EmojiCompat.SpanFactory mSpanFactory;
@Nullable
public UnprecomputeTextOnModificationSpannable spannable;
/* JADX WARN: Can't rename method to resolve collision */
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public UnprecomputeTextOnModificationSpannable getResult() {
return this.spannable;
}
public EmojiProcessAddSpanCallback(@Nullable UnprecomputeTextOnModificationSpannable unprecomputeTextOnModificationSpannable, EmojiCompat.SpanFactory spanFactory) {
this.spannable = unprecomputeTextOnModificationSpannable;
this.mSpanFactory = spanFactory;
}
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
Spannable spannableString;
if (typefaceEmojiRasterizer.isPreferredSystemRender()) {
return true;
}
if (this.spannable == null) {
if (charSequence instanceof Spannable) {
spannableString = (Spannable) charSequence;
} else {
spannableString = new SpannableString(charSequence);
}
this.spannable = new UnprecomputeTextOnModificationSpannable(spannableString);
}
this.spannable.setSpan(this.mSpanFactory.createSpan(typefaceEmojiRasterizer), i, i2, 33);
return true;
}
}
public static class EmojiProcessLookupCallback implements EmojiProcessCallback<EmojiProcessLookupCallback> {
private final int mOffset;
public int start = -1;
public int end = -1;
/* JADX WARN: Can't rename method to resolve collision */
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public EmojiProcessLookupCallback getResult() {
return this;
}
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
int i3 = this.mOffset;
if (i > i3 || i3 >= i2) {
return i2 <= i3;
}
this.start = i;
this.end = i2;
return false;
}
public EmojiProcessLookupCallback(int i) {
this.mOffset = i;
}
}
public static class MarkExclusionCallback implements EmojiProcessCallback<MarkExclusionCallback> {
private final String mExclusion;
/* JADX WARN: Can't rename method to resolve collision */
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public MarkExclusionCallback getResult() {
return this;
}
public MarkExclusionCallback(String str) {
this.mExclusion = str;
}
@Override // androidx.emoji2.text.EmojiProcessor.EmojiProcessCallback
public boolean handleEmoji(@NonNull CharSequence charSequence, int i, int i2, TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
if (!TextUtils.equals(charSequence.subSequence(i, i2), this.mExclusion)) {
return true;
}
typefaceEmojiRasterizer.setExclusion(true);
return false;
}
}
}

View File

@@ -0,0 +1,71 @@
package androidx.emoji2.text;
import android.annotation.SuppressLint;
import android.graphics.Paint;
import android.text.style.ReplacementSpan;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.util.Preconditions;
@RequiresApi(19)
/* loaded from: classes.dex */
public abstract class EmojiSpan extends ReplacementSpan {
@NonNull
private final TypefaceEmojiRasterizer mRasterizer;
private final Paint.FontMetricsInt mTmpFontMetrics = new Paint.FontMetricsInt();
private short mWidth = -1;
private short mHeight = -1;
private float mRatio = 1.0f;
@RestrictTo({RestrictTo.Scope.TESTS})
public final int getHeight() {
return this.mHeight;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public final float getRatio() {
return this.mRatio;
}
@NonNull
public final TypefaceEmojiRasterizer getTypefaceRasterizer() {
return this.mRasterizer;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public final int getWidth() {
return this.mWidth;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public EmojiSpan(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
Preconditions.checkNotNull(typefaceEmojiRasterizer, "rasterizer cannot be null");
this.mRasterizer = typefaceEmojiRasterizer;
}
@Override // android.text.style.ReplacementSpan
public int getSize(@NonNull Paint paint, @SuppressLint({"UnknownNullness"}) CharSequence charSequence, int i, int i2, @Nullable Paint.FontMetricsInt fontMetricsInt) {
paint.getFontMetricsInt(this.mTmpFontMetrics);
Paint.FontMetricsInt fontMetricsInt2 = this.mTmpFontMetrics;
this.mRatio = (Math.abs(fontMetricsInt2.descent - fontMetricsInt2.ascent) * 1.0f) / this.mRasterizer.getHeight();
this.mHeight = (short) (this.mRasterizer.getHeight() * this.mRatio);
short width = (short) (this.mRasterizer.getWidth() * this.mRatio);
this.mWidth = width;
if (fontMetricsInt != null) {
Paint.FontMetricsInt fontMetricsInt3 = this.mTmpFontMetrics;
fontMetricsInt.ascent = fontMetricsInt3.ascent;
fontMetricsInt.descent = fontMetricsInt3.descent;
fontMetricsInt.top = fontMetricsInt3.top;
fontMetricsInt.bottom = fontMetricsInt3.bottom;
}
return width;
}
@RestrictTo({RestrictTo.Scope.TESTS})
public final int getId() {
return getTypefaceRasterizer().getId();
}
}

View File

@@ -0,0 +1,353 @@
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.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.WorkerThread;
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(@NonNull Context context, @NonNull FontRequest fontRequest) {
super(new FontRequestMetadataLoader(context, fontRequest, DEFAULT_FONTS_CONTRACT));
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public FontRequestEmojiCompatConfig(@NonNull Context context, @NonNull FontRequest fontRequest, @NonNull FontProviderHelper fontProviderHelper) {
super(new FontRequestMetadataLoader(context, fontRequest, fontProviderHelper));
}
@NonNull
public FontRequestEmojiCompatConfig setLoadingExecutor(@NonNull Executor executor) {
((FontRequestMetadataLoader) getMetadataRepoLoader()).setExecutor(executor);
return this;
}
@NonNull
@Deprecated
public FontRequestEmojiCompatConfig setHandler(@Nullable Handler handler) {
if (handler == null) {
return this;
}
setLoadingExecutor(ConcurrencyHelpers.convertHandlerToExecutor(handler));
return this;
}
@NonNull
public FontRequestEmojiCompatConfig setRetryPolicy(@Nullable RetryPolicy retryPolicy) {
((FontRequestMetadataLoader) getMetadataRepoLoader()).setRetryPolicy(retryPolicy);
return this;
}
public static class FontRequestMetadataLoader implements EmojiCompat.MetadataRepoLoader {
private static final String S_TRACE_BUILD_TYPEFACE = "EmojiCompat.FontRequestEmojiCompatConfig.buildTypeface";
@Nullable
@GuardedBy("mLock")
EmojiCompat.MetadataRepoLoaderCallback mCallback;
@NonNull
private final Context mContext;
@Nullable
@GuardedBy("mLock")
private Executor mExecutor;
@NonNull
private final FontProviderHelper mFontProviderHelper;
@NonNull
private final Object mLock = new Object();
@Nullable
@GuardedBy("mLock")
private Handler mMainHandler;
@Nullable
@GuardedBy("mLock")
private Runnable mMainHandlerLoadCallback;
@Nullable
@GuardedBy("mLock")
private ThreadPoolExecutor mMyThreadPoolExecutor;
@Nullable
@GuardedBy("mLock")
private ContentObserver mObserver;
@NonNull
private final FontRequest mRequest;
@Nullable
@GuardedBy("mLock")
private RetryPolicy mRetryPolicy;
public FontRequestMetadataLoader(@NonNull Context context, @NonNull FontRequest fontRequest, @NonNull 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(@NonNull Executor executor) {
synchronized (this.mLock) {
this.mExecutor = executor;
}
}
public void setRetryPolicy(@Nullable RetryPolicy retryPolicy) {
synchronized (this.mLock) {
this.mRetryPolicy = retryPolicy;
}
}
@Override // androidx.emoji2.text.EmojiCompat.MetadataRepoLoader
@RequiresApi(19)
public void load(@NonNull EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback) {
Preconditions.checkNotNull(metadataRepoLoaderCallback, "LoaderCallback cannot be null");
synchronized (this.mLock) {
this.mCallback = metadataRepoLoaderCallback;
}
loadInternal();
}
@RequiresApi(19)
public void loadInternal() {
synchronized (this.mLock) {
try {
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();
}
});
} catch (Throwable th) {
throw th;
}
}
}
@WorkerThread
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);
}
}
@RequiresApi(19)
@WorkerThread
private void scheduleRetry(Uri uri, long j) {
synchronized (this.mLock) {
try {
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);
} catch (Throwable th) {
throw th;
}
}
}
private void cleanUp() {
synchronized (this.mLock) {
try {
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;
} catch (Throwable th) {
throw th;
}
}
}
@RequiresApi(19)
@WorkerThread
public void createMetadata() {
synchronized (this.mLock) {
try {
if (this.mCallback == null) {
return;
}
try {
FontsContractCompat.FontInfo retrieveFontInfo = retrieveFontInfo();
int resultCode = retrieveFontInfo.getResultCode();
if (resultCode == 2) {
synchronized (this.mLock) {
try {
RetryPolicy retryPolicy = this.mRetryPolicy;
if (retryPolicy != null) {
long retryDelay = retryPolicy.getRetryDelay();
if (retryDelay >= 0) {
scheduleRetry(retrieveFontInfo.getUri(), retryDelay);
return;
}
}
} finally {
}
}
}
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) {
try {
EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback = this.mCallback;
if (metadataRepoLoaderCallback != null) {
metadataRepoLoaderCallback.onLoaded(create);
}
} finally {
}
}
cleanUp();
} catch (Throwable th) {
TraceCompat.endSection();
throw th;
}
} catch (Throwable th2) {
synchronized (this.mLock) {
try {
EmojiCompat.MetadataRepoLoaderCallback metadataRepoLoaderCallback2 = this.mCallback;
if (metadataRepoLoaderCallback2 != null) {
metadataRepoLoaderCallback2.onFailed(th2);
}
cleanUp();
} finally {
}
}
}
} finally {
}
}
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class FontProviderHelper {
@NonNull
public FontsContractCompat.FontFamilyResult fetchFonts(@NonNull Context context, @NonNull FontRequest fontRequest) throws PackageManager.NameNotFoundException {
return FontsContractCompat.fetchFonts(context, null, fontRequest);
}
@Nullable
public Typeface buildTypeface(@NonNull Context context, @NonNull FontsContractCompat.FontInfo fontInfo) throws PackageManager.NameNotFoundException {
return FontsContractCompat.buildTypeface(context, null, new FontsContractCompat.FontInfo[]{fontInfo});
}
public void registerObserver(@NonNull Context context, @NonNull Uri uri, @NonNull ContentObserver contentObserver) {
context.getContentResolver().registerContentObserver(uri, false, contentObserver);
}
public void unregisterObserver(@NonNull Context context, @NonNull ContentObserver contentObserver) {
context.getContentResolver().unregisterContentObserver(contentObserver);
}
}
}

View File

@@ -0,0 +1,248 @@
package androidx.emoji2.text;
import android.content.res.AssetManager;
import androidx.annotation.AnyThread;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.emoji2.text.flatbuffer.MetadataList;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@AnyThread
@RequiresApi(19)
@RestrictTo({RestrictTo.Scope.LIBRARY})
/* 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;
public 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;
}
public static long toUnsignedInt(int i) {
return i & 4294967295L;
}
public static int toUnsignedShort(short s) {
return s & 65535;
}
public 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);
}
public static MetadataList read(ByteBuffer byteBuffer) throws IOException {
ByteBuffer duplicate = byteBuffer.duplicate();
duplicate.position((int) findOffsetInfo(new ByteBufferReader(duplicate)).getStartOffset());
return MetadataList.getRootAsMetadataList(duplicate);
}
public 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.");
}
public static class OffsetInfo {
private final long mLength;
private final long mStartOffset;
public long getLength() {
return this.mLength;
}
public long getStartOffset() {
return this.mStartOffset;
}
public OffsetInfo(long j, long j2) {
this.mStartOffset = j;
this.mLength = j2;
}
}
public static class InputStreamOpenTypeReader implements OpenTypeReader {
@NonNull
private final byte[] mByteArray;
@NonNull
private final ByteBuffer mByteBuffer;
@NonNull
private final InputStream mInputStream;
private long mPosition = 0;
@Override // androidx.emoji2.text.MetadataListReader.OpenTypeReader
public long getPosition() {
return this.mPosition;
}
public InputStreamOpenTypeReader(@NonNull 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(@IntRange(from = 0, to = 4) int i) throws IOException {
if (this.mInputStream.read(this.mByteArray, 0, i) != i) {
throw new IOException("read failed");
}
this.mPosition += i;
}
}
public static class ByteBufferReader implements OpenTypeReader {
@NonNull
private final ByteBuffer mByteBuffer;
public ByteBufferReader(@NonNull 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() {
}
}

View File

@@ -0,0 +1,169 @@
package androidx.emoji2.text;
import android.content.res.AssetManager;
import android.graphics.Typeface;
import android.util.SparseArray;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.VisibleForTesting;
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;
@AnyThread
@RequiresApi(19)
/* 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";
@NonNull
private final char[] mEmojiCharArray;
@NonNull
private final MetadataList mMetadataList;
@NonNull
private final Node mRootNode = new Node(1024);
@NonNull
private final Typeface mTypeface;
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public char[] getEmojiCharArray() {
return this.mEmojiCharArray;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public MetadataList getMetadataList() {
return this.mMetadataList;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Node getRootNode() {
return this.mRootNode;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Typeface getTypeface() {
return this.mTypeface;
}
private MetadataRepo(@NonNull Typeface typeface, @NonNull MetadataList metadataList) {
this.mTypeface = typeface;
this.mMetadataList = metadataList;
this.mEmojiCharArray = new char[metadataList.listLength() * 2];
constructIndex(metadataList);
}
@NonNull
@RestrictTo({RestrictTo.Scope.TESTS})
public static MetadataRepo create(@NonNull Typeface typeface) {
try {
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
return new MetadataRepo(typeface, new MetadataList());
} finally {
TraceCompat.endSection();
}
}
@NonNull
public static MetadataRepo create(@NonNull Typeface typeface, @NonNull InputStream inputStream) throws IOException {
try {
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
return new MetadataRepo(typeface, MetadataListReader.read(inputStream));
} finally {
TraceCompat.endSection();
}
}
@NonNull
public static MetadataRepo create(@NonNull Typeface typeface, @NonNull ByteBuffer byteBuffer) throws IOException {
try {
TraceCompat.beginSection(S_TRACE_CREATE_REPO);
return new MetadataRepo(typeface, MetadataListReader.read(byteBuffer));
} finally {
TraceCompat.endSection();
}
}
@NonNull
public static MetadataRepo create(@NonNull AssetManager assetManager, @NonNull 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++) {
TypefaceEmojiRasterizer typefaceEmojiRasterizer = new TypefaceEmojiRasterizer(this, i);
Character.toChars(typefaceEmojiRasterizer.getId(), this.mEmojiCharArray, i * 2);
put(typefaceEmojiRasterizer);
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int getMetadataVersion() {
return this.mMetadataList.version();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
@VisibleForTesting
public void put(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
Preconditions.checkNotNull(typefaceEmojiRasterizer, "emoji metadata cannot be null");
Preconditions.checkArgument(typefaceEmojiRasterizer.getCodepointsLength() > 0, "invalid metadata codepoint length");
this.mRootNode.put(typefaceEmojiRasterizer, 0, typefaceEmojiRasterizer.getCodepointsLength() - 1);
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public static class Node {
private final SparseArray<Node> mChildren;
private TypefaceEmojiRasterizer mData;
public final TypefaceEmojiRasterizer getData() {
return this.mData;
}
private Node() {
this(1);
}
public Node(int i) {
this.mChildren = new SparseArray<>(i);
}
public Node get(int i) {
SparseArray<Node> sparseArray = this.mChildren;
if (sparseArray == null) {
return null;
}
return sparseArray.get(i);
}
public void put(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer, int i, int i2) {
Node node = get(typefaceEmojiRasterizer.getCodepointAt(i));
if (node == null) {
node = new Node();
this.mChildren.put(typefaceEmojiRasterizer.getCodepointAt(i), node);
}
if (i2 > i) {
node.put(typefaceEmojiRasterizer, i + 1, i2);
} else {
node.mData = typefaceEmojiRasterizer;
}
}
}
}

View File

@@ -0,0 +1,325 @@
package androidx.emoji2.text;
import android.annotation.SuppressLint;
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.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.core.util.Preconditions;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public final class SpannableBuilder extends SpannableStringBuilder {
@NonNull
private final Class<?> mWatcherClass;
@NonNull
private final List<WatcherWrapper> mWatchers;
private boolean isWatcher(@NonNull Class<?> cls) {
return this.mWatcherClass == cls;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public SpannableBuilder(@NonNull Class<?> cls) {
this.mWatchers = new ArrayList();
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
this.mWatcherClass = cls;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public SpannableBuilder(@NonNull Class<?> cls, @NonNull CharSequence charSequence) {
super(charSequence);
this.mWatchers = new ArrayList();
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
this.mWatcherClass = cls;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public SpannableBuilder(@NonNull Class<?> cls, @NonNull CharSequence charSequence, int i, int i2) {
super(charSequence, i, i2);
this.mWatchers = new ArrayList();
Preconditions.checkNotNull(cls, "watcherClass cannot be null");
this.mWatcherClass = cls;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public static SpannableBuilder create(@NonNull Class<?> cls, @NonNull CharSequence charSequence) {
return new SpannableBuilder(cls, charSequence);
}
private boolean isWatcher(@Nullable Object obj) {
return obj != null && isWatcher(obj.getClass());
}
@Override // android.text.SpannableStringBuilder, java.lang.CharSequence
@SuppressLint({"UnknownNullness"})
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(@Nullable 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
@SuppressLint({"UnknownNullness"})
public <T> T[] getSpans(int i, int i2, @NonNull 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(@Nullable 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(@Nullable 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(@Nullable 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(@Nullable 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, @Nullable 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;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void beginBatchEdit() {
blockWatchers();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
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
@SuppressLint({"UnknownNullness"})
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
@SuppressLint({"UnknownNullness"})
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
@SuppressLint({"UnknownNullness"})
public SpannableStringBuilder insert(int i, CharSequence charSequence) {
super.insert(i, charSequence);
return this;
}
@Override // android.text.SpannableStringBuilder, android.text.Editable
@SuppressLint({"UnknownNullness"})
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
@SuppressLint({"UnknownNullness"})
public SpannableStringBuilder delete(int i, int i2) {
super.delete(i, i2);
return this;
}
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
@NonNull
public SpannableStringBuilder append(@SuppressLint({"UnknownNullness"}) CharSequence charSequence) {
super.append(charSequence);
return this;
}
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
@NonNull
public SpannableStringBuilder append(char c) {
super.append(c);
return this;
}
@Override // android.text.SpannableStringBuilder, android.text.Editable, java.lang.Appendable
@NonNull
public SpannableStringBuilder append(@SuppressLint({"UnknownNullness"}) CharSequence charSequence, int i, int i2) {
super.append(charSequence, i, i2);
return this;
}
@Override // android.text.SpannableStringBuilder
@SuppressLint({"UnknownNullness"})
public SpannableStringBuilder append(CharSequence charSequence, Object obj, int i) {
super.append(charSequence, obj, i);
return this;
}
public static class WatcherWrapper implements TextWatcher, SpanWatcher {
private final AtomicInteger mBlockCalls = new AtomicInteger(0);
final Object mObject;
public 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);
}
}
public final void blockCalls() {
this.mBlockCalls.incrementAndGet();
}
public final void unblockCalls() {
this.mBlockCalls.decrementAndGet();
}
private boolean isEmojiSpan(Object obj) {
return obj instanceof EmojiSpan;
}
}
}

View File

@@ -0,0 +1,156 @@
package androidx.emoji2.text;
import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Typeface;
import androidx.annotation.AnyThread;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.emoji2.text.flatbuffer.MetadataItem;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@AnyThread
@RequiresApi(19)
/* loaded from: classes.dex */
public class TypefaceEmojiRasterizer {
@RestrictTo({RestrictTo.Scope.LIBRARY})
static final int HAS_GLYPH_ABSENT = 1;
@RestrictTo({RestrictTo.Scope.LIBRARY})
static final int HAS_GLYPH_EXISTS = 2;
@RestrictTo({RestrictTo.Scope.LIBRARY})
static final int HAS_GLYPH_UNKNOWN = 0;
private static final ThreadLocal<MetadataItem> sMetadataItem = new ThreadLocal<>();
private volatile int mCache = 0;
private final int mIndex;
@NonNull
private final MetadataRepo mMetadataRepo;
@Retention(RetentionPolicy.SOURCE)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
public @interface HasGlyph {
}
@SuppressLint({"KotlinPropertyAccess"})
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int getHasGlyph() {
return this.mCache & 3;
}
public boolean isPreferredSystemRender() {
return (this.mCache & 4) > 0;
}
@SuppressLint({"KotlinPropertyAccess"})
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void setHasGlyph(boolean z) {
int i = this.mCache & 4;
this.mCache = z ? i | 2 : i | 1;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public TypefaceEmojiRasterizer(@NonNull MetadataRepo metadataRepo, @IntRange(from = 0) int i) {
this.mMetadataRepo = metadataRepo;
this.mIndex = i;
}
public void draw(@NonNull Canvas canvas, float f, float f2, @NonNull 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);
}
@NonNull
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;
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public int getId() {
return getMetadataItem().id();
}
public int getWidth() {
return getMetadataItem().width();
}
public int getHeight() {
return getMetadataItem().height();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public short getCompatAdded() {
return getMetadataItem().compatAdded();
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public short getSdkAdded() {
return getMetadataItem().sdkAdded();
}
@RestrictTo({RestrictTo.Scope.TESTS})
public void resetHasGlyphCache() {
if (isPreferredSystemRender()) {
this.mCache = 4;
} else {
this.mCache = 0;
}
}
@RestrictTo({RestrictTo.Scope.LIBRARY})
public void setExclusion(boolean z) {
int hasGlyph = getHasGlyph();
if (z) {
this.mCache = hasGlyph | 4;
} else {
this.mCache = hasGlyph;
}
}
public boolean isDefaultEmoji() {
return getMetadataItem().emojiStyle();
}
public int getCodepointAt(int i) {
return getMetadataItem().codepoints(i);
}
public int getCodepointsLength() {
return getMetadataItem().codepointsLength();
}
@NonNull
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();
}
}

View File

@@ -0,0 +1,97 @@
package androidx.emoji2.text;
import android.annotation.SuppressLint;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.style.CharacterStyle;
import androidx.annotation.IntRange;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
@RequiresApi(19)
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP})
/* loaded from: classes.dex */
public final class TypefaceEmojiSpan extends EmojiSpan {
@Nullable
private static Paint sDebugPaint;
@Nullable
private TextPaint mWorkingPaint;
public TypefaceEmojiSpan(@NonNull TypefaceEmojiRasterizer typefaceEmojiRasterizer) {
super(typefaceEmojiRasterizer);
}
@Override // android.text.style.ReplacementSpan
public void draw(@NonNull Canvas canvas, @SuppressLint({"UnknownNullness"}) CharSequence charSequence, @IntRange(from = 0) int i, @IntRange(from = 0) int i2, float f, int i3, int i4, int i5, @NonNull Paint paint) {
Paint paint2 = paint;
TextPaint applyCharacterSpanStyles = applyCharacterSpanStyles(charSequence, i, i2, paint2);
if (applyCharacterSpanStyles != null && applyCharacterSpanStyles.bgColor != 0) {
drawBackground(canvas, applyCharacterSpanStyles, f, f + getWidth(), i3, i5);
}
if (EmojiCompat.get().isEmojiSpanIndicatorEnabled()) {
canvas.drawRect(f, i3, f + getWidth(), i5, getDebugPaint());
}
TypefaceEmojiRasterizer typefaceRasterizer = getTypefaceRasterizer();
float f2 = i4;
if (applyCharacterSpanStyles != null) {
paint2 = applyCharacterSpanStyles;
}
typefaceRasterizer.draw(canvas, f, f2, paint2);
}
public void drawBackground(Canvas canvas, TextPaint textPaint, float f, float f2, float f3, float f4) {
int color = textPaint.getColor();
Paint.Style style = textPaint.getStyle();
textPaint.setColor(textPaint.bgColor);
textPaint.setStyle(Paint.Style.FILL);
canvas.drawRect(f, f3, f2, f4, textPaint);
textPaint.setStyle(style);
textPaint.setColor(color);
}
@Nullable
private TextPaint applyCharacterSpanStyles(@Nullable CharSequence charSequence, int i, int i2, Paint paint) {
if (charSequence instanceof Spanned) {
CharacterStyle[] characterStyleArr = (CharacterStyle[]) ((Spanned) charSequence).getSpans(i, i2, CharacterStyle.class);
if (characterStyleArr.length != 0) {
if (characterStyleArr.length != 1 || characterStyleArr[0] != this) {
TextPaint textPaint = this.mWorkingPaint;
if (textPaint == null) {
textPaint = new TextPaint();
this.mWorkingPaint = textPaint;
}
textPaint.set(paint);
for (CharacterStyle characterStyle : characterStyleArr) {
characterStyle.updateDrawState(textPaint);
}
return textPaint;
}
}
if (paint instanceof TextPaint) {
return (TextPaint) paint;
}
return null;
}
if (paint instanceof TextPaint) {
return (TextPaint) paint;
}
return null;
}
@NonNull
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;
}
}

View File

@@ -0,0 +1,148 @@
package androidx.emoji2.text;
import android.os.Build;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.text.PrecomputedTextCompat;
import androidx.core.text.PrecomputedTextCompat$$ExternalSyntheticApiModelOutline0;
import java.util.stream.IntStream;
/* loaded from: classes.dex */
class UnprecomputeTextOnModificationSpannable implements Spannable {
@NonNull
private Spannable mDelegate;
private boolean mSafeToWrite = false;
public Spannable getUnwrappedSpannable() {
return this.mDelegate;
}
public UnprecomputeTextOnModificationSpannable(@NonNull Spannable spannable) {
this.mDelegate = spannable;
}
public UnprecomputeTextOnModificationSpannable(@NonNull Spanned spanned) {
this.mDelegate = new SpannableString(spanned);
}
public UnprecomputeTextOnModificationSpannable(@NonNull 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
@NonNull
public CharSequence subSequence(int i, int i2) {
return this.mDelegate.subSequence(i, i2);
}
@Override // java.lang.CharSequence
@NonNull
public String toString() {
return this.mDelegate.toString();
}
@Override // java.lang.CharSequence
@NonNull
@RequiresApi(api = 24)
public IntStream chars() {
return CharSequenceHelper_API24.chars(this.mDelegate);
}
@Override // java.lang.CharSequence
@NonNull
@RequiresApi(api = 24)
public IntStream codePoints() {
return CharSequenceHelper_API24.codePoints(this.mDelegate);
}
@RequiresApi(24)
public static class CharSequenceHelper_API24 {
private CharSequenceHelper_API24() {
}
public static IntStream codePoints(CharSequence charSequence) {
return charSequence.codePoints();
}
public static IntStream chars(CharSequence charSequence) {
return charSequence.chars();
}
}
public static PrecomputedTextDetector precomputedTextDetector() {
return Build.VERSION.SDK_INT < 28 ? new PrecomputedTextDetector() : new PrecomputedTextDetector_28();
}
public static class PrecomputedTextDetector {
public boolean isPrecomputedText(CharSequence charSequence) {
return charSequence instanceof PrecomputedTextCompat;
}
}
@RequiresApi(28)
public static class PrecomputedTextDetector_28 extends PrecomputedTextDetector {
@Override // androidx.emoji2.text.UnprecomputeTextOnModificationSpannable.PrecomputedTextDetector
public boolean isPrecomputedText(CharSequence charSequence) {
return PrecomputedTextCompat$$ExternalSyntheticApiModelOutline0.m(charSequence) || (charSequence instanceof PrecomputedTextCompat);
}
}
}

View File

@@ -0,0 +1,225 @@
package androidx.emoji2.text.flatbuffer;
import com.applovin.exoplayer2.common.base.Ascii;
import java.util.Arrays;
/* 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] & 255) | (bArr[i + 1] << 8));
}
@Override // androidx.emoji2.text.flatbuffer.ReadBuf
public int getInt(int i) {
byte[] bArr = this.buffer;
return (bArr[i] & 255) | (bArr[i + 3] << Ascii.CAN) | ((bArr[i + 2] & 255) << 16) | ((bArr[i + 1] & 255) << 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;
}
}

View File

@@ -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;
public int __element(int i) {
return this.vector + (i * this.element_size);
}
public int __vector() {
return this.vector;
}
public int length() {
return this.length;
}
public 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);
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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;
}
}

View File

@@ -0,0 +1,19 @@
package androidx.emoji2.text.flatbuffer;
import java.nio.ByteBuffer;
/* 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) & 255;
}
}

View File

@@ -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() {
}
}

View File

@@ -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));
}
}

View File

@@ -0,0 +1,614 @@
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;
/* 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;
}
}
public 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");
}
public 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);
}
public 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);
}
public 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() & 255;
} catch (BufferUnderflowException unused) {
return -1;
}
}
}
}

View File

@@ -0,0 +1,847 @@
package androidx.emoji2.text.flatbuffer;
import com.ironsource.v8;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
/* 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;
public static class Unsigned {
public static int byteToUnsignedInt(byte b) {
return b & 255;
}
public static long intToUnsignedLong(int i) {
return i & 4294967295L;
}
public static int shortToUnsignedInt(short s) {
return s & 65535;
}
}
public static boolean isTypeInline(int i) {
return i <= 3 || i == 26;
}
public static boolean isTypedVector(int i) {
return (i >= 11 && i <= 15) || i == 36;
}
public static boolean isTypedVectorElementType(int i) {
return (i >= 1 && i <= 4) || i == 26;
}
public 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;
}
public 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;
}
public Reference(ReadBuf readBuf, int i, int i2, int i3) {
this(readBuf, i, i2, 1 << (i3 & 3), i3 >> 2);
}
public 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() {
int i = this.type;
if (i == 1) {
return FlexBuffers.readInt(this.bb, this.end, this.parentWidth);
}
if (i == 2) {
return (int) FlexBuffers.readUInt(this.bb, this.end, this.parentWidth);
}
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) {
ReadBuf readBuf2 = this.bb;
return (int) FlexBuffers.readUInt(readBuf2, FlexBuffers.indirect(readBuf2, this.end, this.parentWidth), this.parentWidth);
}
if (i == 8) {
ReadBuf readBuf3 = this.bb;
return (int) FlexBuffers.readDouble(readBuf3, FlexBuffers.indirect(readBuf3, 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);
}
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();
}
public 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('\"');
StringBuilder key = asKey.toString(sb);
key.append('\"');
return key;
case 5:
sb.append('\"');
sb.append(asString());
sb.append('\"');
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;
}
}
public static abstract class Object {
ReadBuf bb;
int byteWidth;
int end;
public abstract StringBuilder toString(StringBuilder sb);
public 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();
}
}
public static abstract class Sized extends Object {
protected final int size;
public int size() {
return this.size;
}
public 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();
}
public 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('\"');
sb.append(this.bb.getString(this.end, size()));
sb.append('\"');
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;
}
public int hashCode() {
return this.end ^ this.byteWidth;
}
public 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++;
}
int i2 = this.end;
return this.bb.getString(i2, i - i2);
}
public 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 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;
}
public 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);
ReadBuf readBuf = this.bb;
int indirect = FlexBuffers.indirect(readBuf, i, this.byteWidth);
ReadBuf readBuf2 = this.bb;
int i2 = this.byteWidth;
return new KeyVector(new TypedVector(readBuf, indirect, FlexBuffers.readInt(readBuf2, i + i2, i2), 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('\"');
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();
}
public 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;
}
public 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;
public KeyVector(TypedVector typedVector) {
this.vec = typedVector;
}
public Key get(int i) {
if (i >= size()) {
return Key.EMPTY;
}
TypedVector typedVector = this.vec;
int i2 = typedVector.end + (i * typedVector.byteWidth);
TypedVector typedVector2 = this.vec;
ReadBuf readBuf = typedVector2.bb;
return new Key(readBuf, FlexBuffers.indirect(readBuf, i2, typedVector2.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(v8.i.e);
return sb.toString();
}
}
public static class FlexBufferException extends RuntimeException {
public FlexBufferException(String str) {
super(str);
}
}
}

View File

@@ -0,0 +1,527 @@
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) {
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);
return (int) writeString.iValue;
}
this.stack.add(Value.blob(putKey, num.intValue(), 5, widthUInBits(str2.length())));
return num.intValue();
}
Value writeString2 = writeString(putKey, str2);
this.stack.add(writeString2);
return (int) writeString2.iValue;
}
private Value writeString(int i, String str) {
return writeBlob(i, str.getBytes(StandardCharsets.UTF_8), 5, true);
}
public 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);
}
public 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);
}
public 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;
}
public 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;
}
public static Value bool(int i, boolean z) {
return new Value(i, 26, 0, z ? 1L : 0L);
}
public static Value blob(int i, int i2, int i3, int i4) {
return new Value(i, i3, i4, i2);
}
public static Value int8(int i, int i2) {
return new Value(i, 1, 0, i2);
}
public static Value int16(int i, int i2) {
return new Value(i, 1, 1, i2);
}
public static Value int32(int i, int i2) {
return new Value(i, 1, 2, i2);
}
public static Value int64(int i, long j) {
return new Value(i, 1, 3, j);
}
public static Value uInt8(int i, int i2) {
return new Value(i, 2, 0, i2);
}
public static Value uInt16(int i, int i2) {
return new Value(i, 2, 1, i2);
}
public static Value uInt32(int i, int i2) {
return new Value(i, 2, 2, i2);
}
public static Value uInt64(int i, long j) {
return new Value(i, 2, 3, j);
}
public static Value float32(int i, float f) {
return new Value(i, 3, 2, f);
}
public 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;
}
}
}

View File

@@ -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));
}
}

View File

@@ -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;
}
}

View File

@@ -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));
}
}

View File

@@ -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(Table.__indirect(__element(i), this.bb), this.bb);
}
}
}

View File

@@ -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(Table.__indirect(__element(i), this.bb), this.bb);
}
}
}

View File

@@ -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();
}

View File

@@ -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();
}

View File

@@ -0,0 +1,19 @@
package androidx.emoji2.text.flatbuffer;
import java.nio.ByteBuffer;
/* 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) & 65535;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
public 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);
}
}

View 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;
}
public int keysCompare(Integer num, Integer num2, ByteBuffer byteBuffer) {
return 0;
}
public int __offset(int i) {
if (i < this.vtable_size) {
return this.bb.getShort(this.vtable_start + i);
}
return 0;
}
public static int __offset(int i, int i2, ByteBuffer byteBuffer) {
int capacity = byteBuffer.capacity() - i2;
return byteBuffer.getShort((i + capacity) - byteBuffer.getInt(capacity)) + capacity;
}
public int __indirect(int i) {
return i + this.bb.getInt(i);
}
public static int __indirect(int i, ByteBuffer byteBuffer) {
return i + byteBuffer.getInt(i);
}
public String __string(int i) {
return __string(i, this.bb, this.utf8);
}
public static String __string(int i, ByteBuffer byteBuffer, Utf8 utf8) {
int i2 = i + byteBuffer.getInt(i);
return utf8.decodeUtf8(byteBuffer, i2 + 4, byteBuffer.getInt(i2));
}
public int __vector_len(int i) {
int i2 = i + this.bb_pos;
return this.bb.getInt(i2 + this.bb.getInt(i2));
}
public int __vector(int i) {
int i2 = i + this.bb_pos;
return i2 + this.bb.getInt(i2) + 4;
}
public 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;
}
public 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;
}
public Table __union(Table table, int i) {
return __union(table, i, this.bb);
}
public static Table __union(Table table, int i, ByteBuffer byteBuffer) {
table.__reset(__indirect(i, byteBuffer), byteBuffer);
return table;
}
public 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;
}
public 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();
}
}
public 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;
}
public 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;
}
public 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);
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,92 @@
package androidx.emoji2.text.flatbuffer;
import com.applovin.exoplayer2.common.base.Ascii;
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;
}
public static class DecodeUtil {
private static char highSurrogate(int i) {
return (char) ((i >>> 10) + 55232);
}
private static boolean isNotTrailingByte(byte b) {
return b > -65;
}
public static boolean isOneByte(byte b) {
return b >= 0;
}
public static boolean isThreeBytes(byte b) {
return b < -16;
}
public 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;
}
public static void handleOneByte(byte b, char[] cArr, int i) {
cArr[i] = (char) b;
}
public 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 & Ascii.US) << 6) | trailingByteValue(b2));
}
public 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 & Ascii.SI) << 12) | (trailingByteValue(b2) << 6) | trailingByteValue(b3));
}
public static void handleFourBytes(byte b, byte b2, byte b3, byte b4, char[] cArr, int i) throws IllegalArgumentException {
if (isNotTrailingByte(b2) || (((b << Ascii.FS) + (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);
}
}
public static class UnpairedSurrogateException extends IllegalArgumentException {
public UnpairedSurrogateException(int i, int i2) {
super("Unpaired surrogate at index " + i + " of " + i2);
}
}
}

View File

@@ -0,0 +1,87 @@
package androidx.emoji2.text.flatbuffer;
import androidx.emoji2.text.flatbuffer.Utf8Old;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.CharacterCodingException;
import java.nio.charset.Charset;
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 = ThreadLocal.withInitial(new Supplier() { // from class: androidx.emoji2.text.flatbuffer.Utf8Old$$ExternalSyntheticLambda0
@Override // java.util.function.Supplier
public final Object get() {
Utf8Old.Cache lambda$static$0;
lambda$static$0 = Utf8Old.lambda$static$0();
return lambda$static$0;
}
});
public static class Cache {
final CharsetDecoder decoder;
final CharsetEncoder encoder;
CharSequence lastInput = null;
ByteBuffer lastOutput = null;
public Cache() {
Charset charset = StandardCharsets.UTF_8;
this.encoder = charset.newEncoder();
this.decoder = charset.newDecoder();
}
}
/* JADX INFO: Access modifiers changed from: private */
public 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());
ByteBuffer byteBuffer = cache.lastOutput;
if (byteBuffer == null || byteBuffer.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);
}
}
}

View File

@@ -0,0 +1,311 @@
package androidx.emoji2.text.flatbuffer;
import androidx.emoji2.text.flatbuffer.Utf8;
import com.mbridge.msdk.playercommon.exoplayer2.extractor.ts.PsExtractor;
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 i;
int length = charSequence.length();
int position = byteBuffer.position();
int i2 = 0;
while (i2 < length) {
try {
char charAt = charSequence.charAt(i2);
if (charAt >= 128) {
break;
}
byteBuffer.put(position + i2, (byte) charAt);
i2++;
} catch (IndexOutOfBoundsException unused) {
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i2) + " at index " + (byteBuffer.position() + Math.max(i2, (position - byteBuffer.position()) + 1)));
}
}
if (i2 == length) {
byteBuffer.position(position + i2);
return;
}
position += i2;
while (i2 < length) {
char charAt2 = charSequence.charAt(i2);
if (charAt2 < 128) {
byteBuffer.put(position, (byte) charAt2);
} else if (charAt2 < 2048) {
int i3 = position + 1;
try {
byteBuffer.put(position, (byte) ((charAt2 >>> 6) | PsExtractor.AUDIO_STREAM));
byteBuffer.put(i3, (byte) ((charAt2 & '?') | 128));
position = i3;
} catch (IndexOutOfBoundsException unused2) {
position = i3;
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i2) + " at index " + (byteBuffer.position() + Math.max(i2, (position - byteBuffer.position()) + 1)));
}
} else if (charAt2 < 55296 || 57343 < charAt2) {
int i4 = position + 1;
byteBuffer.put(position, (byte) ((charAt2 >>> '\f') | 224));
position += 2;
byteBuffer.put(i4, (byte) (((charAt2 >>> 6) & 63) | 128));
byteBuffer.put(position, (byte) ((charAt2 & '?') | 128));
} else {
int i5 = i2 + 1;
if (i5 != length) {
try {
char charAt3 = charSequence.charAt(i5);
if (Character.isSurrogatePair(charAt2, charAt3)) {
int codePoint = Character.toCodePoint(charAt2, charAt3);
int i6 = position + 1;
try {
byteBuffer.put(position, (byte) ((codePoint >>> 18) | PsExtractor.VIDEO_STREAM_MASK));
i = position + 2;
} catch (IndexOutOfBoundsException unused3) {
position = i6;
i2 = i5;
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i2) + " at index " + (byteBuffer.position() + Math.max(i2, (position - byteBuffer.position()) + 1)));
}
try {
byteBuffer.put(i6, (byte) (((codePoint >>> 12) & 63) | 128));
position += 3;
byteBuffer.put(i, (byte) (((codePoint >>> 6) & 63) | 128));
byteBuffer.put(position, (byte) ((codePoint & 63) | 128));
i2 = i5;
} catch (IndexOutOfBoundsException unused4) {
i2 = i5;
position = i;
throw new ArrayIndexOutOfBoundsException("Failed writing " + charSequence.charAt(i2) + " at index " + (byteBuffer.position() + Math.max(i2, (position - byteBuffer.position()) + 1)));
}
} else {
i2 = i5;
}
} catch (IndexOutOfBoundsException unused5) {
}
}
throw new UnpairedSurrogateException(i2, length);
}
i2++;
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: 254
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);
}
}
public static class UnpairedSurrogateException extends IllegalArgumentException {
public UnpairedSurrogateException(int i, int i2) {
super("Unpaired surrogate at index " + i + " of " + i2);
}
}
}